LA7UTL1A ;HOIFO/BH - Microbiology Query Utility ; 3/11/03 10:45am
;;5.2;AUTOMATED LAB INSTRUMENTS;**69**;Sep 27, 1994
;
;
GETDATA(LRDFN,LASDT,LAEDT,LASEARCH,RESULTS) ;
;
; Input:
;
; LRDFN - Lab DFN
; LASDT - Search Start Date
; LAEDT - Search End Date
; LASEARCH - Set to CD (collection date) or RAD (completion date).
; RESULTS - Closed root destination array reference
;
; Output:
; If an error is found with the input variables one for the
; strings will be returned.
;
; -1^Start date is after end date
; -2^No return array global
; -3^Global array only
; -4^No Patient lab DFN
; -5^No Start Date Range
; -6^No End Date Range
;
; If there are no errors with the input variables the processing
; will return '1'. If there is no data in the passed in global
; there was no data available for the patient.
;
; If there is data available for the patient the routine will pass
; back the following data (the example assumes the passed in closed
; root global was "^TMP($J)"):
;
; Fields .01 (Accession date),.05 (Site Specimen),.055 (Sample Type),
; .06 (Accession #),11.51 (Sterility Control),11.57 (Urine Screen),
; 11.58 (Sputum Screen), 22 (TB RPT Date Approved), 23 (TB RPT Status),
; 24 (ACID Fast Stain), 25 (Quantity) and .99 (Specimen Comment) from
; the top node in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"0",Field #,"E" or "I")=Field Data
;
; Field .01 of sub file 63.29 - Gram Stain - in the following format
;
; ^TMP($J,LRDFN,Record_IEN,"2",Sub File IEN,"0",Field #,"E" or "I")=Data
;
; Field .01 (Organism) and 1 (Quantity) of sub file 63.3 in the
; following format;
;
; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"0",Field #,"E" or "I")=Data
;
; Within the Organism data there is an antibiotic multiple. The
; routine returns the antibiotic (.01) along with the Mic (field #1)
; and Mbc (field #2) from the sub file 63.32 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"3",Sub-Sub File IEN,"0"
; ,Field #,"E" or "I")=Data
;
;
; Organisms can potentially have specific antibiotics associated with
; them. This API pulls any of the Antibiotics (along with their
; interpretation and screen) that have been entered in the antibiotic
; fields that exist within the standard Lab DD. Within this sub file
; these fields are numbered between 5 and 160.2 and have node numbers
; that begin with the numbers 2.00.
; It is also possible for sites to enter their own specific named
; antibiotics within this multiple using a lab option. This option
; creates a new node number for the new antibiotic entry that is
; comprised in the
; following way "2.00"_site #_n (where n is an incremented number).
; This node number also becomes the field number for this antibiotic.
; The interpretation and screen values of these antibiotics should
; follow a pattern where interpretation field number is comprised as
; follows "2.00"_site #_n_1 and the screen is "2.00"_site #_n_2.
;
; However only antibiotics have been entered in the standard Organism
; DD will get extracted. Any antibiotics entered into the site
; specified fields will not get extracted.
;
; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"0",Field #,"I")=data
; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"0",Field #,"E")=field name
; ^data
;
; Note the "E" node contains the field name and it's related data.
;
;
; Within the Organism data there is a comment multiple which the
; routine also returns.
; Field .01 Comment of sub file 63.31 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"1",Sub-Sub File IEN,"0"
; ,Field #,"E" or "I")=Data
;
; Field .01 Bact RPT Remark of sub file 63.33 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"4",Sub File IEN,"0",Field #,"E" or "I")=Data
;
; Field .01 Parasite of sub file 63.34 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"6",Sub File IEN,"0",Field #,"E" or "I")=Data
;
; Within Parasite data there is a stage code multiple that the routine
; also returns.
; Fields .01 Stage code and 1 Quantity of sub file 63.35 in the
; following format;
;
; ^TMP($J,LRDFN,Record_IEN,"6",Sub File IEN,"1",Sub-Sub File IEN,"0"
; ,Field #,"E" or "I")=Data
;
; Within the Stage Code multiple there can be a Stage Code Comment
; multiple that this routine also returns;
; Field .01 of the Stage Code Comment Multiple 63.351 in the
; following format;
;
;
; ^TMP($J,LRDFN,Record_IEN,"6",Sub File IEN,"1",Sub-Sub File IEN,"1"
; ,Sub Sub Sub File IEN,"0",Field #,"E" or "I")=Data)
;
; Field .01 Parasite RPT Remark 63.36 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"7",Sub File IEN,"0",Field #,"E" or "I")=Data
;
; Field .01 Fungus/Yeast and field 1 Quantity of sub file 63.37 in the
; following format;
;
; ^TMP($J,LRDFN,Record_IEN,"9",Sub File IEN,"0",Field #,"E" or "I")=Data
;
; Within the Fungus/Yeast data there is a comment multiple which the
; routine also returns.
; Field .01 Comment of sub file 63.372 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"9",Sub File IEN,"1",Sub-Sub File IEN,"0"
; ,Field #,"E" or "I")=Data
;
;
; Field .01 Mycobacterium and field 1 Quantity of sub file 63.39 in
; the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"12",Sub File IEN,"0",Field #,"E" or "I")
; =Data
; Mycobacterium can potentially have antibiotics associated with them.
; This API pulls any of the Antibiotics that have been entered in the
; antibiotic
; fields that exist within the standard Lab DD. Within this sub file
; these fields are numbered between 5 and 55).
; It is also possible for sites to enter their own antibiotics
; within this multiple using a lab option. This option creates a new
; node number for the new antibiotic entry that is comprised in the
; following way "2.00"_site #_n (where n is an incremented number).
; This node number also becomes the field number for this antibiotic.
;
; However only antibiotics have been entered in the standard
; Mycobacterium antibiotic DD will get extracted. Any antibiotics
; entered into the site specified fields will not get extracted.
;
; ^TMP($J,LRDFN,Record_IEN,"12",Sub File IEN,"0",Field #,"I")=data
; ^TMP($J,LRDFN,Record_IEN,"12",Sub File IEN,"0",Field #,"E")
; =field name^data
;
; Note the "E" node contains the field name and it's related data.
;
;
;
; Within the Mycobacterium data there is a comment multiple which the
; routine also returns.
; Field .01 Comment of sub file 63.4 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"12",Sub File IEN,"1",Sub-Sub File IEN,"0"
; ,Field #,"E" or "I")=Data
;
; Field .01 BACT Smear/Prep of sub file 63.291 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"25",Sub File IEN,"0",Field #,"E" or "I")
; = Data
;
; Field .01 PARA Smear/Prep of sub file 63.341 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"24",Sub File IEN,"0",Field #,"E" or "I")
; =Data
;
; Field .01 VIRUS of sub file 63.43 in the following format;
;
; ^TMP($J,LRDFN,Record_IEN,"17",Sub File IEN,"0",Field #,"E" or "I")
; =Data
;
;
; ---------------------------------------------------------------------
;
N LAARRAY,LAINX,LATYP,LAFILE,LAARRET,LACD,LACDFLD,LACDTYP,LADATA,LASET,LASUB,LA763,LATYPE
;
I LASDT>LAEDT Q "-1^Start date is after end date"
I '$D(RESULTS) Q "-2^No return array global"
I $E(RESULTS,1,1)'="^" Q "-3^Global array only"
I '+$G(LRDFN) Q "-4^No Patient lab DFN"
I '$G(LASDT) Q "-5^No Start Date Range"
I '$G(LAEDT) Q "-6^No End Date Range"
S LAFILE=63.05,LATYPE="MI"
;
; - Used for internal processing
S LAARRAY="^XTMP(""LA7UTL1A"",$J)"
; - Passed in global reference, returns results
S LAARRET=$S($G(RESULTS)'="":RESULTS,1:"^TMP(""LA7UTL1A"","_$J_")")
K @LAARRAY,@LAARRET
I LASEARCH="RAD" D RAD
I LASEARCH="CD" D CD
;
Q 1
;
CD ; Search by collection date
;
N LRIDT,LRSS,LANSDT,LANEDT
;
I LASDT S LANSDT=9999999-LASDT
I LAEDT S LANEDT=9999999-LAEDT
;
S LRIDT=LANSDT
F S LRIDT=$O(^LR(LRDFN,LATYPE,LRIDT),-1) Q:LRIDT=""!(LRIDT<LANEDT) D
. D MI^LA7UTL1C(LRDFN,LRIDT,LAARRAY),ARRANGE^LA7UTL1B(LAARRAY,LAARRET)
;
Q
;
RAD ; Search by completion date.
;
N LRIDT
S LRIDT=0
F S LRIDT=$O(^LR(LRDFN,LATYPE,LRIDT)) Q:'LRIDT D
. S LA763(0)=$G(^LR(LRDFN,LATYPE,LRIDT,0))
. I $P(LA763(0),"^",3)>LASDT,$P(LA763(0),"^",3)<LAEDT D MI^LA7UTL1C(LRDFN,LRIDT,LAARRAY),ARRANGE^LA7UTL1B(LAARRAY,LAARRET)
Q
;
;
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLA7UTL1A 9283 printed Oct 16, 2024@17:40:53 Page 2
LA7UTL1A ;HOIFO/BH - Microbiology Query Utility ; 3/11/03 10:45am
+1 ;;5.2;AUTOMATED LAB INSTRUMENTS;**69**;Sep 27, 1994
+2 ;
+3 ;
GETDATA(LRDFN,LASDT,LAEDT,LASEARCH,RESULTS) ;
+1 ;
+2 ; Input:
+3 ;
+4 ; LRDFN - Lab DFN
+5 ; LASDT - Search Start Date
+6 ; LAEDT - Search End Date
+7 ; LASEARCH - Set to CD (collection date) or RAD (completion date).
+8 ; RESULTS - Closed root destination array reference
+9 ;
+10 ; Output:
+11 ; If an error is found with the input variables one for the
+12 ; strings will be returned.
+13 ;
+14 ; -1^Start date is after end date
+15 ; -2^No return array global
+16 ; -3^Global array only
+17 ; -4^No Patient lab DFN
+18 ; -5^No Start Date Range
+19 ; -6^No End Date Range
+20 ;
+21 ; If there are no errors with the input variables the processing
+22 ; will return '1'. If there is no data in the passed in global
+23 ; there was no data available for the patient.
+24 ;
+25 ; If there is data available for the patient the routine will pass
+26 ; back the following data (the example assumes the passed in closed
+27 ; root global was "^TMP($J)"):
+28 ;
+29 ; Fields .01 (Accession date),.05 (Site Specimen),.055 (Sample Type),
+30 ; .06 (Accession #),11.51 (Sterility Control),11.57 (Urine Screen),
+31 ; 11.58 (Sputum Screen), 22 (TB RPT Date Approved), 23 (TB RPT Status),
+32 ; 24 (ACID Fast Stain), 25 (Quantity) and .99 (Specimen Comment) from
+33 ; the top node in the following format;
+34 ;
+35 ; ^TMP($J,LRDFN,Record_IEN,"0",Field #,"E" or "I")=Field Data
+36 ;
+37 ; Field .01 of sub file 63.29 - Gram Stain - in the following format
+38 ;
+39 ; ^TMP($J,LRDFN,Record_IEN,"2",Sub File IEN,"0",Field #,"E" or "I")=Data
+40 ;
+41 ; Field .01 (Organism) and 1 (Quantity) of sub file 63.3 in the
+42 ; following format;
+43 ;
+44 ; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"0",Field #,"E" or "I")=Data
+45 ;
+46 ; Within the Organism data there is an antibiotic multiple. The
+47 ; routine returns the antibiotic (.01) along with the Mic (field #1)
+48 ; and Mbc (field #2) from the sub file 63.32 in the following format;
+49 ;
+50 ; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"3",Sub-Sub File IEN,"0"
+51 ; ,Field #,"E" or "I")=Data
+52 ;
+53 ;
+54 ; Organisms can potentially have specific antibiotics associated with
+55 ; them. This API pulls any of the Antibiotics (along with their
+56 ; interpretation and screen) that have been entered in the antibiotic
+57 ; fields that exist within the standard Lab DD. Within this sub file
+58 ; these fields are numbered between 5 and 160.2 and have node numbers
+59 ; that begin with the numbers 2.00.
+60 ; It is also possible for sites to enter their own specific named
+61 ; antibiotics within this multiple using a lab option. This option
+62 ; creates a new node number for the new antibiotic entry that is
+63 ; comprised in the
+64 ; following way "2.00"_site #_n (where n is an incremented number).
+65 ; This node number also becomes the field number for this antibiotic.
+66 ; The interpretation and screen values of these antibiotics should
+67 ; follow a pattern where interpretation field number is comprised as
+68 ; follows "2.00"_site #_n_1 and the screen is "2.00"_site #_n_2.
+69 ;
+70 ; However only antibiotics have been entered in the standard Organism
+71 ; DD will get extracted. Any antibiotics entered into the site
+72 ; specified fields will not get extracted.
+73 ;
+74 ; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"0",Field #,"I")=data
+75 ; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"0",Field #,"E")=field name
+76 ; ^data
+77 ;
+78 ; Note the "E" node contains the field name and it's related data.
+79 ;
+80 ;
+81 ; Within the Organism data there is a comment multiple which the
+82 ; routine also returns.
+83 ; Field .01 Comment of sub file 63.31 in the following format;
+84 ;
+85 ; ^TMP($J,LRDFN,Record_IEN,"3",Sub File IEN,"1",Sub-Sub File IEN,"0"
+86 ; ,Field #,"E" or "I")=Data
+87 ;
+88 ; Field .01 Bact RPT Remark of sub file 63.33 in the following format;
+89 ;
+90 ; ^TMP($J,LRDFN,Record_IEN,"4",Sub File IEN,"0",Field #,"E" or "I")=Data
+91 ;
+92 ; Field .01 Parasite of sub file 63.34 in the following format;
+93 ;
+94 ; ^TMP($J,LRDFN,Record_IEN,"6",Sub File IEN,"0",Field #,"E" or "I")=Data
+95 ;
+96 ; Within Parasite data there is a stage code multiple that the routine
+97 ; also returns.
+98 ; Fields .01 Stage code and 1 Quantity of sub file 63.35 in the
+99 ; following format;
+100 ;
+101 ; ^TMP($J,LRDFN,Record_IEN,"6",Sub File IEN,"1",Sub-Sub File IEN,"0"
+102 ; ,Field #,"E" or "I")=Data
+103 ;
+104 ; Within the Stage Code multiple there can be a Stage Code Comment
+105 ; multiple that this routine also returns;
+106 ; Field .01 of the Stage Code Comment Multiple 63.351 in the
+107 ; following format;
+108 ;
+109 ;
+110 ; ^TMP($J,LRDFN,Record_IEN,"6",Sub File IEN,"1",Sub-Sub File IEN,"1"
+111 ; ,Sub Sub Sub File IEN,"0",Field #,"E" or "I")=Data)
+112 ;
+113 ; Field .01 Parasite RPT Remark 63.36 in the following format;
+114 ;
+115 ; ^TMP($J,LRDFN,Record_IEN,"7",Sub File IEN,"0",Field #,"E" or "I")=Data
+116 ;
+117 ; Field .01 Fungus/Yeast and field 1 Quantity of sub file 63.37 in the
+118 ; following format;
+119 ;
+120 ; ^TMP($J,LRDFN,Record_IEN,"9",Sub File IEN,"0",Field #,"E" or "I")=Data
+121 ;
+122 ; Within the Fungus/Yeast data there is a comment multiple which the
+123 ; routine also returns.
+124 ; Field .01 Comment of sub file 63.372 in the following format;
+125 ;
+126 ; ^TMP($J,LRDFN,Record_IEN,"9",Sub File IEN,"1",Sub-Sub File IEN,"0"
+127 ; ,Field #,"E" or "I")=Data
+128 ;
+129 ;
+130 ; Field .01 Mycobacterium and field 1 Quantity of sub file 63.39 in
+131 ; the following format;
+132 ;
+133 ; ^TMP($J,LRDFN,Record_IEN,"12",Sub File IEN,"0",Field #,"E" or "I")
+134 ; =Data
+135 ; Mycobacterium can potentially have antibiotics associated with them.
+136 ; This API pulls any of the Antibiotics that have been entered in the
+137 ; antibiotic
+138 ; fields that exist within the standard Lab DD. Within this sub file
+139 ; these fields are numbered between 5 and 55).
+140 ; It is also possible for sites to enter their own antibiotics
+141 ; within this multiple using a lab option. This option creates a new
+142 ; node number for the new antibiotic entry that is comprised in the
+143 ; following way "2.00"_site #_n (where n is an incremented number).
+144 ; This node number also becomes the field number for this antibiotic.
+145 ;
+146 ; However only antibiotics have been entered in the standard
+147 ; Mycobacterium antibiotic DD will get extracted. Any antibiotics
+148 ; entered into the site specified fields will not get extracted.
+149 ;
+150 ; ^TMP($J,LRDFN,Record_IEN,"12",Sub File IEN,"0",Field #,"I")=data
+151 ; ^TMP($J,LRDFN,Record_IEN,"12",Sub File IEN,"0",Field #,"E")
+152 ; =field name^data
+153 ;
+154 ; Note the "E" node contains the field name and it's related data.
+155 ;
+156 ;
+157 ;
+158 ; Within the Mycobacterium data there is a comment multiple which the
+159 ; routine also returns.
+160 ; Field .01 Comment of sub file 63.4 in the following format;
+161 ;
+162 ; ^TMP($J,LRDFN,Record_IEN,"12",Sub File IEN,"1",Sub-Sub File IEN,"0"
+163 ; ,Field #,"E" or "I")=Data
+164 ;
+165 ; Field .01 BACT Smear/Prep of sub file 63.291 in the following format;
+166 ;
+167 ; ^TMP($J,LRDFN,Record_IEN,"25",Sub File IEN,"0",Field #,"E" or "I")
+168 ; = Data
+169 ;
+170 ; Field .01 PARA Smear/Prep of sub file 63.341 in the following format;
+171 ;
+172 ; ^TMP($J,LRDFN,Record_IEN,"24",Sub File IEN,"0",Field #,"E" or "I")
+173 ; =Data
+174 ;
+175 ; Field .01 VIRUS of sub file 63.43 in the following format;
+176 ;
+177 ; ^TMP($J,LRDFN,Record_IEN,"17",Sub File IEN,"0",Field #,"E" or "I")
+178 ; =Data
+179 ;
+180 ;
+181 ; ---------------------------------------------------------------------
+182 ;
+183 NEW LAARRAY,LAINX,LATYP,LAFILE,LAARRET,LACD,LACDFLD,LACDTYP,LADATA,LASET,LASUB,LA763,LATYPE
+184 ;
+185 IF LASDT>LAEDT
QUIT "-1^Start date is after end date"
+186 IF '$DATA(RESULTS)
QUIT "-2^No return array global"
+187 IF $EXTRACT(RESULTS,1,1)'="^"
QUIT "-3^Global array only"
+188 IF '+$GET(LRDFN)
QUIT "-4^No Patient lab DFN"
+189 IF '$GET(LASDT)
QUIT "-5^No Start Date Range"
+190 IF '$GET(LAEDT)
QUIT "-6^No End Date Range"
+191 SET LAFILE=63.05
SET LATYPE="MI"
+192 ;
+193 ; - Used for internal processing
+194 SET LAARRAY="^XTMP(""LA7UTL1A"",$J)"
+195 ; - Passed in global reference, returns results
+196 SET LAARRET=$SELECT($GET(RESULTS)'="":RESULTS,1:"^TMP(""LA7UTL1A"","_$JOB_")")
+197 KILL @LAARRAY,@LAARRET
+198 IF LASEARCH="RAD"
DO RAD
+199 IF LASEARCH="CD"
DO CD
+200 ;
+201 QUIT 1
+202 ;
CD ; Search by collection date
+1 ;
+2 NEW LRIDT,LRSS,LANSDT,LANEDT
+3 ;
+4 IF LASDT
SET LANSDT=9999999-LASDT
+5 IF LAEDT
SET LANEDT=9999999-LAEDT
+6 ;
+7 SET LRIDT=LANSDT
+8 FOR
SET LRIDT=$ORDER(^LR(LRDFN,LATYPE,LRIDT),-1)
if LRIDT=""!(LRIDT<LANEDT)
QUIT
Begin DoDot:1
+9 DO MI^LA7UTL1C(LRDFN,LRIDT,LAARRAY)
DO ARRANGE^LA7UTL1B(LAARRAY,LAARRET)
End DoDot:1
+10 ;
+11 QUIT
+12 ;
RAD ; Search by completion date.
+1 ;
+2 NEW LRIDT
+3 SET LRIDT=0
+4 FOR
SET LRIDT=$ORDER(^LR(LRDFN,LATYPE,LRIDT))
if 'LRIDT
QUIT
Begin DoDot:1
+5 SET LA763(0)=$GET(^LR(LRDFN,LATYPE,LRIDT,0))
+6 IF $PIECE(LA763(0),"^",3)>LASDT
IF $PIECE(LA763(0),"^",3)<LAEDT
DO MI^LA7UTL1C(LRDFN,LRIDT,LAARRAY)
DO ARRANGE^LA7UTL1B(LAARRAY,LAARRET)
End DoDot:1
+7 QUIT
+8 ;
+9 ;
+10 ;