Begin Transaction a
DECLARE @encNum varchar(100)
DECLARE @orgID int
DECLARE @userID int
--Obviously, you change the orgID to match and you change the userID to be usually the hinext_<org> user.
SET @orgID = 5500 -- get orgid from Tr_Organisation
SET @userID = 6 --Get userid from Tr_uses where username = 'hinext_LHC'
SET @encNum = '218130009901'
UPDATE TR_Encounter
SET HospitalService='ABI Serv',PatientLocationNurse='BSG',AdmitDate='2019-01-04 00:00:00.000',DischargeDate='2019-01-08 00:00:00.000',Status=2,LastModifiedDate = GETDATE()
WHERE EncounterNumber = @encNum and EncounterOrg = @orgID
insert into TR_AuditEncounter select GETDATE(), 'update', @userID, @orgID, EncounterNumber,EncounterOrg,TREATClientID,MRN,LastEvent,
LastEventMessageDate,PatientClass,PatientLocationNurse,PatientLocationRoom,PatientLocationBed,AdmissionType,HospitalService,
DoctorLastname_Attend,DoctorFirstname_Attend,DoctorNumber_Attend,DoctorLastname_Refer,DoctorFirstname_Refer,DoctorNumber_Refer,
DoctorLastname_Consult,DoctorFirstname_Consult,DoctorNumber_Consult,DoctorLastname_Admit,DoctorFirstname_Admit,DoctorNumber_Admit,
AdmitSource,PatientType,AdmitDate,DischargeDate,Status,LastEventDate,'',CreateDate,LastTransferAdmitDate,LastModifiedDate,SourceURI,
BedID,ReferralID,FundingSource,FunderID,AccidentLoc,AutoAccidentState,Site,ClinicianName,ClinicianID,DischargeReason,PatientLocationNurseID
from TR_Encounter where EncounterNumber=@encNum and EncounterOrg=@orgID
--commit transaction;
--rollback transaction
select * from TR_Encounter where EncounterNumber='21813000852'
select * from TR_Users where UserName='hsupport'