source: WorldVistAEHR/trunk/r/DSS_EXTRACTS-ECX/ECXUD.m@ 1801

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

revised back to 6/30/08 version

File size: 7.8 KB
Line 
1ECXUD ;ALB/JAP,BIR/DMA,PTD-Extract from UNIT DOSE EXTRACT DATA File (#728.904) ;4/19/2007
2 ;;3.0;DSS EXTRACTS;**10,8,24,33,39,46,49,71,84,92,107**;Dec 22, 1997;Build 9
3BEG ;entry point from option
4 I '$O(^ECX(728.904,"A",0)) W !,"There are no unit dose orders to extract",!! R X:5 K X Q
5 D SETUP I ECFILE="" Q
6 D ^ECXTRAC,^ECXKILL
7 Q
8 ;
9START ;start package specific extract
10 S QFLG=0
11 S ECED=ECED+.3
12 F ECD=ECSD1:0 S ECD=$O(^ECX(728.904,"A",ECD)) Q:'ECD Q:ECD>ECED Q:QFLG D
13 .S ECXJ=0 F S ECXJ=$O(^ECX(728.904,"A",ECD,ECXJ)) Q:'ECXJ Q:QFLG I $D(^ECX(728.904,ECXJ,0)) D
14 ..S DATA=^ECX(728.904,ECXJ,0),^(1)=$P(EC23,U,2),^ECX(728.904,"AC",$P(EC23,U,2),ECXJ)="" D STUFF
15 K ^TMP($J,"ECXP")
16 Q
17 ;
18STUFF ;get data
19 N X,W,OK,P1,P3,PSTAT,PT,ECXPHA,ON,ECDRG
20 S ECXDFN=$P(DATA,U,2),ECDRG=$P(DATA,U,4)
21 ;
22 ;get patient specific data
23 S ECXERR="" D PAT(ECXDFN,ECD,.ECXERR)
24 Q:ECXERR
25 ;
26 S ECXPRO=$P(DATA,U,7),ECXPRO=$E($P(ECXPRO,";",2))_$P(ECXPRO,";")
27 S ECXPRNPI="",W=$P(DATA,U,6)
28 S ECXDIV=$P($G(^DIC(42,+W,0)),U,11),ECXW=$P($G(^DIC(42,+W,44)),U)
29 S ECXUDDT=$$ECXDATE^ECXUTL($P(DATA,U,3),ECXYM)
30 S ECXUDTM=$E($P($P(DATA,U,3),".",2)_"000000",1,6)
31 S ECXQTY=$P(DATA,U,5),ECXCOST=$P(DATA,U,8),ON=$P(DATA,U,10)
32 ;call pharmacy drug file (#50) api via ecxutl5
33 S ECXPHA=$$PHAAPI^ECXUTL5(ECDRG)
34 S ECCAT=$P(ECXPHA,U,2),ECINV=$P(ECXPHA,U,4)
35 S ECINV=$S(ECINV["I":"I",1:"")
36 S ECNDC=$P(ECXPHA,U,3)
37 S ECNFC=$$RJ^XLFSTR($P(ECNDC,"-"),6,0)_$$RJ^XLFSTR($P(ECNDC,"-",2),4,0)_$$RJ^XLFSTR($P(ECNDC,"-",3),2,0),ECNFC=$TR(ECNFC,"*",0)
38 S P1=$P(ECXPHA,U,5),P3=$P(ECXPHA,U,6),X="PSNAPIS"
39 X ^%ZOSF("TEST") I $T S ECNFC=$$DSS^PSNAPIS(P1,P3,ECXYM)_ECNFC
40 I $L(ECNFC)=12 S ECNFC=$$RJ^XLFSTR(P1,4,0)_$$RJ^XLFSTR(P3,3,0)_ECNFC
41 ; - Department and National Production Division
42 ;- Use of DSS Department postponed [S ECXDSSD=$$UDP^ECXDEPT(ECXDIV)]
43 S ECXDSSD=""
44 S ECXPDIV=$$GETDIV^ECXDEPT(ECXDIV)
45 ;- Observation patient indicator (YES/NO)
46 S ECXOBS=$$OBSPAT^ECXUTL4(ECXA,ECXTS)
47 ;- Ordering Date, Ordering Stop Code
48 S ECXORDDT=$TR($$FMTE^XLFDT($P(DATA,U,9),"7DF")," /","0")
49 S ECXORDST="" I ECXA="O" D
50 .;Get ordering stop code based on FY 2006 logic for outpatient
51 .S ECXORDST=$$DOUDO^ECXUTL5(ECXDFN,ON)
52 ;Ordering Provider Person Class
53 S ECXOPPC=$$PRVCLASS^ECXUTL($E(ECXPRO,2,999),$P(DATA,U,9))
54 ;BCMA data (place holder)
55 S (ECXBCDD,ECXBCDG,ECXBCUA,ECXBCIF)=""
56 ;- Set national patient record flag if exist
57 D NPRF^ECXUTL5
58 ;- If no encounter number don't file record
59 S ECXENC=$$ENCNUM^ECXUTL4(ECXA,ECXSSN,ECXADM,$P(DATA,U,3),ECXTS,ECXOBS,ECHEAD,,)
60 D:ECXENC'="" FILE
61 Q
62 ;
63PAT(ECXDFN,ECXDATE,ECXERR) ;get demographics from patient file
64 ;init variables
65 S (ECXCAT,ECXSTAT,ECXPRIOR,ECXSBGRP)=""
66 ;get patient data if saved
67 I $D(^TMP($J,"ECXP",ECXDFN)) D
68 .S PT=^TMP($J,"ECXP",ECXDFN),ECXPNM=$P(PT,U),ECXSSN=$P(PT,U,2)
69 .S ECXMPI=$P(PT,U,3),ECXDOB=$P(PT,U,4)
70 .S ECXELIG=$P(PT,U,5),ECXSEX=$P(PT,U,6)
71 .S ECXSTATE=$P(PT,U,7),ECXCNTY=$P(PT,U,8),ECXZIP=$P(PT,U,9)
72 .S ECXVET=$P(PT,U,10),ECXPOS=$P(PT,U,11),ECXPST=$P(PT,U,12)
73 .S ECXPLOC=$P(PT,U,13),ECXRST=$P(PT,U,14),ECXAST=$P(PT,U,15)
74 .S ECXAOL=$P(PT,U,16),ECXPHI=$P(PT,U,17),ECXMST=$P(PT,U,18)
75 .S ECXENRL=$P(PT,U,19),ECXCNHU=$P(PT,U,20),ECXCAT=$P(PT,U,21)
76 .S ECXSTAT=$P(PT,U,22),ECXPRIOR=$P(PT,U,23),ECXHNCI=$P(PT,U,24)
77 .S ECXETH=$P(PT,U,25),ECXRC1=$P(PT,U,26),ECXMTST=$P(PT,U,27)
78 .S PT1=$G(^TMP($J,"ECXP",ECXDFN,1)),ECXERI=$P(PT1,U),ECXEST=$P(PT1,U,2)
79 .I $$ENROLLM^ECXUTL2(ECXDFN)
80 ;set patient data
81 I '$D(^TMP($J,"ECXP",ECXDFN)) D Q:'OK
82 .K ECXPAT S OK=$$PAT^ECXUTL3(ECXDFN,$P(ECXDATE,"."),"1;2;3;5",.ECXPAT)
83 .I 'OK K ECXPAT S ECXERR=1 Q
84 .S ECXPNM=ECXPAT("NAME"),ECXSSN=ECXPAT("SSN"),ECXMPI=ECXPAT("MPI")
85 .S ECXDOB=ECXPAT("DOB"),ECXELIG=ECXPAT("ELIG"),ECXSEX=ECXPAT("SEX")
86 .S ECXSTATE=ECXPAT("STATE"),ECXCNTY=ECXPAT("COUNTY")
87 .S ECXZIP=ECXPAT("ZIP"),ECXVET=ECXPAT("VET")
88 .S ECXPOS=ECXPAT("POS"),ECXPST=ECXPAT("POW STAT")
89 .S ECXPLOC=ECXPAT("POW LOC"),ECXRST=ECXPAT("IR STAT")
90 .S ECXAST=ECXPAT("AO STAT"),ECXAOL=ECXPAT("AOL")
91 .S ECXPHI=ECXPAT("PHI"),ECXMST=ECXPAT("MST STAT")
92 .S ECXENRL=ECXPAT("ENROLL LOC"),ECXMTST=ECXPAT("MEANS")
93 .;get CNHU status
94 .S ECXCNHU=$$CNHSTAT^ECXUTL4(ECXDFN)
95 .;get enrollment data (category, status and priority)
96 .I $$ENROLLM^ECXUTL2(ECXDFN)
97 .; - Head and Neck Cancer Indicator
98 .S ECXHNCI=$$HNCI^ECXUTL4(ECXDFN)
99 .; - Race and Ethnicity
100 .S ECXETH=ECXPAT("ETHNIC")
101 .S ECXRC1=ECXPAT("RACE1")
102 .;get emergency response indicator (FEMA)
103 .S ECXERI=ECXPAT("ERI")
104 .S ECXEST=ECXPAT("EC STAT")
105 .;save for later
106 .S ^TMP($J,"ECXP",ECXDFN)=ECXPNM_U_ECXSSN_U_ECXMPI_U_ECXDOB_U_ECXELIG_U_ECXSEX_U_ECXSTATE_U_ECXCNTY_U_ECXZIP_U_ECXVET_U_ECXPOS_U_ECXPST_U_ECXPLOC_U_ECXRST_U_ECXAST
107 .S ^TMP($J,"ECXP",ECXDFN)=^TMP($J,"ECXP",ECXDFN)_U_ECXAOL_U_ECXPHI_U_ECXMST_U_ECXENRL_U_ECXCNHU_U_ECXCAT_U_ECXSTAT_U_ECXPRIOR_U_ECXHNCI_U_ECXETH_U_ECXRC1_U_ECXMTST
108 .S ^TMP($J,"ECXP",ECXDFN,1)=ECXERI_U_ECXEST
109 ;
110 ;get inpatient data
111 S X=$$INP^ECXUTL2(ECXDFN,ECXDATE),ECXA=$P(X,U),ECXMN=$P(X,U,2)
112 S ECXTS=$P(X,U,3),ECXADM=$P(X,U,4),ECXDOM=$P(X,U,10)
113 ;
114 ;get primary care data
115 S X=$$PRIMARY^ECXUTL2(ECXDFN,$P(ECXDATE,"."))
116 S ECPTTM=$P(X,U),ECPTPR=$P(X,U,2),ECCLAS=$P(X,U,3),ECPTNPI=$P(X,U,4)
117 S ECASPR=$P(X,U,5),ECCLAS2=$P(X,U,6),ECASNPI=$P(X,U,7)
118 Q
119 ;
120FILE ;file record
121 ;node0
122 ;facility^dfn^ssn^name^in/out^day^drug category^quantity^ward^
123 ;provider^cost^mov #^treat spec^ndc^new feeder key^investigational^
124 ;udp time^adm date^adm time
125 ;node1
126 ;mpi^dss dept^provider npi^dom^observ pat ind^encounter num^
127 ;prod div code^means tst^elig^dob^sex^state^county^zip+4^vet^
128 ;period of svc^pow stat^pow loc^ir status^ao status^ao loc^
129 ;purple heart ind.^mst status^cnh/sh status^enrollment loc^
130 ;enrollment cat^enrollment status^enrollment priority^pc team^
131 ;pc provider^pc provider npi^pc provider p.class^assoc. pc provider^
132 ;assoc. pc provider npi^assoc. pc provider p.class
133 ;node2
134 ;ordering date^ordering stop code^head & neck cancer ind.^ethnicity^
135 ;race1^bcma drug dispensed^bcma dose given^bcma unit of
136 ;administration^bcma icu flag^ordering provider person class^
137 ;^enrollment priority ECXPRIOR_enrollment subgroup
138 ;ECXSBGRP^user enrollee ECXUESTA^patient type ECXPTYPE^combat vet
139 ;elig ECXCVE^combat vet elig end date ECXCVEDT^enc cv eligible
140 ;ECXCVENC^national patient record flag ECXNPRFI^emerg resp indic(FEMA)
141 ;ECXERI^environ contamin ECXEST
142 N DA,DIK
143 S EC7=$O(^ECX(ECFILE,999999999),-1),EC7=EC7+1
144 S ECODE=EC7_U_EC23_U_ECXDIV_U_ECXDFN_U_ECXSSN_U_ECXPNM_U_ECXA_U
145 S ECODE=ECODE_ECXUDDT_U_ECCAT_U_ECXQTY_U_ECXW_U_ECXPRO_U_ECXCOST_U
146 S ECODE=ECODE_ECXMN_U_ECXTS_U_ECNDC_U_ECNFC_U_ECINV_U_ECXUDTM_U
147 ;convert specialty to PTF Code for transmission
148 N ECXDATA
149 S ECXDATA=$$TSDATA^DGACT(42.4,+ECXTS,.ECXDATA)
150 S ECXTS=$G(ECXDATA(7))
151 ;done
152 S ECODE=ECODE_$$ECXDATE^ECXUTL(ECXADM,ECXYM)_U
153 S ECODE=ECODE_$$ECXTIME^ECXUTL(ECXADM)_U
154 S ECODE1=ECXMPI_U_ECXDSSD_U_ECXPRNPI_U_ECXDOM_U_ECXOBS_U_ECXENC_U
155 S ECODE1=ECODE1_ECXPDIV_U_ECXMTST_U_ECXELIG_U_ECXDOB_U_ECXSEX_U
156 S ECODE1=ECODE1_ECXSTATE_U_ECXCNTY_U_ECXZIP_U_ECXVET_U_ECXPOS_U
157 S ECODE1=ECODE1_ECXPST_U_ECXPLOC_U_ECXRST_U_ECXAST_U
158 S ECODE1=ECODE1_ECXAOL_U_ECXPHI_U_ECXMST_U_ECXCNHU_U_ECXENRL_U
159 S ECODE1=ECODE1_ECXCAT_U_ECXSTAT_U_$S(ECXLOGIC<2005:ECXPRIOR,1:"")_U_ECPTTM_U_ECPTPR_U
160 S ECODE1=ECODE1_ECPTNPI_U_ECCLAS_U_ECASPR_U_ECASNPI_U_ECCLAS2_U
161 S ECODE2=ECXORDDT_U_ECXORDST_U_ECXHNCI_U_ECXETH_U_ECXRC1
162 I ECXLOGIC>2003 S ECODE2=ECODE2_U_ECXBCDD_U_ECXBCDG_U_ECXBCUA_U_ECXBCIF_U_ECXOPPC
163 I ECXLOGIC>2004 S ECODE2=ECODE2_U_U_ECXPRIOR_ECXSBGRP_U_ECXUESTA_U_ECXPTYPE_U_ECXCVE_U_ECXCVEDT_U_ECXCVENC_U_ECXNPRFI
164 I ECXLOGIC>2006 S ECODE2=ECODE2_U_ECXERI_U_ECXEST
165 S ^ECX(ECFILE,EC7,0)=ECODE,^ECX(ECFILE,EC7,1)=ECODE1
166 S ^ECX(ECFILE,EC7,2)=ECODE2,ECRN=ECRN+1
167 S DA=EC7,DIK="^ECX("_ECFILE_"," D IX1^DIK K DIK,DA
168 I $D(ZTQUEUED),$$S^%ZTLOAD S QFLG=1
169 Q
170 ;
171SETUP ;Set required input for ECXTRAC
172 S ECHEAD="UDP"
173 D ECXDEF^ECXUTL2(ECHEAD,.ECPACK,.ECGRP,.ECFILE,.ECRTN,.ECPIECE,.ECVER)
174 Q
175 ;
176QUE ; entry point for the background requeuing handled by ECXTAUTO
177 D SETUP,QUE^ECXTAUTO,^ECXKILL
178 Q
Note: See TracBrowser for help on using the repository browser.