SDESCHECKLOCK ;ALB/LAB - SDES CHECK ORDER LOCK ;APR 21,2023
;;5.3;Scheduling;**844**;Aug 13, 1993;Build 12
;;Per VHA Directive 6402, this routine should not be modified
;
; Reference to $$LOCK1^ORX2 is supported by IA #867
; Reference to UNKL1^ORX2 is supported by IA #867
Q
;
LOCKCHECK(JSONRETURN,REQUESTIEN) ;
N REQTYP,RETURN,ORDERID,ERROR,USER,LOCKFLG
S LOCKFLG=0
D VALIDATEREQIEN(.ERRORS,REQUESTIEN)
I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
D GETORDER(.ORDERID,REQUESTIEN)
D CHECKORDERLOCK(.ORDERID,.LOCKFLG)
S RETURN("RecordLock")=LOCKFLG
D BUILDJSON(.JSONRETURN,.RETURN)
Q
;
CHECKORDERLOCK(ORDERID,LOCKFLG) ;
N LOCKED
S LOCKED=0
Q:'ORDERID
I $D(^XTMP("ORLK-"_ORDERID)) D
. S LOCKFLG=1
I LOCKFLG'=1 D
. S LOCKED=$$LOCK1^ORX2(ORDERID)
. S:+LOCKED=0 LOCKFLG=1
. I +LOCKED D
. . D UNLK1^ORX2(ORDERID)
Q
VALIDATEREQIEN(ERRORS,REQUESTIEN) ;
I $G(REQUESTIEN)="" D ERRLOG^SDESJSON(.ERRORS,3) Q
I ('$D(^SDEC(409.85,REQUESTIEN)))!(REQUESTIEN=0) D ERRLOG^SDESJSON(.ERRORS,4)
Q
;
GETORDER(ORDERID,REQUESTIEN) ;
S ORDERID=$$GET1^DIQ(409.85,REQUESTIEN,46,"I")
Q
;
BUILDJSON(JSONRETURN,RETURN) ;
N JSONERROR
D ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERROR")
;
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESCHECKLOCK 1266 printed Dec 13, 2024@02:56:05 Page 2
SDESCHECKLOCK ;ALB/LAB - SDES CHECK ORDER LOCK ;APR 21,2023
+1 ;;5.3;Scheduling;**844**;Aug 13, 1993;Build 12
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Reference to $$LOCK1^ORX2 is supported by IA #867
+5 ; Reference to UNKL1^ORX2 is supported by IA #867
+6 QUIT
+7 ;
LOCKCHECK(JSONRETURN,REQUESTIEN) ;
+1 NEW REQTYP,RETURN,ORDERID,ERROR,USER,LOCKFLG
+2 SET LOCKFLG=0
+3 DO VALIDATEREQIEN(.ERRORS,REQUESTIEN)
+4 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+5 DO GETORDER(.ORDERID,REQUESTIEN)
+6 DO CHECKORDERLOCK(.ORDERID,.LOCKFLG)
+7 SET RETURN("RecordLock")=LOCKFLG
+8 DO BUILDJSON(.JSONRETURN,.RETURN)
+9 QUIT
+10 ;
CHECKORDERLOCK(ORDERID,LOCKFLG) ;
+1 NEW LOCKED
+2 SET LOCKED=0
+3 if 'ORDERID
QUIT
+4 IF $DATA(^XTMP("ORLK-"_ORDERID))
Begin DoDot:1
+5 SET LOCKFLG=1
End DoDot:1
+6 IF LOCKFLG'=1
Begin DoDot:1
+7 SET LOCKED=$$LOCK1^ORX2(ORDERID)
+8 if +LOCKED=0
SET LOCKFLG=1
+9 IF +LOCKED
Begin DoDot:2
+10 DO UNLK1^ORX2(ORDERID)
End DoDot:2
End DoDot:1
+11 QUIT
VALIDATEREQIEN(ERRORS,REQUESTIEN) ;
+1 IF $GET(REQUESTIEN)=""
DO ERRLOG^SDESJSON(.ERRORS,3)
QUIT
+2 IF ('$DATA(^SDEC(409.85,REQUESTIEN)))!(REQUESTIEN=0)
DO ERRLOG^SDESJSON(.ERRORS,4)
+3 QUIT
+4 ;
GETORDER(ORDERID,REQUESTIEN) ;
+1 SET ORDERID=$$GET1^DIQ(409.85,REQUESTIEN,46,"I")
+2 QUIT
+3 ;
BUILDJSON(JSONRETURN,RETURN) ;
+1 NEW JSONERROR
+2 DO ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERROR")
+3 ;
+4 QUIT
+5 ;