source: FOIAVistA/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBUTL.m@ 1757

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

initial load of FOIAVistA 6/30/08 version

File size: 9.5 KB
Line 
1PSBUTL ;BIRMINGHAM/EFC-BCMA UTILITIES ;Mar 2004
2 ;;3.0;BAR CODE MED ADMIN;**3,9,13,38**;Mar 2004;Build 8
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ; Reference/IA
6 ; $$PATCH & $$VERSION^XPDUTL/10141
7 ; File 50/221
8 ; File 200/10060
9 ;
10 ;
11DIWP(X,Y,PSB,PSBARGN) ;
12 K ^UTILITY($J,"W")
13 S DIWL=0,DIWR=Y,DIWF="C"_Y D ^DIWP
14 F X=0:0 S X=$O(^UTILITY($J,"W",0,X)) Q:'X D
15 .S Y=$O(@PSB@(""),-1)+1
16 .; Naked Ref ^UTILITY($J,"W",0,X)
17 .S @PSB@(Y)=$J("",+$G(PSBARGN))_^(X,0)
18 S @PSB@(0)=+$O(@PSB@(""),-1)
19 K ^UTILITY($J,"W"),DIWL,DIWR,DIWF
20 Q
21 ;
22SATURDAY(X,PSBDISP) ;
23 S X=X\1 D H^%DTC ; Convert to $H
24 S %H=%H+(6-%Y) ; Set it forward to Saturday
25 D YMD^%DTC ; Back to FM Format
26 I $G(PSBDISP) S PSBDISP=$E(X,4,5)_"/"_$E(X,6,7)_"/"_(1700+$E(X,1,3)) D EN^DDIOL("Actual date is Saturday "_PSBDISP)
27 Q X
28 ;
29SUNDAY(X,PSBDISP) ;
30 S X=X\1 D H^%DTC ; Convert to $H
31 S %H=%H-%Y ; Set it back to Sunday
32 D YMD^%DTC ; Back to FM Format
33 I $G(PSBDISP) S PSBDISP=$E(X,4,5)_"/"_$E(X,6,7)_"/"_(1700+$E(X,1,3)) D EN^DDIOL("Actual date is Sunday "_PSBDISP)
34 Q X
35 ;
36CLOCK(RESULTS,X) ; Verify Client/Server Date/Times are close enough
37 ;
38 ; RPC: PSB SERVER CLOCK VARIANCE
39 ;
40 ; Description:
41 ; Returns variance from server to client in minutes
42 ;
43 N PSBCLNT,PSBSRVR,PSBDIFF
44 S %DT="RS" D ^%DT S PSBCLNT=Y
45 D NOW^%DTC S PSBSRVR=%
46 S PSBDIFF=$$DIFF(PSBSRVR,PSBCLNT)
47 S X=$$GET^XPAR("DIV","PSB SERVER CLOCK VARIANCE")
48 I PSBDIFF>X!(PSBDIFF<(X*-1)) S RESULTS(0)="-1^"_PSBDIFF
49 E S RESULTS(0)="1^"_PSBDIFF
50 Q
51 ;
52DIFF(X,X1) ; Difference in minutes between 2 FM dates
53 ; Code copied from Fileman Function MINUTES
54 S Y=$E(X1_"000",9,10)-$E(X_"000",9,10)*60+$E(X1_"00000",11,12)-$E(X_"00000",11,12),X2=X,X=$P(X,".",1)'=$P(X1,".",1) D ^%DTC:X S X=X*1440+Y
55 Q X
56 ;
57DRUGINQ ; Drug File Inquiry
58 N PSBRET,PSBIEN,DIC,DIR,IOINORM,IOINHI
59 S X="IOINHI;IOINORM" D ENDR^%ZISS
60 S X=$TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
61 S DIC="^PSDRUG(",DIC(0)="AEQMVTN",DIC("T")="",D="B^C^VAPN^VAC^NDC^XATC",DIC("A")="Select DRUG: "
62 ; Display active drugs and those for appl packages IV and Unit Dose
63 S DIC("S")="I '$G(^PSDRUG(+Y,""I""))!($G(^(""I""))>DT),$P($G(^PSDRUG(+Y,2)),U,3)[""I""!($P($G(^PSDRUG(+Y,2)),U,3)[""U"")"
64 F W @IOF,!,"DRUG FILE INQUIRY",! D ^DIC Q:+Y<1 D
65 .K PSBRET
66 .S PSBIEN=+Y_","
67 .D GETS^DIQ(50,PSBIEN,".01;16;25;51;215;213;101;9*","","PSBRET")
68 .W @IOF,!,"DRUG NAME: ",IOINHI,PSBRET(50,PSBIEN,.01)
69 .W " (IEN: ",+PSBIEN,")",IOINORM,!,$TR($J("",IOM)," ","-"),!
70 .F X=16,25,51,215,213,101 D
71 ..D FIELD^DID(50,X,"","LABEL","PSBRET")
72 ..W !,PSBRET("LABEL"),":",?30,IOINHI
73 ..D:$L(PSBRET(50,PSBIEN,X))>49
74 ...F Y=1:1 Q:$L($P(PSBRET(50,PSBIEN,X)," ",1,Y))>49
75 ...W $P(PSBRET(50,PSBIEN,X)," ",1,Y-1),!?30
76 ...S PSBRET(50,PSBIEN,X)=$P(PSBRET(50,PSBIEN,X)," ",Y,250)
77 ..W ?30,PSBRET(50,PSBIEN,X),IOINORM
78 .W !!,"SYNONYMS:",IOINHI,!?15
79 .S X="" F S X=$O(PSBRET(50.1,X)) Q:X="" W:$X>40 !?15 W:$X>15 ?40 W PSBRET(50.1,X,.01)
80 .W IOINORM
81 .F Q:$Y>(IOSL-3) W !
82 .S DIR(0)="E" D ^DIR
83 Q
84 ;
85DPTSET ; Set Logic for pt-merge x-ref on patient field in file 53.79
86 ;
87 ; Entered Date/Time
88 I $P(^PSB(53.79,DA,0),U,4) S ^PSB(53.79,"AEDT",X,$P(^PSB(53.79,DA,0),U,4),DA)=""
89 ;
90 ; Administration Date/Time
91 D:$P(^PSB(53.79,DA,0),U,6)
92 .S ^PSB(53.79,"AADT",X,$P(^PSB(53.79,DA,0),U,6),DA)=""
93 .;
94 .; Orderable Item + Administration Date/Time
95 .I $P(^PSB(53.79,DA,0),U,8) S ^PSB(53.79,"AOIP",X,$P(^PSB(53.79,DA,0),U,8),$P(^PSB(53.79,DA,0),U,6),DA)=""
96 ;
97 ; PRN's by entered date/time
98 I $P($G(^PSB(53.79,DA,.1)),U,2)="P"&($P(^(0),U,4)) S ^PSB(53.79,"APRN",X,$P(^PSB(53.79,DA,0),U,4),DA)=""
99 ;
100 ; Order+Administration Date and Time
101 I $P($G(^PSB(53.79,DA,.1)),U)]""&($P($G(^PSB(53.79,DA,.1)),U,3)) S ^PSB(53.79,"AORD",X,$P(^PSB(53.79,DA,.1),U),$P(^PSB(53.79,DA,.1),U,3),DA)=""
102 Q
103 ;
104DPTKILL ; Kill Logic for pt-merge x-ref on patient field in file 53.79
105 ;
106 ; Entered Date/Time
107 I $P(^PSB(53.79,DA,0),U,4) K ^PSB(53.79,"AEDT",X,$P(^PSB(53.79,DA,0),U,4),DA)
108 ;
109 ; Administration Date/Time
110 D:$P(^PSB(53.79,DA,0),U,6)
111 .K ^PSB(53.79,"AADT",X,$P(^PSB(53.79,DA,0),U,6),DA)
112 .;
113 .; Orderable Item + Administration Date/Time
114 .I $P(^PSB(53.79,DA,0),U,8) K ^PSB(53.79,"AOIP",X,$P(^PSB(53.79,DA,0),U,8),$P(^PSB(53.79,DA,0),U,6),DA)
115 ;
116 ; PRN's by entered date/time
117 I $P($G(^PSB(53.79,DA,.1)),U,2)="P"&($P(^(0),U,4)) K ^PSB(53.79,"APRN",X,$P(^PSB(53.79,DA,0),U,4),DA)
118 ;
119 ; Order+Administration Date and Time
120 I $P($G(^PSB(53.79,DA,.1)),U)]""&($P($G(^PSB(53.79,DA,.1)),U,3)) K ^PSB(53.79,"AORD",X,$P(^PSB(53.79,DA,.1),U),$P(^PSB(53.79,DA,.1),U,3),DA)
121 Q
122 ;
123TIMEIN ;
124 X ^%ZOSF("UPPERCASE") S X=Y
125 I X="NOON" S X=.12 Q
126 I X="MID" S X=.24 Q
127 I (X="NOW")!(X="N") D NOW^%DTC S X=$E($P(%,".",2)_"0000",1,4)
128 S X="T@"_X,%DT="R" D ^%DT
129 I Y<1 K X Q
130 S X=Y-DT
131 Q
132 ;
133TIMEOUT(X) ;
134 N HOUR,MIN,AMPM
135 S X=$E($P(X,".",2)_"0000",1,4)
136 I X="2400" Q "12:00m"
137 I X="1200" Q "12:00n"
138 S HOUR=+$E(X,1,2),MIN=$E(X,3,4)
139 S AMPM="a"
140 S AMPM=$S(HOUR<12:"a",HOUR>11:"p",1:"**")
141 S:HOUR>12 HOUR=HOUR-12
142 Q HOUR_":"_MIN_AMPM
143 ;
144HFSOPEN(HANDLE) ;
145 N PSBDIR,PSBFILE
146 S PSBDIR=$$GET^XPAR("DIV","PSB HFS SCRATCH")
147 S PSBFILE="PSB"_DUZ_".DAT"
148 D OPEN^%ZISH(HANDLE,PSBDIR,PSBFILE,"W") Q:POP
149 S IOM=132,IOSL=99999,IOST="P-DUMMY",IOF=""""""
150 Q
151 ;
152HFSCLOSE(HANDLE) ;
153 N PSBDIR,PSBFILE,PSBDEL
154 D CLOSE^%ZISH(HANDLE)
155 K ^TMP("PSBO",$J)
156 S PSBDIR=$$GET^XPAR("DIV","PSB HFS SCRATCH")
157 S PSBFILE="PSB"_DUZ_".DAT",PSBDEL(PSBFILE)=""
158 S X=$$FTG^%ZISH(PSBDIR,PSBFILE,$NAME(^TMP("PSBO",$J,2)),3)
159 S X=$$DEL^%ZISH(PSBDIR,$NA(PSBDEL))
160 Q
161 ;
162AUDIT(PSBREC,PSBDD,PSBFLD,PSBDATA,PSBSK) ; Med Log Audit
163 ; used by cross references to 53.79 to track changes to fields in Med Log file
164 ; xref AU05, AU06, AU09, AU16, AU21, AU22 pass the value 53.79 as PSBDD
165 ; xref AU303, AU304 pass the value 53.795 as PSBDD
166 ; xref AU603, AU604 pass the value 53.796 as PSBDD
167 ; xref AU703, AU704 pass the value 53.797 as PSBDD
168 ;
169 N PSBDT,PSBTMP
170 I '$D(PSBOLSTS) S PSBOLSTS=$P(^PSB(53.79,PSBREC,0),U,9)
171 I '$D(PSBOLDUZ) S PSBOLDUZ=$P(^PSB(53.79,PSBREC,0),U,5)
172 Q:$G(PSBDATA)=""!('$G(PSBAUDIT))
173 D NOW^%DTC S PSBDT=%
174 S PSBDATA=$$EXTERNAL^DILFD(PSBDD,PSBFLD,"",PSBDATA) ; PSBDD=53.79, 53.795, 53.796, or 53.797 see comment AUDIT
175 D FIELD^DID(PSBDD,PSBFLD,"","LABEL","PSBTMP") ; PSBDD=53.79, 53.795, 53.796, or 53.797 see comment AUDIT
176 S:'$D(^PSB(53.79,PSBREC,.9,0)) ^(0)="^53.799^^"
177 S Y=$O(^PSB(53.79,PSBREC,.9,""),-1)+1,X=""
178 I PSBTMP("LABEL")["ACTION STATUS" D Q
179 .I PSBSK["K" S XY=Y F S XY=$O(^PSB(53.79,PSBREC,.9,XY),-1) Q:($D(PSBGOON))!(+XY'>0) D
180 ..I ^PSB(53.79,PSBREC,.9,XY,0)["ACTION STATUS Set to '" D Q
181 ...S PSBGOON=1,PSBOLDUZ=$P(^PSB(53.79,PSBREC,.9,XY,0),U,2),X=$P(^PSB(53.79,PSBREC,.9,XY,0),"'",2)
182 .S:$L(X)'>2 X=PSBOLSTS,X=$S(X="G":"GIVEN",X="H":"HELD",X="R":"REFUSED",X="I":"INFUSING",X="C":"COMPLETED",X="S":"STOPPED",X="N":"NOT GIVEN",X="RM":"REMOVED",X="M":"MISSING DOSE",X="":PSBOLSTS)
183 .I PSBSK["K" S ^PSB(53.79,PSBREC,.9,Y,0)=PSBDT_U_DUZ_U_"Field: "_PSBTMP("LABEL")_" '"_PSBDATA_"' by '"_$$GET1^DIQ(200,PSBOLDUZ,"INITIAL")_"' deleted."
184 .E S ^PSB(53.79,PSBREC,.9,Y,0)=PSBDT_U_DUZ_U_"Field: "_PSBTMP("LABEL")_" Set to '"_PSBDATA_"' by '"_$$GET1^DIQ(200,DUZ,"INITIAL")_"'."_U_PSBDATA
185 I PSBSK["K" S ^PSB(53.79,PSBREC,.9,Y,0)=PSBDT_U_DUZ_U_"Field: "_PSBTMP("LABEL")_" '"_PSBDATA_"' deleted."
186 E S ^PSB(53.79,PSBREC,.9,Y,0)=PSBDT_U_DUZ_U_"Field: "_PSBTMP("LABEL")_$S(PSBTMP("LABEL")["DISPENSE DRUG":" Added '",1:" Set to '")_PSBDATA_"'."
187 K XY,PSBGOON
188 Q
189 ;
190CHECK(RESULTS,PSBWHAT,PSBDATA) ; Checks for KIDS Patch or Build
191 ; Module added in Patch PSB*1.0*3 DP/TOPEKA 22-DEC-1999 11:51:22
192 ; PSBWHAT: B = Returns Build Version for packages by Namespace
193 ; P = Returns if Patch is installed
194 ; PSBDATA: Build/Package namespace (i.e. PSB) or Patch Number
195 ; (i.e. PSB*1.0*1)
196 ;
197 S RESULTS(0)="-1^Unknown Parameter "_$G(PSBWHAT,"<PSBWHAT Undefined>")
198 S PSBWHAT=$G(PSBWHAT),PSBDATA=$G(PSBDATA)
199 D:PSBWHAT="B"
200 .S X=$$VERSION^XPDUTL(PSBDATA)
201 .S RESULTS(0)=$S(X="":"-1^Unknown Package/Build",1:"1^"_X)
202 D:PSBWHAT="P"
203 .S X=$$PATCH^XPDUTL(PSBDATA)
204 .S RESULTS(0)=$S(X:"1^Patch Is Installed",1:"-1^Patch Is Not Installed")
205 Q
206 ;
207VERSION() ; [Extrinsic]
208 ; Returns V#.# for display purposes
209 Q "V"_$J(2,0,1)
210 ;
211RESETADM ;
212 ;
213 ; This Subroutine will reset a medication order's resources
214 ; based on Med Log New Entry or Edit Med Log activity.
215 ;
216 ; No input is necessary. Environment should be setup at call.
217 ;
218 I '$G(PSBMMEN) S X=$S($P(PSBIEN,",",2)]"":$P(PSBIEN,",",2),1:+PSBIEN) D CLEAN^PSBVT,PSJ1^PSBVT($P(^PSB(53.79,X,0),U),$P(^PSB(53.79,X,.1),U)) D:($$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,+$G(PSBIVPSH))) D CLEAN^PSBVT
219 .S X=PSBIEN,X2=X_$S(X="+1":",",1:"") Q:'$D(PSBFDA(53.79,X2,.09)) I $F("HR",PSBFDA(53.79,X2,.09))>1 S PSBFDA(53.79,X2,.26)=""
220 I $G(PSBMMEN),PSBIEN="+1",$G(PSBONX)["V" S PSBWSID=PSBFDA(53.79,"+1,",.26) K PSBFDA(53.79,"+1,",.26),PSBFDA(53.79,"+1,",.09)
221 I $G(PSBMMEN) I ($D(PSBWSID))&($G(Y(0))="SAVE") D
222 .S:(PSBREC(3)="G") PSBFDAX(53.79,X,.26)=PSBWSID
223 .S:$F("HR",PSBREC(3))>1 PSBFDAX(53.79,X,.26)=""
224 .S X=$P(PSBIEN,"+1,",2)
225 .D UPDATE^DIE("","PSBFDAX","X","PSBMSG")
226 Q
227 ;
228SCRNPTCH ;
229 ;
230 ; Maintain the "APATCH" index from SCREENMAN and Manual Med Entry.
231 ;
232 I Y(0)'="GIVEN" S PSBGPTCH=0 Q
233 S PSBX=0 F S PSBX=$O(^PSB(53.79,DA,.5,PSBX)) Q:+PSBX=0 Q:$P(^PSB(53.79,DA,.5,+PSBX,0),U,4)="PATCH"
234 Q:+PSBX=0
235 S PSBGPTCH=1
236 Q
237 ;
238GIVEPTCH ;
239 I $D(^PSB(53.79,"AORD",DFN,PSBONX)) N PSBX S PSBX="" F S PSBX=$O(^PSB(53.79,"AORD",DFN,PSBONX,PSBX)) Q:+PSBX=0 D:$D(^PSB(53.79,"AORD",DFN,PSBONX,PSBX,DA)) Q:'$D(PSBX)
240 .I $D(^PSB(53.79,"AORD",DFN,PSBONX,PSBX,DA)) D
241 ..S PSBX=$P(^PSB(53.79,DA,0),U,6)
242 ..I PSBGPTCH S ^PSB(53.79,"APATCH",DFN,PSBX,DA)="" K PSBX,PSBGPTCH Q
243 ..I 'PSBGPTCH K ^PSB(53.79,"APATCH",DFN,PSBX,DA),PSBX,PSBGPTCH
244 Q
Note: See TracBrowser for help on using the repository browser.