source: WorldVistAEHR/trunk/r/LAB_SERVICE-LR-LS/LRCAPR2.m@ 738

Last change on this file since 738 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.9 KB
Line 
1LRCAPR2 ;DALOI/PAC/FHS/JBM - WKLD REP GENERATOR-BUILD ;10/11/92 01:55
2 ;;5.2;LAB SERVICE;**88,105,263,264**;Sep 27, 1994
3 ; Reference to ^DIC(4 Supported by Reference #10090
4 ; Reference to ^SC( Supported by Reference #10040
5 S:$D(ZTQUEUED) ZTREQ="@"
6 K ^TMP("LR",$J) D DATE,^LRCAPR3
7 K LRLDIV,LRDIV
8 Q
9DATE ;
10 N LRNOP
11 I LRTO<LRFR S X=LRFR,LRFR=LRTO,LRTO=X
12 S LRST=LRFR-.000001
13 F S LRST=$O(^LRO(68,LRAA,1,LRST)) Q:'LRST!(LRST>LRTO) D
14 . S LRNT=0
15 . F S LRNT=$O(^LRO(68,LRAA,1,LRST,1,LRNT)) Q:'LRNT D ACC
16 Q
17ACC ;
18 S LRACCREC=$G(^LRO(68,LRAA,1,LRST,1,LRNT,0)) Q:LRACCREC="" D
19 . S LRDIV=+$P($G(^(.3)),U,2)
20 S LRFIL=+$P(LRACCREC,U,2) Q:'LRFIL Q:(LRFIL>67.3)&(LRFIL<67.9999)
21 S LRLTYP=$P(LRACCREC,U,11)
22 S LRPATOK=$$CHKPAT(LRIOPAT,LRLTYP,LRFIL) Q:'+LRPATOK
23 S LRPTYP=$E(LRPATOK,2)
24 S LRLC=+$P(LRACCREC,U,13)
25ACC1 D Q:$G(LRNOP)
26 . S LRNOP=1
27 . I '$G(LRLOC),'$G(LRLDIV) S LRNOP=0 Q
28 . I $G(LRDIV),'$G(LRLDIV) S LRNOP=0 Q
29 . I $G(LRDIV),$G(LRLDIV),$D(LRLDIV(LRDIV)) S LRNOP=0 Q
30 . I '$G(LRLC),'$G(LRLOC),$G(LRFIL)=62.3 S LRNOP=0 Q
31 . I $G(LRLC),'$G(LRLOC) S LRNOP=0 Q
32 . I $G(LRLC),$G(LRLOC),$D(LRLOC(LRLC)) S LRNOP=0
33 . I $G(LRCNTL) S LRNOP=0
34 D
35 . I 'LRLC S LRLC="*MISSING LOC* ["_LRFIL_"]" Q
36 . I +LRLC S LRLC=$P($G(^SC(+LRLC,0)),U) I $L(LRLC) S LRLC=LRLC_" ["_LRFIL_"]"
37 . I LRLDIV,LRDIV,$D(^DIC(4,LRDIV,0))#2 S LRLC=$P(^(0),U)_" ["_LRFIL_"]" Q
38 S LRAANO=$S($D(^LRO(68,LRAA,1,LRST,1,LRNT,.2)):^(.2),1:"NO ACCN")
39 S LRSTCS=$G(^LRO(68,LRAA,1,LRST,1,LRNT,5,1,0)) Q:'LRSTCS
40 I LRSP Q:'$P(LRSTCS,U) Q:'$D(LRSP($P(LRSTCS,U)))
41 I LRCOL Q:'$P(LRSTCS,U,2) Q:'$D(LRCOL($P(LRSTCS,U,2)))
42 S LRTST=0
43 F S LRTST=$O(^LRO(68,LRAA,1,LRST,1,LRNT,4,LRTST)) Q:'LRTST D TEST
44 Q
45TEST ;
46 I LRTSTS,'$D(LRTSTS(LRTST)) Q
47 Q:'$D(^LRO(68,LRAA,1,LRST,1,LRNT,4,LRTST,0))#2 S LRNX=^(0) Q:'$P(LRNX,U,5)
48 S LRNX5=$P(LRNX,U,5),LRNX5D=$P(LRNX5,"."),LRURG=$P(LRNX,U,2)
49 I $G(LRSTAT) Q:LRURG="" Q:'$D(LRSTAT(LRURG))#2
50 S LRURGNAM=$S(LRURG="":"",$D(LRSTAT(LRURG))#2:LRSTAT(LRURG),1:"")
51 S LRTEST=$$TST(LRTST)
52 S LRNX5=$S($L(LRTOV,".")=1:$P(LRNX5,"."),1:LRNX5)
53 S LRCPN=0 D LRCC
54 Q
55LRCC ;
56 S LRCPN=$O(^LRO(68,LRAA,1,LRST,1,LRNT,4,LRTST,1,LRCPN)) Q:'LRCPN S LRNODE=$G(^(LRCPN,0)) G:'LRNODE LRCC
57 I LRSITSEL,'$D(LRSITSEL(+$P(LRNODE,U,8))) G LRCC
58 I LRCAPS,'$D(LRCAPS(+LRNODE)) G LRCC
59 S LRCAPNAM=$$WKLDNAME^LRCAPU(+LRNODE)
60 I (LRRTYP=2)&('LRCAPFLG) G LRCC
61 I (LRRTYP=3)&(LRCAPFLG) G LRCC
62 S:(LRCAPFLG)&($E(LRTEST)'="+") LRTEST="+"_LRTEST
63 S LRCP=LRCAPNUM G:'LRCP LRCC
64 S LRDOT="."_$P(LRCP,".",2)
65 S LRTESTCP=$E(LRTEST_" ",1,8)_" ["_LRCP_"]"
66 I LRCPSX,'$D(LRCPSX(LRDOT)) G LRCC
67 S LRMACN=+$O(^LAB(64.2,"F",LRDOT,0))
68 S LRMAC=$S($L($G(^LAB(64.2,LRMACN,0))):$P(^(0),U),1:"ERROR"_LRMACN)
69 S:'$D(^TMP("LR",$J,"TST/TOT")) ^("TST/TOT")=0 S ^("TST/TOT")=^("TST/TOT")+1
70 S:'$D(^TMP("LR",$J,"TST",LRTEST)) ^(LRTEST)=0 S ^(LRTEST)=^(LRTEST)+1
71 S:'$D(^TMP("LR",$J,"TST",LRTEST,LRLC)) ^(LRLC)=0 S ^(LRLC)=^(LRLC)+1
72 S:'$D(^TMP("LR",$J,"TST",LRTEST,LRLC,LRCP)) ^(LRCP)=0 S ^(LRCP)=^(LRCP)+1,J=^(LRCP)
73 S ^TMP("LR",$J,"TST",LRTEST,LRLC,LRCP,LRAANO,(J+1))=LRNX5_U_LRMAC_U_LRURGNAM
74 S:'$D(^TMP("LR",$J,"TST/LOC",LRLC)) ^(LRLC)=0 S ^(LRLC)=^(LRLC)+1
75 S:'$D(^TMP("LR",$J,"TST/LRM",LRMAC)) ^(LRMAC)=0 S ^(LRMAC)=^(LRMAC)+1
76 S:'$D(^TMP("LR",$J,"TST/LRM",LRMAC,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1
77 I $G(LRCTL),$G(LRCNTL) D
78 . S:'$D(^TMP("LR",$J,"TST/CTL",LRMAC)) ^(LRMAC)=0 S ^(LRMAC)=^(LRMAC)+1
79 . S:'$D(^TMP("LR",$J,"TST/CTL",LRMAC,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1
80 I LRURGNAM'="" D
81 . S:'$D(^TMP("LR",$J,"TST/URG",LRPTYP,LRURGNAM)) ^(LRURGNAM)=0 S ^(LRURGNAM)=^(LRURGNAM)+1
82 . S:'$D(^TMP("LR",$J,"TST/URG",LRPTYP,LRURGNAM,LRTEST)) ^(LRTEST)=0 S ^(LRTEST)=^(LRTEST)+1
83 . S:'$D(^TMP("LR",$J,"TST/URG","A",LRURGNAM)) ^(LRURGNAM)=0 S ^(LRURGNAM)=^(LRURGNAM)+1
84 . S:'$D(^TMP("LR",$J,"TST/URG","A",LRURGNAM,LRTEST)) ^(LRTEST)=0 S ^(LRTEST)=^(LRTEST)+1
85 S:'$D(^TMP("LR",$J,"DATE",LRNX5D)) ^(LRNX5D)=0 S ^(LRNX5D)=^(LRNX5D)+1
86 S:'$D(^TMP("LR",$J,"DATE",LRNX5D,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1
87 S:'$D(^TMP("LR",$J,"DAY",LRNX5D)) ^(LRNX5D)=0 S ^(LRNX5D)=^(LRNX5D)+1
88 S:'$D(^TMP("LR",$J,"DAY",LRNX5D,LRMAC)) ^(LRMAC)=0 S ^(LRMAC)=^(LRMAC)+1
89 S:'$D(^TMP("LR",$J,"DAY",LRNX5D,LRMAC,LRTESTCP)) ^(LRTESTCP)=0 S ^(LRTESTCP)=^(LRTESTCP)+1,J=^(LRTESTCP)
90 G LRCC
91 Q
92TST(X) ; this returns the print test name otherwise the test name.
93 N LRDA
94 ;tests are truncated if greater than 7 chars long
95 S LRDA=$G(X) Q:'LRDA "Unknown"
96 Q:'$D(^LAB(60,LRDA,0))#2 "Unknown"
97 Q:$P($G(^LAB(60,LRDA,.1)),U)'="" $P($G(^(.1)),U)
98 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))
99CHKPAT(LRIOPAT,LRLTYP,LRFIL) ; return flag indicating if this record is for
100 ; a patient type selected for this report and if so, what type.
101 S LRCNTL=$S(LRFIL=62.3:1,1:0)
102 ; I LRIOPAT["A" Q "1A" ;All Patients
103 I ("ORW"[LRLTYP)&((LRFIL=2))&((LRIOPAT["I")) Q "1I" ; Inpatient
104 I ("ORW"'[LRLTYP)&((LRFIL=2))&((LRIOPAT["O")) Q "1O" ; Outpatient
105 I LRFIL'=2,LRIOPAT["R" Q "1R" ; Other
106 Q 0
Note: See TracBrowser for help on using the repository browser.