source: FOIAVistA/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSIVOPT1.m@ 1288

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

initial load of FOIAVistA 6/30/08 version

File size: 6.6 KB
Line 
1PSIVOPT1 ;BIR/MLM-EDIT/DC ORDER (BACKDOOR) ;22 OCT 97 / 3:14 PM
2 ;;5.0; INPATIENT MEDICATIONS ;**29,58,101,110,127**;16 DEC 97
3 ;
4 ; Reference to ^PS(55 is supported by DBIA 2191
5 ; Reference to ^PSSLOCK is supported by DBIA #2789
6 ;
7E ; Edit order through Pharmacy.
8 NEW PSJEDFLG
9 D GSTRING^PSIVORE1,GTFLDS^PSIVORFE
10 I '$G(PSIVENO) S PSIVENO=1 D EN^VALM("PSJ LM IV AC/EDIT") S VALMBCK="Q"
11 Q
12ACCEPT ; To be called by ACCEPT^PSJLIACT
13 I $G(PSJEDFLG) S VALMBCK="" Q
14 I '$G(PSJEDIT1) D CKNEW I PSIVCHG D
15 .S P("OLDON")=ON55,Y=$G(^PS(55,DFN,"IV",+ON55,0)) D NOW^%DTC S P("LOG")=$E(%,1,12)
16 . S P("CLRK")=DUZ_U_$P($G(^VA(200,DUZ,0)),U)
17 .I $G(PSGSDX)!$G(PSGFDX) Q
18 .I $P(Y,U,2)=P(2),$P(Y,U,3)=P(3) D ENT^PSIVCAL S X=P(2),%DT="T" D ^%DT S P(2)=$E(Y,1,12),PSJEDIT1=1 D ENSTOP^PSIVCAL
19 K PSJEDFLG
20 D OK^PSIVOPT2
21 I X["N" S VALMBCK="R" Q
22 I X["^" D GT55^PSIVORFB W !,"Order unchanged." Q
23 ;;I $G(P(21))]"" D CKNEW,@$S(PSIVCHG:"NEWORD",1:"UPDATE") Q:$D(X)
24 I $G(P("21FLG"))]"" D CKNEW,@$S(PSIVCHG:"NEWORD",1:"UPDATE") Q:$D(X)
25 ;;S PSJORL=$$ENORL^PSJUTL($G(VAIN(4))) S ON=ON55,OD=P(2) D EN^PSIVORE,^PSIVORE1
26 S PSJORL=$$ENORL^PSJUTL($G(VAIN(4))) S ON=ON55,OD=P(2)
27 ;D:ON["V" EN^PSIVORE,^PSIVORE1
28 D:ON["V" EN^PSIVORE
29 ;;I $G(PSJIVORF),PSIVCHG D EN1^PSJHL2(DFN,"SN",+ON55_"V","NEW ORDER") NEW PSIVXX S PSIVXX=$$LS^PSSLOCK(DFN,+ON55_"V")
30 I $G(PSJIVORF),PSIVCHG D EN1^PSJHL2(DFN,"SN",ON55,"NEW ORDER") NEW PSIVXX S PSIVXX=$$LS^PSSLOCK(DFN,ON55)
31 S PSIVACEP=1
32 Q
33 ;
34CKNEW ; Check if new order is to be created.
35 N DNE,ND,TDRG S (DRG("DRGC"),DNE,PSIVCHG)=0
36 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"
37 F DRGT="AD","SOL" Q:DRGT="SOL"&(P("DTYP")=1) F DRGI=0:0 S DRGI=$O(^PS(55,DFN,"IV",+ON55,DRGT,DRGI)) Q:'DRGI!DNE D
38 .S X=$G(^PS(55,DFN,"IV",+ON55,DRGT,DRGI,0)),DRG("DRGC")=$G(DRG("DRGC"))+1
39 .I $D(TDRG(DRGT,+$P(X,U),DRGI)),$P(X,U,2)=$P(TDRG(DRGT,+$P(X,U),DRGI),U) Q
40 .S (PSIVCHG,DNE)=1
41 Q:PSIVCHG
42 I $G(DRG("AD",0))+$S(P("DTYP")=1:0,1:+$G(DRG("SOL",0)))'=DRG("DRGC") S PSIVCHG=1 Q
43 S ND(0)=$G(^PS(55,DFN,"IV",+ON55,0)),ND("PD")=$G(^PS(55,DFN,"IV",+ON55,.2))
44 N X S X=$S($P(ND(0),U,8)["@":$P($P(ND(0),U,8),"@"),1:$P(ND(0),U,8))
45 S ND=$S($E(P("OT"))="I":$P(ND("PD"),U,1,2)_U,1:"")_$P(ND("PD"),U,3)_U_$S($E(P("OT"))'="I":X_U,1:"")_+$P(ND(0),U,6)_U_$P(ND(0),U,2)_U_$P(ND(0),U,3)_U_$P(ND(0),U,9)
46 S:ND'=($S($E(P("OT"))="I":+P("PD")_U_$G(P("DO"))_U,1:"")_+P("MR")_U_$S($E(P("OT"))'="I":$S(P(8)["@":$P(P(8),"@"),1:P(8))_U,1:"")_+P(6)_U_P(2)_U_P(3)_U_P(9)) PSIVCHG=1
47 ;* S ND=$S($E(P("OT"))="I":$P(ND("PD"),U,1,2)_U,1:"")_$P(ND("PD"),U,3)_U_$S($E(P("OT"))'="I":$P(ND(0),U,8)_U,1:"")_+$P(ND(0),U,6)_U_$P(ND(0),U,2)_U_$P(ND(0),U,3)_U_$P(ND(0),U,9)
48 ;* S:ND'=($S($E(P("OT"))="I":+P("PD")_U_$G(P("DO"))_U,1:"")_+P("MR")_U_$S($E(P("OT"))'="I":P(8)_U,1:"")_+P(6)_U_P(2)_U_P(3)_U_P(9)) PSIVCHG=1
49 Q
50 ;
51UPDATE ; Update original order.
52 S PSIVALT=1,PSIVALCK="EN",PSIVREA="E",ON=ON55 K P("OLDON") D LOG^PSIVORAL
53 D SET55^PSIVORFB,ENLBL^PSIVOPT(2,DUZ,DFN,3,+ON55,"E")
54 D:'$D(PSJIVORF) ORPARM^PSIVOREN K X Q:'PSJIVORF
55 S PSJORIFN=$P($G(^PS(55,DFN,"IV",+ON55,0)),U,21) Q:'PSJORIFN
56 S P("NAT")=""
57 D EN1^PSJHL2(DFN,"XX",+ON55_"V","UPDATED ORDER")
58 K X
59 Q
60 ;
61NEWORD ; DC orig. order, get new order no.
62 D:'$D(PSJIVORF) ORPARM^PSIVOREN I PSJIVORF D NATURE^PSIVOREN I '$D(P("NAT")) S X=1 W !,"Order unchanged." Q
63 ;;S P("RES")="E",P("OLDON")=ON55,P(16)="" K ON55 D NEW55^PSIVORFB S (P("PON"),P("NEWON"),ON)=ON55,ON55=P("OLDON")
64 S P("RES")="E",P("OLDON")=ON55,P(16)=""
65 Q:$$NONVF()
66 I '($G(PSIVCOPY)=2) K ON55 D NEW55^PSIVORFB
67 S (P("PON"),P("NEWON"),ON)=ON55,ON55=P("OLDON") S:($G(PSIVCOPY)=2) P("OLDON")=""
68 I $P($G(^PS(55,DFN,"IV",+P("OLDON"),0)),U,17)="A" D D1^PSIVOPT2 D
69 . I PSJIVORF,$P($G(^PS(55,DFN,"IV",+ON55,0)),U,21) D EN1^PSJHL2(DFN,"OD",+ON55_"V","ORDER DISCONTINUED")
70 . ;;S P(21)="" W !!,"Original order discontinued...",!!
71 . S P("21FLG")="" W !!,"Original order discontinued...",!!
72 . D UNL^PSSLOCK(DFN,+ON55_"V")
73 F ON55=P("NEWON"),P("OLDON") K DA,DIE,DR D
74 .S DA(1)=DFN,DA=+ON55,DIE="^PS(55,"_DFN_",""IV"",",DR=$S((ON55=P("NEWON")&(+ON55'=+P("OLDON"))):"113////"_P("OLDON")_";122////E",1:"114////"_P("NEWON")_";123////E") D ^DIE
75 .I ON55=P("NEWON") N CLINAPPT S CLINAPPT=$G(^PS(55,DFN,"IV",+P("OLDON"),"DSS")) D
76 ..S:CLINAPPT DR=DR_";136////"_+CLINAPPT S:$P(CLINAPPT,"^",2) DR=DR_";139////"_$P(CLINAPPT,"^",2)
77 .D ^DIE
78 .Q:ON55=P("OLDON")&($P($G(^PS(55,DFN,"IV",+P("OLDON"),0)),U,17)'="D")
79 .D:ON55=P("NEWON") SET55^PSIVORFB
80 .D:ON55=P("NEWON") VF1^PSJLIACT("","",0)
81 .D ENLBL^PSIVOPT(2,DUZ,DFN,3,+ON55,$S(ON55=P("NEWON"):"N",1:"DE"))
82 .S PSIVREA="E",PSIVAL="Order "_$S(ON55=P("OLDON"):"discontinued",1:"created")_" due to edit" S:ON55=P("OLDON") PSIVALCK="STOP" D LOG^PSIVORAL
83 L -^PS(55,DFN,"IV",+P("OLDON")) ;D NEWENT^PSIVORFE
84 K X S ON55=P("NEWON"),P(17)="A" Q:'PSJIVORF D SET^PSIVORFE
85 Q
86 ;
87NEWSTOP ; Set stop date for DC and renewals.
88 S ND=$G(^PS(55,DFN,"IV",+ON55,0)),Y=+$P(ND,U,3),$P(^PS(55,DFN,"IV",+P("OLDON"),2),U,7)=Y,NSTOP=$S(NSTOP>Y:Y,1:NSTOP),$P(^PS(55,DFN,"IV",+ON55,0),U,3)=NSTOP
89 K DA,DIK S DIK="^PS(55,"_DFN_",""IV"",",DA(1)=DFN,DA=+P("OLDON") D IX^DIK K DA,DIK
90 Q
91NONVF() ;
92 NEW PSGOEAV S PSGOEAV=+$P(PSJSYSP0,U,9)
93 I +PSJSYSU=3,PSGOEAV Q 0
94 I +PSJSYSU=1,PSGOEAV Q 0
95 K DA D ENGNN^PSGOETO S (ON,P("NEWON"))=DA_"P",P(17)="N"
96 S (P("DO"),P("PD"))=""
97 D GTPD^PSIVORE2,PUT531^PSIVORFA
98 I $P($G(^PS(55,DFN,"IV",+P("OLDON"),0)),U,17)="A" D D1^PSIVOPT2 D
99 . I PSJIVORF,$P($G(^PS(55,DFN,"IV",+P("OLDON"),0)),U,21) D EN1^PSJHL2(DFN,"OD",+ON55_"V","ORDER DISCONTINUED")
100 . S P("21FLG")="" W !!,"Original order discontinued...",!!
101 . D UNL^PSSLOCK(DFN,+P("OLDON")_"V")
102 F ON55=P("NEWON"),P("OLDON") K DA,DIE,DR D
103 . S DA=+ON55
104 . S:ON55=P("NEWON") DIE="^PS(53.1,",DR="104////"_P("OLDON")_";103////E"
105 . S:ON55=P("OLDON") DA(1)=DFN,DIE="^PS(55,"_DFN_",""IV"",",DR="114////"_P("NEWON")_";123////E"
106 . D ^DIE
107 . Q:ON55=P("OLDON")&($P($G(^PS(55,DFN,"IV",+P("OLDON"),0)),U,17)'="D")
108 . I ON55=P("OLDON") D
109 .. D ENLBL^PSIVOPT(2,DUZ,DFN,3,+ON55,$S(ON55=P("NEWON"):"N",1:"DE"))
110 .. S PSIVALT="",PSIVREA="E",PSIVAL="Order discontinued due to edit" S PSIVALCK="STOP" D LOG^PSIVORAL
111 . D:ON55=P("NEWON") NEWNVAL^PSGAL5(ON55,4100,"","")
112 L -^PS(55,DFN,"IV",+P("OLDON"))
113 K X S (ON,ON55)=P("NEWON")
114 D EN1^PSJHL2(DFN,"SN",ON,"ORDER CREATED")
115 S X=$$LS^PSSLOCK(DFN,ON)
116 D GT531^PSIVORFA(DFN,ON)
117 I ON["P" N CLINAPPT S CLINAPPT=$G(^PS(55,DFN,"IV",+ON,"DSS")) I CLINAPPT D K DIE,DA,DR
118 . S:CLINAPPT DR="136////"_+CLINAPPT_";" S:$P(CLINAPPT,"^",2) DR=DR_"139////"_$P(CLINAPPT,"^",2)_";" D ^DIE
119 S VALMBCK="Q"
120 S PSGACT="EL"
121 I P(17)="N",(P("OLDON")=""),(P("CLRK")=DUZ) S PSGACT="ELD"
122 I +PSJSYSU=3!(+PSJSYSU=1) S PSGACT="DELV"
123 Q 1
Note: See TracBrowser for help on using the repository browser.