Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: LRARCR2

LRARCR2.m

Go to the documentation of this file.
LRARCR2 ; IHS/DIR/AAB - CLONED WKLD REP GENERATOR-BUILD FOR ARCHIVING ; [ 5/8/95 ]
 ;;5.2;LR;**1002**;JUN 01, 1998
 ;;5.2;LAB SERVICE;**59**;Aug 31, 1995
 ;same as LRCAPR2 except archived wkld file
 S:$D(ZTQUEUED) ZTREQ="@"
 K ^TMP("LRAR",$J) D DATE,^LRARCR3
 Q
DATE ;
 I LRTO<LRFR S X=LRFR,LRFR=LRTO,LRTO=X
 S LRST=LRFR-.000001
 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 ACC
 Q
ACC ;
 S LRACCREC=$G(^LRO(68,LRAA,1,LRST,1,LRNT,0)) Q:LRACCREC=""
 S LRFIL=+$P(LRACCREC,U,2) Q:'LRFIL  Q:(LRFIL>67.0)&(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) I LRLOC Q:'$D(LRLOC(LRLC))!(LRLC<1)
 S:+LRLC LRLC=$P($G(^SC(LRLC,0)),U) S:LRLC="" LRLC="*MISSING LOC*"
 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^LRARCU(+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("LRAR",$J,"TST/TOT")) ^("TST/TOT")=0  S ^("TST/TOT")=^("TST/TOT")+1
 S:'$D(^TMP("LRAR",$J,"TST",LRTEST)) ^(LRTEST)=0 S ^(LRTEST)=^(LRTEST)+1
 S:'$D(^TMP("LRAR",$J,"TST",LRTEST,LRLC)) ^(LRLC)=0 S ^(LRLC)=^(LRLC)+1
 S:'$D(^TMP("LRAR",$J,"TST",LRTEST,LRLC,LRCP)) ^(LRCP)=0 S ^(LRCP)=^(LRCP)+1,J=^(LRCP)
 S ^TMP("LRAR",$J,"TST",LRTEST,LRLC,LRCP,LRAANO,(J+1))=LRNX5_U_LRMAC_U_LRURGNAM
 S:'$D(^TMP("LRAR",$J,"TST/LOC",LRLC)) ^(LRLC)=0 S ^(LRLC)=^(LRLC)+1
 S:'$D(^TMP("LRAR",$J,"TST/LRM",LRMAC)) ^(LRMAC)=0 S ^(LRMAC)=^(LRMAC)+1
 S:'$D(^TMP("LRAR",$J,"TST/LRM",LRMAC,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1
 I LRCNTL D
 . S:'$D(^TMP("LRAR",$J,"TST/CTL",LRMAC)) ^(LRMAC)=0 S ^(LRMAC)=^(LRMAC)+1
 . S:'$D(^TMP("LRAR",$J,"TST/CTL",LRMAC,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1
 I LRURGNAM'="" D
 . S:'$D(^TMP("LRAR",$J,"TST/URG",LRPTYP,LRURGNAM)) ^(LRURGNAM)=0 S ^(LRURGNAM)=^(LRURGNAM)+1
 . S:'$D(^TMP("LRAR",$J,"TST/URG",LRPTYP,LRURGNAM,LRTEST)) ^(LRTEST)=0 S ^(LRTEST)=^(LRTEST)+1
 . S:'$D(^TMP("LRAR",$J,"TST/URG","A",LRURGNAM)) ^(LRURGNAM)=0 S ^(LRURGNAM)=^(LRURGNAM)+1
 . S:'$D(^TMP("LRAR",$J,"TST/URG","A",LRURGNAM,LRTEST)) ^(LRTEST)=0 S ^(LRTEST)=^(LRTEST)+1
 S:'$D(^TMP("LRAR",$J,"DATE",LRNX5D)) ^(LRNX5D)=0 S ^(LRNX5D)=^(LRNX5D)+1
 S:'$D(^TMP("LRAR",$J,"DATE",LRNX5D,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1
 S:'$D(^TMP("LRAR",$J,"DAY",LRNX5D)) ^(LRNX5D)=0 S ^(LRNX5D)=^(LRNX5D)+1
 S:'$D(^TMP("LRAR",$J,"DAY",LRNX5D,LRMAC)) ^(LRMAC)=0 S ^(LRMAC)=^(LRMAC)+1
 S:'$D(^TMP("LRAR",$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 ("OW"[LRLTYP)&((LRFIL=2)!(LRFIL=67))&(LRIOPAT["I") Q "1I" ;       Inpatient
 I ("OW"'[LRLTYP)&((LRFIL=2)!(LRFIL=67))&(LRIOPAT["O") Q "1O" ;    Outpatient
 I (LRIOPAT["R") Q "1R" ;     Other
 Q 0