source: FOIAVistA/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJDDUT.m@ 1582

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

initial load of FOIAVistA 6/30/08 version

File size: 8.2 KB
Line 
1PSJDDUT ;BIR/LDT-INPATIENT MEDICATIONS DD UTILITY ;21 AUG 97 7:55 AM
2 ;;5.0; INPATIENT MEDICATIONS ;**40,44,50,83,116,111**;16 DEC 97
3 ;
4 ; Reference to ^PS(51 is supported by DBIA# 2176.
5 ; Reference to ^PS(51.1 is supported by DBIA# 2177.
6 ; Reference to ^PS(55 is supported by DBIA# 2191.
7 ;
8SPCIN ;Called from Non-Verified Orders File (53.1), Special Instructions
9 ;field 8
10 S PSJHLP(1)="IF ABBREVIATIONS ARE USED, THE TOTAL LENGTH OF THE EXPANDED"
11 S PSJHLP(2)="INSTRUCTIONS ALSO MAY NOT BE LONGER THAN 180 CHARACTERS."
12 D WRITE
13 Q
14CHKSI ;Called from Non-Verified Orders File (53.1), Special Instructions
15 ;field 8 (Replaces ^PSGSICHK)
16 I $S(X'?.ANP:1,X["^":1,1:$L(X)>180) K X Q
17 N Y S Y="" F Y(1)=1:1:$L(X," ") S Y(2)=$P(X," ",Y(1)) I Y(2)]"" D CHK1 Q:'$D(X)
18 I $D(X),Y]"",X'=$E(Y,1,$L(Y)-1) D EN^DDIOL("EXPANDS TO:","","!?3") F Y(1)=1:1 S Y(2)=$P(Y," ",Y(1)) Q:Y(2)="" D:$L(Y(2))+$X>78 EN^DDIOL("","","!") D EN^DDIOL(Y(2)_" ","","?0")
19 K Y Q
20CHK1 ;
21 I $L(Y(2))<31,$D(^PS(51,+$O(^PS(51,"B",Y(2),0)),0)),$P(^(0),"^",2)]"",$P(^(0),"^",4) S Y(2)=$P(^(0),"^",2)
22 I $L(Y)+$L(Y(2))>180 K X Q
23 S Y=Y_Y(2)_" " Q
24 ;
25CHK F QQ=1:1:$L(SCH,"-") S WKD=$P(SCH,"-",QQ) I WKD=$E(X,1,$L(WKD)) D TS Q
26 Q
27TS F Q1=1:1:$L(TS,"-") S C=C+1 I C=PSGDL S X=X1_"."_$P(TS,"-",Q1) Q
28 Q
29STRDT ;Called from Non-Verified Orders File (53.1),Start Date/Time field 10
30 ;(Replaces ENPREV^PSGDL)
31 D EN^DDIOL("REVIOUS","","?0") S (X,Y)=0 I '$D(PSGP)!'$D(PSGPDRG) G:$D(DA)[0 POUT S PSGP=$P($G(^PS(53.1,DA,0)),"^",15),PSGPDRG=+$G(^(.2)),Y=1 I 'PSGP!'PSGPDRG D:'PSGPDRG EN^DDIOL("Must have drug from formulary list.","","!?17") G POUT
32 F Q=0:0 S Q=$O(^PS(53.1,"AC",PSGP,Q)) Q:'Q I +$G(^PS(53.1,Q,.2))=PSGPDRG,$D(^PS(53.1,Q,2)),$P(^(2),"^",4)>X S X=$P(^(2),"^",4)
33 F Q=0:0 S Q=$O(^PS(55,PSGP,5,"C",PSGPDRG,Q)) Q:'Q I $D(^PS(55,PSGP,5,Q,2)),$P(^(2),"^",4)>X S X=$P(^(2),"^",4)
34 D:'X EN^DDIOL("No other order found with this drug.","","!?17")
35 ;
36POUT ;
37 K:'X X K:Y PSGPDRG,PSGP,Q Q
38 ;
39UNPD ;Called from Non-Verified Orders File (53.1), Units Per Dose field 13
40 S PSJHLP(1)="ONE (1) UNIT PER DOSE WILL BE ASSUMED IF THERE IS NO ENTRY (OR"
41 S PSJHLP(2)="AN ENTRY OF ZERO (0)) INTO THIS FIELD."
42 D WRITE
43 Q
44 ;
45SCH ;Called from Non-Verified Orders File (53.1), Schedule field 26
46 ;(Replaces EN^PSGS0)
47 ;/I X[""""!($A(X)=45)!(X?.E1C.E)!($L(X," ")>2)!($L(X)>70)!($L(X)<1)!(X["P RN")!(X["PR N") K X Q
48 I X[""""!($A(X)=45)!(X?.E1C.E)!($L(X," ")>3)!($L(X)>70)!($L(X)<1)!(X["P RN")!(X["PR N") K X Q
49 I X?.E1L.E S X=$$ENLU^PSGMI(X) I '$D(PSGOES) D EN^DDIOL(" ("_X_")","","?0")
50 I X["Q0" K X Q
51 ;
52ENOS ; order set entry
53 S (PSGS0XT,PSGS0Y,XT,Y)="" I X["PRN"!(X="ON CALL")!(X="ONCALL")!(X="ON-CALL") G Q
54 S X0=X I X,X'["X",(X?2.4N1"-".E!(X?2.4N)) D ENCHK^PSGS0 S:$D(X) Y=X G Q
55 I $S($D(^PS(51.1,"AC","PSJ",X)):1,1:$E($O(^(X)),1,$L(X))=X) D DIC^PSGS0 I XT]"" G Q
56 I X["@" D DW^PSGS0 S:$D(X) Y=$P(X,"@",2) G Q
57 I Y'>0,$S(X="NOW":1,X="ONCE":1,X="STAT":1,X="ONE TIME":1,X="ONETIME":1,X="1TIME":1,X="1 TIME":1,X="T-TIME":1,1:X="ONE-TIME") D:'$D(PSGOES) EN^DDIOL(" (ONCE ONLY)","","?0") S Y="",XT="O" G Q
58 I $G(PSGSCH)=X S PSGS0Y=$G(PSGAT) Q
59 ;
60NS K PSJNSS I Y'>0 D:'$D(PSGOES) EN^DDIOL(" (Nonstandard schedule)","","?0") S X=X0,Y="",PSJNSS=1
61 I $E(X,1,2)="AD" K X Q
62 I $E(X,1,3)="BID"!($E(X,1,3)="TID")!($E(X,1,3)="QID") S XT=1440/$F("BTQ",$E(X)) G Q
63 S:$E(X)="Q" X=$E(X,2,99) S:'X X="1"_X S X1=+X,X=$P(X,+X,2),X2=0 S:X1<0 X1=-X1 S:$E(X)="X" X2=1,X=$E(X,2,99)
64 S XT=$S(X["'":1,(X["D"&(X'["AD"))!(X["AM")!(X["PM")!(X["HS"&(X'["THS")):1440,X["H"&(X'["TH"):60,X["AC"!(X["PC"):480,X["W":10080,X["M":40320,1:-1) I XT<0,Y'>0 K X G Q
65 S X=X0 I XT S:X2 XT=XT\X1 I 'X2 S:$E(X,1,2)="QO" XT=XT*2 S XT=XT*X1
66 ;
67Q ;
68 S PSGS0XT=$S(XT]"":XT,1:""),PSGS0Y=$S(Y:Y,1:"") K QX,SDW,SWD,X0,XT,Z Q
69 ;
70SCH3 ;Called from Non-Verified Orders File (53.1), Schedule field 26
71 ;(Replaces ENSH3^PSGSH)
72 S:'$D(PSGST) PSGST=$P($G(^PS(53.1,DA,0)),"^",7),PSGDDFLG=1
73 N D,DA,DIC,DIE,DZ,Y
74 D EN^DDIOL("'STAT', 'ONCE', 'NOW', and 'DAILY' are acceptable schedules.") I X?1"???".E F Q=1:1 Q:$P($T(HT+Q),";",3)="" S PSJHLP(Q)=$P($T(HT+Q),";",3)
75 I X?1"???".E D EN^DDIOL(.PSJHLP) K PSJHLP
76 I X?1"???".E R !,"(Press RETURN to continue.) ",Q:DTIME D:'$T EN^DDIOL("","","$C(7)") S:'$T Q="^" I Q="^" K:$D(PSGDDFLG) PSGDDFLG,PSGST Q
77 K DIC S DIC="^PS(51.1,",DIC(0)="E",D="APPSJ",DIC("W")="W "" ""," I $D(PSJPWD),PSJPWD S DIC("W")=DIC("W")_"$S($D(^PS(51.1,+Y,1,PSJPWD,0)):$P(^(0),""^"",2),1:$P(^PS(51.1,+Y,0),""^"",2))"
78 ; Naked references on the following two lines refer to the full reference on the line above
79 E S DIC("W")=DIC("W")_"$P(^(0),""^"",2)"
80 I $D(PSGST) S DIC("S")="I $P(^(0),""^"",5)"_$E("'",PSGST'="O")_"=""O"""
81 S DIC("?N",51.1)=12
82 D IX^DIC K DIC K:$D(PSGDDFLG) PSGDDFLG,PSGST Q
83 ;
84HT ;
85 ;; This is the frequency (ONLY) with which the doses are to be
86 ;;administered. Several forms of entry are acceptable, such as
87 ;;Q6H, 09-12-15, STAT, QOD, and MO-WE-FR@AD (where MO-WE-FR are
88 ;;days of the week, and AD is the admin times). The schedule
89 ;;will show on the MAR, labels, etc. No more than ONE space
90 ;;(Q3H 4 or Q4H PRN) in the schedule is acceptable. If the
91 ;;letters PRN ;;are found as part of the schedule, no admin
92 ;;times will print on the MAR or labels, and the PICK LIST will
93 ;;always show a count of zero (0).
94 ;;Avoid using notation such as W/F (with food) or WM (with meals)
95 ;;in the schedule as it may cause erroneous calculations. That
96 ;;information should be entered into the SPECIAL INSTRUCTIONS.
97 ;; When using the MO-WE-FR@AD schedule, please remember that
98 ;;this type of schedule will not work properly without the "@"
99 ;;character and at least one admin time, and that at least the
100 ;;first two letters of each weekday entered is needed.
101 ;
102ADTM2 ;Called from Non-Verified Orders File (53.1), Admin Times field 39
103 S PSJHLP(1)="EACH TIME MUST BE TWO DIGITS BETWEEN 01 AND 24. THE TIMES MUST BE"
104 S PSJHLP(2)="SEPARATED WITH ""-""'S AND BE IN ASCENDING ORDER."
105 D WRITE
106 Q
107 ;
108WRDGP ;Called from Ward Group File (57.5), Ward Group field .01
109 S PSJHLP(1)="There is at least one PICK LIST for this WARD GROUP. This WARD"
110 S PSJHLP(1,"F")="$C(7),!!?2"
111 S PSJHLP(2)="GROUP cannot be deleted until the PICK LIST(s) is purged or deleted."
112 D WRITE
113 Q
114 ;
115LBLS ;Called from Inpatient Ward Parameters file (59.6), field .11
116 S PSJHLP(1)="ANY NEW LABELS OLDER THAN THE NUMBER OF DAYS SPECIFIED HERE WILL"
117 S PSJHLP(2)="AUTOMATICALLY BE PURGED."
118 D WRITE
119 Q
120 ;
121SCHTP ;Called from the Unit Dose Multiple of file 55, Schedule Type field 7
122 S PSJHLP(1)="CHOOSE FROM:"
123 S PSJHLP(1,"F")="!!"
124 S PSJHLP(2)="C - CONTINUOUS"
125 S PSJHLP(2,"F")="!?3"
126 S PSJHLP(3)="O - ONE-TIME"
127 S PSJHLP(3,"F")="!?3"
128 S PSJHLP(4)="OC - ON CALL"
129 S PSJHLP(4,"F")="!?3"
130 S PSJHLP(5)="P - PRN"
131 S PSJHLP(5,"F")="!?3"
132 S PSJHLP(6)="R - FILL ON REQUEST"
133 S PSJHLP(6,"F")="!?3"
134 D WRITE
135 Q
136 ;
137EN ;Called from Non-Verified Orders file 53.1, Start/Date Time field 10
138 ;and Stop Date/Time field 25 (Replaces EN^PSGDL)
139 K PSGDLS S ND2=^PS(53.1,DA,2) I $P(ND2,"^",5)!$P(ND2,"^",6) D EN^DDIOL(" ...Dose Limit... ","","?0") G ENGO
140 G DONE
141 ;
142ENGO ;
143 S SCH=$P(ND2,"^")
144 S ST=$S($D(PSGDLS):PSGDLS,1:$P(ND2,"^",2))
145 S TS=$P(ND2,"^",5),MN=$P(ND2,"^",6)
146 I $P(PSJSYSW0,U,5)=2 D
147 . Q:'TS S:TS'[$P(ST,".",2) $P(PSJSYSW0,U,5)=1 D
148 .. N STRING,ND2,SCH,TS,MN S STRING=$G(PSGSD)_"^"_$G(PSGFD)_"^"_$G(PSGSCH)_"^"_$G(PSGST)_"^"_$G(PSGPDRG)_"^"_$G(PSGAT)
149 .. S ST=$$ENQ^PSJORP2(PSGP,STRING) S:'ST ST=$S($D(PSGDLS):PSGDLS,1:$P(ND2,"^",2))
150 . S $P(PSJSYSW0,U,5)=2
151 S TS=$P(ND2,"^",5),MN=$P(ND2,"^",6)
152 G MWF:SCH["@",DONE:'TS&'MN
153 I 'TS S AM=MN*PSGDL,X=$$EN^PSGCT(ST,AM) G DONE
154 S TM=$E(ST_"00000",9,8+$L($P(TS,"-")))
155 F Q=1:1 Q:$P(TS,"-",Q)=""!(TM<$P(TS,"-",Q))
156 S X=ST\1,C=0 F Q=Q:1 D:$P(TS,"-",Q)="" ADD S C=C+1 I C=PSGDL S X=X_"."_$P(TS,"-",Q) G DONE
157 ;
158MWF ; if schedule is similar to monday-wednesday-friday
159 S TS=$P(SCH,"@",2),SCH=$P(SCH,"@"),X=$P(ST,"."),C=0 D SCHK G:C=PSGDL DONE F Q=1:1 S X1=$P(ST,"."),X2=Q D C^%DTC S X1=X D DW^%DTC D CHK G:C=PSGDL DONE
160SCHK S X1=X D DW^%DTC F Q=1:1:$L(SCH,"-") S WKD=$P(SCH,"-",Q) I WKD=$E(X,1,$L(WKD)) Q
161 E Q
162 S TM=$E(ST_"00000",9,8+$L($P(TS,"-"))) F Q=1:1:$L(TS,"-") I TM<$P(TS,"-",Q) S C=C+1 I C=PSGDL S X=X1_"."_$P(TS,"-",Q) Q
163 Q
164 ;
165DONE ;
166 K %H,%T,%Y,MN,ND2,ND4,PSGDLS,PSGDL,Q1,QQ,SCH,TM,WKD,TS,X1,X2 Q
167 ;
168ADD ;
169 S X1=$P(X,"."),X2=$S(MN&'(MN#1440):MN\1440,1:1) D C^%DTC S Q=1 Q
170 ;
171WRITE ;Calls EN^DDIOL to write text
172 D EN^DDIOL(.PSJHLP) K PSJHLP Q
Note: See TracBrowser for help on using the repository browser.