RORUTL14 ;HCIOFO/BH,SG - PHARMACY DATA SEARCH ; 12/13/05 2:16pm
;;1.5;CLINICAL CASE REGISTRIES;**28**;Feb 17, 2006;Build 66
;
;
;******************************************************************************
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;ROR*1.5*28 APR 2016 T KOPP Document DAA/in house parameter.
;******************************************************************************
Q
;
;***** SEARCHES THE PHARMACY DATA
;
; PATIEN IEN of the patient (DFN)
;
; ROR8RXS Closed root of a variable, which contains a list
; of drugs of interest (in the same format as
; the list returned by the $$DRUGLIST^RORUTL16).
;
; If the "*" is passed via this parameter then all
; pharmacy orders tests are considered.
;
; If this parameter has a pure numeric value then
; it is considered as registry IEN and the default
; list of registry specific drugs is automatically
; compiled by the $$DRUGLIST^RORUTL16 function.
;
; [[.]ROR8DST] Closed root of an array where the data will be
; returned (the ^TMP("RORUTL14",$J), by default).
; The data will be stored into the destination
; array in following format:
;
; @ROR8DST@(i, Additional drug information
; ^01: Order number
; ^02: Flags describing the order:
; I Inpatient dose
; O Outpatient fill
; P Pending
; V IV
; ^03: Generic drug IEN (file #50.6)
; ^04: Generic drug name
; ^05: Drug class IEN (file #50.605)
; ^06: Drug class code
; 0) Detailed information on pharmacy
; "RXN",0) order loaded by the OEL^PSOORRL
; ...
;
; Example:
; S RORDST=$NA(^TMP("RORTMP",$J))
; S RC=$$RXSEARCH^RORUTL14(DFN,REGIEN,RORDST)
;
; If this parameter is passed by reference, you can
; provide a full name ($$TAG^ROUTINE) of the callback
; function, which will process and store the results,
; as the value of the "RORCB" node.
;
; Any additional nodes created in this variable will
; be accessible in the callback function. The following
; nodes are created automatically:
;
; "RORDFN" IEN of the registry patient (DFN)
;
; "ROREDT" End date
;
; "RORFLAGS" Value of parameter of the same name
;
; "RORSDT" Start date
;
; "RORXGEN" Generic drug
; ^01: Drug IEN in file #50.6
; ^02: Generic drug name
;
; "RORXVCL" VA Drug class
; ^01: Class IEN in file #50.605
; ^02: Class code
;
; The callback function must accept 5 parameters:
;
; .ROR8DST Reference to the ROR8DST parameter
; passed into the $$RXSEARCH function.
;
; ORDER Order number (from condensed list)
;
; FLAGS Flags describing the order to be
; processed.
;
; DRUG Dispensed drug
; ^01: Drug IEN in file #50
; ^02: Drug name
;
; DATE Order date (issue date for outpatient
; drugs or start date for inpatient)
;
; The ^TMP("PS",$J) global node contains the data
; returned by the OEL^PSOORRL procedure (see the
; DBIA #2400 for details).
;
; The callback function is called for each additive
; included in the IV order; the ^TMP("PS",$J) is
; loaded once and stays the same for all of them.
;
; The function should return the following values:
;
; <0 Error code (the search will be aborted)
; 0 Ok
; 1 Skip this pharmacy order
; 2 Skip this and all remaining orders
;
; Example:
; S RORDST=$NA(^TMP("RORBUF",$J))
; S RORDST("RORPTR")=+$O(@RORDST@(""),-1)
; S RORDST("RORCB")="$$RXCB^RORUT999"
; S RC=$$RXSEARCH^RORUTL14(DFN,REGIEN,.RORDST)
;
; [RORFLAGS] Flags to control processing:
; E Load external values for additional fields
; stored into the output array or passed to
; the callback function. Affected fields
; have the (E) marker.
; I Include inpatient doses
; O Include outpatient fills
; P Include pending orders
; V Include IV
; C Include only DAA Drug (remarks contains CHOICE)
; H Include only In-house drug (remarks doesn't contain CHOICE)
;
; If this parameter has no value ($G(RORFLAGS)="")
; then the default set of flags is used: "IO".
;
; RORSDT Start date (FileMan)
; [ROREDT] End date (FileMan)
;
; The search is performed exactly between provided
; boundaries (the time parts are considered).
;
; The following global nodes are used by the function:
;
; ^TMP("PS",$J) The OCL^PSOORRL and OEL^PSOORRL procedures
; return the results into this node.
;
; ^TMP("RORUTL14",$J) If the name of the destination array is
; not provided via the ROR8DST parameter
; then the $$RXSEARCH returns the results
; under this node.
;
; ^TMP("RORUTL14L",$J) If the ROR8RXS parameter is undefined
; then a temporary list of registry specific
; drugs is compiled under this node.
;
; Return Values:
; <0 Error code
; 0 No ordes have been found
; >0 Number of pharmacy orders
;
RXSEARCH(PATIEN,ROR8RXS,ROR8DST,RORFLAGS,RORSDT,ROREDT) ;
N RC,ROR8SET,RORXLST,TMP
S:$G(ROR8DST)="" ROR8DST=$NA(^TMP("RORUTL14",$J))
S RORFLAGS=$S($G(RORFLAGS)'="":RORFLAGS,1:"IO")
Q:$TR(RORFLAGS,"IO")=RORFLAGS 0 ; Neither Inpatient nor Outpatient
Q:$G(ROR8RXS)="" 0 ; No drugs to search for
;---
S:$G(ROREDT)'>0 ROREDT=DT
S RORXLST=$$ALLOC^RORTMP(),RC=0
;
D
. ;--- Prepare the list of drugs of interest
. I (+ROR8RXS)=ROR8RXS D Q:RC'>0
. . S TMP=ROR8RXS,ROR8RXS=$$ALLOC^RORTMP()
. . S RC=$$DRUGLIST^RORUTL16(ROR8RXS,TMP)
. I ROR8RXS'="*",$D(@ROR8RXS)<10 S RC=0 Q
. ;--- Preselect pharmacy orders
. S RC=$$QUERY^RORUTL15(PATIEN,RORFLAGS,RORSDT,ROREDT,RORXLST)
. Q:RC'>0
. ;--- Process selected orders
. S RC=$$PROCESS^RORUTL15(PATIEN,RORFLAGS,RORXLST)
. Q:RC'>0
;
;--- Cleanup
D POP^RORTMP(RORXLST)
Q RC
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORUTL14 7736 printed Nov 22, 2024@16:54:17 Page 2
RORUTL14 ;HCIOFO/BH,SG - PHARMACY DATA SEARCH ; 12/13/05 2:16pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**28**;Feb 17, 2006;Build 66
+2 ;
+3 ;
+4 ;******************************************************************************
+5 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+6 ;----------- ---------- ----------- ----------------------------------------
+7 ;ROR*1.5*28 APR 2016 T KOPP Document DAA/in house parameter.
+8 ;******************************************************************************
+9 QUIT
+10 ;
+11 ;***** SEARCHES THE PHARMACY DATA
+12 ;
+13 ; PATIEN IEN of the patient (DFN)
+14 ;
+15 ; ROR8RXS Closed root of a variable, which contains a list
+16 ; of drugs of interest (in the same format as
+17 ; the list returned by the $$DRUGLIST^RORUTL16).
+18 ;
+19 ; If the "*" is passed via this parameter then all
+20 ; pharmacy orders tests are considered.
+21 ;
+22 ; If this parameter has a pure numeric value then
+23 ; it is considered as registry IEN and the default
+24 ; list of registry specific drugs is automatically
+25 ; compiled by the $$DRUGLIST^RORUTL16 function.
+26 ;
+27 ; [[.]ROR8DST] Closed root of an array where the data will be
+28 ; returned (the ^TMP("RORUTL14",$J), by default).
+29 ; The data will be stored into the destination
+30 ; array in following format:
+31 ;
+32 ; @ROR8DST@(i, Additional drug information
+33 ; ^01: Order number
+34 ; ^02: Flags describing the order:
+35 ; I Inpatient dose
+36 ; O Outpatient fill
+37 ; P Pending
+38 ; V IV
+39 ; ^03: Generic drug IEN (file #50.6)
+40 ; ^04: Generic drug name
+41 ; ^05: Drug class IEN (file #50.605)
+42 ; ^06: Drug class code
+43 ; 0) Detailed information on pharmacy
+44 ; "RXN",0) order loaded by the OEL^PSOORRL
+45 ; ...
+46 ;
+47 ; Example:
+48 ; S RORDST=$NA(^TMP("RORTMP",$J))
+49 ; S RC=$$RXSEARCH^RORUTL14(DFN,REGIEN,RORDST)
+50 ;
+51 ; If this parameter is passed by reference, you can
+52 ; provide a full name ($$TAG^ROUTINE) of the callback
+53 ; function, which will process and store the results,
+54 ; as the value of the "RORCB" node.
+55 ;
+56 ; Any additional nodes created in this variable will
+57 ; be accessible in the callback function. The following
+58 ; nodes are created automatically:
+59 ;
+60 ; "RORDFN" IEN of the registry patient (DFN)
+61 ;
+62 ; "ROREDT" End date
+63 ;
+64 ; "RORFLAGS" Value of parameter of the same name
+65 ;
+66 ; "RORSDT" Start date
+67 ;
+68 ; "RORXGEN" Generic drug
+69 ; ^01: Drug IEN in file #50.6
+70 ; ^02: Generic drug name
+71 ;
+72 ; "RORXVCL" VA Drug class
+73 ; ^01: Class IEN in file #50.605
+74 ; ^02: Class code
+75 ;
+76 ; The callback function must accept 5 parameters:
+77 ;
+78 ; .ROR8DST Reference to the ROR8DST parameter
+79 ; passed into the $$RXSEARCH function.
+80 ;
+81 ; ORDER Order number (from condensed list)
+82 ;
+83 ; FLAGS Flags describing the order to be
+84 ; processed.
+85 ;
+86 ; DRUG Dispensed drug
+87 ; ^01: Drug IEN in file #50
+88 ; ^02: Drug name
+89 ;
+90 ; DATE Order date (issue date for outpatient
+91 ; drugs or start date for inpatient)
+92 ;
+93 ; The ^TMP("PS",$J) global node contains the data
+94 ; returned by the OEL^PSOORRL procedure (see the
+95 ; DBIA #2400 for details).
+96 ;
+97 ; The callback function is called for each additive
+98 ; included in the IV order; the ^TMP("PS",$J) is
+99 ; loaded once and stays the same for all of them.
+100 ;
+101 ; The function should return the following values:
+102 ;
+103 ; <0 Error code (the search will be aborted)
+104 ; 0 Ok
+105 ; 1 Skip this pharmacy order
+106 ; 2 Skip this and all remaining orders
+107 ;
+108 ; Example:
+109 ; S RORDST=$NA(^TMP("RORBUF",$J))
+110 ; S RORDST("RORPTR")=+$O(@RORDST@(""),-1)
+111 ; S RORDST("RORCB")="$$RXCB^RORUT999"
+112 ; S RC=$$RXSEARCH^RORUTL14(DFN,REGIEN,.RORDST)
+113 ;
+114 ; [RORFLAGS] Flags to control processing:
+115 ; E Load external values for additional fields
+116 ; stored into the output array or passed to
+117 ; the callback function. Affected fields
+118 ; have the (E) marker.
+119 ; I Include inpatient doses
+120 ; O Include outpatient fills
+121 ; P Include pending orders
+122 ; V Include IV
+123 ; C Include only DAA Drug (remarks contains CHOICE)
+124 ; H Include only In-house drug (remarks doesn't contain CHOICE)
+125 ;
+126 ; If this parameter has no value ($G(RORFLAGS)="")
+127 ; then the default set of flags is used: "IO".
+128 ;
+129 ; RORSDT Start date (FileMan)
+130 ; [ROREDT] End date (FileMan)
+131 ;
+132 ; The search is performed exactly between provided
+133 ; boundaries (the time parts are considered).
+134 ;
+135 ; The following global nodes are used by the function:
+136 ;
+137 ; ^TMP("PS",$J) The OCL^PSOORRL and OEL^PSOORRL procedures
+138 ; return the results into this node.
+139 ;
+140 ; ^TMP("RORUTL14",$J) If the name of the destination array is
+141 ; not provided via the ROR8DST parameter
+142 ; then the $$RXSEARCH returns the results
+143 ; under this node.
+144 ;
+145 ; ^TMP("RORUTL14L",$J) If the ROR8RXS parameter is undefined
+146 ; then a temporary list of registry specific
+147 ; drugs is compiled under this node.
+148 ;
+149 ; Return Values:
+150 ; <0 Error code
+151 ; 0 No ordes have been found
+152 ; >0 Number of pharmacy orders
+153 ;
RXSEARCH(PATIEN,ROR8RXS,ROR8DST,RORFLAGS,RORSDT,ROREDT) ;
+1 NEW RC,ROR8SET,RORXLST,TMP
+2 if $GET(ROR8DST)=""
SET ROR8DST=$NAME(^TMP("RORUTL14",$JOB))
+3 SET RORFLAGS=$SELECT($GET(RORFLAGS)'="":RORFLAGS,1:"IO")
+4 ; Neither Inpatient nor Outpatient
if $TRANSLATE(RORFLAGS,"IO")=RORFLAGS
QUIT 0
+5 ; No drugs to search for
if $GET(ROR8RXS)=""
QUIT 0
+6 ;---
+7 if $GET(ROREDT)'>0
SET ROREDT=DT
+8 SET RORXLST=$$ALLOC^RORTMP()
SET RC=0
+9 ;
+10 Begin DoDot:1
+11 ;--- Prepare the list of drugs of interest
+12 IF (+ROR8RXS)=ROR8RXS
Begin DoDot:2
+13 SET TMP=ROR8RXS
SET ROR8RXS=$$ALLOC^RORTMP()
+14 SET RC=$$DRUGLIST^RORUTL16(ROR8RXS,TMP)
End DoDot:2
if RC'>0
QUIT
+15 IF ROR8RXS'="*"
IF $DATA(@ROR8RXS)<10
SET RC=0
QUIT
+16 ;--- Preselect pharmacy orders
+17 SET RC=$$QUERY^RORUTL15(PATIEN,RORFLAGS,RORSDT,ROREDT,RORXLST)
+18 if RC'>0
QUIT
+19 ;--- Process selected orders
+20 SET RC=$$PROCESS^RORUTL15(PATIEN,RORFLAGS,RORXLST)
+21 if RC'>0
QUIT
End DoDot:1
+22 ;
+23 ;--- Cleanup
+24 DO POP^RORTMP(RORXLST)
+25 QUIT RC