source: WorldVistAEHR/trunk/r/DSS_EXTRACTS-ECX/ECXLABR.m@ 846

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

revised back to 6/30/08 version

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