source: FOIAVistA/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJLMUTL.m@ 1061

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

initial load of FOIAVistA 6/30/08 version

File size: 8.4 KB
Line 
1PSJLMUTL ;BIR/MLM-INPATIENT LISTMAN UTILITIES ;29 May 98 / 8:35 AM
2 ;;5.0; INPATIENT MEDICATIONS ;**7,67,58,85,111,160**;16 DEC 97;Build 12
3 ;
4 ; Reference to ^ORD(101 is supported by DBIA #872.
5 ; Reference to ^PS(50.606 is supported by DBIA #2174.
6 ; Reference to ^PS(50.7 is supported by DBIA #2180.
7 ; Reference to ^PS(55 is supported by DBIA #2191.
8 ; Reference to ^PSDRUG is supported by DBIA #2192.
9 ; Reference to ^GMRAPEM0 is supported by DBIA #190.
10 ; Reference to ^SDAMA203 is supported by DBIA #4133.
11 ; Reference to ^VSIT is supported by DBIA #1905.
12 ;
13NEWALL(DFN) ; Enter Allergy info.
14 ;
15 D FULL^VALM1,EN2^GMRAPEM0
16 Q
17DISALL(DFN) ; Display brief patient info list.
18 K ^TMP("PSJALL",$J) N PSJLN,X,Y,PSGALG,PSGRALG,PSGLDR,PSJGMRAL,PSJWHERE S PSJWHERE="PSJLMUTL"
19 D ATS^PSJMUTL(57,57,2)
20 I (PSJGMRAL=0) S ^TMP("PSJALL",$J,1,0)=" Allergies/Reactions: "_"NKA",PSJLN=2 G NARRATIV
21 I (PSJGMRAL="") S ^TMP("PSJALL",$J,1,0)=" Allergies/Reactions: No Allergy Assessment",PSJLN=2 G NARRATIV
22 I ($G(PSGVALG(1))="NKA")!((PSGVALG=0)&(PSGALG=0)) D
23 .S ^TMP("PSJALL",$J,1,0)=" Allergies: "_$G(PSGVALG(1)),PSJLN=2,X=1
24 I ($G(PSGVALG(1))'="NKA")&((PSGVALG>0)!(PSGALG>0)) D
25 .S ^TMP("PSJALL",$J,1,0)="Allergies - Verified: "_$G(PSGVALG(1)),PSJLN=2,X=1
26 .F S X=$O(PSGVALG(X)) Q:'X S ^TMP("PSJALL",$J,PSJLN,0)=" "_PSGVALG(X),PSJLN=PSJLN+1
27 .S ^TMP("PSJALL",$J,PSJLN,0)=" Non-Verified: "_$S($G(PSGALG(1))=0:"",1:$G(PSGALG(1))),PSJLN=PSJLN+1,X=1
28 .F S X=$O(PSGALG(X)) Q:'X S ^TMP("PSJALL",$J,PSJLN,0)=" "_PSGALG(X),PSJLN=PSJLN+1
29 D RAD^PSJMUTL
30 I ($G(PSGVADR(1))="NKA")!((PSGVADR=0)&(PSGADR=0)) D
31 .S ^TMP("PSJALL",$J,PSJLN,0)="",^TMP("PSJALL",$J,PSJLN+1,0)=" Adverse Reactions: "_$G(PSGADR(1)),PSJLN=PSJLN+2,X=1
32 I ($G(PSGVADR(1))'="NKA")&((PSGVADR>0)!(PSGADR>0)) D
33 .S ^TMP("PSJALL",$J,PSJLN,0)="",^TMP("PSJALL",$J,PSJLN+1,0)="Reactions - Verified: "_$G(PSGVADR(1)),PSJLN=PSJLN+2,X=1
34 .F S X=$O(PSGVADR(X)) Q:'X S ^TMP("PSJALL",$J,PSJLN,0)=" "_PSGVADR(X),PSJLN=PSJLN+1
35 .S ^TMP("PSJALL",$J,PSJLN,0)=" Non-Verified: "_$G(PSGADR(1)),PSJLN=PSJLN+2,X=1
36 .F S X=$O(PSGADR(X)) Q:'X S ^TMP("PSJALL",$J,PSJLN,0)=" "_PSGADR(X),PSJLN=PSJLN+1
37 ;
38NARRATIV ; print inpatient/outpatient narratives
39 N PSJCLHD
40 S ^TMP("PSJALL",$J,PSJLN,0)="" D SETNAR("PSJALL",$G(^PS(55,DFN,5.3)),"In")
41 S ^TMP("PSJALL",$J,PSJLN+1,0)="" D SETNAR("PSJALL",$G(^PS(55,DFN,1)),"Out")
42 D SDA S PSJLN=0 F X=0:0 S X=$O(^TMP("PSJALL",$J,X)) Q:'X S PSJLN=PSJLN+1
43 I '$G(PSJCLHD)!'$G(VALMCNT) S VALMCNT=PSJLN
44 Q
45 ;
46SDA N PSJPAD,PSJCLIN,PSJCLINO,PSJAPD,PSJSCI,PSJCLOK,VAERR K ^TMP("PSJVSIT"),PSJDBUN S $P(PSJPAD," ",26)=" "
47 Q:'$$PATCH^XPDUTL("SD*5.3*285")
48 D NOW^%DTC S VASD("F")=$P(%,".")-1
49 D SDA^VADPT S:$G(VAERR)=2 (PSJCLHD,PSJDBUN)=2 I $O(^UTILITY("VASD",$J,"")) M PSJUTL=^UTILITY("VASD",$J) D
50 . S PSJSCDT0=0
51 . F S PSJSCDT0=$O(PSJUTL(PSJSCDT0)) Q:'PSJSCDT0 D
52 .. S PSJCLINO=$P($G(PSJUTL(PSJSCDT0,"E")),U,2),PSJCLIN=$P($G(PSJUTL(PSJSCDT0,"I")),U,2)
53 .. S PSJSCI=$G(PSJUTL(PSJSCDT0,"I")),PSJAPD=$$FMTE^XLFDT(+PSJSCI) Q:(PSJCLIN="")!(PSJAPD="")
54 .. S PSJCLOK=1 D SDAUTHCL^SDAMA203(PSJCLIN,.PSJCLOK) Q:(PSJCLOK<1)
55 .. S ^TMP("PSJVSIT",$J,+PSJSCI,PSJCLIN,"V")=$E(PSJCLINO_PSJPAD,1,25)_" "_$TR(PSJAPD,"@","/"),PSJCLHD=1
56 .. D ENC(DFN,PSJCLIN)
57 I $G(PSJCLHD) S PSJLN=PSJLN+1 S ^TMP("PSJALL",$J,PSJLN,0)="Clinic:"_$E(PSJPAD,1,20)_"Date/Time of Appointment:",PSJLN=PSJLN+1 I $G(PSJCLHD)=2 D
58 . S ^TMP("PSJALL",$J,PSJLN,0)=" Scheduling database is unavailable",PSJLN=PSJLN+1
59 N VDAT S VDAT=0 F S VDAT=$O(^TMP("PSJVSIT",$J,VDAT)) Q:'VDAT S VCLIN=0 F S VCLIN=$O(^TMP("PSJVSIT",$J,VDAT,VCLIN)) Q:'VCLIN D
60 . F VTYP="E","V" S VDATA=$G(^TMP("PSJVSIT",$J,VDAT,VCLIN,VTYP)) I VDATA]"" S ^TMP("PSJALL",$J,PSJLN,0)=VDATA,PSJLN=PSJLN+1
61 I $G(PSJCLHD) S VALMCNT=((PSJLN+11\11)*11),PSJX=$O(^TMP("PSJALL",$J,9999),-1) ; F I=PSJX:1:VALMCNT S ^TMP("PSJALL",$J,I,0)=""
62 K PSJUTL,PSJCLHD
63 Q
64 ;
65ENC(SDPATDFN,SDCLIEN) ;
66 N SDFROM,DT,SUBVIS,VIS S SDSTART=$$FMADD^XLFDT($P(PSGDT,"."),-1),SDEND=$$FMADD^XLFDT($P(PSGDT,"."),+365) K ^TMP("VSIT",$J)
67 D SELECTED^VSIT(SDPATDFN,SDSTART,SDEND,SDCLIEN) N VIS S VIS=0 F S VIS=$O(^TMP("VSIT",$J,VIS)) Q:'VIS D
68 . S SUBVIS=0 F S SUBVIS=$O(^TMP("VSIT",$J,VIS,SUBVIS)) Q:'SUBVIS D
69 .. S PSJSCI=$P(^TMP("VSIT",$J,VIS,SUBVIS),U),PSJAPD=$$FMTE^XLFDT(PSJSCI,1) Q:PSJSCI<1!(PSJAPD="")
70 .. S ^TMP("PSJVSIT",$J,PSJSCI,PSJCLIN,"E")=$E(PSJCLINO_PSJPAD,1,25)_" "_$TR(PSJAPD,"@","/")_" *Encounter",PSJCLHD=1
71 Q
72 ;
73SETNAR(SUB,NARR,TYPE) ; Set up Narrative info.
74 S NARR=TYPE_"patient Narrative: "_NARR,Y="" S:TYPE="In" NARR=" "_NARR
75 S START=1 F D Q:NARR=""
76 .I $L($P(NARR," "))>79 S PSJ=$E(NARR,START,START+79),NARR=$E(NARR,START+80,$L(NARR)) Q
77 .I $L(NARR)>79 S PSJ=$P(NARR," ",1,$L($E(NARR,1,80)," ")-1),NARR=$E($P(NARR,PSJ,2),2,$L(NARR)) D SET Q
78 .S PSJ=NARR,NARR="" D SET
79 Q
80 ;
81SET ; Set ^TMP for narratives.
82 S ^TMP(SUB,$J,PSJLN,0)=PSJ,PSJLN=PSJLN+1
83 Q
84 ;
85ACTIONS() ;
86 N DIC,X,Y
87 S Y=$P($G(^ORD(101,+$G(^ORD(101,DA(1),10,DA,0)),0)),U) I Y="" Q 0
88 I Y="PSJ LM DC" Q $S(PSGACT["D":1,1:0)
89 I Y="PSJU LM EDIT" Q $S(PSGACT["E":1,1:0)
90 I Y="PSJU LM RENEW" Q $S(PSGACT["R":1,1:0)
91 I Y="PSJ LM HOLD" Q $S(PSGACT["H":1,1:0)
92 I Y="PSJU LM VERIFY" Q $S(PSGACT["V":1,1:0)
93 I Y="PSJ LM EDIT NEW" Q $S(PSGACT["E":1,1:0)
94 I Y="PSJ LM FLAG" Q $S(PSGACT["G":1,1:0)
95 Q 1
96RNACT() ;
97 I '$G(PSJRNF),'$G(PSJIRNF) Q 0
98 NEW X S X=$G(^PS(53.1,+PSJORD,0))
99 S PSGACT=""
100 I $S(+$P(X,U,13):1,$G(PSJRNF)&($P(X,U,4)="U"):1,$G(PSJIRNF)&($P(X,U,4)'="U"):1,1:0) S PSGACT="BFDE"
101 NEW X,Y
102 S Y=$P($G(^ORD(101,+$G(^ORD(101,DA(1),10,DA,0)),0)),U) I Y="" Q 0
103 I Y="PSJ LM DC" Q $S(PSGACT["D":1,1:0)
104 I Y="PSJ LM BYPASS" Q $S(PSGACT["B":1,1:0)
105 I Y="PSJ LM FINISH" Q $S(PSGACT["F":1,1:0)
106 I Y="PSJI LM DISCONTINUE" Q $S(PSGACT["D":1,1:0)
107 I Y="PSJI LM EDIT" Q $S(PSGACT["E":1,1:0)
108 I Y="PSJI LM FINISH" Q $S(PSGACT["F":1,1:0)
109 I Y="PSJ LM FLAG" Q 0
110 Q 1
111 ;
112TECHACT() ; Allowable actions for IV technician (PSJI PHARM TECH)
113 Q:'$G(PSJITECH) 0
114 NEW X S X=$G(^PS(53.1,+PSJORD,0))
115 I $S(+$P(X,U,13):1,$P(X,U,4)'="U":1,1:0) S PSGACT="F"
116 N DIC,X,Y
117 S Y=$P($G(^ORD(101,+$G(^ORD(101,DA(1),10,DA,0)),0)),U) I Y="" Q 0
118 I Y="PSJ LM DC" Q $S(PSGACT["D":1,1:0)
119 I Y="PSJ LM BYPASS" Q $S(PSGACT["B":1,1:0)
120 I Y="PSJ LM FINISH" Q $S(PSGACT["F":1,1:0)
121 I Y="PSJI LM DISCONTINUE" Q $S(PSGACT["D":1,1:0)
122 I Y="PSJI LM EDIT" Q $S(PSGACT["E":1,1:0)
123 I Y="PSJI LM FINISH" Q $S(PSGACT["F":1,1:0)
124 I Y="PSJ LM FLAG" Q 0
125 Q 1
126PATINFO() ; Determines if detailed allergy info can be displayed.
127 S Y=$P($G(^ORD(101,+$G(^ORD(101,DA(1),10,DA,0)),0)),U) I Y="" Q 0
128 I Y="PSJ LM SHOW PROFILE",$D(PSJLMPRO) Q 0
129 Q 1
130HIDDEN(CHK) ; Determines if certain Hidden actions are to be available.
131 I CHK="JUMP",'$G(PSJPNV) D NA("Jump is only available through Non-Verified/Pending Orders option.") Q 0
132 I CHK="SPEED",'$D(PSJUDPRF) D NA("Speed options are only available from the Unit Dose Order Entry Profile.") Q 0
133 Q 1
134 ;
135NA(TXT) ;
136 D FULL^VALM1 W !!,TXT,!! N DIR S DIR(0)="E" D ^DIR
137 Q
138 ;
139UPR(DFN) ; UPDATE PATIENT SPECIFIC DATA IN 55
140 N DIE,DR S PSJC10=VALMCNT
141 S DA=DFN,DIE="^PS(55,",DR="62.2;62.01" D ^DIE,DISALL^PSJLMUTL(DFN)
142 S VALMCNT=PSJC10 K PSJC10
143 Q
144 ;
145DETALL(DFN) ; Enter Detailed Allergy Display list.
146 D EN^VALM("PSJ LM ALLERGY DISPLAY")
147 Q
148BRFALL(DFN) ;
149 D EN^VALM("PSJ LM BRIEF PATIENT INFO")
150 Q
151PAUSE ;
152 N DIR S DIR(0)="E" D ^DIR
153 Q
154DRUGNAME(DFN,ON) ; Find drug name to display
155 ;If order is in 55:
156 ;.If Dosage Ordered is found, returns OI_U_Dosage Ordered.
157 ;.If no Dosage Ordered, returns Dispense Drug only.
158 ;If order in 53.1:
159 ;.If Dosage Ordered, returns OI_U_Dosage Ordered.
160 ;.If Dispense Drug is found, returns Dispense Drug name_U_Instructions.
161 ;.If no dispense drug, returns OI_U_Instructions.
162 I ON["U" D Q DN
163 .S OIND=$G(^PS(55,DFN,5,+ON,.2))
164 .I $P(OIND,U,2)]"",($G(^PS(50.7,+OIND,0))]"") S DN=$$OINAME(OIND)_U_.2 Q
165 .S X=+$O(^PS(55,DFN,5,+ON,1,0)),X=$G(^PS(55,DFN,5,+ON,1,X,0)) I $P(X,U)]"" S DN=$$DDNAME(+X)_"^^"_$P(X,"^",2) Q ;$S($P(OIND,U,2)]"":.2,1:.3) Q
166 .S DN=$$OINAME(+OIND)_U_.3 Q
167 S OIND=$G(^PS(53.1,+ON,.2)) Q:$P(OIND,U,2)]"" $$OINAME(OIND)_U_.2
168 S X=+$O(^PS(53.1,+ON,1,0)) I X,'$O(^PS(53.1,+ON,1,X)) S X=$G(^PS(53.1,+ON,1,X,0)) I $P(X,U)]"" Q $$DDNAME(+X)_U_.3_$P(X,"^",2)
169 Q $$OINAME(OIND)_U_.3
170 ;
171DDNAME(X) ;
172 Q $$FOUND($P($G(^PSDRUG(+X,0)),U),X,"PSDRUG(,")
173 ;
174OINAME(ND) ; Return Orderable Item Name_" "_Dose Form_U_Dosage Ordered
175 N DF,DNME,X
176 S X=$G(^PS(50.7,+ND,0)),DNME="" S:X]"" DF=$P($G(^PS(50.606,+$P(X,U,2),0)),U),DNME=$P(X,U)_" "_DF
177 Q $$FOUND(DNME,+ND,"PS(50.7")
178 ;
179FOUND(DNME,DN,FN) ;
180 Q $S(DNME]"":DNME,1:"NOT FOUND "_DN_";"_FN)
Note: See TracBrowser for help on using the repository browser.