LRCAPR2 ;DALOI/PAC/FHS/JBM - WKLD REP GENERATOR-BUILD ;10/11/92 01:55
;;5.2;LAB SERVICE;**88,105,263,264,396**;Sep 27, 1994;Build 3
; Reference to ^DIC(4 Supported by Reference #10090
; Reference to ^SC( Supported by Reference #10040
S:$D(ZTQUEUED) ZTREQ="@"
K ^TMP("LR",$J) D DATE,^LRCAPR3
K LRLDIV,LRDIV
Q
DATE ;
N LRNOP,ACCTRNS,LRNTDAT
I LRTO<LRFR S X=LRFR,LRFR=LRTO,LRTO=X
S LRTO=LRTO_".99999"
S ACCTRNS=$P(^LRO(68,LRAA,0),U,3)
I ACCTRNS="D" S LRST=LRFR-.000001
I ACCTRNS="Y" S LRST=$E(LRFR,1,3)_"0000"-.001
I ACCTRNS="M"!(ACCTRNS="Q") S LRST=$E(LRFR,1,5)_"00"-.001
F S LRST=$O(^LRO(68,LRAA,1,LRST)) Q:'LRST!(LRST>LRTO) D
. S LRNT=0
. F S LRNT=$O(^LRO(68,LRAA,1,LRST,1,LRNT)) Q:'LRNT D
. . Q:'$D(^LRO(68,LRAA,1,LRST,1,LRNT,0))#2 S LRNTDAT=+$P($G(^(3)),U,3)
. . I LRNTDAT,LRNTDAT'>LRTO,LRNTDAT'<LRFR D ACC
Q
ACC ;
S LRACCREC=$G(^LRO(68,LRAA,1,LRST,1,LRNT,0)) Q:LRACCREC="" D
. S LRDIV=+$P($G(^(.3)),U,2)
S LRFIL=+$P(LRACCREC,U,2) Q:'LRFIL Q:(LRFIL>67.3)&(LRFIL<67.9999)
S LRLTYP=$P(LRACCREC,U,11)
S LRPATOK=$$CHKPAT(LRIOPAT,LRLTYP,LRFIL) Q:'+LRPATOK
S LRPTYP=$E(LRPATOK,2)
S LRLC=+$P(LRACCREC,U,13)
ACC1 D Q:$G(LRNOP)
. S LRNOP=1
. I '$G(LRLOC),'$G(LRLDIV) S LRNOP=0 Q
. I $G(LRDIV),'$G(LRLDIV) S LRNOP=0 Q
. I $G(LRDIV),$G(LRLDIV),$D(LRLDIV(LRDIV)) S LRNOP=0 Q
. I '$G(LRLC),'$G(LRLOC),$G(LRFIL)=62.3 S LRNOP=0 Q
. I $G(LRLC),'$G(LRLOC) S LRNOP=0 Q
. I $G(LRLC),$G(LRLOC),$D(LRLOC(LRLC)) S LRNOP=0
. I $G(LRCNTL) S LRNOP=0
D
. I 'LRLC S LRLC="*MISSING LOC* ["_LRFIL_"]" Q
. I +LRLC S LRLC=$P($G(^SC(+LRLC,0)),U) I $L(LRLC) S LRLC=LRLC_" ["_LRFIL_"]"
. I LRLDIV,LRDIV,$D(^DIC(4,LRDIV,0))#2 S LRLC=$P(^(0),U)_" ["_LRFIL_"]" Q
S LRAANO=$S($D(^LRO(68,LRAA,1,LRST,1,LRNT,.2)):^(.2),1:"NO ACCN")
S LRSTCS=$G(^LRO(68,LRAA,1,LRST,1,LRNT,5,1,0)) Q:'LRSTCS
I LRSP Q:'$P(LRSTCS,U) Q:'$D(LRSP($P(LRSTCS,U)))
I LRCOL Q:'$P(LRSTCS,U,2) Q:'$D(LRCOL($P(LRSTCS,U,2)))
S LRTST=0
F S LRTST=$O(^LRO(68,LRAA,1,LRST,1,LRNT,4,LRTST)) Q:'LRTST D TEST
Q
TEST ;
I LRTSTS,'$D(LRTSTS(LRTST)) Q
Q:'$D(^LRO(68,LRAA,1,LRST,1,LRNT,4,LRTST,0))#2 S LRNX=^(0) Q:'$P(LRNX,U,5)
S LRNX5=$P(LRNX,U,5),LRNX5D=$P(LRNX5,"."),LRURG=$P(LRNX,U,2)
I $G(LRSTAT) Q:LRURG="" Q:'$D(LRSTAT(LRURG))#2
S LRURGNAM=$S(LRURG="":"",$D(LRSTAT(LRURG))#2:LRSTAT(LRURG),1:"")
S LRTEST=$$TST(LRTST)
S LRNX5=$S($L(LRTOV,".")=1:$P(LRNX5,"."),1:LRNX5)
S LRCPN=0 D LRCC
Q
LRCC ;
S LRCPN=$O(^LRO(68,LRAA,1,LRST,1,LRNT,4,LRTST,1,LRCPN)) Q:'LRCPN S LRNODE=$G(^(LRCPN,0)) G:'LRNODE LRCC
I LRSITSEL,'$D(LRSITSEL(+$P(LRNODE,U,8))) G LRCC
I LRCAPS,'$D(LRCAPS(+LRNODE)) G LRCC
S LRCAPNAM=$$WKLDNAME^LRCAPU(+LRNODE)
I (LRRTYP=2)&('LRCAPFLG) G LRCC
I (LRRTYP=3)&(LRCAPFLG) G LRCC
S:(LRCAPFLG)&($E(LRTEST)'="+") LRTEST="+"_LRTEST
S LRCP=LRCAPNUM G:'LRCP LRCC
S LRDOT="."_$P(LRCP,".",2)
S LRTESTCP=$E(LRTEST_" ",1,8)_" ["_LRCP_"]"
I LRCPSX,'$D(LRCPSX(LRDOT)) G LRCC
S LRMACN=+$O(^LAB(64.2,"F",LRDOT,0))
S LRMAC=$S($L($G(^LAB(64.2,LRMACN,0))):$P(^(0),U),1:"ERROR"_LRMACN)
S:'$D(^TMP("LR",$J,"TST/TOT")) ^("TST/TOT")=0 S ^("TST/TOT")=^("TST/TOT")+1
S:'$D(^TMP("LR",$J,"TST",LRTEST)) ^(LRTEST)=0 S ^(LRTEST)=^(LRTEST)+1
S:'$D(^TMP("LR",$J,"TST",LRTEST,LRLC)) ^(LRLC)=0 S ^(LRLC)=^(LRLC)+1
S:'$D(^TMP("LR",$J,"TST",LRTEST,LRLC,LRCP)) ^(LRCP)=0 S ^(LRCP)=^(LRCP)+1,J=^(LRCP)
S ^TMP("LR",$J,"TST",LRTEST,LRLC,LRCP,LRAANO,(J+1))=LRNX5_U_LRMAC_U_LRURGNAM
S:'$D(^TMP("LR",$J,"TST/LOC",LRLC)) ^(LRLC)=0 S ^(LRLC)=^(LRLC)+1
S:'$D(^TMP("LR",$J,"TST/LRM",LRMAC)) ^(LRMAC)=0 S ^(LRMAC)=^(LRMAC)+1
S:'$D(^TMP("LR",$J,"TST/LRM",LRMAC,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1
I $G(LRCTL),$G(LRCNTL) D
. S:'$D(^TMP("LR",$J,"TST/CTL",LRMAC)) ^(LRMAC)=0 S ^(LRMAC)=^(LRMAC)+1
. S:'$D(^TMP("LR",$J,"TST/CTL",LRMAC,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1
I LRURGNAM'="" D
. S:'$D(^TMP("LR",$J,"TST/URG",LRPTYP,LRURGNAM)) ^(LRURGNAM)=0 S ^(LRURGNAM)=^(LRURGNAM)+1
. S:'$D(^TMP("LR",$J,"TST/URG",LRPTYP,LRURGNAM,LRTEST)) ^(LRTEST)=0 S ^(LRTEST)=^(LRTEST)+1
. S:'$D(^TMP("LR",$J,"TST/URG","A",LRURGNAM)) ^(LRURGNAM)=0 S ^(LRURGNAM)=^(LRURGNAM)+1
. S:'$D(^TMP("LR",$J,"TST/URG","A",LRURGNAM,LRTEST)) ^(LRTEST)=0 S ^(LRTEST)=^(LRTEST)+1
S:'$D(^TMP("LR",$J,"DATE",LRNX5D)) ^(LRNX5D)=0 S ^(LRNX5D)=^(LRNX5D)+1
S:'$D(^TMP("LR",$J,"DATE",LRNX5D,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1
S:'$D(^TMP("LR",$J,"DAY",LRNX5D)) ^(LRNX5D)=0 S ^(LRNX5D)=^(LRNX5D)+1
S:'$D(^TMP("LR",$J,"DAY",LRNX5D,LRMAC)) ^(LRMAC)=0 S ^(LRMAC)=^(LRMAC)+1
S:'$D(^TMP("LR",$J,"DAY",LRNX5D,LRMAC,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1,J=^(LRTESTCP)
G LRCC
Q
TST(X) ; this returns the print test name otherwise the test name.
N LRDA
;tests are truncated if greater than 7 chars long
S LRDA=$G(X) Q:'LRDA "Unknown"
Q:'$D(^LAB(60,LRDA,0))#2 "Unknown"
Q:$P($G(^LAB(60,LRDA,.1)),U)'="" $P($G(^(.1)),U)
Q $S($L($P(^LAB(60,LRDA,0),U))>7:$E($P(^LAB(60,LRDA,0),U),1,6)_"*",1:$P(^LAB(60,LRDA,0),U))
CHKPAT(LRIOPAT,LRLTYP,LRFIL) ; return flag indicating if this record is for
; a patient type selected for this report and if so, what type.
S LRCNTL=$S(LRFIL=62.3:1,1:0)
; I LRIOPAT["A" Q "1A" ;All Patients
I ("ORW"[LRLTYP)&((LRFIL=2))&((LRIOPAT["I")) Q "1I" ; Inpatient
I ("ORW"'[LRLTYP)&((LRFIL=2))&((LRIOPAT["O")) Q "1O" ; Outpatient
I LRFIL'=2,LRIOPAT["R" Q "1R" ; Other
Q 0
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLRCAPR2 5441 printed Dec 13, 2024@02:13:18 Page 2
LRCAPR2 ;DALOI/PAC/FHS/JBM - WKLD REP GENERATOR-BUILD ;10/11/92 01:55
+1 ;;5.2;LAB SERVICE;**88,105,263,264,396**;Sep 27, 1994;Build 3
+2 ; Reference to ^DIC(4 Supported by Reference #10090
+3 ; Reference to ^SC( Supported by Reference #10040
+4 if $DATA(ZTQUEUED)
SET ZTREQ="@"
+5 KILL ^TMP("LR",$JOB)
DO DATE
DO ^LRCAPR3
+6 KILL LRLDIV,LRDIV
+7 QUIT
DATE ;
+1 NEW LRNOP,ACCTRNS,LRNTDAT
+2 IF LRTO<LRFR
SET X=LRFR
SET LRFR=LRTO
SET LRTO=X
+3 SET LRTO=LRTO_".99999"
+4 SET ACCTRNS=$PIECE(^LRO(68,LRAA,0),U,3)
+5 IF ACCTRNS="D"
SET LRST=LRFR-.000001
+6 IF ACCTRNS="Y"
SET LRST=$EXTRACT(LRFR,1,3)_"0000"-.001
+7 IF ACCTRNS="M"!(ACCTRNS="Q")
SET LRST=$EXTRACT(LRFR,1,5)_"00"-.001
+8 FOR
SET LRST=$ORDER(^LRO(68,LRAA,1,LRST))
if 'LRST!(LRST>LRTO)
QUIT
Begin DoDot:1
+9 SET LRNT=0
+10 FOR
SET LRNT=$ORDER(^LRO(68,LRAA,1,LRST,1,LRNT))
if 'LRNT
QUIT
Begin DoDot:2
+11 if '$DATA(^LRO(68,LRAA,1,LRST,1,LRNT,0))#2
QUIT
SET LRNTDAT=+$PIECE($GET(^(3)),U,3)
+12 IF LRNTDAT
IF LRNTDAT'>LRTO
IF LRNTDAT'<LRFR
DO ACC
End DoDot:2
End DoDot:1
+13 QUIT
ACC ;
+1 SET LRACCREC=$GET(^LRO(68,LRAA,1,LRST,1,LRNT,0))
if LRACCREC=""
QUIT
Begin DoDot:1
+2 SET LRDIV=+$PIECE($GET(^(.3)),U,2)
End DoDot:1
+3 SET LRFIL=+$PIECE(LRACCREC,U,2)
if 'LRFIL
QUIT
if (LRFIL>67.3)&(LRFIL<67.9999)
QUIT
+4 SET LRLTYP=$PIECE(LRACCREC,U,11)
+5 SET LRPATOK=$$CHKPAT(LRIOPAT,LRLTYP,LRFIL)
if '+LRPATOK
QUIT
+6 SET LRPTYP=$EXTRACT(LRPATOK,2)
+7 SET LRLC=+$PIECE(LRACCREC,U,13)
ACC1 Begin DoDot:1
+1 SET LRNOP=1
+2 IF '$GET(LRLOC)
IF '$GET(LRLDIV)
SET LRNOP=0
QUIT
+3 IF $GET(LRDIV)
IF '$GET(LRLDIV)
SET LRNOP=0
QUIT
+4 IF $GET(LRDIV)
IF $GET(LRLDIV)
IF $DATA(LRLDIV(LRDIV))
SET LRNOP=0
QUIT
+5 IF '$GET(LRLC)
IF '$GET(LRLOC)
IF $GET(LRFIL)=62.3
SET LRNOP=0
QUIT
+6 IF $GET(LRLC)
IF '$GET(LRLOC)
SET LRNOP=0
QUIT
+7 IF $GET(LRLC)
IF $GET(LRLOC)
IF $DATA(LRLOC(LRLC))
SET LRNOP=0
+8 IF $GET(LRCNTL)
SET LRNOP=0
End DoDot:1
if $GET(LRNOP)
QUIT
+9 Begin DoDot:1
+10 IF 'LRLC
SET LRLC="*MISSING LOC* ["_LRFIL_"]"
QUIT
+11 IF +LRLC
SET LRLC=$PIECE($GET(^SC(+LRLC,0)),U)
IF $LENGTH(LRLC)
SET LRLC=LRLC_" ["_LRFIL_"]"
+12 IF LRLDIV
IF LRDIV
IF $DATA(^DIC(4,LRDIV,0))#2
SET LRLC=$PIECE(^(0),U)_" ["_LRFIL_"]"
QUIT
End DoDot:1
+13 SET LRAANO=$SELECT($DATA(^LRO(68,LRAA,1,LRST,1,LRNT,.2)):^(.2),1:"NO ACCN")
+14 SET LRSTCS=$GET(^LRO(68,LRAA,1,LRST,1,LRNT,5,1,0))
if 'LRSTCS
QUIT
+15 IF LRSP
if '$PIECE(LRSTCS,U)
QUIT
if '$DATA(LRSP($PIECE(LRSTCS,U)))
QUIT
+16 IF LRCOL
if '$PIECE(LRSTCS,U,2)
QUIT
if '$DATA(LRCOL($PIECE(LRSTCS,U,2)))
QUIT
+17 SET LRTST=0
+18 FOR
SET LRTST=$ORDER(^LRO(68,LRAA,1,LRST,1,LRNT,4,LRTST))
if 'LRTST
QUIT
DO TEST
+19 QUIT
TEST ;
+1 IF LRTSTS
IF '$DATA(LRTSTS(LRTST))
QUIT
+2 if '$DATA(^LRO(68,LRAA,1,LRST,1,LRNT,4,LRTST,0))#2
QUIT
SET LRNX=^(0)
if '$PIECE(LRNX,U,5)
QUIT
+3 SET LRNX5=$PIECE(LRNX,U,5)
SET LRNX5D=$PIECE(LRNX5,".")
SET LRURG=$PIECE(LRNX,U,2)
+4 IF $GET(LRSTAT)
if LRURG=""
QUIT
if '$DATA(LRSTAT(LRURG))#2
QUIT
+5 SET LRURGNAM=$SELECT(LRURG="":"",$DATA(LRSTAT(LRURG))#2:LRSTAT(LRURG),1:"")
+6 SET LRTEST=$$TST(LRTST)
+7 SET LRNX5=$SELECT($LENGTH(LRTOV,".")=1:$PIECE(LRNX5,"."),1:LRNX5)
+8 SET LRCPN=0
DO LRCC
+9 QUIT
LRCC ;
+1 SET LRCPN=$ORDER(^LRO(68,LRAA,1,LRST,1,LRNT,4,LRTST,1,LRCPN))
if 'LRCPN
QUIT
SET LRNODE=$GET(^(LRCPN,0))
if 'LRNODE
GOTO LRCC
+2 IF LRSITSEL
IF '$DATA(LRSITSEL(+$PIECE(LRNODE,U,8)))
GOTO LRCC
+3 IF LRCAPS
IF '$DATA(LRCAPS(+LRNODE))
GOTO LRCC
+4 SET LRCAPNAM=$$WKLDNAME^LRCAPU(+LRNODE)
+5 IF (LRRTYP=2)&('LRCAPFLG)
GOTO LRCC
+6 IF (LRRTYP=3)&(LRCAPFLG)
GOTO LRCC
+7 if (LRCAPFLG)&($EXTRACT(LRTEST)'="+")
SET LRTEST="+"_LRTEST
+8 SET LRCP=LRCAPNUM
if 'LRCP
GOTO LRCC
+9 SET LRDOT="."_$PIECE(LRCP,".",2)
+10 SET LRTESTCP=$EXTRACT(LRTEST_" ",1,8)_" ["_LRCP_"]"
+11 IF LRCPSX
IF '$DATA(LRCPSX(LRDOT))
GOTO LRCC
+12 SET LRMACN=+$ORDER(^LAB(64.2,"F",LRDOT,0))
+13 SET LRMAC=$SELECT($LENGTH($GET(^LAB(64.2,LRMACN,0))):$PIECE(^(0),U),1:"ERROR"_LRMACN)
+14 if '$DATA(^TMP("LR",$JOB,"TST/TOT"))
SET ^("TST/TOT")=0
SET ^("TST/TOT")=^("TST/TOT")+1
+15 if '$DATA(^TMP("LR",$JOB,"TST",LRTEST))
SET ^(LRTEST)=0
SET ^(LRTEST)=^(LRTEST)+1
+16 if '$DATA(^TMP("LR",$JOB,"TST",LRTEST,LRLC))
SET ^(LRLC)=0
SET ^(LRLC)=^(LRLC)+1
+17 if '$DATA(^TMP("LR",$JOB,"TST",LRTEST,LRLC,LRCP))
SET ^(LRCP)=0
SET ^(LRCP)=^(LRCP)+1
SET J=^(LRCP)
+18 SET ^TMP("LR",$JOB,"TST",LRTEST,LRLC,LRCP,LRAANO,(J+1))=LRNX5_U_LRMAC_U_LRURGNAM
+19 if '$DATA(^TMP("LR",$JOB,"TST/LOC",LRLC))
SET ^(LRLC)=0
SET ^(LRLC)=^(LRLC)+1
+20 if '$DATA(^TMP("LR",$JOB,"TST/LRM",LRMAC))
SET ^(LRMAC)=0
SET ^(LRMAC)=^(LRMAC)+1
+21 if '$DATA(^TMP("LR",$JOB,"TST/LRM",LRMAC,LRTESTCP))
SET ^(LRTESTCP)=0
SET ^(LRTESTCP)=^(LRTESTCP)+1
+22 IF $GET(LRCTL)
IF $GET(LRCNTL)
Begin DoDot:1
+23 if '$DATA(^TMP("LR",$JOB,"TST/CTL",LRMAC))
SET ^(LRMAC)=0
SET ^(LRMAC)=^(LRMAC)+1
+24 if '$DATA(^TMP("LR",$JOB,"TST/CTL",LRMAC,LRTESTCP))
SET ^(LRTESTCP)=0
SET ^(LRTESTCP)=^(LRTESTCP)+1
End DoDot:1
+25 IF LRURGNAM'=""
Begin DoDot:1
+26 if '$DATA(^TMP("LR",$JOB,"TST/URG",LRPTYP,LRURGNAM))
SET ^(LRURGNAM)=0
SET ^(LRURGNAM)=^(LRURGNAM)+1
+27 if '$DATA(^TMP("LR",$JOB,"TST/URG",LRPTYP,LRURGNAM,LRTEST))
SET ^(LRTEST)=0
SET ^(LRTEST)=^(LRTEST)+1
+28 if '$DATA(^TMP("LR",$JOB,"TST/URG","A",LRURGNAM))
SET ^(LRURGNAM)=0
SET ^(LRURGNAM)=^(LRURGNAM)+1
+29 if '$DATA(^TMP("LR",$JOB,"TST/URG","A",LRURGNAM,LRTEST))
SET ^(LRTEST)=0
SET ^(LRTEST)=^(LRTEST)+1
End DoDot:1
+30 if '$DATA(^TMP("LR",$JOB,"DATE",LRNX5D))
SET ^(LRNX5D)=0
SET ^(LRNX5D)=^(LRNX5D)+1
+31 if '$DATA(^TMP("LR",$JOB,"DATE",LRNX5D,LRTESTCP))
SET ^(LRTESTCP)=0
SET ^(LRTESTCP)=^(LRTESTCP)+1
+32 if '$DATA(^TMP("LR",$JOB,"DAY",LRNX5D))
SET ^(LRNX5D)=0
SET ^(LRNX5D)=^(LRNX5D)+1
+33 if '$DATA(^TMP("LR",$JOB,"DAY",LRNX5D,LRMAC))
SET ^(LRMAC)=0
SET ^(LRMAC)=^(LRMAC)+1
+34 if '$DATA(^TMP("LR",$JOB,"DAY",LRNX5D,LRMAC,LRTESTCP))
SET ^(LRTESTCP)=0
SET ^(LRTESTCP)=^(LRTESTCP)+1
SET J=^(LRTESTCP)
+35 GOTO LRCC
+36 QUIT
TST(X) ; this returns the print test name otherwise the test name.
+1 NEW LRDA
+2 ;tests are truncated if greater than 7 chars long
+3 SET LRDA=$GET(X)
if 'LRDA
QUIT "Unknown"
+4 if '$DATA(^LAB(60,LRDA,0))#2
QUIT "Unknown"
+5 if $PIECE($GET(^LAB(60,LRDA,.1)),U)'=""
QUIT $PIECE($GET(^(.1)),U)
+6 QUIT $SELECT($LENGTH($PIECE(^LAB(60,LRDA,0),U))>7:$EXTRACT($PIECE(^LAB(60,LRDA,0),U),1,6)_"*",1:$PIECE(^LAB(60,LRDA,0),U))
CHKPAT(LRIOPAT,LRLTYP,LRFIL) ; return flag indicating if this record is for
+1 ; a patient type selected for this report and if so, what type.
+2 SET LRCNTL=$SELECT(LRFIL=62.3:1,1:0)
+3 ; I LRIOPAT["A" Q "1A" ;All Patients
+4 ; Inpatient
IF ("ORW"[LRLTYP)&((LRFIL=2))&((LRIOPAT["I"))
QUIT "1I"
+5 ; Outpatient
IF ("ORW"'[LRLTYP)&((LRFIL=2))&((LRIOPAT["O"))
QUIT "1O"
+6 ; Other
IF LRFIL'=2
IF LRIOPAT["R"
QUIT "1R"
+7 QUIT 0