LRMITSRS ;SLC/STAFF - MICRO TREND REPORT SETUP ;11/7/93 12:33
;;5.2;LAB SERVICE;**96**;Sep 27, 1994
; from LRMITSR
; sets up static information on reports
;
K LRHDR S LRHDR1=$P($$HTE^XLFDT($H),":",1,2)_" ANTIBIOTIC TREND REPORT (from "_LRFBEG_" to: "_LRFEND_" "
S LRSPACE=$$REPEAT^XLFSTR(" ",5)
I $D(LROTYPE("B")) D
.S LRHDR(2)=LRSPACE,LRABRV="",LRAPRT=0
.I '$D(^TMP($J,"PSRT")) F S LRABRV=$O(^TMP($J,"AB",LRABRV)) Q:LRABRV="" S LRHDR(2)=LRHDR(2)_"|"_$E(LRABRV,1,3)
.I $D(^TMP($J,"PSRT")) F S LRAPRT=$O(^TMP($J,"PSRT",LRAPRT)) Q:+LRAPRT'>0 S LRABRV=$G(^TMP($J,"PSRT",LRAPRT)),LRHDR(2)=LRHDR(2)_"|"_$E(LRABRV,1,3)
.S LRHDR(2)=LRHDR(2)_"|"
I LRLOS S LRHDR(3)=" ** Reports only those specimens collected > "_LRLOS_$S(LRLOS>1:" days",1:" day")_" from admission date **"
S LRHDR(4)=(IOM-5)\4 S LRHDR(4)=" "_$$REPEAT^XLFSTR("|---",(LRHDR(4)))
I $D(LRAP) D
. S LRHDR(5)="* ANTIBIOTIC PATTERN *",LRHDR(6)=LRSPACE
. S LRABRV="" F S LRABRV=$O(^TMP($J,"AB",LRABRV)) Q:LRABRV="" S LRDN=+^(LRABRV) D
..S LRHDR(6)=LRHDR(6)_"|"_$J($G(LRAP(LRDN)),3)
.S LRHDR(6)=LRHDR(6)_"|"
; header information
K LRLINE S LRLINE1="ANTIBIOTIC TREND REPORT BY "
S LRCNT=2,LRX=LRFBEG_" - "_LRFEND,LRLINE(LRCNT)=$J(LRX,IOM+$L(LRX)\2)
S LRCNT=LRCNT+1,LRLINE(LRCNT)="",LRCNT=LRCNT+1,LRLINE(LRCNT)="Data reported on: "
S LRN="" F S LRN=$O(LROTYPE(LRN)) Q:LRN="" D
.S LRLINE(LRCNT)=LRLINE(LRCNT)_$S(LRN="B":"Bacteria",LRN="F":"Fungus",LRN="M":"Mycobacteria",LRN="P":"Parasite",1:"Virus")_$S($L($O(LROTYPE(LRN))):", ",1:"")
I $D(LRSORG) D
.S LRCNT=LRCNT+1,LRLINE(LRCNT)="** Only the following organisms are reported:"
.K LRTEMP S LRNM="" F S LRNM=$O(LRSORG(LRNM)) Q:LRNM="" D
..S LRN=0 F S LRN=$O(LRSORG(LRNM,LRN)) Q:LRN<1 S LRX=$P(^LAB(61.2,LRN,0),U),LRX=$E(LRX)_$$LOW^XLFSTR($E(LRX,2,99)),LRTEMP(LRNM_LRN)=LRX
.D HLIST("LRTEMP","LRLINE",", ",IOM,.LRCNT) K LRTEMP
I LRLOS S LRCNT=LRCNT+1,LRLINE(LRCNT)="** Data are restricted to specimens collected within "_LRLOS_" days of admission."
I $D(LRAP) S LRCNT=LRCNT+1,LRLINE(LRCNT)="** Data are restricted to a specific antibiotic pattern."
I LRDETAIL S LRCNT=LRCNT+1,LRLINE(LRCNT)="** This report includes detailed information on all isolates."
I LRMERGE="N" S LRCNT=LRCNT+1,LRLINE(LRCNT)="Isolates are NOT merged."
I LRMERGE'="N" D
.S LRCNT=LRCNT+1,LRLINE(LRCNT)="Isolates are merged when same patient, same organism, and "_$S(LRMERGE="S":"same specimen",LRMERGE="C":"same collection sample",1:"any sample")_" exists."
.S LRCNT=LRCNT+1,LRLINE(LRCNT)="Merged isolates are those not having conflicting antibiotic patterns."
I $D(LROTYPE("B")) D
.S LRCNT=LRCNT+1,LRLINE(LRCNT)=""
.S LRCNT=LRCNT+1,LRLINE(LRCNT)="Antibiotics:"
.K LRTEMP S LRABRV="" F S LRABRV=$O(^TMP($J,"AB",LRABRV)) Q:LRABRV="" S LRTEMP(LRABRV)=LRABRV_"="_$P(^(LRABRV),U,2)
.D HLIST("LRTEMP","LRLINE",", ",IOM,.LRCNT) K LRTEMP
S LRCNT=LRCNT+1,LRLINE(LRCNT)=""
Q
HLIST(IN,OUT,DEL,LEN,CNT) ; transforms array IN to horizontal list array OUT, delimited by DEL for maximum length of LEN
; CNT is the starting subscript for the OUT array, CNT can be called by reference
N NEXT,SUB,VALUE S:'$D(LEN) LEN=$S($D(IOM):IOM,1:80) S:'$D(CNT) CNT=0
S CNT=CNT+1,(@OUT@(CNT),SUB)="" F S SUB=$O(@IN@(SUB)) Q:SUB="" S VALUE=$P(@IN@(SUB),U),NEXT=$P($O(@IN@(SUB)),U) D
.I $L(@OUT@(CNT))+$L(VALUE)>(LEN-$L(DEL)) S CNT=CNT+1,@OUT@(CNT)=""
.S @OUT@(CNT)=@OUT@(CNT)_VALUE_$S($L(NEXT):DEL,1:"")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLRMITSRS 3470 printed Oct 16, 2024@18:18:23 Page 2
LRMITSRS ;SLC/STAFF - MICRO TREND REPORT SETUP ;11/7/93 12:33
+1 ;;5.2;LAB SERVICE;**96**;Sep 27, 1994
+2 ; from LRMITSR
+3 ; sets up static information on reports
+4 ;
+5 KILL LRHDR
SET LRHDR1=$PIECE($$HTE^XLFDT($HOROLOG),":",1,2)_" ANTIBIOTIC TREND REPORT (from "_LRFBEG_" to: "_LRFEND_" "
+6 SET LRSPACE=$$REPEAT^XLFSTR(" ",5)
+7 IF $DATA(LROTYPE("B"))
Begin DoDot:1
+8 SET LRHDR(2)=LRSPACE
SET LRABRV=""
SET LRAPRT=0
+9 IF '$DATA(^TMP($JOB,"PSRT"))
FOR
SET LRABRV=$ORDER(^TMP($JOB,"AB",LRABRV))
if LRABRV=""
QUIT
SET LRHDR(2)=LRHDR(2)_"|"_$EXTRACT(LRABRV,1,3)
+10 IF $DATA(^TMP($JOB,"PSRT"))
FOR
SET LRAPRT=$ORDER(^TMP($JOB,"PSRT",LRAPRT))
if +LRAPRT'>0
QUIT
SET LRABRV=$GET(^TMP($JOB,"PSRT",LRAPRT))
SET LRHDR(2)=LRHDR(2)_"|"_$EXTRACT(LRABRV,1,3)
+11 SET LRHDR(2)=LRHDR(2)_"|"
End DoDot:1
+12 IF LRLOS
SET LRHDR(3)=" ** Reports only those specimens collected > "_LRLOS_$SELECT(LRLOS>1:" days",1:" day")_" from admission date **"
+13 SET LRHDR(4)=(IOM-5)\4
SET LRHDR(4)=" "_$$REPEAT^XLFSTR("|---",(LRHDR(4)))
+14 IF $DATA(LRAP)
Begin DoDot:1
+15 SET LRHDR(5)="* ANTIBIOTIC PATTERN *"
SET LRHDR(6)=LRSPACE
+16 SET LRABRV=""
FOR
SET LRABRV=$ORDER(^TMP($JOB,"AB",LRABRV))
if LRABRV=""
QUIT
SET LRDN=+^(LRABRV)
Begin DoDot:2
+17 SET LRHDR(6)=LRHDR(6)_"|"_$JUSTIFY($GET(LRAP(LRDN)),3)
End DoDot:2
+18 SET LRHDR(6)=LRHDR(6)_"|"
End DoDot:1
+19 ; header information
+20 KILL LRLINE
SET LRLINE1="ANTIBIOTIC TREND REPORT BY "
+21 SET LRCNT=2
SET LRX=LRFBEG_" - "_LRFEND
SET LRLINE(LRCNT)=$JUSTIFY(LRX,IOM+$LENGTH(LRX)\2)
+22 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)=""
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="Data reported on: "
+23 SET LRN=""
FOR
SET LRN=$ORDER(LROTYPE(LRN))
if LRN=""
QUIT
Begin DoDot:1
+24 SET LRLINE(LRCNT)=LRLINE(LRCNT)_$SELECT(LRN="B":"Bacteria",LRN="F":"Fungus",LRN="M":"Mycobacteria",LRN="P":"Parasite",1:"Virus")_$SELECT($LENGTH($ORDER(LROTYPE(LRN))):", ",1:"")
End DoDot:1
+25 IF $DATA(LRSORG)
Begin DoDot:1
+26 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="** Only the following organisms are reported:"
+27 KILL LRTEMP
SET LRNM=""
FOR
SET LRNM=$ORDER(LRSORG(LRNM))
if LRNM=""
QUIT
Begin DoDot:2
+28 SET LRN=0
FOR
SET LRN=$ORDER(LRSORG(LRNM,LRN))
if LRN<1
QUIT
SET LRX=$PIECE(^LAB(61.2,LRN,0),U)
SET LRX=$EXTRACT(LRX)_$$LOW^XLFSTR($EXTRACT(LRX,2,99))
SET LRTEMP(LRNM_LRN)=LRX
End DoDot:2
+29 DO HLIST("LRTEMP","LRLINE",", ",IOM,.LRCNT)
KILL LRTEMP
End DoDot:1
+30 IF LRLOS
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="** Data are restricted to specimens collected within "_LRLOS_" days of admission."
+31 IF $DATA(LRAP)
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="** Data are restricted to a specific antibiotic pattern."
+32 IF LRDETAIL
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="** This report includes detailed information on all isolates."
+33 IF LRMERGE="N"
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="Isolates are NOT merged."
+34 IF LRMERGE'="N"
Begin DoDot:1
+35 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="Isolates are merged when same patient, same organism, and "_$SELECT(LRMERGE="S":"same specimen",LRMERGE="C":"same collection sample",1:"any sample")_" exists."
+36 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="Merged isolates are those not having conflicting antibiotic patterns."
End DoDot:1
+37 IF $DATA(LROTYPE("B"))
Begin DoDot:1
+38 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)=""
+39 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="Antibiotics:"
+40 KILL LRTEMP
SET LRABRV=""
FOR
SET LRABRV=$ORDER(^TMP($JOB,"AB",LRABRV))
if LRABRV=""
QUIT
SET LRTEMP(LRABRV)=LRABRV_"="_$PIECE(^(LRABRV),U,2)
+41 DO HLIST("LRTEMP","LRLINE",", ",IOM,.LRCNT)
KILL LRTEMP
End DoDot:1
+42 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)=""
+43 QUIT
HLIST(IN,OUT,DEL,LEN,CNT) ; transforms array IN to horizontal list array OUT, delimited by DEL for maximum length of LEN
+1 ; CNT is the starting subscript for the OUT array, CNT can be called by reference
+2 NEW NEXT,SUB,VALUE
if '$DATA(LEN)
SET LEN=$SELECT($DATA(IOM):IOM,1:80)
if '$DATA(CNT)
SET CNT=0
+3 SET CNT=CNT+1
SET (@OUT@(CNT),SUB)=""
FOR
SET SUB=$ORDER(@IN@(SUB))
if SUB=""
QUIT
SET VALUE=$PIECE(@IN@(SUB),U)
SET NEXT=$PIECE($ORDER(@IN@(SUB)),U)
Begin DoDot:1
+4 IF $LENGTH(@OUT@(CNT))+$LENGTH(VALUE)>(LEN-$LENGTH(DEL))
SET CNT=CNT+1
SET @OUT@(CNT)=""
+5 SET @OUT@(CNT)=@OUT@(CNT)_VALUE_$SELECT($LENGTH(NEXT):DEL,1:"")
End DoDot:1
+6 QUIT