source: WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVORC2.m@ 1150

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

initial load of WorldVistAEHR

File size: 8.5 KB
RevLine 
[613]1PSIVORC2 ;BIR/MLM-PROCESS INCOMPLETE IV ORDER - CONT ;22 OCT 97 / 3:16 PM
2 ;;5.0; INPATIENT MEDICATIONS ;**29,49,50,65,58,85,101,110,127,151**;16 DEC 97
3 ;
4 ; Reference to ^ORD(101 is supported by DBIA #872
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(52.6 is supported by DBIA #1231.
8 ; Reference to ^PS(52.7 is supported by DBIA #2173.
9 ; Reference to EN1^ORCFLAG is supported by DBIA #3620.
10 ; Reference to ^PSSLOCK is supported by DBIA #2789
11 ;
12EDCHK ;Update or create new order in 55.
13 D CKORD D:'$G(PSJIVORF) ORPARM^PSIVOREN I 'PSJIVORF W !,"Either the Inpatient Medications or the IV Medications package is not on, please check the Order Parameters file" Q
14 I PSIVCHG,PSJIVORF D NATURE^PSIVOREN I '$D(P("NAT")) W $C(7),"Order unchanged" Q
15 ;;S:PSIVCHG P(21)=""
16 S:PSIVCHG P("21FLG")=""
17 I $G(PSJCOM) D IV^PSJCOMV Q
18 Q:$$NONVF()
19ACTIVE ;
20 S PSJCOM=P("PRNTON")
21 I PSJCOM D VFYIV^PSJCOMV Q
22 S P("RES")=$P($G(^PS(53.1,+ON,0)),U,24)
23 I P("RES")="R" S P("NEWON")=P("OLDON") S PSJOSTOP="" D RUPDATE^PSIVOREN(DFN,ON,P(2))
24 I P("RES")'="R" S PSJORD=ON,P(17)="A",ORSTS=6,PSJORNP=P(6) D SETNEW^PSIVORFB S P("NEWON")=ON55 D @$S(PSIVCHG:"NEWORD",1:"OLDORD")
25 S (ON55,ON)=P("NEWON"),OD=P(2) D EN^PSIVORE
26 D VF1^PSJLIACT("F","ORDER VERIFIED BY ",1)
27 D ENLBL^PSIVOPT(2,DUZ,DFN,3,+ON55,"N")
28 I $G(^PS(55,DFN,"IV",+ON55,4)) D EN1^PSJHL2(DFN,"ZV",ON55)
29 L -^PS(53.1,+$G(PSJORD)) L -^PS(55,DFN,"IV",+ON55)
30 Q
31 ;
32CKORD ;Check if new order is to be created.
33 I $G(PSIVCOPY) S PSIVCHG=0 Q
34 N ND S PSIVCHG=0,ND(0)=$G(^PS(53.1,+ON,0)),ND("PD")=$G(^PS(53.1,+ON,.2))_U_$P(ND(0),U,3)
35 N X S X=$P($G(^PS(53.1,+ON,8)),U,5),X=$S(P(8)["@":$P(X,"@"),1:X)
36 S ND=$S($E(P("OT"))="I":P(8)_U_$P($G(^PS(53.1,+ON,2)),U)_U_$P(ND(0),U,3)_U_+$P(ND("PD"),U),1:X_U_$P($G(^PS(53.1,+ON,2)),U)_U_+P("MR")_U_+P("PD"))
37 S ND=ND_U_$S($P(ND(0),U,2)=+P("CLRK"):+$P(ND(0),U,2),1:+P(6))
38 I ND'=($S($E(P("OT"))="I":P(8),P(8)["@":$P(P(8),"@"),1:P(8))_U_P(9)_U_+P("MR")_U_+P("PD")_U_+P(6)) S PSIVCHG=1 Q
39 Q:P(17)="P"
40 N DNE,ND,TDRG S (DRG("DRGC"),DNE)=0
41 Q:PSIVCHG F DRGT="AD","SOL" F DRGI=0:0 S DRGI=$O(DRG(DRGT,DRGI)) Q:'DRGI S TDRG(DRGT,+$P(DRG(DRGT,DRGI),U),DRGI)=$P(DRG(DRGT,DRGI),U,3) I $P(P("OT"),U)="F",'$P(DRG(DRGT,DRGI),U,5) S P("OT")="I"
42 F DRGT="AD","SOL" Q:DRGT="SOL"&(P("DTYP")=1) F DRGI=0:0 S DRGI=$O(^PS(53.1,+ON,DRGT,DRGI)) Q:'DRGI!DNE D
43 .S X=$G(^PS(53.1,+ON,DRGT,DRGI,0)),DRG("DRGC")=$G(DRG("DRGC"))+1
44 .I $D(TDRG(DRGT,+$P(X,U),DRGI)),$P(X,U,2)=$P(TDRG(DRGT,+$P(X,U),DRGI),U) Q
45 .S (PSIVCHG,DNE)=1
46 Q:PSIVCHG
47 I $G(DRG("AD",0))+$S(P("DTYP")=1:0,1:DRG("SOL",0))'=DRG("DRGC") S PSIVCHG=1 Q
48CKPC ;
49 Q:PSIVCHG I $E(P("OT"))'="I" D
50 .;
51 .; Check IV drugs for changes.
52 .S DNE=0 F DRGT="AD","SOL" I $D(DRG(DRGT)) S FIL="52."_$S(DRGT="AD":6,1:7) D
53 ..N ND,TDRG F DRGI=0:0 S DRGI=$O(DRG(DRGT,DRGI)) Q:'DRGI!DNE S TDRG(+$P(DRG(DRGT,DRGI),U),DRGI)=DRGI,TDRG("CNT")=+$G(TDRG("CNT"))+1
54 ..F ON1=0:0 S ON1=$O(^PS(53.1,+ON,DRGT,ON1)) Q:'+ON1!DNE S ND=$G(^PS(53.1,+ON,DRGT,ON1,0)),ND("CNT")=$G(ND("CNT"))+1 D
55 ...S DRG=+$P(ND,U) S:'$D(TDRG(+DRG)) (DNE,PSIVCHG)=1 F DRGI=0:0 S DRGI=$O(TDRG(+DRG,DRGI)) Q:'DRGI!DNE I $P($G(DRG(DRGT,DRGI)),U)_U_$P($G(DRG(DRGT,DRGI)),U,3)'=$P(ND,U,1,2) S (DNE,PSIVCHG)=1
56 ..S:$G(ND("CNT"))'=$G(TDRG("CNT")) (DNE,PSIVCHG)=1 K ND,TDRG
57 Q
58 ;
59OLDORD ; Update old order, update order links.
60 Q:P("RES")="R"
61 S P("OLDON")=$P($G(^PS(53.1,+ON,0)),U,25) I P("OLDON")'=ON55 S $P(^PS(55,DFN,"IV",+ON55,2),U,8)=P("RES"),$P(^(2),U,5)=P("OLDON") I P("OLDON") D
62 .I P("OLDON")["V",$D(^PS(55,DFN,"IV",+P("OLDON"),0)) S $P(^(2),U,6)=ON55,$P(^(2),U,9)=P("RES")
63 .I P("OLDON")["A",$D(^PS(55,DFN,5,+P("OLDON"),0)) S $P(^(0),U,26,27)=ON55_U_P("RES")
64 .;I P("OLDON")["P",$D(^PS(53.1,+P("OLDON"),0)) S $P(^(0),U,26,27)=ON55_U_P("RES")
65 .I $S(P("OLDON")["P":1,P("OLDON")["N":1,1:0),$D(^PS(53.1,+P("OLDON"),0)) S $P(^(0),U,26,27)=ON55_U_P("RES")
66 D PUT531^PSIVORFA S $P(^PS(53.1,+ON,0),U,25,26)="^",ON=ON55 D UPD100^PSIVORFA
67 Q
68 ;
69NEWORD ; Create new order, update order links.
70 Q:P("RES")="R"
71 S $P(^PS(53.1,+ON,0),U,26,27)=P("NEWON")_U_"E",PSIVAC="CE",PSJORNAT=P("NAT") D DC^PSIVORA
72 S P("NEWON")=$P($G(^PS(53.1,+PSJORD,0)),U,26),$P(^PS(55,DFN,"IV",+P("NEWON"),2),U,5)=PSJORD,$P(^(2),U,8)="E",ON=ON55
73 ;;I PSJIVORF D SET^PSIVORFE D EN1^PSJHL2(DFN,"SN",+ON55_"V","NEW ORDER CREATED")
74 I PSJIVORF D EN1^PSJHL2(DFN,"SN",+ON55_"V","NEW ORDER CREATED")
75 Q
76 ;
77GTIVDRG ; Try to find an IV drug from the Orderable Item.
78 ; If there is only 1 match to OI then stuff in DRG otherwise prompt user to select which
79 ; ad/sol matched to OI
80 K PSIVOI NEW FIL,ND,SCR,PSJNOW
81 D NOW^%DTC S PSJNOW=%
82 S SCR("S")="S ND=$P($G(^(""I"")),U) I ND=""""!(ND>PSJNOW)"
83 F FIL=52.6,52.7 D FIND^DIC(FIL,,"@;.01;2","QXP",+P("PD"),,"AOI",SCR("S"),,"PSIVOI") I +PSIVOI("DILIST",0)>0 D Q
84 . S DRGT=$S(FIL=52.6:"AD",1:"SOL"),PSIVOI=DRGT
85 . I PSIVOI="AD" D
86 .. N XX,XXX,QC S XX=0 F S XX=$O(PSIVOI("DILIST",XX)) Q:XX="" S XXX=+PSIVOI("DILIST",XX,0) D LIST^DIC(52.61,","_XXX_",","@;.01","PQ",,,,,,,"PSIVQC") D
87 ... I +$G(PSIVQC("DILIST",0))>0 S QC=0 F S QC=$O(PSIVQC("DILIST",QC)) Q:QC="" S PSIVOI("DILIST",XX,QC,0)=PSIVQC("DILIST",QC,0)
88 ... K PSIVQC("DILIST",0),PSIVQC("DILIST",0,"MAP")
89 .. D RESET
90 . I +PSIVOI("DILIST",0)=1 D
91 .. S DRG=+PSIVOI("DILIST",1,0)
92 .. S DNE=1,DRG(DRGT,0)=1,ND=$G(^PS(FIL,+DRG,0)),DRG(DRGT,1)=+DRG_U_$P(ND,U)_U_$S(FIL=52.7:$P(ND,U,3),1:"")_U_U_$P(ND,U,13)_U_$P(ND,U,11)
93 K:+PSIVOI("DILIST",0)<2 PSIVOI
94 Q
95 ;
96EDIT ; Edit incomplete order
97 S PSIVAC="CE"
98 I $E(P("OT"))="I",'$D(DRG("AD")),('$D(DRG("SOL"))) D GTIVDRG
99 I P(4)="" D 53^PSIVORC1 Q:P(4)="" D ^PSIVORV2
100 D GSTRING^PSIVORE1,GTFLDS^PSIVORFE ;S (PSIVOK,EDIT)="57^58^59^3"_$S(P("DTYP")=1:"^26^39",1:"")_"^63^64^"_$S($E(P("OT"))="I":"101^109^",1:"")_"10^25"_$S(+P(6)'=+P("CLRK"):"^1",1:"") D GTFLDS^PSIVORFE
101 Q:$G(DONE)
102 I $G(^ORD(101,+$P($G(VALM("PROTOCOL")),";"),0))["PSJ PC IV AC/EDIT ACTION" S PSIVENO=1
103 I '$G(PSIVENO) S PSIVENO=1 D EN^VALM("PSJ LM IV AC/EDIT") S VALMBCK="Q"
104 ;;K ON55 D COMPLTE^PSIVORC1
105 Q
106 ;
107FINISH ; Ask only for missing data in incomplete IV order.
108 S P("OPI")=$$ENPC^PSJUTL("V",+PSIVUP,60,P("OPI")) I $E(P("OT"))="I",'$D(DRG("AD")),('$D(DRG("SOL"))) S DNE=0 D GTIVDRG
109 D:P(4)="" 53^PSIVORC1 Q:P(4)="" S P("DTYP")=$S(P(4)="":0,P(4)="P"!(P(23)="P")!(P(5)):1,P(4)="H":2,1:3)
110 I 'P(2) D ENT^PSIVCAL K %DT S X=P(2),%DT="RTX" D ^%DT S P(2)=+Y
111 I 'P(3) D ENSTOP^PSIVCAL K %DT S X=P(3),%DT="RTX" D ^%DT S P(3)=+Y
112 I 'P("MR") S P("MR")=$O(^PS(51.2,"B","INTRAVENOUS",0))_"^IV"
113 S PSIVOK="1^3^10^25^26^39^57^58^59^63^64" D CKFLDS^PSIVORC1 D:EDIT]"" EDIT^PSIVEDT G COMPLTE^PSIVORC1
114 Q
115NONVF() ; Updated 53.1 status to non-verified after finish.
116 NEW PSGOEAV S PSGOEAV=+$P(PSJSYSP0,U,9)
117 I +PSJSYSU=3,PSGOEAV Q 0
118 I +PSJSYSU=1,PSGOEAV Q 0
119 I PSIVCHG D NWNONVF Q 1
120 S P(17)="N",P("REN")=0
121 D GTPD^PSIVORE2
122 W !,"...transcribing this non-verified order...."
123 S $P(^PS(53.1,+ON,.2),U)=""
124 D PUT531^PSIVORFA
125 D NEWNVAL^PSGAL5(ON,$S(+PSJSYSU=1:22000,+PSJSYSU=3:22005,1:22006),"","")
126 NEW PSIVORFA S PSIVORFA=1 D:ON["V" DEL55^PSIVORE2
127 D EN1^PSJHL2(DFN,"XX",ON,"UPDATED ORDER")
128 D VF
129 Q 1
130NWNONVF ;Create non-verified due to edit
131 ;D NATURE^PSIVOREN I '$D(P("NAT")) Q
132 K DA D ENGNN^PSGOETO S P("NEWON")=DA_"P",P(17)="N",P("REN")=0
133 S PSJORD=ON,$P(^PS(53.1,+ON,0),U,26,27)=P("NEWON")_U_"E",PSIVAC="CE",PSJORNAT=P("NAT") D DC^PSIVORA
134 S P("OLDON")=ON,ON=P("NEWON")
135 S P("RES")="E"
136 ;D:P("DO")="" GTPD^PSIVORE2 ;Get dosage order if not defined for IPM IV
137 S P("DO")="" D GTPD^PSIVORE2 ;Get dosage order if not defined for IPM IV
138 D PUT531^PSIVORFA
139 S $P(^PS(53.1,+ON,0),U,25,26)=P("OLDON")_U_""
140 D NEWNVAL^PSGAL5(ON,$S(+PSJSYSU=1:22000,+PSJSYSU=3:22005,1:22006),"","")
141 D EN1^PSJHL2(DFN,"SN",ON,"SEND ORDER NUMBER")
142 S:$D(PSGP)#10 PSJNOL=$$LS^PSSLOCK(PSGP,ON)
143 D VF
144 Q
145VF ; Display Verify screen
146 Q:ON'["P"
147 K PSJIVBD
148 D GT531^PSIVORFA(DFN,ON)
149 S PSGACT="EL"
150 I P(17)="N",(P("OLDON")=""),(+P("CLRK")=DUZ) S PSGACT="ELD"
151 I +PSJSYSU=3!(+PSJSYSU=1) S PSGACT="DELV"
152 I +PSJSYSU=3,$L($T(EN1^ORCFLAG)) S PSGACT=PSGACT_"G"
153 I P("OT")="I" S PSJSTAR="(1)^(5)^(7)^(9)^(10)"
154 I P("OT")'="I" S PSJSTAR="(1)^(2)^(3)^(5)^(7)^(9)"
155 D EN^VALM("PSJ LM IV INPT ACTIVE")
156 Q
157 ;
158RESET ;Reset PSIVOI("DILIST") for additives with quick codes
159 N XX,XXX,CNT S CNT=0
160 S XX=0 F S XX=$O(PSIVOI("DILIST",XX)) Q:XX="" S CNT=CNT+1,LYN(CNT)=PSIVOI("DILIST",XX,0) D
161 . S XXX=0 F S XXX=$O(PSIVOI("DILIST",XX,XXX)) Q:XXX="" S CNT=CNT+1,LYN(CNT)=$P(PSIVOI("DILIST",XX,0),"^")_"^"_$P(PSIVOI("DILIST",XX,XXX,0),"^",2)_"^"_$P(PSIVOI("DILIST",XX,XXX,0),"^")_"^"_"QC"
162 K PSIVOI("DILIST")
163 S PSIVOI("DILIST",0)=CNT_"^*^0^"
164 S XX=0 F S XX=$O(LYN(XX)) Q:'XX S PSIVOI("DILIST",XX,0)=LYN(XX)
165 K LYN
166 Q
Note: See TracBrowser for help on using the repository browser.