source: FOIAVistA/trunk/r/DSS_EXTRACTS-ECX/ECXLABR.m@ 1154

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

initial load of FOIAVistA 6/30/08 version

File size: 5.0 KB
Line 
1ECXLABR ;ALB/JAP,BIR/CML-LAR Extract for DSS (New Format - With LMIP Codes) ; 6/5/07 2:33pm
2 ;;3.0;DSS EXTRACTS;**8,24,33,37,39,46,71,80,107,105**;Dec 22, 1997;Build 70
3BEG ;entry point from option
4 D SETUP I ECFILE="" Q
5 D ^ECXTRAC,^ECXKILL
6 Q
7 ;
8START ; entry when queued
9 N X,OK,ECTRS,ECTRANS,ECTRIEN,ECDOC,ECDOCPC
10 K ^LAR(64.036) S LRSDT=ECSD,LREDT=ECED
11 D ^LRCAPDAR
12 ;quit if no completion date for API compile
13 I '$P($G(^LAR(64.036,1,2,1,0)),U,4) Q
14 ;build local array of workload codes for local lab tests linked to
15 ;DSS tests
16 K ECLOC S ECDTST=0
17 F S ECDTST=$O(^ECX(727.2,1,1,ECDTST)) Q:('ECDTST) S ECLTST=0 D
18 .F S ECLTST=$O(^ECX(727.2,1,1,ECDTST,"LOC",ECLTST)) Q:'ECLTST D
19 ..S ECLTIEN=+^ECX(727.2,1,1,ECDTST,"LOC",ECLTST,0)
20 ..S ECWCDA=+$G(^LAB(60,ECLTIEN,64))
21 ..I ECWCDA S ECWC=$P(^LAM(ECWCDA,0),U,2),ECLOC(ECWCDA)=ECWC
22 K ECLTIEN
23 ;process temporary lab file #64.036
24 S QFLG=0,ECLRN=1
25 F S ECLRN=$O(^LAR(64.036,ECLRN)) Q:('ECLRN)!(QFLG) D
26 .I $D(^LAR(64.036,ECLRN,0)) D
27 ..S EC1=^LAR(64.036,ECLRN,0),ECF=$P(EC1,U,2)
28 ..Q:ECF=""
29 ..S ECXDFN=$P(EC1,U,3),ECPTPR=$P($G(EC1),U,11),ECCLASS=""
30 ..S ECXTIME=$S($P(EC1,U,10)="":"000300",1:$P(EC1,U,10))
31 ..S ECXDATE=$P(EC1,U,9)_"."_$P(EC1,U,10)
32 ..I ECPTPR S ECCLASS=$$PRVCLASS^ECXUTL(ECPTPR,ECXDATE)
33 ..I ECPTPR S ECPTNPI=$$NPI^XUSNPI("Individual_ID",ECPTPR,+ECXDATE) D
34 ...S:+ECPTNPI'>0 ECPTNPI="" S ECPTNPI=$P(ECPTNPI,U)
35 ..S ECORDT=$$ECXDATE^ECXUTL($P(EC1,U,4),ECXYM)
36 ..S ECORTM=$$ECXTIME^ECXUTL($P(EC1,U,4)_"."_$P(EC1,U,5))
37 ..S ECREDT=$$ECXDATE^ECXUTL($P(EC1,U,6),ECXYM)
38 ..S ECRETM=$$ECXTIME^ECXUTL($P(EC1,U,6)_"."_$P(EC1,U,7))
39 ..S ECSCDT=$$ECXDATE^ECXUTL($P(EC1,U,9),ECXYM)
40 ..S ECSCTM=$$ECXTIME^ECXUTL($P(EC1,U,9)_"."_$P(EC1,U,10))
41 ..S (ECXADMDT,ECXDOM,ECXDSSD,ECXPNM,ECXSSN,ECXA,ECXMN,ECXTS)=""
42 ..I ECF=2 D Q:'OK
43 ...K ECXPAT S OK=$$PAT^ECXUTL3(ECXDFN,ECXDATE,"1;",.ECXPAT)
44 ...Q:'OK
45 ...S ECXPNM=ECXPAT("NAME"),ECXSSN=ECXPAT("SSN"),ECXMPI=ECXPAT("MPI")
46 ...S X=$$INP^ECXUTL2(ECXDFN,ECXDATE),ECXA=$P(X,U),ECXADMDT=$P(X,U,4)
47 ...S ECXMN=$P(X,U,2),ECXTS=$P(X,U,3),ECXDOM=$P(X,U,10)
48 ..;allow for referral patients in future??
49 ..;I ECF=67 S ECSN="000123456",ECNA="RFRL"
50 ..;loop on results multiple
51 ..;
52 ..;Get production division ECXDIEN added p-80
53 ..N ECXPDIV,ECXDIEN S ECXDIEN=$O(^DIC(4,"D",ECINST,"")),ECXPDIV=$$RADDIV^ECXDEPT(ECXDIEN) ;p-46
54 ..K ECXDIEN
55 ..;- Observation patient indicator (y/n)
56 ..S ECXOBS=$$OBSPAT^ECXUTL4(ECXA,ECXTS)
57 ..;
58 ..;- If no encounter number don't file record
59 ..S ECXENC=$$ENCNUM^ECXUTL4(ECXA,ECXSSN,ECXADMDT,$P(EC1,U,9),ECXTS,ECXOBS,ECHEAD,,) Q:ECXENC=""
60 ..S ECRES=0
61 ..F S ECRES=$O(^LAR(64.036,ECLRN,1,ECRES)) Q:('ECRES)!(QFLG) D
62 ...I $D(^LAR(64.036,ECLRN,1,ECRES,0)) D Q:QFLG
63 ....S EC2=^LAR(64.036,ECLRN,1,ECRES,0),ECN=$P(EC2,U),ECRS=$P(EC2,U,2)
64 ....S ECHL=$E($P(EC2,U,3)),ECWC=+$P(EC2,U,4)
65 ....S ECWC=$S($D(ECLOC(ECWC)):ECLOC(ECWC),1:"")
66 ....;
67 ....; - Free text results translation
68 ....S ECTRANS="",ECTRS=ECRS
69 ....I +ECTRS S ECTRS=$TR(ECTRS,",","") D
70 .....I (ECTRS?.N)!(ECTRS?.N1".".N) S ECRS=ECTRS
71 ....F Q:$E(ECTRS,1)'=" " S ECTRS=$E(ECTRS,2,$L(ECTRS))
72 ....F Q:$E(ECTRS,$L(ECTRS))'=" " S ECTRS=$E(ECTRS,1,($L(ECTRS)-1))
73 ....I ECTRS]"" I ECTRS'?.N I ECTRS'?.N1".".N D ;translate
74 .....S ECTRS=$TR(ECRS,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
75 .....S ECTRIEN="",ECTRIEN=$O(^ECX(727.7,"B",ECTRS,ECTRIEN))
76 .....S ECTRANS=$S(ECTRIEN:$P(^ECX(727.7,ECTRIEN,0),U,2),1:5)
77 ....;
78 ....I ECWC]"" D FILE
79 K ^LAR(64.036) S ^LAR(64.036,0)="LAB DSS LAR EXTRACT^64.036^"
80 Q
81 ;
82FILE ;file record
83 ;node0
84 ;facility (ECINST)^dfn (ECXDFN)^ssn (ECXSSN)^name(ECXPNM)^in/out (ECXA)^
85 ;day(ECSCDT)^
86 ;lab test code (ECN)^results (ECRS)^hi/lo indicator (ECHL)^
87 ;date ordered (ECORDT)^time ordered (ECORTM)^date ready (ECREDT)^
88 ;time ready (ECRETM)^
89 ;movement file # (ECXMN)^treating specialty (ECXTS)^
90 ;workload code(ECWC)^
91 ;node1
92 ;mpi (ECXMPI)^dss dept (ECXDSSD)^dom (ECXDOM)^time (ECSCTM)^
93 ;observ pat ind (ECXOBS)^encounter num (ECXENC)^prod div ECXPDIV^
94 ;lab results translation ECXTRANS^ordering provider (ECPTPR)^
95 ;ordering provider person class (ECCLASS)^ordering provider npi ECPTNPI
96 N DA,DIK
97 S EC7=$O(^ECX(ECFILE,999999999),-1),EC7=EC7+1
98 S ECODE=EC7_U_EC23_U_ECINST_U_ECXDFN_U_ECXSSN_U_ECXPNM_U_ECXA_U
99 S ECODE=ECODE_ECSCDT_U_$$RJ^XLFSTR(ECN,4,0)_U_ECRS_U_ECHL_U_ECORDT_U
100 S ECODE=ECODE_$$LJ^XLFSTR(ECORTM,6,0)_U
101 ;convert specialty to PTF Code for transmission
102 N ECXDATA
103 S ECXDATA=$$TSDATA^DGACT(42.4,+ECXTS,.ECXDATA)
104 S ECXTS=$G(ECXDATA(7))
105 ;done
106 S ECODE=ECODE_ECREDT_U_$$LJ^XLFSTR(ECRETM,6,0)_U_ECXMN_U_ECXTS_U_ECWC_U
107 S ECODE1=ECXMPI_U_ECXDSSD_U_ECXDOM_U_ECSCTM_U_ECXOBS_U_ECXENC_U_ECXPDIV_U_ECTRANS
108 I ECXLOGIC>2004 S ECODE1=ECODE1_U_2_ECPTPR_U_ECCLASS
109 I ECXLOGIC>2007 S ECODE1=ECODE1_U_ECPTNPI
110 S ^ECX(ECFILE,EC7,0)=ECODE,^ECX(ECFILE,EC7,1)=ECODE1,ECRN=ECRN+1
111 S DA=EC7,DIK="^ECX("_ECFILE_"," D IX1^DIK K DIK,DA
112 I $D(ZTQUEUED),$$S^%ZTLOAD S QFLG=1
113 Q
114 ;
115SETUP ;Set required input for ECXTRAC
116 S ECHEAD="LAR"
117 D ECXDEF^ECXUTL2(ECHEAD,.ECPACK,.ECGRP,.ECFILE,.ECRTN,.ECPIECE,.ECVER)
118 Q
119 ;
120QUE ; entry point for the background requeuing handled by ECXTAUTO
121 D SETUP,QUE^ECXTAUTO,^ECXKILL Q
Note: See TracBrowser for help on using the repository browser.