source: WorldVistAEHR/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBOMM2.m@ 1789

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

initial load of WorldVistAEHR

File size: 6.0 KB
Line 
1PSBOMM2 ;BIRMINGHAM/EFC-MISSED MEDS ;Mar 2004
2 ;;3.0;BAR CODE MED ADMIN;**26,32**;Mar 2004;Build 32
3 ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
4 ;
5MISSED(PSBADMN,PSBEDIT,PSBXDT) ;
6 N PSBMISD,PSBAUDT,PSBSTRT2
7 S PSBSTRT2=(PSBXDT\1) F D Q:PSBODD S PSBSTRT2=$$FMADD^XLFDT(PSBSTRT2,1) Q:PSBSTRT2>PSBSTOP
8 .F Y=1:1:$L(PSBADMN,"-") S PSBDT=+("."_$P(PSBADMN,"-",Y))+(PSBSTRT2) D
9 ..S PSBMISD=$$CHECK(PSBDT)
10 ..;CHECK AUDITED ADMIN TIMES FOR MISSED MED
11 ..I PSBMISD F I=1:1:$P(PSBOACTL(0),U,4) I $P($G(PSBOACTL(I,1)),U,3)["ADMIN TIMES" D Q:'PSBMISD
12 ...Q:$P(PSBOACTL(I,1),U)<PSBSTRT2
13 ...Q:$P(PSBOACTL(I,1),U)>PSBSTOP
14 ...S PSBAUDT=+("."_$P(PSBOACTL(I,2),"-",Y))+(PSBSTRT2\1)
15 ...S PSBMISD=$$CHECK(PSBAUDT),PSBEDIT=1
16 ..I PSBMISD D
17 ...Q:'$$OKAY^PSBVDLU1(PSBOST,PSBSTRT2,PSBSCH,PSBONX,$P(^TMP("PSJ",$J,PSBX,3),U,2),PSBFREQ,PSBOSTS)
18 ...S:'$D(^TMP("PSB",$J,DFN,PSBDT,"* "_PSBOITX,PSBONX)) ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX)=""
19 ...D UDCONT
20 Q
21CHECK(PSBDT) ;
22 I PSBDT<PSBOST Q 0 ; Order Start Date
23 I PSBDT'<PSBOSP Q 0 ; Order Stop Date
24 I PSBDT<PSBSTRT Q 0 ; Report Window
25 I PSBDT>PSBSTOP Q 0 ; Report Window
26 I $D(^PSB(53.79,"AORD",DFN,PSBONX,PSBDT)) D Q:PSBSTUS'="N" $G(PART,0)
27 .K PART S PSBIX=$O(^PSB(53.79,"AORD",DFN,PSBONX,PSBDT,"")),PSBSTUS=$P(^PSB(53.79,PSBIX,0),U,9)
28 .I PSBOCRIT[PSBOSTS D:(PSBACRIT[PSBSTUS) Q
29 ..I (PSBSTUS="G")&$D(^PSB(53.79,PSBIX,.5)) D
30 ...S X=0 F S X=$O(^PSB(53.79,PSBIX,.5,X)) Q:+X=0 D
31 ....I $P(^PSB(53.79,PSBIX,.5,X,0),U,2)>$P(^PSB(53.79,PSBIX,.5,X,0),U,3) D S PSBOITX=$E(PSBOITX,3,999)
32 .....S PSBOITX="* "_PSBOITX S ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX,"X")="Units Ordered: "_$P(^PSB(53.79,PSBIX,.5,X,0),U,2)_" Units Given: "_$P(^PSB(53.79,PSBIX,.5,X,0),U,3)_" Admin. Status: * Partial (Given)"
33 .....S PART=1
34 .....D:PSBINCC GCMNTS(PSBIX)
35 ..I PSBSTUS'="G" I PSBACRIT[PSBSTUS S PART=1 S ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX,"X")="Admin. Status: ("_$S(PSBSTUS="":" *UNKNOWN* ",PSBSTUS="M":"Missing Dose",PSBSTUS="H":"Held",PSBSTUS="R":"Refused")_")" D:PSBINCC GCMNTS(PSBIX)
36 Q 1
37UDCONT ;
38 S PSBFLAG=0,J=1
39 K ^TMP("PSB1",$J)
40 F I=1:1:$P(PSBOACTL(0),U,4) D
41 . I $P($G(PSBOACTL(I,1)),U,4)["ON HOLD"!($P($G(PSBOACTL(I,1)),U,4)="HOLD") S ^TMP("PSB1",$J,DFN,J)="HOLD"_U_$E($P($G(PSBOACTL(I,1)),U,1),1,12)
42 . I $P($G(PSBOACTL(I,1)),U,4)["TAKEN OFF HOLD"!($P($G(PSBOACTL(I,1)),U,4)["UNHOLD") S $P(^TMP("PSB1",$J,DFN,J),U,3)="OFF HOLD"_U_$E($P($G(PSBOACTL(I,1)),U,1),1,12),J=J+1
43 D:$D(^TMP("PSB1",$J,DFN))&($P(PSBOACTL(0),U,4)'=1)
44 .S J=0 F S J=$O(^TMP("PSB1",$J,DFN,J)) Q:'J Q:PSBFLAG D
45 ..S PSBHDDT=$P(^TMP("PSB1",$J,DFN,J),U,2)
46 ..S PSBHDST=$P(^TMP("PSB1",$J,DFN,J),U)
47 ..S PSBOFDT=$P(^TMP("PSB1",$J,DFN,J),U,4)
48 ..S PSBOFST=$P(^TMP("PSB1",$J,DFN,J),U,3)
49 ..I PSBDT>PSBHDDT,PSBHDST="HOLD",PSBOFST'="" I PSBDT<PSBOFDT,PSBOFST="OFF HOLD" S PSBFLAG=2,PSBUNHD=PSBOFDT
50 ..I PSBDT>PSBHDDT,PSBHDST="HOLD",PSBOFST="" S PSBFLAG=1
51 K PSBCNT,TMP("PSB1",$J)
52 S PSBOITX2=PSBOITX
53 I $D(^TMP("PSB",$J,DFN,PSBDT,"* "_PSBOITX,PSBONX)) S PSBOITX="* "_PSBOITX
54 I PSBFLAG=1 S ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX)="(On Hold) "_$$DTFMT(PSBHDDT)
55 I PSBFLAG=2 S ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX)="(On Hold) "_$$DTFMT(PSBHDDT)_" "_"(Off Hold) "_$$DTFMT(PSBUNHD)
56 S PSBOITX=PSBOITX2
57 Q
58 ;
59UDONE ;
60 S PSBFLAG=0,J=1
61 F I=1:1:$P(PSBOACTL(0),U,4) D
62 .I $P($G(PSBOACTL(I,1)),U,4)["ON HOLD"!($P($G(PSBOACTL(I,1)),U,4)="HOLD") S ^TMP("PSB1",$J,DFN,J)="HOLD"_U_$E($P($G(PSBOACTL(I,1)),U,1),1,12)
63 .I $P($G(PSBOACTL(I,1)),U,4)["TAKEN OFF HOLD"!($P($G(PSBOACTL(I,1)),U,4)["UNHOLD") S $P(^TMP("PSB1",$J,DFN,J),U,3)="OFF HOLD"_U_$E($P($G(PSBOACTL(I,1)),U,1),1,12),J=J+1
64 D:$D(^TMP("PSB1",$J,DFN))&($P(PSBOACTL(0),U,4)'=1)
65 .S J="" F S J=$O(^TMP("PSB1",$J,DFN,J)) Q:'J Q:PSBFLAG D
66 ..S PSBHDDT=$P(^TMP("PSB1",$J,DFN,J),U,2)
67 ..S PSBHDST=$P(^TMP("PSB1",$J,DFN,J),U)
68 ..S PSBOFDT=$P(^TMP("PSB1",$J,DFN,J),U,4)
69 ..S PSBOFST=$P(^TMP("PSB1",$J,DFN,J),U,3)
70 ..I PSBOSTS="A",PSBHDST="HOLD",PSBOFST'="",'$D(^TMP("PSB1",$J,DFN,J+1)) I PSBSTOP>PSBOFDT,PSBOFST="OFF HOLD" S PSBFLAG=2,PSBUNHD=PSBOFDT
71 ..I PSBOSTS="A",PSBHDST="HOLD",PSBOFST'="",PSBOFDT'<PSBSTOP S PSBFLAG=1
72 ..I PSBOSTS="H",PSBHDST="HOLD",'$D(^TMP("PSB1",$J,DFN,J+1)) S PSBFLAG=1
73 K PSBCNT,^TMP("PSB1",$J)
74 S PSBOITX2=PSBOITX
75 I $D(^TMP("PSB",$J,DFN,PSBDT,"* "_PSBOITX,PSBONX)) S PSBOITX="* "_PSBOITX
76 I PSBFLAG=1 S ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX)="(On Hold) "_$$DTFMT(PSBHDDT)
77 I PSBFLAG=2 S ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX)="(On Hold) "_$$DTFMT(PSBHDDT)_" "_"(Off Hold) "_$$DTFMT(PSBUNHD)
78 S PSBOITX=PSBOITX2
79 Q
80GCMNTS(XIEN) ;
81 Q:'$D(^PSB(53.79,XIEN,.3,1))
82 N X
83 S X=$O(^PSB(53.79,XIEN,.3,""),-1) Q:+X=0 S ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX,.3)="Comment: "_$P(^PSB(53.79,XIEN,.3,X,0),U)
84 Q
85PARTG1(XIEN) ;
86 I $D(^PSB(53.79,XIEN)) D
87 .S PSBSTUS=$P(^PSB(53.79,XIEN,0),U,9)
88 .I PSBOCRIT[PSBOSTS I PSBACRIT[PSBSTUS D S PSBEXST=1 Q
89 ..I (PSBSTUS="G")&$D(^PSB(53.79,XIEN,.5)) D
90 ...S X=0 F S X=$O(^PSB(53.79,XIEN,.5,X)) Q:+X=0 D
91 ....I $P(^PSB(53.79,XIEN,.5,X,0),U,2)>$P(^PSB(53.79,XIEN,.5,X,0),U,3) D S PSBOITX=$E(PSBOITX,3,999),PSBGVN=0
92 .....S PSBOITX="* "_PSBOITX S ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX,"X")="Units Ordered: "_$P(^PSB(53.79,XIEN,.5,X,0),U,2)_" Units Given: "_$P(^PSB(53.79,XIEN,.5,X,0),U,3)_" Admin. Status: * Partial (Given)"
93 .....I PSBINCC D GCMNTS(XIEN)
94 ..I PSBSTUS'="G" D S PSBGVN=0
95 ...I PSBACRIT[PSBSTUS S ^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX,"X")="Admin. Status: ("_$S(PSBSTUS="":" *UNKNOWN* ",PSBSTUS="M":"Missing Dose",PSBSTUS="H":"Held",PSBSTUS="R":"Refused")_")"
96 ...I PSBINCC D GCMNTS(XIEN)
97 Q
98LN1 ;
99 W !,$TR($J("",IOM)," ","-")
100 Q
101DEFLT ;
102 S PSBFUTR=$TR(PSBRPT(1),"~","^")
103 Q:PSBRPT(1)]""
104 S PSBFUTR="^^^^1^^1^1^^^^^^^^1" ;default MM Report settings Per GUI MM report...
105 S X01=""
106 D RPC^PSBPAR(.X01,"GETPAR","ALL","PSB RPT INCL COMMENTS")
107 S $P(PSBRPT(.2),U,8)=+X01(0)
108 K PSBSTOP S PSBSTOP=$P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,9)
109 Q
110DTFMT(DT) ;
111 N Y,X
112 I +DT'>0 S DTFMT=DT Q DTFMT
113 S Y=DT,X=$E($P(Y,".",2)_"0000",1,4)
114 S DTFMT=$TR($J(+$E(Y,4,5),2)_"/"_$J(+$E(Y,6,7),2)_"/"_($E(Y,1,3)+1700)," ","0")_"@"_X
115 Q DTFMT
Note: See TracBrowser for help on using the repository browser.