source: FOIAVistA/trunk/r/DSS_EXTRACTS-ECX/ECXNUT.m@ 1608

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

initial load of FOIAVistA 6/30/08 version

File size: 5.9 KB
Line 
1ECXNUT ;ALB/JRC Nutrition DSS Extract ; 9/24/07 9:33am
2 ;;3.0;DSS EXTRACTS;**92,107,105**;Dec 22, 1997;Build 70
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,ARRAY
12 S ECED=ECED+.3,ECSD=ECSD1,ARRAY="^TMP($J,""FH"")"
13 K @ARRAY
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 @ARRAY
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,ECORNPI
30 N ECXOEF,ECXOEFDT
31 ;
32 ;- Prefix ordering pro with a 2 and get person class
33 S ECXORDPC=$$PRVCLASS^ECXUTL(+ECXORDPH,DATE)
34 S ECORNPI=$$NPI^XUSNPI("Individual_ID",+ECXORDPH,DATE)
35 S:+ECORNPI'>0 ECORNPI="" S ECORNPI=$P(ECORNPI,U)
36 S ECXORDPH=$S(ECXORDPH:2_ECXORDPH,1:"")
37 ;
38 ;set patient file (#2) dfn and get patient demographics
39 S ECXDFN=$P($G(^TMP($J,"FH","ZN",FHDFN)),U,3)
40 S ECXERR=0 D PAT(ECXDFN)
41 Q:ECXERR
42 ;Set demographic variables
43 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")
44 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")
45 S ECXPOS=ECPAT("POS"),ECXAST=ECPAT("AO STAT"),ECXAOL=ECPAT("AOL"),ECXRST=ECPAT("IR STAT"),ECXEST=ECPAT("EC STAT")
46 ;
47 ;Get oef/oif data
48 S ECXOEF=ECPAT("ECXOEF")
49 S ECXOEFDT=ECPAT("ECXOEFDT")
50 ;
51 ;Get enrollment status
52 I $$ENROLLM^ECXUTL2(ECXDFN)
53 ;
54 S ECXTM=$$ECXTIME^ECXUTL(DATE)
55 S ECXDATE=$$ECXDATE^ECXUTL(+DATE,ECXYM)
56 ;
57 ;- Use movement record date & time
58 S ADM=$$INP^ECXUTL2(ECXDFN,DATE),ECXA=$P(ADM,U)
59 S ECXMN=$P(ADM,U,2),ECXSPC=$P(ADM,U,3),ECXADMDT=$P(ADM,U,4)
60 S W=$P(ADM,U,9),ECXWRD=$P(W,";",1),ECXFAC=$P(W,";",2)
61 S ECXPRV=$P(ADM,U,7),ECXPRNPI="",ECXATT=$P(ADM,U,8),ECXATNPI=""
62 S ECXDOM=$P(ADM,U,10),ECXATTPC=$P(ADM,U,12),ECXPRVPC=$P(ADM,U,11)
63 ;
64 S ECXPDIV=$$GETDIV^ECXDEPT(ECXFAC) ;Get production division
65 S ECXCBOC=$$CBOC^ECXSCX2(+ECXFAC) ;Get cboc facility
66 ;
67 ;- Get primary care data
68 S X=$$PRIMARY^ECXUTL2(ECXDFN,DATE)
69 S ECPTPR=$P(X,U,2),ECCLASS=$P(X,U,3),ECPTTM=$P(X,U),ECPTNPI=$P(X,U,4)
70 ;
71 ;- Observation patient indicator (YES/NO)
72 S ECXOBS=$$OBSPAT^ECXUTL4(ECXA,ECXSPC)
73 ;
74 ;- Get head and neck cancer indicator
75 S ECXHNCI=$$HNCI^ECXUTL4(ECXDFN)
76 ;
77 ;- Get national patient record flag indicator
78 N ECXNPRFI D NPRF^ECXUTL5
79 ;
80 ;- National response indicator
81 S ECXERI=$$EMGRES^DGUTL(ECXDFN)
82 ;
83 ;- If null encounter number, don't file record
84 S ECXENC=$$ENCNUM^ECXUTL4(ECXA,ECXSSN,ECXADMDT,DATE,ECXSPC,ECXOBS,ECHEAD,,)
85 D:ECXENC'="" FILE
86 Q
87 ;
88PAT(ECXDFN) ;get/set patient data
89 ; INPUT - ECXDFN = patient ien (DFN)
90 ; OUTPUT - ECPAT array:
91 ; ECPAT("SSN")
92 ; ECPAT("NAME")
93 ; returns 0 or 1 in ECXERR - 0=successful
94 ; 1=error condition
95 N X,OK
96 ;get data
97 S ECXERR=0
98 K ECXPAT S OK=$$PAT^ECXUTL3(ECXDFN,"","1;2;3;5",.ECPAT)
99 I 'OK S ECXERR=1
100 Q ECXERR
101 ;
102FILE ;file the n&fs extract record
103 ;node
104 ;facility^dfn^ssn^name^in/out^day^time^treating specialty^
105 ;ordering provider^ordering provider person class^primary
106 ;care provider^primary person class^primary care team^mpi^dob^sex^
107 ;race 1^ethnicity^veteran^enrollment status^enrollment location^
108 ;enrollment category^enrollment priority^eligibility^period of
109 ;service^agent orange status^agent orange location^radiation status
110 ;^environmental contaminants^mst status^head & neck cancer indicator
111 ;pow status^pow location^purple heart indicator^means test^state code
112 ;^county code^zip+4^observation patient indicator^rrtp,prrtp and
113 ;saartp indicator^encounter number^patient division^food production
114 ;division^delivery division^product feeder key^food production
115 ;facility^delivery location type^delivery feeder location^quantity^
116 ;cboc^status^user enrollee^patient type^cv status eligibility^
117 ;national patient record flag^emergency response indicator^admission
118 ;date^oef/oif ECXOEF^oef/oif return date ECXOEFDT^ordering provider
119 ;npi ECORNPI^primary care provider npi ECPTNPI
120 ;
121 N DA,DIK,ECODE,ECODE1
122 S EC7=$O(^ECX(ECFILE,999999999),-1),EC7=EC7+1
123 S ECODE=EC7_U_EC23_U_ECINST_U_ECXDFN_U_ECXSSN_U_ECXPNM_U_ECXA_U
124 ;
125 ;convert specialty to PTF Code
126 ;
127 N ECXDATA
128 S ECXDATA=$$TSDATA^DGACT(42.4,+ECXSPC,.ECXDATA)
129 S ECXSPC=$G(ECXDATA(7))
130 ;
131 S ECODE=ECODE_ECXDATE_U_ECXTM_U_ECXSPC_U_ECXORDPH_U_ECXORDPC_U
132 S ECODE=ECODE_ECPTPR_U_ECCLASS_U_ECPTTM_U_ECXMPI_U_ECXDOB_U_ECXSEX_U
133 S ECODE=ECODE_ECXRC1_U_ECXETH_U_ECXVET_U_ECXSTAT_U_ECXENRL_U_ECXCAT_U
134 S ECODE=ECODE_ECXPRIOR_U_ECXELIG_U_ECXPOS_U_ECXAST_U_ECXAOL_U_ECXRST
135 S ECODE=ECODE_U_ECXEST_U_ECXMST_U_ECXHNCI_U_ECXPST_U_ECXPLOC_U_ECXPHI
136 S ECODE=ECODE_U_ECXMNS_U_ECXSTATE_U_ECXCNTY_U
137 S ECODE1=ECXZIP_U_ECXOBS_U_ECXDOM_U_ECXENC_U_ECXPDIV_U_ECXFPD_U
138 S ECODE1=ECODE1_ECXFDD_U_ECXKEY_U_ECXFPF_U_ECXDLT_U_ECXDFL_U_ECXQTY_U
139 S ECODE1=ECODE1_ECXCBOC_U_ECXUESTA_U_ECXPTYPE_U_ECXCVE_U_ECXNPRFI_U
140 S ECODE1=ECODE1_ECXERI_U_$S(ECXADMDT:$$ECXDATE^ECXUTL(ECXADMDT,ECXYM),1:"")
141 I ECXLOGIC>2007 S ECODE1=ECODE1_U_ECXOEF_U_ECXOEFDT_U_$G(ECXTFU)_U_ECORNPI_U_ECPTNPI
142 S ^ECX(ECFILE,EC7,0)=ECODE,^ECX(ECFILE,EC7,1)=ECODE1
143 S ECRN=ECRN+1
144 S DA=EC7,DIK="^ECX("_ECFILE_"," D IX1^DIK K DIK,DA
145 Q
146 ;
147SETUP ;Set required input for ECXTRAC.
148 S ECHEAD="NUT"
149 D ECXDEF^ECXUTL2(ECHEAD,.ECPACK,.ECGRP,.ECFILE,.ECRTN,.ECPIECE,.ECVER)
150 Q
Note: See TracBrowser for help on using the repository browser.