source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORKCHK.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: 6.4 KB
Line 
1ORKCHK ; slc/CLA - Main routine called by OE/RR to initiate order checks ; 1/16/07 6:28am
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**6,32,94,105,123,232,267**;Dec 17, 1997;Build 6
3EN(ORKY,ORKDFN,ORKA,ORKMODE) ;initiate order checking
4 ;ORKY: array of returned msgs in format: ornum^orderchk ien^clin danger^msg
5 ;ORKDFN: patient dfn
6 ;ORKA: array of order information in the format:
7 ; orderable item ien|
8 ; display group-filler app|
9 ; nat'l id^nat'l text^nat'l code sys^local id^local text^local code sys|
10 ; effective d/t|
11 ; order number|
12 ; filler data (LR: specimen ien, PS: meds prev ordered during this session in format med1^med2^...)
13 ;ORKMODE: mode/event trigger (DISPLAY,SELECT,ACCEPT,SESSION,ALL,NOTIF)
14 ; PS: meds previously ordered during this session med1^med2^...
15 ;
16 N ORKQ,ORKN S ORKQ=0,ORKN=1
17 S:+$G(ORKDFN)<1 ORKY(ORKN)="^^^Order Checking Unavailable - invalid patient id",ORKQ=1,ORKN=ORKN+1
18 S:'$L($G(ORKMODE)) ORKY(ORKN)="^^^Order Checking Unavailable - invalid mode/event",ORKQ=1,ORKN=ORKN+1
19 Q:$G(ORKQ)=1
20 Q:+$G(ORKA)<1
21 N ORKX,ORKS,DNGR,ORENT,ORKENT,ORKNENT,ORNUM,ORKOFF,ORKTMODE
22 N ORKADUZ,ORKNDUZ,ORKI,ORKPRIM,ORKNMSG,ORKMSG,ORKLOG,ORKLD,ORKLI,ORKOI
23 N ORKDG,ORKLPS,ORKPSA,ORKCNT,ORKDGI
24 ;
25 ;save array of orders for use in session processing:
26 M ^TMP("ORKA",$J)=ORKA
27 ;
28 ;get patient's location flag (INPATIENT ONLY - outpt locations cannot be
29 ;reliably determined, and many simultaneous outpt locations can occur):
30 N DFN,ORKLOC
31 S DFN=ORKDFN,VA200="" D OERR^VADPT
32 S ORKLOC=+$G(^DIC(42,+VAIN(4),44))
33 K VA200,VAIN
34 ;
35 ;get user's service/section flag:
36 N ORKSRV
37 S ORKSRV=$$GET1^DIQ(200,DUZ,29,"I") I +ORKSRV>0 S ORKSRV=$P(ORKSRV,U)
38 ;
39 ;log order check debug messages (or not)
40 S ORKLOG=$$GET^XPAR("DIV^SYS^PKG","ORK DEBUG ENABLE/DISABLE",1,"I")
41 I $G(ORKLOG)="D" K ^XTMP("ORKLOG") S ^XTMP("ORKLOG",0)=""
42 I +$P($G(^XTMP("ORKLOG",0)),U,3)>5000 K ^XTMP("ORKLOG")
43 ;
44 ;if SESSION mode & pharmacy order occurred in session get unsigned med orders
45 I ORKMODE="SESSION" D
46 .S ORKDG=$P(ORKA(1),"|",2)
47 .I $E($G(ORKDG),1,2)="PS" D
48 ..S ORKDGI=0,ORKDGI=$O(^ORD(100.98,"B","PHARMACY",ORKDGI))
49 ..K ^TMP("ORR",$J)
50 ..D EN^ORQ1(DFN_";DPT(",ORKDGI,11,"","","",0,0)
51 ..;store unsigned med orders in ^TMP("ORR",$J for processing in ORKPS
52 ;
53 ;main processing loop:
54 S ORKX="" F S ORKX=$O(ORKA(ORKX)) Q:ORKX="" D
55 .S ORKOI=$P(ORKA(ORKX),"|")
56 .;
57 .;log debug msgs if parameter is enabled:
58 .I $G(ORKLOG)="E" D
59 ..S ORKLD=$$NOW^XLFDT
60 ..S ORKLI=0
61 ..I +$P($G(^XTMP("ORKLOG",0)),U,3)<1 S $P(^XTMP("ORKLOG",0),U,3)=0
62 ..S ORKCNT=$P(^XTMP("ORKLOG",0),U,3)+1
63 ..S ^XTMP("ORKLOG",0)=$$FMADD^XLFDT(ORKLD,3,"","","")_U_ORKLD_U_ORKCNT
64 ..S ^XTMP("ORKLOG",ORKLD,ORKDFN,+$G(ORKOI),ORKMODE,DUZ,ORKLI)=ORKA(ORKX)
65 .;
66 .S ORKDG=$P(ORKA(ORKX),"|",2),ORKTMODE=""
67 .S ORKENT="USR^LOC.`"_+$G(ORKLOC)_"^SRV.`"_+$G(ORKSRV)_"^DIV^SYS^PKG"
68 .Q:'$L($G(ORKDG))
69 .;
70 .;if pharmacy order and multiple pharmacy orders in session add data node:
71 .I $E(ORKDG,1,2)="PS",($L($G(ORKPSA))) D
72 ..S $P(ORKA(ORKX),"|",6)=ORKPSA
73 .;
74 .S ORNUM=$P(ORKA(ORKX),"|",5)
75 .; get correct DUZ for notification processing if in NOTIF mode:
76 .I ORKMODE="NOTIF" D
77 ..S:+$G(ORNUM)>0 ORKNDUZ=$$ORDERER^ORQOR2(ORNUM) ;ordering provider
78 ..S:+$G(ORNUM)<1 ORKNDUZ=$P($$PRIM^ORQPTQ4(ORKDFN),U) ;prim provider
79 ..I +$G(ORKNDUZ)>0 D
80 ...S ORKSRV=$$GET1^DIQ(200,ORKNDUZ,29,"I") I +ORKSRV>0 S ORKSRV=$P(ORKSRV,U)
81 ...S ORKNENT="USR.`"_+ORKNDUZ_"^LOC.`"_+$G(ORKLOC)_"^SRV.`"_+$G(ORKSRV)_"^DIV^SYS^PKG"
82 ..S:+$G(ORKNDUZ)<1 ORKNENT="LOC.`"_+$G(ORKLOC)_"^DIV^SYS^PKG"
83 .S ORENT=$S(ORKMODE="NOTIF":ORKNENT,1:ORKENT)
84 .;
85 .;If the order is a delayed release order (NOTIF) process all nodes.
86 .;If it is a renewal, edit or delayed signature order (ALL) process all
87 .;modes except SESSION which gets processed just before signature:
88 .I ORKMODE="NOTIF"!(ORKMODE="ALL") S ORKTMODE=ORKMODE D
89 ..D EN^ORKCHK3(.ORKS,ORKDFN,ORKA(ORKX),ORENT,ORKTMODE) ;DISPLAY
90 ..D EN^ORKCHK4(.ORKS,ORKDFN,ORKA(ORKX),ORENT,ORKTMODE) ;SELECT
91 ..D EN^ORKCHK5(.ORKS,ORKDFN,ORKA(ORKX),ORENT,ORKTMODE) ;ACCEPT
92 ..I ORKMODE="NOTIF" D EN^ORKCHK6(.ORKS,ORKDFN,ORKA(ORKX),ORENT,ORKTMODE) ;SESSION
93 ..S ORKMODE=ORKTMODE
94 .;
95 .;Process regular orders/modes:
96 .I '$L($G(ORKTMODE)) D
97 ..I ORKMODE="DISPLAY" D EN^ORKCHK3(.ORKS,ORKDFN,ORKA(ORKX),ORENT,ORKTMODE)
98 ..I ORKMODE="SELECT" D EN^ORKCHK4(.ORKS,ORKDFN,ORKA(ORKX),ORENT,ORKTMODE)
99 ..I ORKMODE="ACCEPT" D EN^ORKCHK5(.ORKS,ORKDFN,ORKA(ORKX),ORENT,ORKTMODE)
100 ..I ORKMODE="SESSION" D EN^ORKCHK6(.ORKS,ORKDFN,ORKA(ORKX),ORENT,ORKTMODE)
101 ;
102 ;set messages into sorting array then into ORKY ORKS("ORK",clinical danger level,oi,msg)=ornum^order check ien^clin danger level^message
103 S ORKX="",ORKI=1
104 F S ORKX=$O(ORKS("ORK",ORKX)) Q:ORKX="" D
105 .S ORKY(ORKI)=$E(ORKS("ORK",ORKX),1,250)
106 .;
107 .;log debug msgs if parameter is enabled:
108 .I $G(ORKLOG)="E" D
109 ..S ORKLI=$G(ORKLI)+1
110 ..S ^XTMP("ORKLOG",$$NOW^XLFDT,ORKDFN,+$G(ORKOI),ORKMODE,DUZ,ORKLI)=ORKY(ORKI)
111 ..S $P(^XTMP("ORKLOG",0),U,3)=$P($G(^XTMP("ORKLOG",0)),U,3)+1
112 .;
113 .;send moderate and high danger order checks for delayed orders as notifications:
114 .I ORKMODE="NOTIF" S DNGR=$P(ORKY(ORKI),U,3) I $G(DNGR)<3 D
115 ..S ORKADUZ="",ORNUM=$P(ORKY(ORKI),U)
116 ..S:+$G(ORKNDUZ)>0 ORKADUZ(ORKNDUZ)=""
117 ..S ORKNMSG="Order check: "_$P(ORKY(ORKI),U,4)
118 ..D EN^ORB3(54,ORKDFN,$G(ORNUM),.ORKADUZ,ORKNMSG,"")
119 .S ORKI=ORKI+1
120 ;
121 K ^TMP("ORKA",$J),^TMP("ORR",$J)
122 I $G(ORKLOG)="E" D
123 .S ORKLI=$G(ORKLI)+1
124 .S ^XTMP("ORKLOG",$$NOW^XLFDT,ORKDFN,+$G(ORKOI),ORKMODE,DUZ,ORKLI)="LEAVING ORDER CHECKING"
125 .S $P(^XTMP("ORKLOG",0),U,3)=$P($G(^XTMP("ORKLOG",0)),U,3)+1
126 D CHKRMT
127 Q
128 ;
129OI2DD(ORPSA,OROI,ORPSPKG) ;rtn dispense drugs for a PS OI
130 N PSOI
131 Q:'$D(^ORD(101.43,OROI,0))
132 S PSOI=$P($P(^ORD(101.43,OROI,0),U,2),";")
133 Q:+$G(PSOI)<1
134 D DRG^PSSUTIL1(.ORPSA,PSOI,ORPSPKG)
135 Q
136CHKRMT ;
137 N I,ORQFLAG
138 S ORQFLAG=1
139 S I=0 F S I=$O(ORKA(I)) Q:'I I $E($P(ORKA(I),"|",2),1,2)="PS"!($E($P(ORKA(I),"|",2),1,2)="RA") S ORQFLAG=0
140 Q:$G(ORQFLAG)
141 Q:'$$HAVEHDR^ORRDI1
142 Q:$$LDPTTVAL^ORRDI2($G(DFN))
143 Q:$P($G(^XTMP("ORRDI","PSOO",ORKDFN,0)),U,3)'<0&($P($G(^XTMP("ORRDI","ART",ORKDFN,0)),U,3)'<0)
144 I $G(ORKMODE)="ACCEPT" D
145 . N IFN
146 . S IFN=$O(ORKY(""),-1)+1
147 . S ORKY(IFN)="^99^2^Order check performed on local data only"
148 . K ^TMP($J,"ORRDI") S ^TMP($J,"ORRDI",ORKDFN)=1
149 I $G(ORKMODE)="SESSION" D
150 . N I,IFN,ORARR
151 . S IFN=$O(ORKY(""),-1)
152 . S I=0 F S I=$O(ORKY(I)) Q:'I S ORARR(+ORKY(I))=""
153 . S I=0 F S I=$O(ORARR(I)) Q:'I S IFN=IFN+1,ORKY(IFN)=I_"^99^2^Order check performed on local data only."
154 . K ^TMP($J,"ORRDI") S ^TMP($J,"ORRDI",ORKDFN)=1
155 Q
Note: See TracBrowser for help on using the repository browser.