source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWDX.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 8.2 KB
Line 
1ORWDX ; SLC/KCM/REV/JLI - Order dialog utilities ;11/09/2006
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,125,131,132,141,164,178,187,190,195,215,246**;Dec 17, 1997;Build 8
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5ORDITM(Y,FROM,DIR,XREF) ; Subset of orderable items
6 ; Y(n)=IEN^.01 Name^.01 Name -or- IEN^Synonym <.01 Name>^.01 Name
7 N I,IEN,CNT,X,DTXT,CURTM
8 S I=0,CNT=44,CURTM=$$NOW^XLFDT
9 F Q:I'<CNT S FROM=$O(^ORD(101.43,XREF,FROM),DIR) Q:FROM="" D
10 . S IEN="" F S IEN=$O(^ORD(101.43,XREF,FROM,IEN),DIR) Q:'IEN D
11 . . S X=^ORD(101.43,XREF,FROM,IEN)
12 . . I +$P(X,U,3),$P(X,U,3)<CURTM Q
13 . . Q:$P(X,U,5) S I=I+1
14 . . I 'X S Y(I)=IEN_U_$P(X,U,2)_U_$P(X,U,2)
15 . . E S Y(I)=IEN_U_$P(X,U,2)_$C(9)_"<"_$P(X,U,4)_">"_U_$P(X,U,4)
16 Q
17ODITMBC(Y,XREF,ODLST) ;
18 N CNT,NM,XRF
19 S CNT=0,NM=0,XRF=XREF
20 F S CNT=$O(ODLST(CNT)) Q:'CNT D FNDINFO(.Y,ODLST(CNT))
21 Q
22FNDINFO(Y,ODIEN) ;
23 D FNDINFO^ORWDX1(.Y,.ODIEN)
24 Q
25DLGDEF(LST,DLG) ; Format mapping for a dlg
26 D DLGDEF^ORWDX1(.LST,.DLG)
27 Q
28DLGQUIK(LST,QO) ;(NOT USED)
29 D LOADRSP(.LST,QO)
30 Q
31LOADRSP(LST,RSPID) ; Load responses from 101.41 or 100
32 ; RSPID: C123456;1-3243 = cached copy, 134-3234 = cached quick
33 ; X123456;1 = change order, 134 = quick dialog
34 N I,J,DLG,INST,ID,VAL,ILST,ROOT S ROOT=""
35 I RSPID["-" S ROOT="^TMP(""ORWDXMQ"",$J,"""_RSPID_""")" G XROOT^ORWDX2
36 I $E(RSPID)="X" S ROOT="^OR(100,"_+$P(RSPID,"X",2)_",4.5)" G XROOT^ORWDX2
37 I +RSPID=RSPID S ROOT="^ORD(101.41,"_+RSPID_",6)" G XROOT^ORWDX2
38 Q:ROOT=""
39 G XROOT^ORWDX2
40SAVE(REC,ORVP,ORNP,ORL,DLG,ORDG,ORIT,ORIFN,ORDIALOG,ORDEA,ORAPPT,ORSRC,OREVTDF) ;
41 ; ORVP=DFN, ORNP=Provider, ORL=Location, DLG=Order Dialog,
42 ; ORDG=Display Group, ORIT=Quick Order Dialog, ORAPPT=Appointment
43 N ORDUZ,ORSTS,OREVENT,ORCAT,ORDA,ORTS,ORNEW,ORCHECK,ORLOG,ORLEAD,ORTRAIL,ORPKG,ORWP94,ORCATFN,OREVTYPE,ONPASS
44 ; JD FIX FOR WASHINGTON DC
45 ;I '$L(ORSRC)!($G(ORSRC)=" ")!($G(ORSRC)=0) S ORSRC=$P(ORVP,U,2)
46 ;S ORVP=$P(ORVP,U)
47 ; END FIX JD
48 S ORCATFN=""
49 I $L($P(DLG,U,2)) S ORCATFN=$P(DLG,U,2),DLG=$P(DLG,U,1)
50 ;Remove treating facility if inpatient and IMO order 26.42
51 I $G(^DPT(ORVP,.1))'="",$P($G(^ORD(100.98,ORDG,0)),U)="CLINIC ORDERS" K ORDIALOG("ORTS")
52 I $G(ORDIALOG("ORTS")) S ORTS=ORDIALOG("ORTS") K ORDIALOG("ORTS")
53 I $G(ORDIALOG("ORSLOG")) S ORLOG=ORDIALOG("ORSLOG") K ORDIALOG("ORSLOG")
54 I $D(ORDIALOG("OREVENT")) S OREVENT=ORDIALOG("OREVENT") K ORDIALOG("OREVENT")
55 ;=====================================================
56 ; Changed for v26.27 (RV)
57 S ORCAT=$$INPT^ORCD,ORCAT=$S(ORCAT=1:"I",1:"O")
58 ;I $L($G(OREVENT)) D
59 ;. S ONPASS=0
60 ;. S OREVTYPE=$$TYPE^OREVNTX(OREVENT)
61 ;. I OREVTYPE="T" D ISPASS^OREVNTX1(.ONPASS,+OREVENT,"T")
62 ;. S ORCAT=$S(OREVTYPE="A":"I",OREVTYPE="T":"I",ONPASS=1:"O",1:"O")
63 ;E S ORCAT=$S($L($P($G(^DPT(+ORVP,.1)),U)):"I",1:"O")
64 ;=====================================================
65 I DLG="PS MEDS" S ORWP94=1 D
66 . I ORIT=$O(^ORD(101.41,"AB","PSO SUPPLY",0)) S DLG="PSO SUPPLY"
67 . I ORIT=$O(^ORD(101.41,"AB","PSO OERR",0)) S DLG="PSO OERR"
68 . I ORIT=$O(^ORD(101.41,"AB","PSJ OR PAT OE",0)) S DLG="PSJ OR PAT OE"
69 I DLG="PSO OERR" S ORCAT="O" I $G(OREVENT("EFFECTIVE")) D
70 . S ORDIALOG($O(^ORD(101.41,"B","OR GTX START DATE"_$S($G(ORWP94):"/TIME",1:""),0)),1)=OREVENT("EFFECTIVE")
71 I DLG="PSJ OR PAT OE" S ORCAT="I"
72 S:DLG="FHW1" ORCAT="I" S:DLG?1"FHW "2.7U1" MEAL" ORCAT="O"
73 S ORVP=ORVP_";DPT(",ORL(2)=ORL_";SC(",ORL=ORL(2)
74 K:'ORDG ORDG K:'ORIT ORIT ; Dgrp & Quick must be non-zero
75 M ORCHECK=ORDIALOG("ORCHECK") K ORDIALOG("ORCHECK")
76 S ORDIALOG=$O(^ORD(101.41,"AB",DLG,0))
77 I 'ORDIALOG S ORDIALOG=$O(^ORD(101.41,"B",DLG,0))
78 I $D(ORDIALOG("ORLEAD")) S ORLEAD=ORDIALOG("ORLEAD")
79 I $D(ORDIALOG("ORTRAIL")) S ORTRAIL=ORDIALOG("ORTRAIL")
80 D GETDLG1^ORCD(ORDIALOG)
81 I $L(ORCATFN) S ORCAT=ORCATFN
82 I $G(ORWP94) D
83 . N SIGPRMT S SIGPRMT=$O(^ORD(101.41,"B","OR GTX SIG",0))
84 . N INSPRMT S INSPRMT=$O(^ORD(101.41,"B","OR GTX INSTRUCTIONS",0))
85 . I $L($G(ORDIALOG(SIGPRMT,1))) S ORDIALOG(INSPRMT,"FORMAT")="@"
86 . I ORCAT="O" S ORPKG=$O(^DIC(9.4,"C","PSO",0))
87 . I ORCAT="I" S ORPKG=$O(^DIC(9.4,"C","PSJ",0))
88 S ORSRC=$G(ORSRC)
89 D DELPI^ORWDX1 ;delete empty PI
90 I $G(ORIFN)="" D ; new order
91 . D EN^ORCSAVE
92 . S REC="" I ORIFN D GETBYIFN^ORWORR(.REC,ORIFN)
93 . I '$D(^TMP("ORECALL",$J,ORDIALOG)) M ^TMP("ORECALL",$J,ORDIALOG)=ORDIALOG
94 E D
95 . N OR0
96 . S OR0=$G(^OR(100,+ORIFN,0)),ORSTS=$P($G(^(3)),U,3),ORDG=$P(OR0,U,11)
97 . I $L($P(OR0,U,17)),ORSTS=10 S OREVENT=$P(OR0,U,17),OREVENT("TS")=$P(OR0,U,13)
98 . D XX^ORCSAVE ; edit order
99 . S REC="" S ORIFN=+ORIFN_";"_ORDA D GETBYIFN^ORWORR(.REC,ORIFN)
100 Q
101SENDED(ORWLST,ORIENS,TS,LOC) ; Release EDOs to svc
102 N OK,ORVP,ORWERR,ORSIGST,ORDA,ORNATURE,ORIX,X,PTEVT,ORIFN,J,EVENT,LOCK
103 S ORWERR="",ORIX=0,LOC=LOC_";SC("
104 F S ORIX=$O(ORIENS(ORIX)) Q:'ORIX D
105 . S ORIFN=ORIENS(ORIX)
106 . S PTEVT=$P(^OR(100,+ORIFN,0),U,17) I PTEVT S LOCK=$$LCKEVT^ORX2(PTEVT) S:LOCK EVENT(PTEVT)="" I 'LOCK S ORWERR="1^delayed event is locked - another user is processing orders for this event" ;195
107 . S ORDA=$P(ORIFN,";",2) S:'ORDA ORDA=1
108 . S ORVP=$P($G(^OR(100,+ORIFN,0)),U,2)
109 . I $D(^OR(100,+ORIFN,8,ORDA,0)) D
110 .. S ORSIGST=$P($G(^(0)),U,4)
111 .. S ORNATURE=$P($G(^(0)),U,12)
112 . S:$G(LOC) $P(^OR(100,+ORIFN,0),U,10)=LOC ;set location
113 . S:$G(TS) $P(^OR(100,+ORIFN,0),U,13)=TS ;set specialty
114 . S OK=$$LOCK1^ORX2(ORIFN) I 'OK S ORWERR="1^"_$P(OK,U,2)
115 . I OK,$G(LOCK) D EN2^ORCSEND(ORIENS(ORIX),ORSIGST,ORNATURE,.ORWERR),UNLK1^ORX2(ORIENS(ORIX)) ;add ,LOCK to if statement for 195
116 . S ORWLST(ORIX)=ORIENS(ORIX)
117 . I $L(ORWERR) S ORWLST(ORIX)=ORWLST(ORIX)_"^E^"_ORWERR Q
118 . E D
119 .. S PTEVT=$P($G(^OR(100,+ORIENS(ORIX),0)),U,17)
120 .. D:$$TYPE^OREVNTX(PTEVT)="M" SAVE^ORMEVNT1(ORIENS(ORIX),PTEVT,2)
121 . S X="RS"
122 . S $P(ORWLST(ORIX),U,2)=X
123 S J=0 F S J=$O(EVENT(J)) Q:'+J D UNLEVT^ORX2(J) ;195
124 Q
125SEND(ORWLST,DFN,ORNP,ORL,ES,ORWREC) ; Sign
126 ; DFN=Patient, ORNP=Provider, ORL=Location, ES=Encrypted ES code
127 ; ORWREC(n)=ORIFN;Action^Signature Sts^Release Sts^Nature of Order
128SEND1 N ORVP,ORWI,ORWERR,ORWREL,ORWSIG,ORWNATR,ORDERID,ORBEF,ORLR,ORLAB,X,I
129 S ORVP=DFN_";DPT(",ORL=ORL_";SC(",ORL(2)=ORL,ORWLST=0
130 F I="LR","VBEC" S X=+$O(^DIC(9.4,"C",I,0)) S:X ORLR(X)=1
131 S ORWI=0 F S ORWI=$O(ORWREC(ORWI)) Q:'ORWI D
132 . S X=ORWREC(ORWI),ORWERR=""
133 . S ORDERID=$P(X,U),ORWSIG=$P(X,U,2),ORWREL=$P(X,U,3),ORWNATR=$P(X,U,4)
134 . S ORBEF=0
135 . I '$D(^OR(100,+ORDERID,0)) Q
136 . I $D(^OR(100,+ORDERID,8,+$P(ORDERID,";",2),0)) S ORBEF=$P(^OR(100,+ORDERID,8,+$P(ORDERID,";",2),0),U,15)
137 . S:$D(^OR(100,+ORDERID,8,+$P(ORDERID,";",2),0)) ORWNATR=$S($P(^OR(100,+ORDERID,8,+$P(ORDERID,";",2),0),"^",4)=3:"",1:ORWNATR)
138 . S ORWERR=$$CHKACT^ORWDXR(ORDERID,ORWSIG,ORWREL,ORWNATR)
139 . I $L(ORWERR) S ORWERR="1^"_ORWERR
140 . I '$L(ORWERR) D
141 .. I $G(ORLR(+$P(^OR(100,+ORDERID,0),U,14))),'$G(ORLAB) D ; lab batch start
142 ... I $L($T(BHS^ORMBLD)) D BHS^ORMBLD(ORVP) S ORLAB=1
143 .. N OK S OK=$$LOCK1^ORX2(ORDERID) I 'OK S ORWERR="1^"_$P(OK,U,2)
144 .. I OK D EN^ORCSEND(ORDERID,"",ORWSIG,ORWREL,ORWNATR,"",.ORWERR),UNLK1^ORX2(ORDERID)
145 . S ORWLST(ORWI)=ORDERID,X=""
146 . I $L(ORWERR) S ORWLST(ORWI)=ORWLST(ORWI)_"^E^"_ORWERR Q
147 . I ORWREL,((ORBEF=10)!(ORBEF=11)),($P(^OR(100,+ORDERID,3),U,3)'=10) S X="R"
148 . I ORWSIG'=2 S X=X_"S"
149 . S $P(ORWLST(ORWI),U,2)=X
150 I $G(ORLAB) D BTS^ORMBLD(ORVP)
151 Q
152DLGID(VAL,ORIFN) ; return dlg IEN for order
153 S VAL=$P(^OR(100,+ORIFN,0),U,5)
154 S VAL=$S($P(VAL,";",2)="ORD(101.41,":+VAL,1:0)
155 Q
156FORMID(VAL,ORIFN) ; Base dlg FormID for an order
157 N DLG
158 S VAL=0,DLG=$P(^OR(100,+ORIFN,0),U,5)
159 Q:$P(DLG,";",2)'="ORD(101.41,"
160 D FORMID^ORWDXM(.VAL,+DLG)
161 Q
162AGAIN(VAL,DLG) ; return true to keep dlg for another order
163 S VAL=''$P($G(^ORD(101.41,DLG,0)),U,9)
164 Q
165DGRP(VAL,DLG) ; Display grp pointer for a dlg
166 S DLG=$S($E(DLG)="`":+$P(DLG,"`",2),1:$O(^ORD(101.41,"AB",DLG,0))) ;kcm
167 S VAL=$P($G(^ORD(101.41,DLG,0)),U,5)
168 Q
169DGNM(VAL,NM) ; Display grp pointer for name
170 S VAL=$O(^ORD(100.98,"B",NM,0))
171 Q
172WRLST(LST,LOC) ; List of dlgs for writing orders
173 G WRLST1^ORWDX1
174MSG(LST,IEN) ; Msg text for orderable item
175 N I
176 S I=0 F S I=$O(^ORD(101.43,IEN,8,I)) Q:I'>0 S LST(I)=^(I,0)
177 Q
178DISMSG(VAL,IEN) ; Disabled mge for ordering dlg
179 S VAL=$P($G(^ORD(101.41,+IEN,0)),U,3)
180 Q
181LOCK(OK,DFN) ; Attempt to lock pt for ordering
182 S OK=$$LOCK^ORX2(DFN)
183 Q
184UNLOCK(OK,DFN) ; Unlock pt for ordering
185 D UNLOCK^ORX2(DFN) S OK=1
186 Q
187LOCKORD(OK,ORIFN) ; Attempt to lock order
188 S OK=$$LOCK1^ORX2(ORIFN)
189 Q
190UNLKORD(OK,ORIFN) ; Unlock order
191 D UNLK1^ORX2(ORIFN) S OK=1
192 Q
Note: See TracBrowser for help on using the repository browser.