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