1 | PSJORPOE ;BIR/MLM,LDT-MISC. PROCEDURE CALLS FOR OE/RR 3.0 ;24 Feb 99 / 10:43 AM
|
---|
2 | ;;5.0; INPATIENT MEDICATIONS ;**50,56,92,80,110,127,133,134**;16 DEC 97;Build 124
|
---|
3 | ;
|
---|
4 | ; Reference to ^PS(50.7 is supported by DBIA# 2180.
|
---|
5 | ; Reference to ^PS(51.2 is supported by DBIA# 2178.
|
---|
6 | ; Reference to ^PS(55 is supported by DBIA# 2191.
|
---|
7 | ; Reference to ^PS(51.1 is supported by DBIA# 2177.
|
---|
8 | ; Reference to ^PS(52.6 is supported by DBIA# 1231.
|
---|
9 | ; Reference to ^PS(52.7 is supported by DBIA# 2173.
|
---|
10 | ; Reference to ^PSDRUG is supported by DBIA# 2192.
|
---|
11 | ;
|
---|
12 | STARTSTP(PSGP,SCH,OI,PSJPWD,PSGORD,PSJADM) ;
|
---|
13 | ; PSGP=Patient IEN
|
---|
14 | ; SCH=Schedule
|
---|
15 | ; OI=Orderable Item
|
---|
16 | ; PSJPWD=Ward Location (Optional)
|
---|
17 | ; PSGORD=Pharmacy Order Number if the order being placed is a Renewal (Optional)
|
---|
18 | ;
|
---|
19 | Q:+PSGP'>0 ""
|
---|
20 | Q:SCH']"" ""
|
---|
21 | Q:+OI'>0 ""
|
---|
22 | I SCH?.E1L.E S SCH=$$ENLU^PSGMI(SCH)
|
---|
23 | K DFN,PSGNEFDO,PSGNEFD,PSGST,PSGSCH,PSGNEDFD,PSGNESD,PSJSYSW,PSJSYSW0 N RESULT
|
---|
24 | S:'$D(PSGS0XT) PSGS0XT="" S:'$D(PSGS0Y) PSGSOY=""
|
---|
25 | I $G(PSJPWD)']"" S DFN=PSGP D IN5^VADPT S:VAIP(5)]"" PSJPWD=+VAIP(5)
|
---|
26 | S PSJSYSW0="",PSJSYSW=0 I $G(PSJPWD)]"" S PSJSYSW=+$O(^PS(59.6,"B",PSJPWD,0)) I PSJSYSW S PSJSYSW0=$G(^PS(59.6,PSJSYSW,0))
|
---|
27 | S RESULT=$S($P(PSJSYSW0,"^",5)=0:"CLOSEST",$P(PSJSYSW0,"^",5)=1:"NEXT",1:"NOW")
|
---|
28 | I OI]"" S PSGST=$S($P($G(^PS(50.7,OI,0)),"^",7)]"":$P($G(^PS(50.7,OI,0)),"^",7),1:"C")
|
---|
29 | N %,PSGXSCH D NOW^%DTC S PSGDT=%,DFN=PSGP,(PSGSCH,PSGXSCH)=SCH
|
---|
30 | S X=PSGSCH,PSGS0Y="" D ADMIN
|
---|
31 | I $G(PSGORD)]"" D
|
---|
32 | .S PSGNESD=$$DSTART^PSJDCU(PSGP,PSGORD) I PSGNESD]"" S $P(RESULT,"^",2)=PSGNESD Q
|
---|
33 | .S ND=$S(PSGORD["U":$G(^PS(55,PSGP,5,+PSGORD,2)),1:$G(^PS(55,PSGP,"IV",+PSGORD,0)))
|
---|
34 | .N PSJADM,PSJSTRT S PSJADM=$S(PSGORD["U":$P(ND,"^",5),1:$P(ND,"^",11)),PSJSTRT=$P(ND,"^",2),PSJREN=1
|
---|
35 | S SCH=PSGXSCH
|
---|
36 | N PSJTMPW0 S PSJTMPW0=PSJSYSW0 S $P(PSJSYSW0,"^",5)=1
|
---|
37 | I $G(PSGNESD)="" S RESULT=RESULT_"^"_$$ENSD^PSGNE3(PSGSCH,$S($G(PSJADM)]"":$G(PSJADM),1:PSGS0Y),PSGDT,$S($G(PSJSTRT)]"":$G(PSJSTRT),1:PSGDT))
|
---|
38 | S PSJSYSW0=PSJTMPW0
|
---|
39 | S PSGNESD=$P(RESULT,"^",2)
|
---|
40 | S PSGNEDFD=$$GTNEDFD^PSGOE7("U",OI)
|
---|
41 | K PSGODF,PSGOES,PSJREN
|
---|
42 | S SCH=PSGXSCH
|
---|
43 | D ENFD^PSGNE3(PSGDT) S RESULT=RESULT_"^"_$G(PSGNEFD) ;_"^"_$G(PSGNEFDO)
|
---|
44 | N DATE S DATE=$$FMDIFF^XLFDT($P(RESULT,"^",3),$P(RESULT,"^",2),3)
|
---|
45 | S $P(RESULT,"^",3)=$S($G(PSGST)="O":0,+DATE>0:+DATE_"D",$P($P(DATE," ",2),":")>0:$P($P(DATE," ",2),":")_"H",1:0)
|
---|
46 | N STRING S STRING=PSGNESD_U_PSGNEFD_U_$G(PSGSCH)_U_$G(PSGST)_U_$G(OI) I ($P($G(ZZND),U,2)]"")&($P($G(ZZND),"^")=$G(PSGSCH)) S STRING=STRING_U_$P(ZZND,U,2)
|
---|
47 | I $G(PSGSCH)]"" I $$DOW^PSIVUTL(PSGSCH) S:$G(PSGS0Y) $P(STRING,"^",6)=PSGS0Y
|
---|
48 | I $G(PSJADM) S $P(STRING,"^",6)=PSJADM
|
---|
49 | S RESULT=RESULT_"^"_$$ENQ^PSJORP2(PSGP,STRING) I ($G(PSGSCH)]"") I $$DOW^PSIVUTL(PSGSCH),(PSGSCH'["@"),'$G(PSGS0Y) S $P(RESULT,"^",4)=$P(RESULT,"^",2)
|
---|
50 | I ($G(PSGSCH)]"") I $$PRNOK^PSGS0(PSGSCH) S $P(RESULT,"^",4)=$P(RESULT,"^",2)
|
---|
51 | D KVAR^VADPT K LYN,ND,PSGDT,PSGNEDFD,PSGNEFD,PSGNEFDO,PSGNESD,PSGS0Y,PSGSCH,PSGST,PSJSYSW,PSJSYSW0,ZZ
|
---|
52 | ;RESULT=WARD PARAMETER^DEFAULT START DATE/TIME^#_D(NUMBER OF DAYS ORDER LASTS) OR #_H(NUMBER OF HOURS ORDER LASTS)^EXPECTED FIRST DOSE
|
---|
53 | Q RESULT
|
---|
54 | ;
|
---|
55 | RESOLVE(PSGP,SCH,OI,PCH,PSJPWD,PSJADM) ;
|
---|
56 | ; PSGP=Patient IEN
|
---|
57 | ; SCH=Schedule
|
---|
58 | ; OI=Orderable Item
|
---|
59 | ; PCH=Providers Choice
|
---|
60 | ; PSJPWD=Ward Location (Optional)
|
---|
61 | ; PSJADM=Admin Times (Optional)
|
---|
62 | ;
|
---|
63 | N PSJSYSW0,PSJSYSW,PSGSCH,PSGOES,PSGS0Y,DFN,RESULT1
|
---|
64 | I $G(PSJPWD)']"" S DFN=PSGP D IN5^VADPT S:VAIP(5)]"" PSJPWD=+VAIP(5)
|
---|
65 | S PSJSYSW0="",PSJSYSW=0 I $G(PSJPWD)]"" S PSJSYSW=+$O(^PS(59.6,"B",PSJPWD,0)) I PSJSYSW S PSJSYSW0=$G(^PS(59.6,PSJSYSW,0))
|
---|
66 | S $P(PSJSYSW0,"^",5)=$S($$ONE(SCH):2,PCH="NEXT":1,1:0)
|
---|
67 | S RESULT1=$S($P(PSJSYSW0,"^",5)=0:"CLOSEST",$P(PSJSYSW0,"^",5)=1:"NEXT",1:"NOW")
|
---|
68 | I OI]"" S PSGST=$S($P($G(^PS(50.7,OI,0)),"^",7)]"":$P($G(^PS(50.7,OI,0)),"^",7),1:"C")
|
---|
69 | N % D NOW^%DTC S PSGDT=%,DFN=PSGP,PSGSCH=SCH
|
---|
70 | S X=PSGSCH,PSGS0Y="" I $D(^PS(51.1,"AC","PSJ",X)) D ADMIN
|
---|
71 | S:$G(PSJADM) PSGS0Y=PSJADM
|
---|
72 | S RESULT1=RESULT1_"^"_$$ENSD^PSGNE3(SCH,PSGS0Y,PSGDT,PSGDT)
|
---|
73 | I $G(PSGSCH)]"" I $$DOW^PSIVUTL(PSGSCH),(PSGSCH'["@"),'$G(PSGS0Y) S $P(RESULT,"^",4)=$P(RESULT,"^",2)
|
---|
74 | I $G(PSGSCH)]"" I $$PRNOK^PSGS0(PSGSCH) S $P(RESULT1,"^",4)=$P(RESULT,"^",2)
|
---|
75 | D KVAR^VADPT K LYN,PSGDT,PSGNEDFD,PSGNEFD,PSGNEFDO,PSGNESD,PSGS0Y,PSGSCH,PSGST,PSJSYSW,PSJSYSW0,ZZ,PSGS0XT,PSGS0Y
|
---|
76 | Q RESULT1
|
---|
77 | ;
|
---|
78 | SCHREQ(MR,OI,DD) ;
|
---|
79 | ; MR=Medication Route from 51.2 (Required)
|
---|
80 | ; OI=Orderable Item from 50.7 (Optional)
|
---|
81 | ; DD=Dispense Drug from 50 (Optional)
|
---|
82 | N ADDITIVE,SOLUTION,REQ S REQ=0,(SOLUTION,ADDITIVE)=""
|
---|
83 | I '+$G(MR) S REQ=1 Q REQ
|
---|
84 | I '+$G(OI),'+$G(DD) S REQ=1 Q REQ
|
---|
85 | I +$G(DD) S:$P($G(^PSDRUG(+DD,2)),U,3)["U" REQ=1 Q REQ
|
---|
86 | I '$D(PS(51.2,+MR,0)) S REQ=1 Q REQ
|
---|
87 | I $P($G(^PS(51.2,+MR,0)),"^",6)=1 D
|
---|
88 | .I +$G(OI) D
|
---|
89 | ..I '$D(^PS(50.7,+OI,0)) S REQ=1 Q
|
---|
90 | ..F S SOLUTION=$O(^PS(52.7,"AOI",+OI,SOLUTION)) Q:'SOLUTION Q:REQ=1 S:$P(^PSDRUG(+$P(^PS(52.7,SOLUTION,0),U,2),2),U,3)["U" REQ=1
|
---|
91 | ..F S ADDITIVE=$O(^PS(52.6,"AOI",+OI,ADDITIVE)) Q:'ADDITIVE Q:REQ=1 S:$P(^PSDRUG(+$P(^PS(52.6,ADDITIVE,0),U,2),2),U,3)["U" REQ=1
|
---|
92 | Q REQ
|
---|
93 | ;
|
---|
94 | ADMIN ; Get admin times associated with schedule
|
---|
95 | S PSGS0Y="",ZZ=0
|
---|
96 | I $$DOW^PSIVUTL($P(X,"@")),'$D(^PS(51.1,"AC","PSJ",X)) S PSGST="D" D Q:$G(PSGS0Y)
|
---|
97 | .I $P(X,"@",2) N PSJADBAD D Q
|
---|
98 | ..S PSGS0Y=$S($G(PSJADBAD):"",1:$P(X,"@",2))
|
---|
99 | ..N ADMIN,TIME,II S ADMIN=$P(X,"@",2) F II=1:1:$L(ADMIN,"-") S TIME=$P(ADMIN,"-",II) I TIME'?2N&(TIME'?4N) S PSJADBAD=1
|
---|
100 | .I $P(X,"@",2)]"",$D(^PS(51.1,"APPSJ",$P(X,"@",2))) S X=$P(X,"@",2)
|
---|
101 | D FIND^DIC(51.1,,,,X,,"APPSJ",,,"LYN")
|
---|
102 | S ZZ=$O(LYN("DILIST",2,ZZ)) I ZZ S ZZ=+LYN("DILIST",2,ZZ) I ZZ S ZZND=$G(^PS(51.1,ZZ,0)) S PSGST=$P(ZZND,U,5),PSGS0XT=$P(ZZND,U,3) S:$G(PSGSFLG) PSGSCIEN=$G(LYN("DILIST",2,ZZ)) I $G(PSJPWD) D
|
---|
103 | . N ZZNDW S ZZNDW=$G(^PS(51.1,ZZ,1,PSJPWD,0)) I $P(ZZNDW,"^",2)]"" S PSGS0Y=$P(ZZNDW,"^",2),$P(ZZND,"^",2)=PSGS0Y I $G(PSGSFLG) S PSGSCIEN=$G(LYN("DILIST",2,ZZ))
|
---|
104 | S ZZ=0 F S ZZ=$O(LYN("DILIST",1,ZZ)) Q:'ZZ I $G(LYN("DILIST",1,ZZ))'=X K LYN("DILIST",1,ZZ),LYN("DILIST",2,ZZ),LYN("DILIST","ID",ZZ,1)
|
---|
105 | I $D(PSJPWD) S ZZ=0 F S ZZ=$O(LYN("DILIST",2,ZZ)) Q:'ZZ!$G(PSGS0Y) I $P($G(^PS(51.1,+LYN("DILIST",2,ZZ),1,+PSJPWD,0)),U,2)]"" S PSGS0Y=$P($G(^(0)),U,2) I $G(PSGSFLG) S PSGSCIEN=$G(LYN("DILIST",2,ZZ))
|
---|
106 | Q:PSGS0Y]"" S ZZ=0 F S ZZ=$O(LYN("DILIST",2,ZZ)) Q:'ZZ!$G(PSGS0Y) I $G(LYN("DILIST","ID",ZZ,1))]"" S PSGS0Y=$G(LYN("DILIST","ID",ZZ,1))
|
---|
107 | Q
|
---|
108 | ;
|
---|
109 | ONE(SCH) ;
|
---|
110 | ; SCH=Admin Schedule
|
---|
111 | ; Returns 0 = (zero) Not a one time schedule.
|
---|
112 | ; 1 = One time schedule.
|
---|
113 | Q:$G(SCH)="" 0
|
---|
114 | N X,SCHLST
|
---|
115 | S SCHLST=",TODAY,ONCE,NOW,ONE TIME,ONETIME,ONE-TIME,1TIME,1 TIME,1-TIME,STAT,"
|
---|
116 | I SCHLST[(","_SCH_",") Q 1
|
---|
117 | I $D(^PS(51.1,"AC","PSJ",SCH)) S X=$O(^(SCH,"")) S X=$P(^PS(51.1,X,0),"^",5) Q $S(X="O":1,1:0)
|
---|
118 | Q 0
|
---|