source: WorldVistAEHR/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBOMH.m@ 1777

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

initial load of WorldVistAEHR

File size: 9.4 KB
Line 
1PSBOMH ;BIRMINGHAM/EFC-MAH ;Mar 2004
2 ;;3.0;BAR CODE MED ADMIN;**5,9,38**;Mar 2004;Build 8
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ; Reference/IA
6 ; EN^PSJBCMA/2828
7 ; EN^PSJBCMA2/2830
8 ; File 200/10060
9 ; ^DIWP/10011
10 ;
11EN ; Called from DQ^PSBO
12 N PSBGBL,DFN
13 S PSBGBL=$NAME(^TMP("PSBO",$J,"B"))
14 F S PSBGBL=$Q(@PSBGBL) Q:PSBGBL="" Q:$QS(PSBGBL,2)'=$J Q:$QS(PSBGBL,1)'["PSBO" D
15 .S DFN=$QS(PSBGBL,5)
16 .S (PSBSTRT,X)=$P(PSBRPT(.1),U,6) D H^%DTC S PSBSTH=%H
17 .S (PSBSTOP,X)=$P(PSBRPT(.1),U,8)+.235959 D H^%DTC S PSBSPH=%H
18 .S PSBCNT=0 F I=PSBSTH:1:PSBSPH S PSBAR(I)=PSBSTH+((PSBCNT\7)*7),PSBCNT=PSBCNT+1
19 .D EN1
20 K PSBCNT,PSBAR Q
21EN1 ; Expects DFN,STRT,STOP
22 N PSBGBL,PSBHDR,PSBX,PSBFLAG
23 K ^TMP("PSJ",$J),^TMP("PSB",$J)
24 S PSBEVDT=PSBSTRT
25 D EN^PSJBCMA(DFN,PSBSTRT)
26 I $G(^TMP("PSJ",$J,1,0))=-1 D PT^PSBOHDR(DFN,.PSBHDR) W !!,"****NO MEDICATIONS FOUND****" Q ; No Ord
27 S PSBX=""
28 F S PSBX=$O(^TMP("PSJ",$J,PSBX)) Q:PSBX="" D
29 .Q:$P(^TMP("PSJ",$J,PSBX,0),U,3)?.N1"P" ; No Pnd
30 .Q:$P(^TMP("PSJ",$J,PSBX,1),U,5)<PSBSTRT!($P(^TMP("PSJ",$J,PSBX,1),U,4)>PSBSTOP) ;display orders active in date range of report
31 .S X=$P(^TMP("PSJ",$J,PSBX,1),U,2)
32 .S ^TMP("PSB",$J,"ORDERS",$P(^TMP("PSJ",$J,PSBX,0),U,3))=X
33 I '$D(^TMP("PSB",$J,"ORDERS")) D PT^PSBOHDR(DFN,.PSBHDR) W !!,"****NO MEDICATIONS FOUND****" Q ; No Orders
34 S PSBMHND="PSBOMH"
35 ; Act on Orders
36 S PSBX="" F S PSBX=$O(^TMP("PSB",$J,"ORDERS",PSBX)) Q:PSBX="" S PSBTYPE=^(PSBX) D
37 .S:PSBTYPE'="C" PSBTYPE="P"
38 .D CLEAN^PSBVT
39 .D PSJ1^PSBVT(DFN,PSBX)
40 .S X1=((PSBEVDT)\1) S X2=-1 D C^%DTC S PSBCNTST=X
41 .S X1=((PSBSTOP)\1) S X2=1 D C^%DTC S PSBXSTOP=X
42 .S PSBVALB=""
43 .S PSBVALB=$$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,PSBIVPSH)
44 .S PSBZ=""
45 .S X1=PSBXSTOP,X2=PSBCNTST D ^%DTC S PSBNCT=X
46 .F PSBZ=1:1:PSBNCT S X1=PSBCNTST S X2=1 D C^%DTC S PSBCNTST=X D
47 ..I (PSBX["V")!(PSBX'["V") D
48 ...I PSBCNTST'>(PSBOST\1) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
49 ...I PSBCNTST=(PSBOST\1)!($G(^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST))) K ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)
50 ...I PSBCNTST>(PSBOSP\1) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
51 ...I PSBCNTST=(PSBOSP\1)&($G(^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST))) K ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
52 ..S PSBDODD=""
53 ..I (PSBFREQ#1440'=0),(1440#PSBFREQ'=0) S PSBDODD=1
54 ..I ((PSBX'["V")!(PSBVALB="1")),((PSBDODD="1")&(PSBADST'="")) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)=""
55 ..I ((PSBX'["V")!(PSBVALB="1")),('$$OKAY^PSBVDLU1(PSBOST,PSBCNTST,PSBSCH,PSBON,PSBOITX,PSBFREQ,PSBOSTS)) S ^TMP("PSB",$J,"ORDERS",PSBONX,"NTDUE",PSBCNTST)="" ;W t TMP
56 .S (PSBYES,PSBODD,PSBFLAG,PSBYTFN,PSBDAYN)=0
57 .S:$$PSBDCHK1^PSBVT1(PSBSCH) PSBYES=1,PSBDAYN=1
58 .I PSBYES,PSBADST="",PSBSCHT'="O",PSBSCHT'="OC",PSBSCHT'="P" Q
59 .F I=1:1 Q:$P(PSBSCH,"-",I)="" I $P(PSBSCH,"-",I)?2N!($P(PSBSCH,"-",I)?4N) S PSBYES=1,PSBYTFN=1
60 .I (PSBFREQ="O")!(PSBTYPE="P") S PSBYES=1
61 .I (PSBFREQ#1440'=0),(1440#PSBFREQ'=0) S PSBODD=1
62 .;flg / admn t
63 .S:PSBONX["U" PSBFLAG=1
64 .I PSBIVT="A" S PSBADST="0000"
65 .I PSBIVT="H" S PSBADST="0000"
66 .I PSBIVT="C",PSBCHEMT="P" S:PSBADST="" PSBFLAG=1
67 .I PSBIVT="C",PSBISYR=1 S:PSBADST="" PSBFLAG=1
68 .I PSBIVT="C",PSBCHEMT="A" S PSBADST="0000"
69 .I PSBIVT="C",PSBISYR=0 S PSBADST="0000"
70 .I PSBIVT="P",($G(PSBADST)=0) S:PSBADST="" PSBFLAG=1
71 .I PSBIVT="P" S:PSBADST="" PSBFLAG=1
72 .I PSBIVT="S",PSBISYR=0 S PSBADST="0000"
73 .I PSBIVT="S",PSBISYR=1 S:PSBADST="" PSBFLAG=1
74 .I PSBFREQ="D" S PSBFREQ=""
75 .I 'PSBYES,PSBADST="",PSBFREQ<1 Q
76 .S (PSBEE,PSBZZ)=0
77 .I (PSBVALB="1")!(PSBX'["V") D Q:(PSBEE!PSBZZ)=1
78 ..I PSBSCHT="C",PSBYTFN="1",PSBADST="" S PSBEE=1
79 ..I PSBSCHT="C",PSBDAYN'="1",PSBYTFN'="1",PSBADST'="",PSBFREQ<1 S PSBZZ=1
80 .I 'PSBODD,PSBFLAG,PSBTYPE="C",PSBADST="" S PSBADST=$$GETADMIN^PSBVDLU1(DFN,PSBONX,PSBOST,PSBFREQ,PSBSTOP)
81 .E I PSBADST'="" K ^TMP("PSB",$J,"GETADMIN") S ^TMP("PSB",$J,"GETADMIN",0)=PSBADST
82 .;Calc adm/frq
83 .S PSBDT=PSBSTRT
84 .K PSBO,^UTILITY($J)
85 .F X=1:1:8 S PSBO(X)=""
86 .S DIWL=0,DIWR=32,DIWF="C32"
87 .S X=$P(PSBOSTX," ")_" "_$P(PSBOSPX," ") D ^DIWP
88 .S X="@"_$P(PSBOSTX," ",3)_" @"_$P(PSBOSPX," ",3)_" " D ^DIWP
89 .S X="" D ^DIWP
90 .S X=PSBOITX D ^DIWP
91 .; DD,SOL,ADD
92 .S X=""
93 .F Y=0:0 S Y=$O(PSBDDA(Y)) Q:'Y S X=X_$S(X]"":", ",1:"")_$P(PSBDDA(Y),U,3)
94 .F Y=0:0 S Y=$O(PSBADA(Y)) Q:'Y S X=X_$S(X]"":", ",1:"")_$P(PSBADA(Y),U,3)_" "_$P(PSBADA(Y),U,4)_$P(PSBADA(Y),U,5)
95 .F Y=0:0 S Y=$O(PSBSOLA(Y)) Q:'Y S X=X_$S(X]"":", ",1:"")_$P(PSBSOLA(Y),U,3)_" "_$P(PSBSOLA(Y),U,4)
96 .S X=" "_X,DIWF="I2C32" D ^DIWP S DIWF="C32"
97 .S PSBTXT=" Give: "_PSBDOSE_" "_PSBMRAB_" "_PSBSCH_" "_PSBIFR
98 .F S PSBWORD=$P(PSBTXT," ",1),PSBTXT=$P(PSBTXT," ",2,250) D Q:PSBTXT=""
99 ..F Q:'$L(PSBWORD) S X=$E(PSBWORD,1,30),PSBWORD=$E(PSBWORD,30,250) D ^DIWP
100 .K ^TMP("PSJ",$J) D EN^PSJBCMA2(DFN,PSBX) I ^TMP("PSJ",$J,0)'=-1 D ;get activity log
101 ..S (PSBDISX,PSBHLDX)=0 F I=1:1:$P(^TMP("PSJ",$J,0),U,4) S X=$G(^TMP("PSJ",$J,I,1)) D ;loop activities
102 ...Q:X["EDITED"!(X["VERIF") ;
103 ...S Z=0
104 ...I X'["OFF HOLD",X'["UNHOLD",X'["REINSTATE" S Z=1 ; inc iv's
105 ...S PSBHLDX=PSBHLDX+$S(Z>0:1,1:0)
106 ...S $P(PSBHLD(PSBHLDX),U,$S(Z>0:1,1:11))=^TMP("PSJ",$J,I,1) ;set up for multiple on hold entries save start & stop as pair if exists
107 ..F PSBHLDX=1:1 S X=$G(PSBHLD(PSBHLDX)) Q:'X D ;if a hold index - process
108 ...S PSBHLDN=$P(PSBHLD(PSBHLDX),U,1),PSBHLDF=$P(PSBHLD(PSBHLDX),U,11) ;get on/off hold, dates, IEN number(for UD orders) of person.
109 ...Q:PSBHLDN>PSBSTOP Q:(PSBHLDF<PSBSTRT)&(PSBHLDF'="")
110 ...F PSBHLDT=PSBSTRT\1:1:PSBSTOP\1 I (PSBHLDT'<(PSBHLDN\1)),(PSBHLDT'>PSBSTOP) D
111 ....I X["DISCONTINUED" K ^TMP("PSB",$J,"ORDERS",PSBONX,"HOLD",PSBHLDT) S ^TMP("PSB",$J,"ORDERS",PSBONX,"DISC",PSBHLDT)=""
112 ....I (X["HOLD")&((PSBHLDN\1)'>PSBHLDT)&((PSBHLDF'<PSBHLDT)!(PSBHLDF="")) S ^TMP("PSB",$J,"ORDERS",PSBONX,"HOLD",PSBHLDT)=""
113 ....I X["REINSTATE" K ^TMP("PSB",$J,"ORDERS",PSBONX,"DISC",PSBHLDT) I PSBOSTS="H" S ^TMP("PSB",$J,"ORDERS",PSBONX,"HOLD",PSBHLDT)=""
114 ...F PSBHLDXP=1:10:$P(PSBHLD(PSBHLDX),U,11)]""+10 D
115 ....S PSBDESC=$P(PSBHLD(PSBHLDX),U,PSBHLDXP+3),X=$S(PSBDESC["DISCONTINUE":"***",1:"")
116 ....S X=" "_X_PSBDESC D ^DIWP ;output activity text
117 ....S X="",PSBHLDI=$P(PSBHLD(PSBHLDX),U,PSBHLDXP+4) I PSBHLDI'="" S X=$$GET1^DIQ(200,PSBHLDI,"INITIAL")
118 ....S:X="" X="99" ;no init present
119 ....I X'="99" S X=" "_X D ^DIWP ;get init & store
120 ....S Y=$P(PSBHLD(PSBHLDX),U,PSBHLDXP) D DD^%DT S X=Y D ^DIWP ;format hold date / write
121 ..K PSBHLD,PSBHLDF,PSBHLDN,PSBHLDT,PSBHLDX,PSBHLDXP,PSBHLDI,PSBDISX,PSBDISC,PSBDISXP,PSBDISI,PSBDIST,PSBDISN,PSBDESC
122 .I PSBOTXT]"" D
123 ..I $E(PSBOTXT,1)="!" S $E(PSBOTXT,1)=""
124 ..S PSBOTXT=" Spec Inst: "_PSBOTXT
125 ..F S PSBWORD=$P(PSBOTXT," ",1),PSBOTXT=$P(PSBOTXT," ",2,250) D Q:PSBOTXT=""
126 ...F Q:'$L(PSBWORD) S X=$E(PSBWORD,1,30),PSBWORD=$E(PSBWORD,30,250) D ^DIWP
127 .F X=0:0 S X=$O(^UTILITY($J,"W",0,X)) Q:'X S PSBO(X)=$G(^(X,0)) D
128 .S X=$O(PSBO(""),-1) S X=$S(X<8:8,1:X+1)
129 .S PSBO(X)=" RPH: "_PSBVPHI_" RN: "_PSBVNI
130 .S PSBVAL=$$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,PSBIVPSH)
131 .I PSBODD="1",PSBADST'="" D
132 ..I (PSBVAL="1")!(PSBX'["V") D ;checks iv/pb and u dose
133 ...S PSBO(X+1)=""
134 ...S PSBO(X+2)="NOTE - ODD SCHEDULE NO LONGER",PSBO(X+3)=" ALLOWS ADMIN TIMES."
135 .K ^UTILITY($J)
136 .M ^TMP("PSB",$J,"ORDERS",PSBX,"INST")=PSBO
137 .D:PSBTYPE="C"
138 ..F D Q:PSBDT>PSBSTOP
139 ...S X=PSBDT D H^%DTC S PSBWEEK=%H
140 ...S ^TMP("PSB",$J,PSBWEEK,PSBONX)=""
141 ...; Odd schd - msg
142 ...S PSBIDOW=0 I PSBONX["U"!("PCS"[PSBIVT) S PSBIDOW=1
143 ...I PSBADST="",PSBIDOW,(PSBODD) D
144 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",0)=7
145 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",1)="odd"
146 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",2)="sched"
147 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",3)=$E(PSBSCH,1,5)
148 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",4)="no"
149 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",5)="fixed"
150 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",6)="admin"
151 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",7)="times"
152 ...I PSBADST'="",PSBADST'="0000",+$G(PSBFREQ)>0,+$G(PSBFREQ)<45 D
153 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",0)=5
154 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",1)="Due"
155 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",2)="every"
156 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",3)=$E(PSBFREQ,1,5)
157 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",4)="mins."
158 ....S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",5)=" "
159 ...S PSBATCNT=0 ; # times to print...
160 ...I PSBADST'="",((+$G(PSBFREQ)>44)!(PSBFREQ="")!(PSBADST="0000")) F PSBXX=0:1 Q:$G(^TMP("PSB",$J,"GETADMIN",PSBXX))="" D
161 ....S PSBADST2=$G(^TMP("PSB",$J,"GETADMIN",PSBXX))
162 ....F Y=1:1:$L(PSBADST2,"-") D
163 .....Q:($P(PSBADST2,"-",Y)'?2N)&($P(PSBADST2,"-",Y)'?4N) S PSBATCNT=PSBATCNT+1,^TMP("PSB",$J,"ORDERS",PSBONX,"AT",PSBATCNT)=$P(PSBADST2,"-",Y)
164 ...I PSBADST'="",PSBFREQ>44 S ^TMP("PSB",$J,"ORDERS",PSBONX,"AT",0)=PSBATCNT
165 ...S ^TMP("PSB",$J,PSBWEEK,"SORT",PSBTYPE,PSBOITX,PSBX)=""
166 ...F PSBDOW=0:1:6 D Q:X>(PSBSTOP-1)
167 ....S %H=PSBWEEK+PSBDOW D YMD^%DTC
168 ....S ^TMP("PSB",$J,PSBWEEK,PSBONX,X,0)=0
169 ....I '$D(^TMP("PSB",$J,PSBWEEK,"HDR",X)) S ^TMP("PSB",$J,PSBWEEK,"HDR",X)=$E(X,4,5)_"/"_$E(X,6,7)_"/"_(1700+$E(X,1,3))
170 ...S %H=PSBWEEK+7 D YMD^%DTC S PSBDT=X
171 .D:PSBTYPE'="C"
172 ..S X=PSBDT D H^%DTC S PSBWEEK=%H
173 ..S (^TMP("PSB",$J,PSBWEEK,PSBONX),^TMP("PSB",$J,PSBWEEK,PSBONX,"AT",0))="",^TMP("PSB",$J,PSBWEEK,"SORT",PSBTYPE,PSBOITX,PSBX)=""
174 D EN^PSBOMH1,EN^PSBOMH2
175 Q
176INSTR S PSBINIT=PSBINIT_"*"
177 S PSBNAME=PSBNAME_"/"_$P(^PSB(53.79,PSBIEN,.9,$P(PSBDT,"."),0),U,3)_" "_$$GET1^DIQ(53.79,PSBIEN_",",.06)
178 Q
179 ;
Note: See TracBrowser for help on using the repository browser.