Does anybody have a script for unlocking a locked document in SQL?
You can use the CPS admin tool for that.
We have C-EMR and use
set numwidth 16 (enter)
select masterlock,pid,searchname from person where patientid='logician#here'; (enter)
Update person set masterlock=0 where patientid='logician#here'; (enter)
commit; (enter)
exit; (enter)
First one is to see if there are locks and then the second one is to actually unlock the patient.
--== FIND LOCK for Patient by Patient ID ==
--==============================================
DECLARE @Pid Numeric,@PPid Numeric, @Id VarChar(15)--==============================
SET @Id = 'xxxx' --ENTER PatientID
--==============================
Print @Id
SELECT @Pid= PID,@PPid=PatientProfileId FROM PatientProfile WHERE PatientID=@Id
IF (@Id ='')
BEGIN
RAISERROR(' PatientID NEEDED -- Please enter PatientID',16,1)
End
ELSE
BEGIN
SELECT masterlock,First,Last,PatientID FROM PatientProfile
WHERE PatientProfileId =@PPidSELECT AL.LockId,AP.LoginName AS [Locked BY] From Applocks AL
LEFT JOIN Appsession AP ON AL.AppSessionID = AP.AppsessionID
WHERE ObjectID= @PPidSELECT * FROM LogLocks
WHERE (PROBLOCK=@Pid) or (MEDLOCK=@Pid) or (ALLERGYLOCK=@Pid) or (FLOWLOCK=@Pid) or (ORDERLOCK=@Pid) or (DIRECTLOCK=@Pid) or (SETUPLOCK=@Pid) or (DEMOGLOCK=@Pid) or
(ENDLOCK=@Pid) or (L3QLOCK=@Pid) or (OTHER1LOCK=@Pid) or (OTHER2LOCK=@Pid) or (CONFCHLOCK=@Pid) or (DOCPROPCHLOCK=@Pid) or (APPTLOCK=@Pid) or (BUSLOCK=@Pid) or
(NOTETEXTLOCK=@Pid) or (FAXDELETELOCK=@Pid) or (IMGEDITLOCK=@Pid)
END
--==============================================
--== REMOVE LOCK for Patient ==
--==============================================DECLARE @Pid Numeric,@PPid Numeric, @Id VarChar(15)
--==============================
set @Id = 'xxxx' --ENTER PatientID
--==============================SELECT @Pid= PID,@PPid=PatientProfileId
FROM PatientProfile WHERE PatientID= @Id
IF (@Id ='')
BEGIN
RAISERROR(' PatientID NEEDED -- Please enter PatientID',16,1)
End
ELSE
BEGIN
DELETE FROM Applocks
WHERE ObjectID= @PPidUPDATE PatientProfile
SET MasterLock = NULL
WHERE PatientProfileID=@PPidUPDATE LogLocks
SET PROBLOCK=Null,MEDLOCK=Null,ALLERGYLOCK=Null,FLOWLOCK=Null,ORDERLOCK=Null,DIRECTLOCK=Null,SETUPLOCK=Null,
DEMOGLOCK=Null,ENDLOCK=Null,L3QLOCK=Null,OTHER1LOCK=Null,OTHER2LOCK=Null,CONFCHLOCK=Null,DOCPROPCHLOCK=Null,
APPTLOCK=Null,BUSLOCK=Null,NOTETEXTLOCK=Null,IMGEDITLOCK=Null
WHERE (PROBLOCK=@Pid)or(MEDLOCK=@Pid)or(ALLERGYLOCK=@Pid)or(FLOWLOCK=@Pid)or(ORDERLOCK=@Pid)or
(DIRECTLOCK=@Pid)or(SETUPLOCK=@Pid)or(DEMOGLOCK=@Pid)or(ENDLOCK=@Pid)or(L3QLOCK=@Pid)or
(OTHER1LOCK=@Pid)or(OTHER2LOCK=@Pid)or(CONFCHLOCK=@Pid)or(DOCPROPCHLOCK=@Pid)or(APPTLOCK=@Pid)or
(BUSLOCK=@Pid)or(NOTETEXTLOCK=@Pid)or(FAXDELETELOCK=@Pid)or(IMGEDITLOCK=@Pid)
END
Here is what I use:
-- Error message in CPS when user tried to update anything in chart - Pop up Error "Unsigned Clinical List changes..." but all documents in chart were signed already.
-- Normally the MasterLock field should have value of Null or Zero. If value in it and no one truly has an open update in progress then run second script below to Null the MasterLock value.
-- Update PatientID with value for problem patient
SELECT PID,PatientProfileId,masterlock, *
FROM PatientProfile
WHERE PatientID = '28980'
-- First highlight all but the commit line and execute. If only 1 row modified then execute the commit statement.
Begin Tran
Update patientprofile
set masterlock = Null
Where PatientProfileId=28980
commit
Thank You!
Thank You!
Thank You!
I received the following from GE (replace the x's with the patient ID):
--==============================================
--== REMOVE LOCK for Patient ==
--==============================================
DECLARE @Pid Numeric,@PPid Numeric, @Id VarChar(15)
--==============================
set @Id ='xxxxxx'--ENTER PatientID
--==============================
SELECT @Pid= PID,@PPid=PatientProfileId
FROM PatientProfile WHERE PatientID= @Id
IF (@Id ='')
BEGIN
RAISERROR(' PatientID NEEDED -- Please enter PatientID',16,1)
End
ELSE
BEGIN
DELETEFROM Applocks
WHERE ObjectID= @PPid
UPDATE PatientProfile
SET MasterLock =NULL
WHERE PatientProfileID=@PPid
UPDATE LogLocks
SET PROBLOCK=Null,MEDLOCK=Null,ALLERGYLOCK=Null,FLOWLOCK=Null,ORDERLOCK=Null,DIRECTLOCK=Null,SETUPLOCK=Null,
DEMOGLOCK=Null,ENDLOCK=Null,L3QLOCK=Null,OTHER1LOCK=Null,OTHER2LOCK=Null,CONFCHLOCK=Null,DOCPROPCHLOCK=Null,
APPTLOCK=Null,BUSLOCK=Null,NOTETEXTLOCK=Null,IMGEDITLOCK=Null
WHERE (PROBLOCK=@Pid)or(MEDLOCK=@Pid)or(ALLERGYLOCK=@Pid)or(FLOWLOCK=@Pid)or(ORDERLOCK=@Pid)or
(DIRECTLOCK=@Pid)or(SETUPLOCK=@Pid)or(DEMOGLOCK=@Pid)or(ENDLOCK=@Pid)or(L3QLOCK=@Pid)or
(OTHER1LOCK=@Pid)or(OTHER2LOCK=@Pid)or(CONFCHLOCK=@Pid)or(DOCPROPCHLOCK=@Pid)or(APPTLOCK=@Pid)or
(BUSLOCK=@Pid)or(NOTETEXTLOCK=@Pid)or(FAXDELETELOCK=@Pid)or(IMGEDITLOCK=@Pid)
END
I wrote a tool some time back that can be used for this (and other stuff too). Actually, it was shortly after I released mine that GE came out with theirs. They even used the same name and icon as mine. Although I have no way of proving it, I believe they plagiarized mine. Anyway, I changed the name of mine to CPS Essentials, and it way better than GE's (IMHA). You can download it for free at www.triadt.com, then click on "Software". Download the 2nd application on the list, called "CPS Essentials 2.0".
The Triadt tool is very slick. Thanks, saves a lot of effort.
Can any of these script work for EMR 9.8?
yes mine will work as long as you use sqlplus. I use it all the time, GE gave it to me.
Is this tool still available anywhere? We found it very useful in the past.
Steve