source: WorldVistAEHR/trunk/r/DSS_EXTRACTS-ECX/ECXLABN.m@ 724

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

revised back to 6/30/08 version

File size: 5.9 KB
RevLine 
[623]1ECXLABN ;ALB/JAP,BIR/CML-Lab Extract for DSS (New Format - With LMIP Codes) ; 4/25/07 8:52am
2 ;;3.0;DSS EXTRACTS;**1,11,8,13,28,24,30,31,32,33,39,42,46,70,71,80,92,107**;Dec 22, 1997;Build 9
3BEG ;entry point
4 D SETUP I ECFILE="" Q
5 D ^ECXTRAC,^ECXKILL
6 Q
7 ;
8START ; entry when queued
9 K ^LRO(64.03),^TMP($J,"ECXP")
10 N ECDOCPC
11 S LRSDT=ECSD,LREDT=ECED,QFLG=0
12 D ^LRCAPDSS
13 ;quit if no completion date for API compile
14 I '$P($G(^LRO(64.03,1,1,1,0)),U,4) Q
15 ;quit if tasked and user sends stop request
16 I $D(ZTQUEUED),$$S^%ZTLOAD D Q
17 .S QFLG=1
18 .K ^LRO(64.03) S ^LRO(64.03,0)="WKLD LOG FILE^64.03^"
19 ;otherwise, continue
20 K ECXDD D FIELD^DID(64.03,1,,"SPECIFIER","ECXDD")
21 S ECPROF=$E(+$P(ECXDD("SPECIFIER"),"P",2)),ECLRN=1 K ECXDD
22 F S ECLRN=$O(^LRO(64.03,ECLRN)) Q:'ECLRN D Q:QFLG
23 .Q:'$D(^LRO(64.03,ECLRN,0))
24 .S EC1=^LRO(64.03,ECLRN,0),ECDOC=ECPROF_$P(EC1,U,2),ECDOCNPI=""
25 .S ECLOC=$P(EC1,U,15),EC=$P(EC1,U,3),ECDOCPC=$$PRVCLASS^ECXUTL($P(EC1,U,2),$P(EC1,U,4))
26 .I EC]"" D GET
27 K ^LRO(64.03),^TMP($J,"ECXP") S ^LRO(64.03,0)="WKLD LOG FILE^64.03^"
28 K ECDOCNPI,ECXAGC,ECXL1,ECXL2
29 Q
30 ;
31GET ;get data
32 N X,ECXSTN
33 S ECF=$S($P(EC,";",2)="DPT(":2,$P(EC,";",2)="LRT(67,":67,1:0) Q:'ECF
34 S ECIFN=$P(EC,";")
35 ;resolve ecloc
36 S ECXL1=+$P(ECLOC,";",1),ECXL2=$P(ECLOC,";",2)
37 I ECF=2 S ECLOC=$S(ECXL1>0:ECXL1,1:"") I ECXL2]"",ECXL2'="SC(" S ECLOC=""
38 I ECF=67 D S ECLOC=ECXSTN
39 .S (ECXSTN,ECXAGC)=""
40 .I (ECXL2'="DIC(4,")!('$D(^DIC(4,ECXL1))) S ECXSTN="XXXXX",ECXAGC="XX" Q
41 .S ECXSTN=$P(^DIC(4,ECXL1,"99"),U,1),ECXAGC=$E($P(^(99),U,5),1,2)
42 .S:ECXSTN="" ECXSTN="ZZZZZ" S:ECXAGC="" ECXAGC="ZZ"
43 S ECDT=$P(EC1,U,13),ECD=$P(ECDT,"."),ECTM=$$ECXTIME^ECXUTL(ECDT)
44 S ECWKLD=$P(EC1,U,11),ECWK="" I $D(^LAM(ECWKLD,0)) S ECWK=$P(^(0),U,2)
45 S (ECXADMDT,ECTREAT,ECNA,ECSN,ECMN,ECPTTM,ECPTPR,ECCLAS)="",ECA="O",ECXERR=0
46 S (ECPTNPI,ECASPR,ECCLAS2,ECASNPI)=""
47 ;get the patient data if record is in file #2
48 I ECF=2 D PAT(ECIFN,ECDT,.ECXERR)
49 Q:ECXERR
50 ;get patient data if record is in file #67
51 I ECF=67 S ECSN="000123456",ECNA="RFRL" I $D(^LRT(67,ECIFN,0)) D
52 .S ECXMPI="",EC0=^LRT(67,ECIFN,0),ECNA=$E($P($P(EC0,U),",")_" ",1,4)
53 .S ECSN=$P(EC0,U,9),ECXERI="" D
54 ..S ECNA=$TR(ECNA,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
55 ..I ECSN="" S ECSN="000123456" Q
56 ..S ECSN=$TR(ECSN," "),ECSN=$TR(ECSN,"-")
57 ..I ($L(ECSN)<9)!($L(ECSN)>10) S ECSN="000123456" Q
58 ..I $L(ECSN)=9,ECSN'?9N S ECSN="000123456" Q
59 ..I $L(ECSN)=10,ECSN'?9N1"P" S ECSN="000123456"
60 ;
61 ;- Only set treating spec (TS) to TS in file #64.03 if it does not exist
62 I ECA="I",ECTREAT="" S ECTREAT=$P($G(^DIC(45.7,+$P(EC1,U,10),0)),U,2)
63 S (ECXDOM,ECXDSSD)=""
64 S X=$G(^ECX(727.831,+ECTREAT,0)) S:X'="" ECXDOM=$P(X,U,2)
65 ;
66 ;- Get ordering stop code and ordering date
67 S ECXORDST=+$P(EC1,U,15),ECXORDST=$S(ECXORDST:$P($G(^ECX(728.44,ECXORDST,0)),U,2),1:"")
68 S ECXORDDT=$S($P(EC1,U,14):$$ECXDATE^ECXUTL($P(EC1,U,14),ECXYM),1:"")
69 ;
70 ;- Get Production Division - ECXDIEN added p-80
71 N ECXPDIV,ECXDIEN S ECXDIEN=$O(^DIC(4,"D",ECINST,"")),ECXPDIV=$$RADDIV^ECXDEPT(ECXDIEN) ;P-46
72 K ECXDIEN
73 ;
74 ;- Observation patient indicator (YES/NO)
75 S ECXOBS=$$OBSPAT^ECXUTL4(ECA,ECTREAT)
76 ;
77 ;- If no encounter number don't file record
78 S ECXENC=$$ENCNUM^ECXUTL4(ECA,ECSN,ECXADMDT,ECD,ECTREAT,ECXOBS,ECHEAD,,) Q:ECXENC=""
79 ;create extract record only if patient name and accession area exist
80 I ECNA]"" S ECT=$P(EC1,U,8),ECURG=$P(EC1,U,9),EC=+$P(EC1,U,7) I EC D
81 .S:ECF=2 ECACA=EC_U_$P($G(^LRO(68,EC,0)),U,11)
82 .S:ECF=67 ECACA=ECXAGC_U_$P($G(^LRO(68,EC,0)),U,11)
83 .D FILE
84 Q
85 ;
86PAT(ECXDFN,ECXDATE,ECXERR) ;get/set patient data
87 N X,OK,PT
88 ;get data
89 I $D(^TMP($J,"ECXP",ECXDFN)) D
90 .S PT=^TMP($J,"ECXP",ECXDFN),ECNA=$P(PT,U)
91 .S ECSN=$P(PT,U,2),ECXMPI=$P(PT,U,3),ECXERI=$P(PT,U,4)
92 ;set data and save for later
93 I '$D(^TMP($J,"ECXP",ECXDFN)) D Q:'OK
94 .K ECXPAT S OK=$$PAT^ECXUTL3(ECXDFN,$P(ECSD,"."),"1;3",.ECXPAT)
95 .I 'OK S ECXERR=1 Q
96 .S ECNA=ECXPAT("NAME"),ECSN=ECXPAT("SSN"),ECXMPI=ECXPAT("MPI")
97 .S ECXERI=ECXPAT("ERI")
98 .S ^TMP($J,"ECXP",ECXDFN)=ECNA_U_ECSN_U_ECXMPI_U_ECXERI
99 ;get date specific data
100 S X=$$INP^ECXUTL2(ECXDFN,ECXDATE),ECA=$P(X,U),ECMN=$P(X,U,2),ECTREAT=$P(X,U,3),ECXADMDT=$P(X,U,4)
101 S X=$$PRIMARY^ECXUTL2(ECXDFN,$P(ECXDATE,"."),ECPROF)
102 S ECPTTM=$P(X,U,1),ECPTPR=$P(X,U,2),ECCLAS=$P(X,U,3),ECPTNPI=$P(X,U,4)
103 S ECASPR=$P(X,U,5),ECCLAS2=$P(X,U,6),ECASNPI=$P(X,U,7)
104 Q
105 ;
106FILE ;file record
107 ;node0
108 ;facility^patient number^SSN (or equivalent)^name^in/out ECA^
109 ;day^accession area^abbreviation^test^urgency^treating spec^
110 ;location^provider and file^
111 ;movement number^file^time^workload code^primary care team^
112 ;primary care provider
113 ;node1
114 ;mpi^dss dept^provider npi^pc provider npi^pc prov person class^
115 ;assoc pc prov^assoc pc prov person class^assoc pc prov npi^
116 ;dom ECXDOM^observ pat ind ECXOBS^encounter num ECXENC^
117 ;ord stop code ECXORDST^ord date ECXORDDT^production division
118 ;ECXPDIV^^ordering provider person class^emergency response indicator
119 ;(FEMA) ECXERI
120 ;ECDOCPC
121 N DA,DIK
122 S EC7=$O(^ECX(ECFILE,999999999),-1),EC7=EC7+1
123 S ECODE=EC7_U_EC23_U_ECINST_U_ECIFN_U_ECSN_U_ECNA_U_ECA_U
124 S ECODE=ECODE_$$ECXDATE^ECXUTL(ECD,ECXYM)_U_ECACA_U_ECT_U_ECURG_U
125 ;convert specialty to PTF Code for transmission
126 N ECXDATA
127 S ECXDATA=$$TSDATA^DGACT(42.4,+ECTREAT,.ECXDATA)
128 S ECTREAT=$G(ECXDATA(7))
129 ;done
130 S ECODE=ECODE_ECTREAT_U_ECLOC_U_ECDOC_U_ECMN_U_ECF_U_ECTM_U_ECWK_U
131 S ECODE=ECODE_ECPTTM_U_ECPTPR_U
132 ;(ECACA=acc area^abbreviation)
133 S ECODE1=ECXMPI_U_ECXDSSD_U_ECDOCNPI_U_ECPTNPI_U_ECCLAS_U_ECASPR_U
134 S ECODE1=ECODE1_ECCLAS2_U_ECASNPI_U_ECXDOM_U_ECXOBS_U_ECXENC_U
135 S ECODE1=ECODE1_ECXORDST_U_ECXORDDT_U_ECXPDIV_U
136 I ECXLOGIC>2004 S ECODE1=ECODE1_U_ECDOCPC
137 I ECXLOGIC>2006 S ECODE1=ECODE1_U_ECXERI
138 S ^ECX(ECFILE,EC7,0)=ECODE,^ECX(ECFILE,EC7,1)=ECODE1,ECRN=ECRN+1
139 S DA=EC7,DIK="^ECX("_ECFILE_"," D IX1^DIK K DIK,DA
140 I $D(ZTQUEUED),$$S^%ZTLOAD S QFLG=1
141 Q
142 ;
143SETUP ;Set required input for ECXTRAC
144 S ECHEAD="LAB"
145 D ECXDEF^ECXUTL2(ECHEAD,.ECPACK,.ECGRP,.ECFILE,.ECRTN,.ECPIECE,.ECVER)
146 Q
147 ;
148QUE ; entry point for the background requeuing handled by ECXTAUTO
149 D SETUP,QUE^ECXTAUTO,^ECXKILL Q
Note: See TracBrowser for help on using the repository browser.