source: WorldVistAEHR/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBOWA.m@ 1582

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

initial load of WorldVistAEHR

File size: 7.1 KB
RevLine 
[613]1PSBOWA ;BIRMINGHAM/EFC-WARD ADMINISTRATION TIMES ;Mar 2004
2 ;;3.0;BAR CODE MED ADMIN;**9,32**;Mar 2004;Build 32
3 ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
4 ;
5 ; Reference/IA
6 ; ^DPT/10035
7 ; EN^PSJBCMA/2828
8EN ;
9 N PSBHDR,PSBGTOT,PSBTOT,PSBINDX,DFN,PSBX,PSBY,PSBSM,PSBADST,PSBZ
10 S (Y,PSBEVDT)=$P(PSBRPT(.1),U,6) D D^DIQ
11 S PSBHDR(2)="ADMINISTRATION DATE: "_Y
12 S (Y,PSBEVDT2)=$S($P(PSBRPT(.1),U,8)']"":PSBEVDT,1:$P(PSBRPT(.1),U,8)) D D^DIQ
13 S PSBHDR(2)=PSBHDR(2)_" to "_Y
14 F PSBIX=0:1 S PSBRPDT=$$FMADD^XLFDT(PSBEVDT,PSBIX) Q:PSBRPDT>PSBEVDT2 D
15 .D:$P(PSBRPT(.1),U)="W"
16 ..F X=0,.01:.01:.24 S PSBGTOT(X)=""
17 ..W $$WRDHDR()
18 ..S PSBINDX=""
19 ..F S PSBINDX=$O(^TMP("PSBO",$J,"B",PSBINDX)) Q:PSBINDX="" D
20 ...F DFN=0:0 S DFN=$O(^TMP("PSBO",$J,"B",PSBINDX,DFN)) Q:'DFN D
21 ....W:$Y>(IOSL-10) $$WRDHDR()
22 ....W !,$P(^DPT(DFN,0),U,1),!,"SSN: ",$P(^(0),U,9)
23 ....W !,"Ward: ",$E($G(^DPT(DFN,.1)),1,25),!,"Room-Bed: ",$E($G(^(.101)),1,21)
24 ....W ?32
25 ....F X=0,.01:.01:.24 S PSBTOT(X)=""
26 ....K ^TMP("PSJ",$J)
27 ....D EN^PSJBCMA(DFN,$P(PSBRPT(.1),U,6))
28 ....F PSBX=0:0 S PSBX=$O(^TMP("PSJ",$J,PSBX)) Q:'PSBX D
29 .....Q:^TMP("PSJ",$J,PSBX,0)=-1 ; No Orders
30 .....D CLEAN^PSBVT
31 .....D PSJ^PSBVT(PSBX)
32 .....Q:PSBSCHT'="C" ; Not a Continuous
33 .....Q:PSBOSTS'="A"&(PSBOSTS'="R") ; Active?
34 .....Q:PSBSM=1 ;Self med?
35 .....S (PSBCADM,PSBYES,PSBODD)=0
36 .....S PSBFREQ=$$GETFREQ^PSBVDLU1(DFN,PSBONX)
37 .....S:$$PSBDCHK1^PSBVT1(PSBSCH) PSBYES=1
38 .....F I=1:1 Q:$P(PSBSCH,"-",I)="" I ($P(PSBSCH,"-",I)?2N)!($P(PSBSCH,"-",I)?4N) S PSBYES=1
39 .....I PSBYES,PSBADST="",PSBSCHT'="O",PSBSCHT'="OC",PSBSCHT'="P" D Q
40 ......D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Admin times required",PSBSCH)
41 .....I "PCS"'[PSBIVT,PSBONX'["U" Q
42 .....I PSBIVT["S",PSBISYR'=1 Q ; allow intermittent syringe only
43 .....I PSBIVT["C",PSBCHEMT'="P",PSBISYR'=1 Q
44 .....I PSBIVT["C",PSBCHEMT="A" Q ; allow Chemo with intermittent syringe or Piggyback type only
45 .....I PSBFREQ="D" S PSBFREQ=""
46 .....I 'PSBYES,PSBFREQ<1 D Q
47 ......D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid frequency received from order",PSBSCH)
48 .....I +PSBFREQ>0 D
49 ......I (PSBFREQ#1440'=0),(1440#PSBFREQ'=0) S PSBODD=1
50 .....I PSBODD,PSBADST'="" D Q
51 ......D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Administration Times on ODD SCHEDULE",PSBSCH)
52 .....K ^TMP("PSB",$J,"GETADMIN")
53 .....I PSBADST="" S PSBADST=$$GETADMIN^PSBVDLU1(DFN,PSBONX,PSBOST,PSBFREQ,PSBRPDT) S:PSBADST'="" PSBCADM=1
54 .....E S ^TMP("PSB",$J,"GETADMIN",0)=PSBADST
55 .....Q:PSBADST=""
56 .....I PSBONX'["V" D Q:'$$OKAY^PSBVDLU1(PSBOST,$P(PSBRPT(.1),U,6),PSBSCH,PSBONX,PSBOIT,PSBFREQ)
57 .....I PSBONX["V",PSBSCH'="" Q:'$$OKAY^PSBVDLU1(PSBOST,$P(PSBRPT(.1),U,6),PSBSCH,PSBONX,PSBOIT,PSBFREQ)
58 .....F PSBXX=0:1 Q:'$D(^TMP("PSB",$J,"GETADMIN",PSBXX)) S PSBADST=$G(^TMP("PSB",$J,"GETADMIN",PSBXX)) D
59 ......F Y=1:1:$L(PSBADST,"-") S Z=+("."_$E($P(PSBADST,"-",Y),1,2)) D
60 .......Q:(($P(PSBRPT(.1),U,6)+Z)<$E(PSBOST,1,12))&($G(Z)'=0) ;Start Date
61 .......Q:($P(PSBRPT(.1),U,6)+Z)'<$E(PSBOSP,1,12) ;Stop Date
62 .......;For invalid admin times
63 .......D:($P(PSBADST,"-",Y)'?2N)&($P(PSBADST,"-",Y)'?4N)
64 ........D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid Admin times",PSBSCH)
65 .......S PSBTOT(Z)=PSBTOT(Z)+1
66 .......S PSBGTOT(Z)=PSBGTOT(Z)+1
67 ....S PSBX="" F S PSBX=$O(PSBTOT(PSBX)) Q:$G(PSBX)="" W $J(PSBTOT(PSBX),4)
68 ....W !,$TR($J("",IOM)," ","-")
69 ..W !!,$TR($J("",IOM)," ","=")
70 ..W !?32 F X=0,.01:.01:.24 W $J($E(X_"00",2,3),4)
71 ..W !,"Hourly Totals:",?32
72 ..S PSBGTOT=0
73 ..S PSBX="" F S PSBX=$O(PSBGTOT(PSBX)) Q:$G(PSBX)="" D
74 ...W $J(PSBGTOT(PSBX),4)
75 ...S PSBGTOT=PSBGTOT+PSBGTOT(PSBX)
76 ..W !!,"Ward Total:",?32,$J(PSBGTOT,4)
77 ..W !!,$TR($J("",IOM)," ","-")
78 ..K ^TMP("PSJ",$J)
79 .D:$P(PSBRPT(.1),U)="P"
80 ..S DFN=PSBDFN
81 ..S PSBHDR(1)="WARD ADMINISTRATION TIMES"
82 ..S Y=$P(PSBRPT(.1),U,6) D D^DIQ S PSBHDR(2)="ADMINISTRATION DATE: "_Y
83 ..S Y=PSBEVDT2 D D^DIQ S PSBHDR(2)=PSBHDR(2)_" to "_Y
84 ..W $$PTHDR()
85 ..K ^TMP("PSJ",$J),PSBTOT
86 ..D EN^PSJBCMA(PSBDFN,PSBRPDT,"")
87 ..F PSBX=0:0 S PSBX=$O(^TMP("PSJ",$J,PSBX)) Q:'PSBX D
88 ...Q:^TMP("PSJ",$J,PSBX,0)=-1 ; No Orders
89 ...D CLEAN^PSBVT
90 ...D PSJ^PSBVT(PSBX)
91 ...Q:PSBSCHT'="C" ; Not a Continuous
92 ...Q:PSBOSTS'="A"&(PSBOSTS'="R") ; Active?
93 ...S (PSBCADM,PSBYES,PSBODD)=0
94 ...S PSBFREQ=$$GETFREQ^PSBVDLU1(DFN,PSBONX)
95 ...S:$$PSBDCHK1^PSBVT1(PSBSCH) PSBYES=1
96 ...F I=1:1 Q:$P(PSBSCH,"-",I)="" I ($P(PSBSCH,"-",I)?2N)!($P(PSBSCH,"-",I)?4N) S PSBYES=1
97 ...I PSBYES,PSBADST="",PSBSCHT'="O",PSBSCHT'="OC",PSBSCHT'="P" D Q
98 ....D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Admin times required",PSBSCH)
99 ...I "PCS"'[PSBIVT,PSBONX'["U" Q
100 ...I PSBIVT["S",PSBISYR'=1 Q ; allow intermittent syringe only
101 ...I PSBIVT["C",PSBCHEMT'="P",PSBISYR'=1 Q
102 ...I PSBIVT["C",PSBCHEMT="A" Q ; allow Chemo with intermittent syringe or Piggyback type only
103 ...I PSBFREQ="D" S PSBFREQ=""
104 ...I 'PSBYES,PSBFREQ<1 D Q
105 ....D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid frequency received from order",PSBSCH)
106 ...I +PSBFREQ>0 D
107 ....I (PSBFREQ#1440'=0),(1440#PSBFREQ'=0) S PSBODD=1
108 ...I PSBODD,PSBADST'="" D Q
109 ....D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Administration Times on ODD SCHEDULE",PSBSCH)
110 ...K ^TMP("PSB",$J,"GETADMIN")
111 ...I PSBADST="",+$G(PSBFREQ)>0,$G(PSBFREQ)<30 S PSBADST="MESSAGE",$P(PSBTOT(PSBADST,PSBOITX,PSBONX),2)="Due every "_PSBFREQ_" Mins" Q
112 ...I PSBADST="",+$G(PSBFREQ)'<30 S PSBADST=$$GETADMIN^PSBVDLU1(DFN,PSBONX,PSBOST,PSBFREQ,PSBRPDT) S:PSBADST'="" PSBCADM=1
113 ...E S ^TMP("PSB",$J,"GETADMIN",0)=PSBADST
114 ...Q:PSBADST=""
115 ...I PSBONX'["V" D Q:'$$OKAY^PSBVDLU1(PSBOST,PSBRPDT,PSBSCH,PSBONX,PSBOIT,PSBFREQ)
116 ...I PSBONX["V",PSBSCH'="" Q:'$$OKAY^PSBVDLU1(PSBOST,PSBRPDT,PSBSCH,PSBONX,PSBOIT,PSBFREQ)
117 ...F PSBXX=0:1 Q:'$D(^TMP("PSB",$J,"GETADMIN",PSBXX)) S PSBADST=$G(^TMP("PSB",$J,"GETADMIN",PSBXX)) D
118 ....F Y=1:1:$L(PSBADST,"-") S Z=+("."_$P(PSBADST,"-",Y)) D
119 .....Q:(PSBRPDT+Z)<$E(PSBOST,1,12) ; Start Date
120 .....Q:(PSBRPDT+Z)'<$E(PSBOSP,1,12) ; Stop Date
121 .....;For Invalid admin times
122 .....D:($P(PSBADST,"-",Y)'?2N)&($P(PSBADST,"-",Y)'?4N)
123 ......D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid Admin times",PSBSCH)
124 .....S PSBSM=$S(PSBHSM=1:"HSM",PSBSM=1:"SM",1:"")
125 .....;*** Local array to include order no
126 .....S PSBTOT(Z,PSBOITX,PSBONX)=PSBSM_U_"Dosage: "_PSBDOSE_" Route: "_PSBMR_" "_PSBIFR
127 ..S PSBX="" F S PSBX=$O(PSBTOT(PSBX)) Q:PSBX="" D
128 ...W !
129 ...S PSBY="" F S PSBY=$O(PSBTOT(PSBX,PSBY)) Q:PSBY="" D
130 ....S PSBZ="" F S PSBZ=$O(PSBTOT(PSBX,PSBY,PSBZ)) Q:PSBZ="" D
131 .....W:$Y>(IOSL-6) $$PTFTR^PSBOHDR(),$$PTHDR()
132 .....I PSBX="MESSAGE" W !,$P(PSBTOT(PSBX,PSBY,PSBZ),U,1),?20,PSBY Q
133 .....W !,$$TIMEOUT^PSBUTL(PSBX),?10
134 .....W $P(PSBTOT(PSBX,PSBY,PSBZ),U,1),?20,PSBY,?55,$P(PSBTOT(PSBX,PSBY,PSBZ),U,2)
135 ..W $$PTFTR^PSBOHDR()
136 .K ^TMP("PSJ",$J),^TMP("PSB",$J)
137 .Q
138 ;
139WRDHDR() ;
140 S PSBHDR(1)="WARD ADMINISTRATION TIMES"
141 D WARD^PSBOHDR(PSBWRD,.PSBHDR)
142 S Y=PSBRPDT D D^DIQ
143 W !,"Patient Name",?64,Y_" Administration Times"
144 W !,"Room-Bed",?32
145 F X=0,.01:.01:.24 W $J($E(X_"00",2,3),4)
146 W !,$TR($J("",IOM)," ","-")
147 Q ""
148 ;
149PTHDR() ;
150 S PSBHDR(1)="PATIENT ADMINISTRATION TIMES"
151 D PT^PSBOHDR(PSBDFN,.PSBHDR)
152 W !,"Date/Time",?10,"Self Med",?20,"Medication",?55,"Dose/Route"
153 W !,$TR($J("",IOM)," ","-")
154 S Y=PSBRPDT D D^DIQ
155 W !!,Y,!
156 Q ""
157 ;
Note: See TracBrowser for help on using the repository browser.