source: WorldVistAEHR/trunk/r/DSS_EXTRACTS-ECX/ECXNUT.m@ 1746

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

revised back to 6/30/08 version

File size: 5.5 KB
Line 
1ECXNUT ;ALB/JRC Nutrition DSS Extract ; 4/2/2007
2 ;;3.0;DSS EXTRACTS;**92,107**;Dec 22, 1997;Build 9
3BEG ;entry point from option
4 N EC23,EC7,ECED,ECFILE,ECGRP,ECHEAD,ECINST,ECPACK,ECPIECE,ECRN,ECRTN,ECSD1,ECVER,ECXYM
5 D SETUP I ECFILE="" Q
6 D ^ECXTRAC,^ECXKILL
7 Q
8 ;
9START ; start package specific extract
10 ;Init variables
11 N ECSD
12 S ECED=ECED+.3,ECSD=ECSD1
13 K ^TMP($J,"FH")
14 ;
15 ;Call n&fs api and store in ^TMP($J,"FH" global
16 D DATA^FHDSSAPI(ECSD,ECED)
17 ;
18 ;Get n&fs records from ^TMP($J,"FH" global and file
19 D GETMEALS^ECXNUT1
20 ;
21 ;kill ^tmp global
22 K ^TMP($J,"FH")
23 ;
24 Q
25 ;
26GET ;gather extract data
27 ;Init variables
28 N ECXORDPC,ECXSSN,ECXPNM,ECXSEX,ECXDOB,ECXMPI,ECXRC1,ECXETH,ECXVET,ECXENRL,ECXELIG,ECXMST,ECXPST,ECXPLOC,ECXPHI,ECXMNS,ECXSTATE,ECXCNTY,ECXZIP,ECXPOS,ECXAST,ECXAOL,ECXRST,ECXEST,ECXTM,ECXDATE,ECXMN,ECXSPC
29 N ECXADMDT,ECXWRD,ECXFAC,ECXPRV,ECXPRNPI,ECXATT,ECXATNPI,ECXDOM,ECXATTPC,ECXPRVPC,ECXPDIV,ECXCBOC,ECPTPR,ECCLASS,ECPTTM,ECXOBS,ECXHNCI,ECXNPRFI,ECXERI,ECXENC,ECPAT,ECXERR,ADM,W,X,ECXCAT,ECXCVE,ECXPRIOR,ECXPTYPE,ECXSTAT,ECXUESTA,ECXA
30 ;
31 ;- Prefix ordering pro with a 2 and get person class
32 S ECXORDPC=$$PRVCLASS^ECXUTL(+ECXORDPH,DATE)
33 S ECXORDPH=$S(ECXORDPH:2_ECXORDPH,1:"")
34 ;
35 ;set patient file (#2) dfn and get patient demographics
36 S ECXDFN=$P($G(^TMP($J,"FH","ZN",FHDFN)),U,3)
37 S ECXERR=0 D PAT(ECXDFN)
38 Q:ECXERR
39 ;Set demographic variables
40 S ECXSSN=ECPAT("SSN"),ECXPNM=ECPAT("NAME"),ECXSEX=ECPAT("SEX"),ECXDOB=ECPAT("DOB"),ECXMPI=ECPAT("MPI"),ECXRC1=ECPAT("RACE1"),ECXETH=ECPAT("ETHNIC"),ECXVET=ECPAT("VET"),ECXENRL=ECPAT("ENROLL LOC"),ECXELIG=ECPAT("ELIG")
41 S ECXMST=ECPAT("MST STAT"),ECXPST=ECPAT("POW STAT"),ECXPLOC=ECPAT("POW LOC"),ECXPHI=ECPAT("PHI"),ECXMNS=ECPAT("MEANS"),ECXSTATE=ECPAT("STATE"),ECXCNTY=ECPAT("COUNTY"),ECXZIP=ECPAT("ZIP")
42 S ECXPOS=ECPAT("POS"),ECXAST=ECPAT("AO STAT"),ECXAOL=ECPAT("AOL"),ECXRST=ECPAT("IR STAT"),ECXEST=ECPAT("EC STAT")
43 ;
44 ;Get enrollment status
45 I $$ENROLLM^ECXUTL2(ECXDFN)
46 ;
47 S ECXTM=$$ECXTIME^ECXUTL(DATE)
48 S ECXDATE=DATE
49 ;
50 ;- Use movement record date & time
51 S ADM=$$INP^ECXUTL2(ECXDFN,DATE),ECXA=$P(ADM,U)
52 S ECXMN=$P(ADM,U,2),ECXSPC=$P(ADM,U,3),ECXADMDT=$P(ADM,U,4)
53 S W=$P(ADM,U,9),ECXWRD=$P(W,";",1),ECXFAC=$P(W,";",2)
54 S ECXPRV=$P(ADM,U,7),ECXPRNPI="",ECXATT=$P(ADM,U,8),ECXATNPI=""
55 S ECXDOM=$P(ADM,U,10),ECXATTPC=$P(ADM,U,12),ECXPRVPC=$P(ADM,U,11)
56 ;
57 S ECXPDIV=$$GETDIV^ECXDEPT(ECXFAC) ;Get production division
58 S ECXCBOC=$$CBOC^ECXSCX2(+ECXFAC) ;Get cboc facility
59 ;
60 ;- Get primary care data
61 S X=$$PRIMARY^ECXUTL2(ECXDFN,DATE)
62 S ECPTPR=$P(X,U,2),ECCLASS=$P(X,U,3),ECPTTM=$P(X,U)
63 ;
64 ;- Observation patient indicator (YES/NO)
65 S ECXOBS=$$OBSPAT^ECXUTL4(ECXA,ECXSPC)
66 ;
67 ;- Get head and neck cancer indicator
68 S ECXHNCI=$$HNCI^ECXUTL4(ECXDFN)
69 ;
70 ;- Get national patient record flag indicator
71 N ECXNPRFI D NPRF^ECXUTL5
72 ;
73 ;- National response indicator
74 S ECXERI=$$EMGRES^DGUTL(ECXDFN)
75 ;
76 ;- If null encounter number, don't file record
77 S ECXENC=$$ENCNUM^ECXUTL4(ECXA,ECXSSN,ECXADMDT,DATE,ECXSPC,ECXOBS,ECHEAD,,)
78 D:ECXENC'="" FILE
79 Q
80 ;
81PAT(ECXDFN) ;get/set patient data
82 ; INPUT - ECXDFN = patient ien (DFN)
83 ; OUTPUT - ECPAT array:
84 ; ECPAT("SSN")
85 ; ECPAT("NAME")
86 ; returns 0 or 1 in ECXERR - 0=successful
87 ; 1=error condition
88 N X,OK
89 ;get data
90 S ECXERR=0
91 K ECXPAT S OK=$$PAT^ECXUTL3(ECXDFN,"","1;2;3;5",.ECPAT)
92 I 'OK S ECXERR=1
93 Q ECXERR
94 ;
95FILE ;file the n&fs extract record
96 ;node
97 ;facility^dfn^ssn^name^in/out^day^time^treating specialty^
98 ;ordering provider^ordering provider person class^primary
99 ;care provider^primary person class^primary care team^mpi^dob^sex^
100 ;race 1^ethnicity^veteran^enrollment status^enrollment location^
101 ;enrollment category^enrollment priority^eligibility^period of
102 ;service^agent orange status^agent orange location^radiation status
103 ;^environmental contaminants^mst status^head & neck cancer indicator
104 ;pow status^pow location^purple heart indicator^means test^state code
105 ;^county code^zip+4^observation patient indicator^rrtp,prrtp and
106 ;saartp indicator^encounter number^patient division^food production
107 ;division^delivery division^product feeder key^food production
108 ;facility^delivery location type^delivery feeder location^quantity^
109 ;cboc^status^user enrollee^patient type^cv status eligibility^
110 ;national^patient record flag^emergency response indicator^admission
111 ;date
112 ;
113 N DA,DIK,ECODE,ECODE1
114 S EC7=$O(^ECX(ECFILE,999999999),-1),EC7=EC7+1
115 S ECODE=EC7_U_EC23_U_ECINST_U_ECXDFN_U_ECXSSN_U_ECXPNM_U_ECXA_U
116 ;
117 ;convert specialty to PTF Code
118 ;
119 N ECXDATA
120 S ECXDATA=$$TSDATA^DGACT(42.4,+ECXSPC,.ECXDATA)
121 S ECXSPC=$G(ECXDATA(7))
122 ;
123 S ECODE=ECODE_$$ECXDATE^ECXUTL(DATE,ECXYM)_U_ECXTM_U_ECXSPC_U_ECXORDPH_U_ECXORDPC_U
124 S ECODE=ECODE_ECPTPR_U_ECCLASS_U_ECPTTM_U_ECXMPI_U_ECXDOB_U_ECXSEX_U
125 S ECODE=ECODE_ECXRC1_U_ECXETH_U_ECXVET_U_ECXSTAT_U_ECXENRL_U_ECXCAT_U
126 S ECODE=ECODE_ECXPRIOR_U_ECXELIG_U_ECXPOS_U_ECXAST_U_ECXAOL_U_ECXRST
127 S ECODE=ECODE_U_ECXEST_U_ECXMST_U_ECXHNCI_U_ECXPST_U_ECXPLOC_U_ECXPHI
128 S ECODE=ECODE_U_ECXMNS_U_ECXSTATE_U_ECXCNTY_U
129 S ECODE1=ECXZIP_U_ECXOBS_U_ECXDOM_U_ECXENC_U_ECXPDIV_U_ECXFPD_U
130 S ECODE1=ECODE1_ECXFDD_U_ECXKEY_U_ECXFPF_U_ECXDLT_U_ECXDFL_U_ECXQTY_U
131 S ECODE1=ECODE1_ECXCBOC_U_ECXUESTA_U_ECXPTYPE_U_ECXCVE_U_ECXNPRFI_U
132 S ECODE1=ECODE1_ECXERI_U_$S(ECXADMDT:$$ECXDATE^ECXUTL(ECXADMDT,ECXYM),1:"")
133 S ^ECX(ECFILE,EC7,0)=ECODE,^ECX(ECFILE,EC7,1)=ECODE1
134 S ECRN=ECRN+1
135 S DA=EC7,DIK="^ECX("_ECFILE_"," D IX1^DIK K DIK,DA
136 Q
137 ;
138SETUP ;Set required input for ECXTRAC.
139 S ECHEAD="NUT"
140 D ECXDEF^ECXUTL2(ECHEAD,.ECPACK,.ECGRP,.ECFILE,.ECRTN,.ECPIECE,.ECVER)
141 Q
Note: See TracBrowser for help on using the repository browser.