source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORCACT1.m@ 1499

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

initial load of FOIAVistA 6/30/08 version

File size: 7.0 KB
Line 
1ORCACT1 ;SLC/MKB-Act on orders cont ;7/29/97 08:26
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**7,27,56,48,86,92,116,149,215**;Dec 17, 1997
3 ;
4FLAG ; -- flag orders
5 D EN("FL") Q
6 ;
7UNFLAG ; -- unflag orders
8 D EN("UF") Q
9 ;
10COMMENT ; -- add ward comments to orders
11 D EN("CM") Q
12 ;
13ALERT ; -- alert provider when results available
14 D EN("AL") Q
15 ;
16UNHOLD ; -- release hold on orders - no longer in use
17 Q ; see UNHOLD^ORCACT instead
18 ;
19EN(ORACT) ; -- Actions that don't create orders
20 ; ORNMBR = #,#,...,# of selected orders
21 ; ORACT = action to be taken
22 ;
23 ; OREBUILD defined on return if Orders tab needs to be rebuilt
24 ;
25 N ORLK,ORI,NMBR,IDX,ORIFN,ORDITM,ORERR,ORQUIT
26 I '$G(ORNMBR) S ORNMBR=$$ORDERS^ORCHART("") Q:'ORNMBR
27 D FREEZE^ORCMENU S VALMBCK="R" K OREBUILD
28 F ORI=1:1:$L(ORNMBR,",") S NMBR=$P(ORNMBR,",",ORI) D:NMBR Q:$D(ORQUIT)
29 . S IDX=$G(^TMP("OR",$J,ORTAB,"IDX",NMBR)),ORIFN=$P(IDX,U)
30 . Q:'ORIFN S:'$P(ORIFN,";",2) ORIFN=+ORIFN_";1"
31 . I '$D(^OR(100,+ORIFN,0)) W !,"This order has been deleted!" H 1 Q
32 . S ORDITM=$$ORDITEM^ORCACT(ORIFN) D SUBHDR^ORCACT(ORDITM)
33 . I '$$VALID^ORCACT0(ORIFN,ORACT,.ORERR) W !,ORERR H 1 Q
34 . S ORLK=$$LOCK1^ORX2(+ORIFN) I 'ORLK W !,$P(ORLK,U,2) H 1 Q
35 . D @ORACT,UNLK1^ORX2(+ORIFN)
36ENQ Q
37 ;
38FL ; -- Flag order ORIFN
39 D EN^ORCFLAG
40 Q
41 ;
42UF ; -- Unflag order ORIFN
43 D UN^ORCFLAG
44 Q
45 ;
46CM ; -- Ward Comments on order ORIFN
47 N DIC,DWPK,DIWEPSE,DIWESUB,DDWRW
48 S DIC="^OR(100,"_+ORIFN_",8,"_+$P(ORIFN,";",2)_",5,",(DWPK,DIWEPSE)=1
49 S DIWESUB=ORDITM,DDWRW="B" ;go to bottom of text
50 D EN^DIWE
51 Q
52 ;
53AL ; -- Alert when results are available for order ORIFN
54 S $P(^OR(100,+ORIFN,3),U,10)=1
55 W !?10,"... done." H 1
56 Q
57 ;
58RL ; -- Release hold on order ORIFN [No longer used]
59 D EN^ORCSEND(+ORIFN,ORACT,3,1,,,.ORERR)
60 W !,"... order "_$S($G(ORERR):"not ",1:"")_"released from hold."
61 W:$L($P($G(ORERR),U,2)) !," >> "_$P(ORERR,U,2) H 1
62 S OREBUILD=1 ; print?
63 Q
64 ;
65VERIFY(ORVER) ; -- Verify orders
66 N ORLK,ORI,NMBR,IDX,ORIFN,ORDITM,ORES,ORERR,ORSIG,OROLDSTS,ORNEW,ORWAIT
67 I "^"[$G(ORVER) W $C(7),!!,"You must be a nurse or clerk to verify these orders!" S VALMBCK="" H 2 Q
68 I '$G(ORNMBR) S ORNMBR=$$ORDERS^ORCHART("") Q:'ORNMBR
69 D FREEZE^ORCMENU S VALMBCK="R" K OREBUILD
70 F ORI=1:1:$L(ORNMBR,",") S NMBR=$P(ORNMBR,",",ORI) D:NMBR Q:$D(ORQUIT)
71 . S IDX=$G(^TMP("OR",$J,ORTAB,"IDX",NMBR)),ORIFN=$P(IDX,U)
72 . Q:'ORIFN S:'$P(ORIFN,";",2) ORIFN=+ORIFN_";1" Q:$D(ORES(ORIFN))
73 . I '$$VALID^ORCACT0(ORIFN,"VR",.ORERR) W !!,$$ORDITEM^ORCACT(ORIFN)_" invalid.",!," >> "_ORERR H 1 Q
74 . S ORLK=$$LOCK1^ORX2(+ORIFN) I 'ORLK W !!,$$ORDITEM^ORCACT(ORIFN)_" invalid.",!," >> "_$P(ORLK,U,2) H 1 Q
75 . S ORES(ORIFN)="" D REPLCD
76VR1 Q:'$O(ORES(0)) D COMPLX S ORSIG=$S($$ESIG^ORCSIGN:1,1:0)
77 I 'ORSIG W !,"Nothing verified!" D UNLOCK H 1 Q
78 W !!,"Verifying orders ..."
79 S ORIFN=0 F S ORIFN=$O(ORES(ORIFN)) Q:ORIFN'>0 D
80 . S OROLDSTS=+$P($G(^OR(100,+ORIFN,3)),U,3)
81 . D EN^ORCSEND(ORIFN,"VR","","",,,.ORERR),UNLK1^ORX2(+ORIFN)
82 . I $G(ORERR) D Q
83 . . W !,$$ORDITEM^ORCACT(ORIFN)_" not verified."
84 . . W:$L($P($G(ORERR),U,2)) !," >> "_$P(ORERR,U,2) H 1
85 . S ORNEW=+$P($G(^OR(100,+ORIFN,3)),U,3) I ORNEW'=OROLDSTS W !,$$ORDITEM^ORCACT(ORIFN)_" is now "_$$STS(ORNEW)_"." S ORWAIT=1
86 S OREBUILD=1 D:'$D(XQAID) CKALERT I $G(ORWAIT) H 2
87VRQ Q
88 ;
89STS(X) ; -- Return name of status X
90 N Y S Y=$P($G(^ORD(100.01,+$G(X),0)),U)
91 Q Y
92 ;
93REPLCD ; -- Ck for unverified replaced orders for ORIFN, add to ORES(order#)
94 ; [Expects ORVER; also called from VERIFY^ORWDXA,VERIFY^ORRCOR]
95 N OR3,ORIG,ORFLD,ORDA,ORI,ORLK
96 S ORFLD=$S($G(ORVER)="N":8,1:10),ORDA=+$P(ORIFN,";",2)
97 I ORDA>1 D Q ;ck for prior unverified actions
98 . ;Q:$P($G(^OR(100,+ORIFN,8,ORDA,0)),U,2)'="XX"
99 . S ORI=0 F S ORI=$O(^OR(100,+ORIFN,8,ORI)) Q:ORI<1 Q:ORI'<ORDA D
100 .. Q:$P($G(^OR(100,+ORIFN,8,ORI,0)),U,ORFLD) ;already verified
101 .. S ORLK=$$LOCK1^ORX2(+ORIFN) Q:'ORLK
102 .. S ORES(+ORIFN_";"_ORI)=""
103 S OR3=$G(^OR(100,+ORIFN,3)) Q:$P(OR3,U,11)'=1
104 S ORIG=+$P(OR3,U,5) Q:'ORIG Q:$P($G(^OR(100,ORIG,3)),U,3)'=12
105 S ORDA=0 F S ORDA=$O(^OR(100,ORIG,8,ORDA)) Q:ORDA'>0 I '$P($G(^(ORDA,0)),U,ORFLD) D
106 . S ORLK=$$LOCK1^ORX2(ORIG) Q:'ORLK
107 . S ORES(ORIG_";"_ORDA)=""
108 Q
109 ;
110COMPLX ; -- Ck for other child orders to be verified at same time
111 N IFN,DAD,CHLD,ALL,P,X,I
112 S P=$S(ORVER="N":9,ORVER="C":11,ORVER="R":19,1:0) Q:P<1
113 S IFN=0 F S IFN=$O(ORES(IFN)) Q:IFN<1 D
114 . S X=+$P($G(^OR(100,+IFN,0)),U,14) Q:$$NMSP^ORCD(X)'["PS"
115 . S X=$P($G(^OR(100,+IFN,8,+$P(IFN,";",2),0)),U,2) Q:X'="NW"&(X'="XX")
116 . I $P($G(^OR(100,+IFN,3)),U,9) S DAD(+$P(^(3),U,9))=""
117 Q:'$O(DAD(0)) S IFN=0 F S IFN=+$O(DAD(IFN)) Q:IFN<1 D
118 . S CHLD=0,ALL=1
119 . F S CHLD=+$O(^OR(100,IFN,2,CHLD)) Q:CHLD<1 F X="NW","XX" D
120 .. S I=+$O(^OR(100,CHLD,8,"C",X,0)) Q:I<1
121 .. Q:$P($G(^OR(100,CHLD,8,I,0)),U,P) Q:$D(ORES(CHLD_";"_I))
122 .. S ORES(CHLD_";"_I)="",ALL=0
123 . Q:ALL S X=$$ORDITEM^ORCACT(IFN) D SUBHDR^ORCACT(X)
124 . W !,"All doses of this complex order must be verified together;"
125 . W !,"adding remaining doses to signature list..."
126 Q
127 ;
128CKALERT ; -- Ck if Unverified Orders alerts can be deleted
129 N ORNOW,ORBEG,ORLIST,ORALL,ORMEDS S ORNOW=$$NOW^XLFDT
130 S:'$G(ORWARD) ORBEG=$$FMADD^XLFDT(ORNOW,"-30") I $G(ORWARD) D
131 . N DFN,VAIN,VAERR S DFN=+ORVP D INP^VADPT
132 . S ORBEG=$S($G(VAIN(7)):$P(VAIN(7),U),1:$$FMADD^XLFDT(ORNOW,-30))
133 D EN^ORQ1(ORVP,,9,,ORBEG,ORNOW) ;see if any unverified orders remain
134 I $G(ORLIST),$G(^TMP("ORR",$J,ORLIST,"TOT")) D ;see if any are meds
135 . N ORRX,ORGRP,I,IFN,DG S ORALL=1
136 . S ORRX=+$O(^ORD(100.98,"B","RX",0)) D GRP^ORQ1(ORRX)
137 . S I=0 F S I=$O(^TMP("ORR",$J,ORLIST,I)) Q:I'>0 S IFN=+^(I),DG=+$P($G(^OR(100,IFN,0)),U,11) I $D(ORGRP(DG)) S ORMEDS=1 Q
138 D:'$G(ORALL) DELALRT("UNVERIFIED ORDER")
139 D:'$G(ORMEDS) DELALRT("UNVERIFIED MEDICATION ORDER")
140 Q
141 ;
142DELALRT(X) ; -- delete alert X
143 N ORNIFN,XQAKILL,XQAID
144 S ORNIFN=+$O(^ORD(100.9,"B",X,0)) Q:ORNIFN'>0
145 S XQAKILL=$$XQAKILL^ORB3F1(ORNIFN)
146 S XQAID=$P($G(^ORD(100.9,ORNIFN,0)),U,2)_","_+ORVP_","_ORNIFN
147 D DELETEA^XQALERT
148 Q
149 ;
150UNLOCK ; -- Unlock orders in ORES(ORIFN) [from VR1]
151 F S ORIFN=$O(ORES(ORIFN)) Q:ORIFN'>0 D UNLK1^ORX2(+ORIFN)
152 Q
153 ;
154SIGNREQD(IFN) ; -- Returns 2, 1, or 0, if order/actions need ES
155 Q +$P($G(^OR(100,IFN,0)),U,16)
156 ;
157SIGN ; -- Sign orders [no longer used]
158 D EN^ORCSIGN
159 Q
160 ;
161COMPLETE ; -- complete orders
162 N ORLK,ORI,NMBR,IDX,ORIFN,ORDITM,ORES,ORERR,ORSIG,ORSTOP
163 I '$G(ORNMBR) S ORNMBR=$$ORDERS^ORCHART("complete") Q:'ORNMBR
164 D FREEZE^ORCMENU S VALMBCK="R" K OREBUILD
165 F ORI=1:1:$L(ORNMBR) S NMBR=$P(ORNMBR,",",ORI) D:NMBR Q:$D(ORQUIT)
166 . S IDX=$G(^TMP("OR",$J,ORTAB,"IDX",NMBR)),ORIFN=$P(IDX,U)
167 . Q:'ORIFN S:'$P(ORIFN,";",2) ORIFN=+ORIFN_";1"
168 . I '$$VALID^ORCACT0(ORIFN,"CP",.ORERR) W !!,$$ORDITEM^ORCACT(ORIFN)_" invalid.",!," >> "_ORERR H 1 Q
169 . S ORLK=$$LOCK1^ORX2(+ORIFN) I 'ORLK W !!,$$ORDITEM^ORCACT(ORIFN)_" invalid.",!," >> "_$P(ORLK,U,2) H 1 Q
170 . S ORES(ORIFN)=""
171CP1 Q:'$O(ORES(0)) S ORSIG=$S($$ESIG^ORCSIGN:1,1:0)
172 I 'ORSIG W !,"Nothing completed!" D UNLOCK H 1 Q
173 W !!,"Completing orders ..." S ORSTOP=+$E($$NOW^XLFDT,1,12),ORIFN=0
174 F S ORIFN=$O(ORES(ORIFN)) Q:ORIFN'>0 D COMP^ORCSAVE2(ORIFN,DUZ,ORSTOP),UNLK1^ORX2(+ORIFN)
175 S OREBUILD=1
176CPQ Q
Note: See TracBrowser for help on using the repository browser.