LRMITSRS ; IHS/DIR/FJE - MICRO TREND REPORT SETUP 12:33 ;
;;5.2;LR;**1013**;JUL 15, 2002
;
;;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
LRMITSRS ; IHS/DIR/FJE - MICRO TREND REPORT SETUP 12:33 ;
+1 ;;5.2;LR;**1013**;JUL 15, 2002
+2 ;
+3 ;;5.2;LAB SERVICE;**96**;Sep 27, 1994
+4 ; from LRMITSR
+5 ; sets up static information on reports
+6 ;
+7 KILL LRHDR
SET LRHDR1=$PIECE($$HTE^XLFDT($HOROLOG),":",1,2)_" ANTIBIOTIC TREND REPORT (from "_LRFBEG_" to: "_LRFEND_" "
+8 SET LRSPACE=$$REPEAT^XLFSTR(" ",5)
+9 IF $DATA(LROTYPE("B"))
Begin DoDot:1
+10 SET LRHDR(2)=LRSPACE
SET LRABRV=""
SET LRAPRT=0
+11 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)
+12 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)
+13 SET LRHDR(2)=LRHDR(2)_"|"
End DoDot:1
+14 IF LRLOS
SET LRHDR(3)=" ** Reports only those specimens collected > "_LRLOS_$SELECT(LRLOS>1:" days",1:" day")_" from admission date **"
+15 SET LRHDR(4)=(IOM-5)\4
SET LRHDR(4)=" "_$$REPEAT^XLFSTR("|---",(LRHDR(4)))
+16 IF $DATA(LRAP)
Begin DoDot:1
+17 SET LRHDR(5)="* ANTIBIOTIC PATTERN *"
SET LRHDR(6)=LRSPACE
+18 SET LRABRV=""
FOR
SET LRABRV=$ORDER(^TMP($JOB,"AB",LRABRV))
IF LRABRV=""
QUIT
SET LRDN=+^(LRABRV)
Begin DoDot:2
+19 SET LRHDR(6)=LRHDR(6)_"|"_$JUSTIFY($GET(LRAP(LRDN)),3)
End DoDot:2
+20 SET LRHDR(6)=LRHDR(6)_"|"
End DoDot:1
+21 ; header information
+22 KILL LRLINE
SET LRLINE1="ANTIBIOTIC TREND REPORT BY "
+23 SET LRCNT=2
SET LRX=LRFBEG_" - "_LRFEND
SET LRLINE(LRCNT)=$JUSTIFY(LRX,IOM+$LENGTH(LRX)\2)
+24 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)=""
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="Data reported on: "
+25 SET LRN=""
FOR
SET LRN=$ORDER(LROTYPE(LRN))
IF LRN=""
QUIT
Begin DoDot:1
+26 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
+27 IF $DATA(LRSORG)
Begin DoDot:1
+28 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="** Only the following organisms are reported:"
+29 KILL LRTEMP
SET LRNM=""
FOR
SET LRNM=$ORDER(LRSORG(LRNM))
IF LRNM=""
QUIT
Begin DoDot:2
+30 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
+31 DO HLIST("LRTEMP","LRLINE",", ",IOM,.LRCNT)
KILL LRTEMP
End DoDot:1
+32 IF LRLOS
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="** Data are restricted to specimens collected within "_LRLOS_" days of admission."
+33 IF $DATA(LRAP)
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="** Data are restricted to a specific antibiotic pattern."
+34 IF LRDETAIL
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="** This report includes detailed information on all isolates."
+35 IF LRMERGE="N"
SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="Isolates are NOT merged."
+36 IF LRMERGE'="N"
Begin DoDot:1
+37 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."
+38 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="Merged isolates are those not having conflicting antibiotic patterns."
End DoDot:1
+39 IF $DATA(LROTYPE("B"))
Begin DoDot:1
+40 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)=""
+41 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)="Antibiotics:"
+42 KILL LRTEMP
SET LRABRV=""
FOR
SET LRABRV=$ORDER(^TMP($JOB,"AB",LRABRV))
IF LRABRV=""
QUIT
SET LRTEMP(LRABRV)=LRABRV_"="_$PIECE(^(LRABRV),U,2)
+43 DO HLIST("LRTEMP","LRLINE",", ",IOM,.LRCNT)
KILL LRTEMP
End DoDot:1
+44 SET LRCNT=LRCNT+1
SET LRLINE(LRCNT)=""
+45 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