RORRP031 ;HCIOFO/SG - RPC: LOCAL LAB TEST NAMES ; 2/10/04 8:59am
;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
;
; This routine uses the following IAs:
;
; #91 Access to the LABORATORY TEST file
;
Q
;
;***** PROCESSES THE ERROR(S) AND UNLOCKS THE RECORD(S)
ERROR(RESULTS,RC) ;
D RPCSTK^RORERR(.RESULTS,RC)
D UNLOCK^RORLOCK(.RORLOCK)
Q
;
;***** RETURNS THE LIST OF LOCAL TEST NAMES
; RPC: [ROR LIST LOCAL LAB TESTS]
;
; .RESULTS Reference to a local variable where the results
; are returned to.
;
; REGIEN Registry IEN
;
; [GROUP] Code of the Lab Group. If this parameter is
; defined and greater than zero then only the tests
; associated with this group will be returned.
;
; The ^TMP("DILIST",$J) global node is used by the procedure.
;
; Return Values:
;
; A negative value of the first "^"-piece of the RESULTS(0)
; indicates an error (see the RPCSTK^RORERR procedure for more
; details).
;
; Otherwise, number of lab tests is returned in the @RESULTS@(0)
; and the subsequent nodes of the global array contain the tests.
;
; @RESULTS@(0) Number of Local Tests
;
; @RESULTS@(i) Test Descriptor
; ^01: IEN in the LOCAL TEST NAME multiple
; ^02: Local test name
; ^03: IEN of the local test
; ^04: Code of the Lab Group
;
LTLIST(RESULTS,REGIEN,GROUP) ;
N GROUPIEN,IENS,IR,RC,RORERRDL,RORMSG,SCR,TMP
D CLEAR^RORERR("LTLIST^RORRP031",1)
K RESULTS S RESULTS=$NA(^TMP("DILIST",$J)) K @RESULTS
;
;--- Check the parameters
S RC=0 D I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
. ;--- Registry IEN
. I $G(REGIEN)'>0 D Q
. . S RC=$$ERROR^RORERR(-88,,,,"REGIEN",$G(REGIEN))
. S REGIEN=+REGIEN
. ;--- Code of the Lab Group
. S GROUP=+$G(GROUP)
. S GROUPIEN=$S(GROUP>0:$$ITEMIEN^RORUTL09(3,REGIEN,GROUP),1:0)
. I GROUPIEN<0 D Q
. . S RC=$$ERROR^RORERR(GROUPIEN)
;
;--- Compile the screen logic (be careful with naked references)
S SCR=""
S:GROUPIEN>0 SCR=SCR_"I $P($G(^(0)),U,2)="_GROUPIEN_" "
;--- Get the list of tests
S IENS=","_REGIEN_",",TMP="@;.01E;.01I;.02I"
D LIST^DIC(798.128,IENS,TMP,"PU",,,,"B",SCR,,,"RORMSG")
I $G(DIERR) D D RPCSTK^RORERR(.RESULTS,RC) Q
. S RC=$$DBS^RORERR("RORMSG",-9,,,798.128,IENS)
;
;--- Replace the group IEN's with the group code(s)
S (IR,RC)=0
F S IR=$O(@RESULTS@(IR)) Q:IR'>0 D Q:RC<0
. I GROUPIEN>0 S $P(@RESULTS@(IR,0),U,4)=GROUP Q
. S TMP=+$P(@RESULTS@(IR,0),U,4)
. I TMP'>0 S $P(@RESULTS@(IR,0),U,4)="" Q
. S RC=$$ITEMCODE^RORUTL09(TMP)
. S:RC>0 $P(@RESULTS@(IR,0),U,4)=RC
I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
;--- Success
S TMP=+$G(^TMP("DILIST",$J,0))
K ^TMP("DILIST",$J,0) S @RESULTS@(0)=TMP
Q
;
;***** UPDATES THE LIST OF LOCAL TEST NAMES
; RPC: [ROR UPDATE LOCAL LAB TESTS]
;
; .RESULTS Reference to a local variable where the results
; are returned to.
;
; REGIEN Registry IEN
;
; GROUP Code of the Lab Group.
;
; If this parameter is equal to 0 then every item of
; the LTLST must contain a valid group code. If an
; empty list is passed into the RPC then ALL records
; will be deleted from the LOCAL TEST NAME multiple.
;
; If this parameter is not zero then it should contain
; a valid group code. All records of the LTLST will be
; associated with this group. If an empty list is
; passed into the RPC then only records associated
; with this group will be deleted from the multiple.
;
; .LTLST( Reference to a local variable that contains
; a list of local laboratory tests
;
; i) Test Descriptor
; ^01: Ignored
; ^02: Ignored
; ^03: IEN of the local test
; ^04: Code of the Lab Group
; (see also the GROUP parameter)
;
; Return Values:
;
; A negative value of the first "^"-piece of the RESULTS(0)
; indicates an error (see the RPCSTK^RORERR procedure for more
; details).
;
; Otherwise, zero is returned in the RESULTS(0).
;
LTLUPD(RESULTS,REGIEN,GROUP,LTLST) ;
N DA,DIK,ECNT,GROUPIEN,GRPIEN,IENS,IR,LTL,RC,ROOT,RORERRDL,RORFDA,RORLOCK,RORMSG,TMP,TSTIEN
D CLEAR^RORERR("LTLUPD^RORRP031",1) K RESULTS
S ECNT=0
;
;--- Check the parameters
S RC=0 D I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
. ;--- Registry IEN
. I $G(REGIEN)'>0 D Q
. . S RC=$$ERROR^RORERR(-88,,,,"REGIEN",$G(REGIEN))
. S REGIEN=+REGIEN
. ;--- Code of the Lab Group
. S GROUPIEN=$S($G(GROUP)>0:$$ITEMIEN^RORUTL09(3,REGIEN,GROUP),1:0)
. I GROUPIEN<0 D Q
. . S RC=$$ERROR^RORERR(-88,,,,"GROUP",$G(GROUP))
. S GROUP=+$G(GROUP)
;
;--- Lock the LOCAL TEST NAME multiple
S IENS=","_REGIEN_","
S RC=$$LOCK^RORLOCK(798.128,IENS)
I RC D:RC>0 D RPCSTK^RORERR(.RESULTS,RC) Q
. S RC=$$ERROR^RORERR(-11,,,,"the LOCAL TEST NAME multiple")
;---
S RORLOCK(798.128,IENS)=""
S ROOT=$$ROOT^DILFD(798.128,IENS,1)
;
;--- Prepare the data
S IR="",RC=0
F S IR=$O(LTLST(IR)) Q:IR="" D Q:RC<0
. ;--- Check if the test is defined in the LABORATORY TEST file
. S TSTIEN=+$P(LTLST(IR),U,3)
. Q:$$FIND1^DIC(60,,,"`"_TSTIEN,,,"RORMSG")'>0
. ;--- Assign the default Group IEN (if the GROUP is provided)
. I GROUPIEN>0 S LTL(GROUPIEN,TSTIEN)="" Q
. ;--- Get IEN of the Lab Group
. S TMP=+$P(LTLST(IR),U,4)
. S GRPIEN=$$ITEMIEN^RORUTL09(3,REGIEN,TMP)
. I GRPIEN'>0 D:GRPIEN<0 Q
. . S RC=$$ERROR^RORERR(GRPIEN)
. ;--- Create the reference
. S LTL(GRPIEN,TSTIEN)=""
I RC<0 D ERROR(.RESULTS,RC) Q
;
;--- Mark the groups to be cleared
I GROUPIEN'>0 S GRPIEN="" D
. F S GRPIEN=$O(@ROOT@("G",GRPIEN)) Q:GRPIEN="" S LTL(GRPIEN)=""
E S LTL(GROUPIEN)=""
;
;--- Update the multiple
S IENS="?+1,"_REGIEN_",",ECNT=0
S GRPIEN=""
F S GRPIEN=$O(LTL(GRPIEN)) Q:GRPIEN="" D
. ;--- Delete the old records
. S DIK=$$OREF^DILF(ROOT),DA(1)=REGIEN
. S TSTIEN=""
. F S TSTIEN=$O(@ROOT@("G",GRPIEN,TSTIEN)) Q:TSTIEN="" D
. . S DA=""
. . F S DA=$O(@ROOT@("G",GRPIEN,TSTIEN,DA)) Q:DA="" D ^DIK
. ;--- Store the new records
. S TSTIEN=""
. F S TSTIEN=$O(LTL(GRPIEN,TSTIEN)) Q:TSTIEN="" D
. . S RORFDA(798.128,IENS,.01)=TSTIEN
. . S RORFDA(798.128,IENS,.02)=GRPIEN
. . D UPDATE^DIE(,"RORFDA",,"RORMSG")
. . I $G(DIERR) D S ECNT=ECNT+1 Q
. . . D DBS^RORERR("RORMSG",-9,,,798.128,IENS)
;
;--- Unlock the multiple and check for errors
D UNLOCK^RORLOCK(798.128,","_REGIEN_",")
I ECNT>0 D RPCSTK^RORERR(.RESULTS,-9) Q
;--- Success
S RESULTS(0)=0
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORRP031 6907 printed Dec 13, 2024@01:43:12 Page 2
RORRP031 ;HCIOFO/SG - RPC: LOCAL LAB TEST NAMES ; 2/10/04 8:59am
+1 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
+2 ;
+3 ; This routine uses the following IAs:
+4 ;
+5 ; #91 Access to the LABORATORY TEST file
+6 ;
+7 QUIT
+8 ;
+9 ;***** PROCESSES THE ERROR(S) AND UNLOCKS THE RECORD(S)
ERROR(RESULTS,RC) ;
+1 DO RPCSTK^RORERR(.RESULTS,RC)
+2 DO UNLOCK^RORLOCK(.RORLOCK)
+3 QUIT
+4 ;
+5 ;***** RETURNS THE LIST OF LOCAL TEST NAMES
+6 ; RPC: [ROR LIST LOCAL LAB TESTS]
+7 ;
+8 ; .RESULTS Reference to a local variable where the results
+9 ; are returned to.
+10 ;
+11 ; REGIEN Registry IEN
+12 ;
+13 ; [GROUP] Code of the Lab Group. If this parameter is
+14 ; defined and greater than zero then only the tests
+15 ; associated with this group will be returned.
+16 ;
+17 ; The ^TMP("DILIST",$J) global node is used by the procedure.
+18 ;
+19 ; Return Values:
+20 ;
+21 ; A negative value of the first "^"-piece of the RESULTS(0)
+22 ; indicates an error (see the RPCSTK^RORERR procedure for more
+23 ; details).
+24 ;
+25 ; Otherwise, number of lab tests is returned in the @RESULTS@(0)
+26 ; and the subsequent nodes of the global array contain the tests.
+27 ;
+28 ; @RESULTS@(0) Number of Local Tests
+29 ;
+30 ; @RESULTS@(i) Test Descriptor
+31 ; ^01: IEN in the LOCAL TEST NAME multiple
+32 ; ^02: Local test name
+33 ; ^03: IEN of the local test
+34 ; ^04: Code of the Lab Group
+35 ;
LTLIST(RESULTS,REGIEN,GROUP) ;
+1 NEW GROUPIEN,IENS,IR,RC,RORERRDL,RORMSG,SCR,TMP
+2 DO CLEAR^RORERR("LTLIST^RORRP031",1)
+3 KILL RESULTS
SET RESULTS=$NAME(^TMP("DILIST",$JOB))
KILL @RESULTS
+4 ;
+5 ;--- Check the parameters
+6 SET RC=0
Begin DoDot:1
+7 ;--- Registry IEN
+8 IF $GET(REGIEN)'>0
Begin DoDot:2
+9 SET RC=$$ERROR^RORERR(-88,,,,"REGIEN",$GET(REGIEN))
End DoDot:2
QUIT
+10 SET REGIEN=+REGIEN
+11 ;--- Code of the Lab Group
+12 SET GROUP=+$GET(GROUP)
+13 SET GROUPIEN=$SELECT(GROUP>0:$$ITEMIEN^RORUTL09(3,REGIEN,GROUP),1:0)
+14 IF GROUPIEN<0
Begin DoDot:2
+15 SET RC=$$ERROR^RORERR(GROUPIEN)
End DoDot:2
QUIT
End DoDot:1
IF RC<0
DO RPCSTK^RORERR(.RESULTS,RC)
QUIT
+16 ;
+17 ;--- Compile the screen logic (be careful with naked references)
+18 SET SCR=""
+19 if GROUPIEN>0
SET SCR=SCR_"I $P($G(^(0)),U,2)="_GROUPIEN_" "
+20 ;--- Get the list of tests
+21 SET IENS=","_REGIEN_","
SET TMP="@;.01E;.01I;.02I"
+22 DO LIST^DIC(798.128,IENS,TMP,"PU",,,,"B",SCR,,,"RORMSG")
+23 IF $GET(DIERR)
Begin DoDot:1
+24 SET RC=$$DBS^RORERR("RORMSG",-9,,,798.128,IENS)
End DoDot:1
DO RPCSTK^RORERR(.RESULTS,RC)
QUIT
+25 ;
+26 ;--- Replace the group IEN's with the group code(s)
+27 SET (IR,RC)=0
+28 FOR
SET IR=$ORDER(@RESULTS@(IR))
if IR'>0
QUIT
Begin DoDot:1
+29 IF GROUPIEN>0
SET $PIECE(@RESULTS@(IR,0),U,4)=GROUP
QUIT
+30 SET TMP=+$PIECE(@RESULTS@(IR,0),U,4)
+31 IF TMP'>0
SET $PIECE(@RESULTS@(IR,0),U,4)=""
QUIT
+32 SET RC=$$ITEMCODE^RORUTL09(TMP)
+33 if RC>0
SET $PIECE(@RESULTS@(IR,0),U,4)=RC
End DoDot:1
if RC<0
QUIT
+34 IF RC<0
DO RPCSTK^RORERR(.RESULTS,RC)
QUIT
+35 ;--- Success
+36 SET TMP=+$GET(^TMP("DILIST",$JOB,0))
+37 KILL ^TMP("DILIST",$JOB,0)
SET @RESULTS@(0)=TMP
+38 QUIT
+39 ;
+40 ;***** UPDATES THE LIST OF LOCAL TEST NAMES
+41 ; RPC: [ROR UPDATE LOCAL LAB TESTS]
+42 ;
+43 ; .RESULTS Reference to a local variable where the results
+44 ; are returned to.
+45 ;
+46 ; REGIEN Registry IEN
+47 ;
+48 ; GROUP Code of the Lab Group.
+49 ;
+50 ; If this parameter is equal to 0 then every item of
+51 ; the LTLST must contain a valid group code. If an
+52 ; empty list is passed into the RPC then ALL records
+53 ; will be deleted from the LOCAL TEST NAME multiple.
+54 ;
+55 ; If this parameter is not zero then it should contain
+56 ; a valid group code. All records of the LTLST will be
+57 ; associated with this group. If an empty list is
+58 ; passed into the RPC then only records associated
+59 ; with this group will be deleted from the multiple.
+60 ;
+61 ; .LTLST( Reference to a local variable that contains
+62 ; a list of local laboratory tests
+63 ;
+64 ; i) Test Descriptor
+65 ; ^01: Ignored
+66 ; ^02: Ignored
+67 ; ^03: IEN of the local test
+68 ; ^04: Code of the Lab Group
+69 ; (see also the GROUP parameter)
+70 ;
+71 ; Return Values:
+72 ;
+73 ; A negative value of the first "^"-piece of the RESULTS(0)
+74 ; indicates an error (see the RPCSTK^RORERR procedure for more
+75 ; details).
+76 ;
+77 ; Otherwise, zero is returned in the RESULTS(0).
+78 ;
LTLUPD(RESULTS,REGIEN,GROUP,LTLST) ;
+1 NEW DA,DIK,ECNT,GROUPIEN,GRPIEN,IENS,IR,LTL,RC,ROOT,RORERRDL,RORFDA,RORLOCK,RORMSG,TMP,TSTIEN
+2 DO CLEAR^RORERR("LTLUPD^RORRP031",1)
KILL RESULTS
+3 SET ECNT=0
+4 ;
+5 ;--- Check the parameters
+6 SET RC=0
Begin DoDot:1
+7 ;--- Registry IEN
+8 IF $GET(REGIEN)'>0
Begin DoDot:2
+9 SET RC=$$ERROR^RORERR(-88,,,,"REGIEN",$GET(REGIEN))
End DoDot:2
QUIT
+10 SET REGIEN=+REGIEN
+11 ;--- Code of the Lab Group
+12 SET GROUPIEN=$SELECT($GET(GROUP)>0:$$ITEMIEN^RORUTL09(3,REGIEN,GROUP),1:0)
+13 IF GROUPIEN<0
Begin DoDot:2
+14 SET RC=$$ERROR^RORERR(-88,,,,"GROUP",$GET(GROUP))
End DoDot:2
QUIT
+15 SET GROUP=+$GET(GROUP)
End DoDot:1
IF RC<0
DO RPCSTK^RORERR(.RESULTS,RC)
QUIT
+16 ;
+17 ;--- Lock the LOCAL TEST NAME multiple
+18 SET IENS=","_REGIEN_","
+19 SET RC=$$LOCK^RORLOCK(798.128,IENS)
+20 IF RC
if RC>0
Begin DoDot:1
+21 SET RC=$$ERROR^RORERR(-11,,,,"the LOCAL TEST NAME multiple")
End DoDot:1
DO RPCSTK^RORERR(.RESULTS,RC)
QUIT
+22 ;---
+23 SET RORLOCK(798.128,IENS)=""
+24 SET ROOT=$$ROOT^DILFD(798.128,IENS,1)
+25 ;
+26 ;--- Prepare the data
+27 SET IR=""
SET RC=0
+28 FOR
SET IR=$ORDER(LTLST(IR))
if IR=""
QUIT
Begin DoDot:1
+29 ;--- Check if the test is defined in the LABORATORY TEST file
+30 SET TSTIEN=+$PIECE(LTLST(IR),U,3)
+31 if $$FIND1^DIC(60,,,"`"_TSTIEN,,,"RORMSG")'>0
QUIT
+32 ;--- Assign the default Group IEN (if the GROUP is provided)
+33 IF GROUPIEN>0
SET LTL(GROUPIEN,TSTIEN)=""
QUIT
+34 ;--- Get IEN of the Lab Group
+35 SET TMP=+$PIECE(LTLST(IR),U,4)
+36 SET GRPIEN=$$ITEMIEN^RORUTL09(3,REGIEN,TMP)
+37 IF GRPIEN'>0
if GRPIEN<0
Begin DoDot:2
+38 SET RC=$$ERROR^RORERR(GRPIEN)
End DoDot:2
QUIT
+39 ;--- Create the reference
+40 SET LTL(GRPIEN,TSTIEN)=""
End DoDot:1
if RC<0
QUIT
+41 IF RC<0
DO ERROR(.RESULTS,RC)
QUIT
+42 ;
+43 ;--- Mark the groups to be cleared
+44 IF GROUPIEN'>0
SET GRPIEN=""
Begin DoDot:1
+45 FOR
SET GRPIEN=$ORDER(@ROOT@("G",GRPIEN))
if GRPIEN=""
QUIT
SET LTL(GRPIEN)=""
End DoDot:1
+46 IF '$TEST
SET LTL(GROUPIEN)=""
+47 ;
+48 ;--- Update the multiple
+49 SET IENS="?+1,"_REGIEN_","
SET ECNT=0
+50 SET GRPIEN=""
+51 FOR
SET GRPIEN=$ORDER(LTL(GRPIEN))
if GRPIEN=""
QUIT
Begin DoDot:1
+52 ;--- Delete the old records
+53 SET DIK=$$OREF^DILF(ROOT)
SET DA(1)=REGIEN
+54 SET TSTIEN=""
+55 FOR
SET TSTIEN=$ORDER(@ROOT@("G",GRPIEN,TSTIEN))
if TSTIEN=""
QUIT
Begin DoDot:2
+56 SET DA=""
+57 FOR
SET DA=$ORDER(@ROOT@("G",GRPIEN,TSTIEN,DA))
if DA=""
QUIT
DO ^DIK
End DoDot:2
+58 ;--- Store the new records
+59 SET TSTIEN=""
+60 FOR
SET TSTIEN=$ORDER(LTL(GRPIEN,TSTIEN))
if TSTIEN=""
QUIT
Begin DoDot:2
+61 SET RORFDA(798.128,IENS,.01)=TSTIEN
+62 SET RORFDA(798.128,IENS,.02)=GRPIEN
+63 DO UPDATE^DIE(,"RORFDA",,"RORMSG")
+64 IF $GET(DIERR)
Begin DoDot:3
+65 DO DBS^RORERR("RORMSG",-9,,,798.128,IENS)
End DoDot:3
SET ECNT=ECNT+1
QUIT
End DoDot:2
End DoDot:1
+66 ;
+67 ;--- Unlock the multiple and check for errors
+68 DO UNLOCK^RORLOCK(798.128,","_REGIEN_",")
+69 IF ECNT>0
DO RPCSTK^RORERR(.RESULTS,-9)
QUIT
+70 ;--- Success
+71 SET RESULTS(0)=0
+72 QUIT