source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORCACT0.m@ 1015

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

initial load of FOIAVistA 6/30/08 version

File size: 7.4 KB
Line 
1ORCACT0 ;SLC/MKB-Validate order action ;2/24/03 10:35
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**7,27,48,72,86,92,94,141,165,177,173,190,215**;Dec 17, 1997
3 ;
4VALID(IFN,ACTION,ERROR,NATR) ; -- Determines if action is valid for order IFN
5 N OR0,OR3,ORA0,AIFN,PKG,DG,ORDSTS,ACTSTS,VER,X,Y,MEDPARM K ERROR
6 S OR0=$G(^OR(100,+IFN,0)),OR3=$G(^(3)),PKG=$$NMSP^ORCD($P(OR0,U,14))
7 S DG=$P($G(^ORD(100.98,+$P(OR0,U,11),0)),U,3)
8 S MEDPARM=$S($G(NATR)="A":2,PKG'="PS":2,'$D(^XUSEC("OREMAS",DUZ)):2,DG="NV RX":$$GET^XPAR("ALL","OR OREMAS NON-VA MED ORDERS"),1:$$GET^XPAR("ALL","OR OREMAS MED ORDERS"))
9 S AIFN=$P(IFN,";",2) S:'AIFN AIFN=+$P(OR3,U,7)
10 S ORA0=$G(^OR(100,+IFN,8,AIFN,0)),ACTSTS=$P(ORA0,U,15)
11 S ORDSTS=$P(OR3,U,3),VER=$S($P(OR0,U,5)["101.41":3,1:2)
12CM I ACTION="CM" S ERROR="This action is no longer available!" G VQ ; ward comments - no restrictions
13FL I ACTION="FL" D G VQ ; flag
14 . I +$G(^OR(100,+IFN,8,AIFN,3)) S ERROR="This order is already flagged!" Q
15UF I ACTION="UF" D G VQ ; unflag
16 . I '+$G(^OR(100,+IFN,8,AIFN,3)) S ERROR="This order is not flagged!" Q
17DC1 I ACTION="DC",ACTSTS D G VQ ; discontinue/cancel unrel or canc order
18 . I (ACTSTS=11)!(ACTSTS=10) D Q ; unreleased
19 .. I 'MEDPARM S ERROR="You are not authorized to cancel med orders!" Q
20 .. I $G(NATR)="A" S X=$O(^ORE(100.2,"AO",+IFN,0)) I X,'$G(^ORE(100.2,X,1)) S ERROR="Future event orders may not be auto-discontinued!" Q
21 . I ACTSTS=12 S ERROR="This order has been dc'd due to edit!" Q
22 . I ACTSTS=13 S ERROR="This order has been cancelled!" Q
23ES I (ACTION="ES")!(ACTION="OC")!(ACTION="RS")!(ACTION="DS") D ES^ORCACT01 G VQ ; sign
24VR I ACTION="VR" D G VQ ; verify
25 . I $G(ORVER)="N",$P(ORA0,U,9) S ERROR="This order has been verified!" Q
26 . I $G(ORVER)="C",$P(ORA0,U,11) S ERROR="This order has been verified!" Q
27 . I $G(ORVER)="R",$P(ORA0,U,19) S ERROR="This order has been reviewed!" Q
28 . I (ACTSTS=11)!(ACTSTS=10) S ERROR="This order has not been released to the service." Q
29 . I AIFN=1,ORDSTS=5,PKG="PS" S X=$$DISABLED I X S ERROR=$P(X,U,2) Q
30DIS S X=$$DISABLED I X S ERROR=$P(X,U,2) G VQ
31MN I ACTION="MN" D G VQ ; manually release (delayed)
32 . I ACTSTS'=10,ACTSTS'=11 S ERROR="This order has already been released!" Q
33 . I $P(OR0,U,12)="I",'$G(^DPT(+ORVP,.105)) S ERROR="This patient is not currently admitted!"
34GMRA I PKG="GMRA" S ERROR="This action is not allowed on an allergy/adverse reaction!" G VQ ; no actions allowed on Allergies
35MEDS I PKG="PS",'MEDPARM S ERROR="You are not authorized to enter med orders!" G VQ
36RW I ACTION="RW" D RW^ORCACT01 G VQ ; rewrite/copy
37XFR I ACTION="XFR" D XFR^ORCACT01 G VQ ; transfer to in/outpt
38RN I ACTION="RN" D RN^ORCACT01 G VQ ; renew
39TRM I $$DONE G VQ ; ORDSTS=1,2,7,12,13
40EV I ACTION="EV" D G VQ ; change delay event
41 . I ORDSTS'=10,ORDSTS'=11 S ERROR="This order has been released!" Q
42 . I DG="NV RX" S ERROR="Non-VA Med orders do not support this action!" Q
43 . I $$EVTORDER^OREVNTX(IFN) S ERROR="The release event for this order may not be changed!" Q
44 . S X=$P(ORA0,U,4) I X'=2,X'=3 S ERROR="Signed orders may not be delayed to another event!" Q
45DC2 I ACTION="DC",ACTSTS="" D G VQ ; DC released order
46 . I $G(NATR)="A" D Q:$D(ERROR)
47 .. S X=$O(^ORE(100.2,"AO",+IFN,0)) I X S:'$G(^ORE(100.2,X,1)) ERROR="Future event orders may not be auto-discontinued!" Q
48 .. I $$GET1^DIQ(9.4,+$P(OR0,U,14)_",",1)="PSO",$G(DGPMT)=1 Q ;177 If admission auto-dc and order is outpt med then no further checking needed
49 .. I $G(DGPMT)=1,$P($G(^SC(+$P(OR0,U,10),0)),U,3)'="C" S ERROR="Only outpatient orders may be auto-discontinued!" Q
50 .. I $G(DGPMT)'=1,$P($G(^SC(+$P(OR0,U,10),0)),U,3)="C" S ERROR="Only inpatient orders may be auto-discontinued!" Q
51 . I PKG="RA",ORDSTS=6 S ERROR="Active Radiology orders cannot be discontinued!" Q
52 . I PKG="VBEC",ORDSTS=6 S ERROR="Active Blood Product orders cannot be discontinued!" Q
53 . I PKG="LR" D Q
54 .. I $$COLLECTD S ERROR="Lab orders that have been collected may not be discontinued!" Q
55 .. I $G(NATR)="A","^12^38^"'[(U_$P($G(DGPMA),U,18)_U),$$VALUE^ORX8(+IFN,"COLLECT")="SP",$P(OR0,U,8)'<DT S ERROR="Future Send Patient orders may not be auto-discontinued!" Q
56 . I PKG="GMRC",ORDSTS=9 S ERROR="Consults orders with partial results cannot be discontinued!" Q
57 . I DG="DO",$G(DGPMT)'=3,ORDSTS=6,'$$NPO(+IFN) S ERROR="Active Diets cannot be discontinued; please order a new diet!" Q
58RL I ACTION="RL" D G VQ ; release hold
59 . I ORDSTS'=3 S ERROR="Orders not on hold cannot be released!" Q
60 . I ACTSTS S ERROR=$$ACTION($P(ORA0,U,2))_" orders cannot be released from hold!" Q
61 . N NATR,ACT S ACT=$S($P(ORA0,U,2)="HD":AIFN,1:+$P(OR3,U,7))
62 . S NATR=+$P($G(^OR(100,+IFN,8,ACT,0)),U,12),ACT=$P($G(^(0)),U,2)
63 . I PKG="RA"!(ACT'="HD")!($P($G(^ORD(100.02,NATR,0)),U,2)="S") S ERROR="Orders held by a service must be released from hold through the service!" Q
64AIFN S X=$P(ORA0,U,2) I AIFN>1,ACTSTS S ERROR="This action is not allowed on a "_$$ACTION(X)_" order!" G VQ
65RF I ACTION="RF" D G VQ
66 . I DG'="O RX" S ERROR="Only Outpatient Med orders may be refilled!" Q
67 . I ORDSTS=5 S ERROR="Pending orders may not be refilled!" Q
68 . N X,PSIFN S PSIFN=$G(^OR(100,+IFN,4))
69 . S X=$$REFILL^PSOREF(PSIFN) I X'>0 S ERROR=$P(X,U,2) Q
70CP I ACTION="CP" D G VQ ; complete
71 . I PKG'="OR" S ERROR="Only generic text orders may be completed through this option!" Q
72 . I ORDSTS=11!(ORDSTS=10) S ERROR="This order has not been released!" Q
73AL I ACTION="AL" D G VQ
74 . I PKG'="LR",PKG'="RA",PKG'="GMRC" S ERROR="This order does not generate results!" Q
75 . I $P(OR3,U,10) S ERROR="This order is already flagged to alert the provider when resulted!" Q
76XX I ACTION="XX" D XX^ORCACT01 G VQ ; edit/change
77HD I ACTION="HD" D G VQ ; hold
78 . I PKG="FH" S ERROR="Diet orders cannot be held!" Q
79 . I PKG="LR" S ERROR="Lab orders cannot be held!" Q
80 . I PKG="RA" S ERROR="Radiology orders cannot be held!" Q
81 . I PKG="GMRC" S ERROR="Consult orders cannot be held!" Q
82 . I DG="NV RX" S ERROR="Non-VA Med orders cannot be held!" Q
83 . I ORDSTS=3 S ERROR="This order is already on hold!" Q
84 . I ORDSTS'=6,PKG="PS" S ERROR="Only active Pharmacy orders may be held!" Q
85 . I (ORDSTS=11)!(ORDSTS=10) S ERROR="This order has not been released to the service." Q
86VQ S Y=$S($D(ERROR):0,1:1)
87 Q Y
88 ;
89ACTION(X) ; -- Return text of action X
90 N Y S Y=$S(X="NW":"New",X="DC":"Discontinue",X="HD":"Hold",X="RL":"Release Hold",X="RN":"Renew",1:X)
91 Q Y
92 ;
93NPO(ORIFN) ; -- Returns 1 or 0, if order ORIFN is for NPO
94 N X,Y S X=$$VALUE^ORX8(+ORIFN,"ORDERABLE",1,"E")
95 S Y=$S($E(X,1,3)="NPO":1,1:0)
96 Q Y
97 ;
98COLLECTD() ; -- Lab order collected/active (incl all children)?
99 I (ORDSTS=11)!(ORDSTS=10) Q 0 ; unreleased
100 I '$O(^OR(100,+IFN,2,0)) Q (ORDSTS'=5)
101 ;I ORDSTS'=6 Q 1 ; Parent -> active instead of pending
102 N Y,Z S Y=1,Z=0
103 F S Z=$O(^OR(100,+IFN,2,Z)) Q:Z'>0 I $P($G(^OR(100,Z,3)),U,3)=5 S Y=0 Q
104 Q Y
105 ;
106DONE() ; -- sets ERROR if terminal status
107 I ORDSTS=1 S ERROR="This order has been discontinued!" Q 1
108 I ORDSTS=2 S ERROR="This order has been completed!" Q 1
109 I ORDSTS=7 S ERROR="This order has expired!" Q 1
110 I ORDSTS=12 S ERROR="This order has been changed!" Q 1
111 I ORDSTS=13 S ERROR="This order has been cancelled!" Q 1
112 I ORDSTS=14 S ERROR="This order has lapsed!" Q 1
113 I ORDSTS=15 S ERROR="This order has been renewed!" Q 1
114 Q 0
115 ;
116DISABLED() ; -- Order dialog [or protocol] disabled?
117 N X,DLG S DLG=$P(OR0,U,5),X=0 I +DLG'>0 Q X
118 I VER'<3,DLG?1.N1";ORD(101.41," S X=$$MSG^ORXD(+DLG) Q X
119 S DLG=$S(PKG="RA":"RA OERR EXAM",PKG="GMRC":"GMRCOR CONSULT",1:"")
120 I $L(DLG) S DLG=+$O(^ORD(101.41,"AB",DLG,0)),X=$$MSG^ORXD(DLG)
121 Q X
Note: See TracBrowser for help on using the repository browser.