[613] | 1 | ECXMTL ;ALB/JAP - DSS Mental Health Extract ; 8/17/07 9:52am
|
---|
| 2 | ;;3.0;DSS EXTRACTS;**24,30,33,39,46,49,71,82,84,92,105**;Dec 22, 1997;Build 70
|
---|
| 3 | ;
|
---|
| 4 | BEG ;entry point from option
|
---|
| 5 | D SETUP I ECFILE="" Q
|
---|
| 6 | D ^ECXTRAC,^ECXKILL
|
---|
| 7 | Q
|
---|
| 8 | ;
|
---|
| 9 | START ;entry point from tasked job
|
---|
| 10 | S QFLG=0
|
---|
| 11 | ;get first record #
|
---|
| 12 | S EC7=$O(^ECX(ECFILE,999999999),-1)
|
---|
| 13 | ;call mh/dss api for extract record creation
|
---|
| 14 | ;variables ecfile,ecxym,ecinst,ecsd,eced passed in by taskmanager
|
---|
| 15 | S ECXSEQ=EC7,ECXECX=$P(EC23,U,2),ECXERR=0
|
---|
| 16 | ;call mh api to create extract records
|
---|
| 17 | S X="YSDSS" X ^%ZOSF("TEST") I '$T S QFLG=1 Q
|
---|
| 18 | D UPD^YSDSS(ECFILE,.ECXSEQ,ECXYM,ECXECX,ECINST,ECSD,ECED,.ECXERR)
|
---|
| 19 | Q:ECXERR
|
---|
| 20 | Q:QFLG
|
---|
| 21 | ;if no error, continue
|
---|
| 22 | D UPDATE
|
---|
| 23 | Q
|
---|
| 24 | ;
|
---|
| 25 | UPDATE ;add non-mh data to each record created by mh api
|
---|
| 26 | N ECXADT,JJ,ECXNPRFI
|
---|
| 27 | S EC7=EC7+1
|
---|
| 28 | F JJ=EC7:1:ECXSEQ Q:QFLG D
|
---|
| 29 | .Q:'$D(^ECX(ECFILE,JJ,0))
|
---|
| 30 | .S ECXDFN=$P(^ECX(ECFILE,JJ,0),U,5),ECXDATE=$P(^ECX(ECFILE,JJ,0),U,9),ECXPRV=$P(^ECX(ECFILE,JJ,0),U,18)
|
---|
| 31 | .S ECXSCNUM=$P(^ECX(ECFILE,JJ,0),U,23),ECXSCNAM=$P(^ECX(ECFILE,JJ,0),U,24)
|
---|
| 32 | .D PAT(ECXDFN,ECXDATE)
|
---|
| 33 | .S (ECXPRCLS,ECPRNPI,ECXDIV,ECXPDIV)="" I ECXPRV D PROV(.ECXPRV,ECXDATE)
|
---|
| 34 | .S ECXDSSI=""
|
---|
| 35 | .I ECXLOGIC>2003 D
|
---|
| 36 | ..I "^18^23^24^36^41^65^94^"[("^"_ECXTS_"^") S ECXDSSI=$$TSMAP^ECXUTL4(ECXTS)
|
---|
| 37 | .;
|
---|
| 38 | .;- Observation patient indicator (YES/NO)
|
---|
| 39 | .S ECXOBS=$$OBSPAT^ECXUTL4(ECXA,ECXTS,ECXDSSI)
|
---|
| 40 | .;
|
---|
| 41 | .;- set national patient record flag if exist
|
---|
| 42 | .D NPRF^ECXUTL5
|
---|
| 43 | .;
|
---|
| 44 | .;- If no encounter number don't file record
|
---|
| 45 | .S ECXENC=$$ENCNUM^ECXUTL4(ECXA,ECXSSN,ECXADT,ECXDATE,ECXTS,ECXOBS,ECHEAD,,) Q:ECXENC=""
|
---|
| 46 | .S ECD=ECXDATE,ECXDATE=$$ECXDATE^ECXUTL(ECXDATE,ECXYM)
|
---|
| 47 | .;adjust scale name & scale number
|
---|
| 48 | .S ECXSCNAM=$E(ECXSCNAM,1,10)
|
---|
| 49 | .I ECXSCNUM]"",ECXSCNUM'=+ECXSCNUM S ECXSCNUM=+$E(ECXSCNUM,2,99)
|
---|
| 50 | .N ECXDEPT S ECXDEPT="" ;dss department use postponed S ECXDEPT=$$MTL^ECXDEPT(ECXDIV,ECXSCNAM,ECINST) ;p-46 line added
|
---|
| 51 | .;Set division to external value if extract is for FY05 or higher
|
---|
| 52 | .D FILE
|
---|
| 53 | Q
|
---|
| 54 | ;
|
---|
| 55 | PAT(ECXDFN,ECXDATE) ;determine in/outpatient status, demographics, primary care
|
---|
| 56 | N OK
|
---|
| 57 | S (ECXADT,ECXPNM,ECXSSN,ECXMPI)=""
|
---|
| 58 | K ECXPAT S OK=$$PAT^ECXUTL3(ECXDFN,ECXDATE,"1;3;5;",.ECXPAT)
|
---|
| 59 | S ECXPNM=ECXPAT("NAME"),ECXSSN=ECXPAT("SSN"),ECXMPI=ECXPAT("MPI")
|
---|
| 60 | S ECXDOB=ECXPAT("DOB")
|
---|
| 61 | ;agent orange status
|
---|
| 62 | S ECXAST=ECXPAT("AO STAT")
|
---|
| 63 | ;- Purple Heart Indicator, Period of Service, Agent Orange Location
|
---|
| 64 | S ECXPHI=$G(ECXPAT("PHI")),ECXPOS=ECXPAT("POS"),ECXAOL=ECXPAT("AOL")
|
---|
| 65 | I $$ENROLLM^ECXUTL2(ECXDFN)
|
---|
| 66 | ;Combat Veteran Status
|
---|
| 67 | S X3=$$CVEDT^ECXUTL5(ECXDFN,$S($G(ECD):ECD,$G(ECXDATE):ECXDATE,1:DT))
|
---|
| 68 | ; - Head and Neck Cancer Indicator
|
---|
| 69 | S ECXHNCI=$$HNCI^ECXUTL4(ECXDFN)
|
---|
| 70 | ; - Race and Ethnicity
|
---|
| 71 | S ECXETH=ECXPAT("ETHNIC")
|
---|
| 72 | S ECXRC1=ECXPAT("RACE1")
|
---|
| 73 | ;get primary care data
|
---|
| 74 | S X=$$PRIMARY^ECXUTL2(ECXDFN,ECXDATE),ECPTTM=$P(X,U)
|
---|
| 75 | S ECPTPR=$P(X,U,2),ECCLAS=$P(X,U,3),ECPTNPI=$P(X,U,4)
|
---|
| 76 | S ECASPR=$P(X,U,5),ECCLAS2=$P(X,U,6),ECASNPI=$P(X,U,7)
|
---|
| 77 | ;get inpatient data
|
---|
| 78 | S X=$$INP^ECXUTL2(ECXDFN,ECXDATE),ECXDOM=$P(X,U,10),ECXTS=$P(X,U,3)
|
---|
| 79 | S ECXA=$P(X,U),(ECXADT,ECXADMDT)=$P($P(X,U,4),"."),ECXDCDT=$P($P(X,U,6),".")
|
---|
| 80 | S ECXWPRV=$P(X,U,7),ECXATT=$P(X,U,8)
|
---|
| 81 | S ECWPRNPI=$$NPI^XUSNPI("Individual_ID",ECXWPRV,ECXDATE)
|
---|
| 82 | S:+ECWPRNPI'>0 ECWPRNPI="" S ECWPRNPI=$P(ECWPRNPI,U)
|
---|
| 83 | S ECATTNPI=$$NPI^XUSNPI("Individual_ID",ECXATT,ECXDATE)
|
---|
| 84 | S:+ECATTNPI'>0 ECATTNPI="" S ECATTNPI=$P(ECATTNPI,U)
|
---|
| 85 | ;Get ward provider and attending phy person classes
|
---|
| 86 | S ECXWPRPC=$P(X,U,11),ECXATTPC=$P(X,U,12)
|
---|
| 87 | I ECXADMDT S ECXADMDT=$$ECXDATE^ECXUTL(ECXADMDT,ECXYM)
|
---|
| 88 | I ECXDCDT S ECXDCDT=$$ECXDATE^ECXUTL(ECXDCDT,ECXYM)
|
---|
| 89 | Q
|
---|
| 90 | ;
|
---|
| 91 | PROV(ECXPRV,ECXDATE) ;get provider data
|
---|
| 92 | N INST,DGIEN,ARR,DIC,DR,DA,DIQ
|
---|
| 93 | S ECXPRCLS=$$PRVCLASS^ECXUTL(ECXPRV,ECXDATE)
|
---|
| 94 | S ECPRNPI=$$NPI^XUSNPI("Individual_ID",ECXPRV,ECXDATE)
|
---|
| 95 | S:+ECPRNPI'>0 ECPRNPI="" S ECPRNPI=$P(ECPRNPI,U)
|
---|
| 96 | ;get division identifier using provider
|
---|
| 97 | S (ECXDIV,ECXPDIV)=""
|
---|
| 98 | S IEN=0 F D Q:'IEN Q:'INST Q:ECXDIV
|
---|
| 99 | .;get pointer to file #4 from provider record
|
---|
| 100 | .I '$D(^VA(200,ECXPRV,0)) Q
|
---|
| 101 | .S IEN=$O(^VA(200,ECXPRV,2,IEN))
|
---|
| 102 | .Q:'IEN
|
---|
| 103 | .S DIC="^VA(200,",DR="16",DA=ECXPRV
|
---|
| 104 | .S DR(200.02)=".01",DA(200.02)=IEN,DIQ="ARR",DIQ(0)="I"
|
---|
| 105 | .D EN^DIQ1
|
---|
| 106 | .S INST=$G(ARR(200.02,IEN,.01,"I"))
|
---|
| 107 | .Q:'INST
|
---|
| 108 | .;get production division
|
---|
| 109 | .S ECXPDIV=$$RADDIV^ECXDEPT(INST) ;p-46 line added
|
---|
| 110 | .;get medical center division
|
---|
| 111 | .S DGIEN=$O(^DG(40.8,"AD",INST,0)) I DGIEN D
|
---|
| 112 | ..S ECXDIV=$P($G(^ECX(727.3,DGIEN,0)),U,2)
|
---|
| 113 | S ECXPRV="2"_ECXPRV
|
---|
| 114 | Q
|
---|
| 115 | ;
|
---|
| 116 | FILE ;file record in #727.812
|
---|
| 117 | ;node0
|
---|
| 118 | ;facility^dfn^ssn ECXSSN^name ECXPNM^i/o status ECXA^
|
---|
| 119 | ;day ECXDATE^division ECXDIV^admit date ECXADMDT^
|
---|
| 120 | ;d/c date ECXDCDT^dss id ECXDSSI^pc team ECPTTM^pc provider ECPTPR^
|
---|
| 121 | ;placeholder^pc prov person class ECCLAS^
|
---|
| 122 | ;provider ECXPRV^placeholder^prov person class ECXPRCLS^
|
---|
| 123 | ;test name ECXSCNAM(?)^test ien ECXSCNUM(?)^scale number^scale name^
|
---|
| 124 | ;test score^scale score^attend phys^ward provider
|
---|
| 125 | ;node1
|
---|
| 126 | ;mpi^assoc pc provider^placeholder^
|
---|
| 127 | ;assoc pc prov person class^asi class^asi special^asi encounter date^
|
---|
| 128 | ;purple heart ind.^dom prrtp & saartp ind.^enrollment cat^
|
---|
| 129 | ;enrollment stat^enrollment prior^period of serv.^obs. pat ind.^
|
---|
| 130 | ;encounter num^agent orange loc^dob^production division^dss
|
---|
| 131 | ;department ECXDEPT^head & neck canc. indi.^ethnicity^race1^^
|
---|
| 132 | ;enrollment prior ECXPRIOR_enrollment subgroup
|
---|
| 133 | ;ECXSBGRP^enrollee user ECXUESTA^division ECXDIV^patient type
|
---|
| 134 | ;ECXPTYPE^combat vet elig ECXCVE^combat vet elig end date ECXCVEDT^
|
---|
| 135 | ;enc cv eligible ECXCVENC^national patient record flag ECXNPRFI
|
---|
| 136 | ;attending phy person class ECXATTPC^ward provider person class
|
---|
| 137 | ;ECXWPRPC^^agent orange status ECXAST^asso prov npi ECASNPI^att phy
|
---|
| 138 | ;npi ECATTNPI^primary care prov npi ECPTNPI^provider npi ECPRNPI^ward
|
---|
| 139 | ;provider npi ECWPRNPI
|
---|
| 140 | N DA,DIK,STR
|
---|
| 141 | I $P(^ECX(ECFILE,JJ,0),U,21)="ASI" S $P(^ECX(ECFILE,JJ,1),U,7)=ECXDATE
|
---|
| 142 | S $P(^ECX(ECFILE,JJ,0),U,6,9)=ECXSSN_U_ECXPNM_U_ECXA_U_ECXDATE
|
---|
| 143 | S STR=$S(ECXLOGIC<2005:ECXDIV,1:"")_U_ECXADMDT_U_ECXDCDT_U_ECXDSSI_U_ECPTTM_U_ECPTPR_U
|
---|
| 144 | S STR=STR_U_ECCLAS,$P(^ECX(ECFILE,JJ,0),U,10,17)=STR,STR=""
|
---|
| 145 | S $P(^ECX(ECFILE,JJ,0),U,18,20)=ECXPRV_U_U_ECXPRCLS
|
---|
| 146 | S $P(^ECX(ECFILE,JJ,0),U,23,24)=ECXSCNUM_U_ECXSCNAM
|
---|
| 147 | S $P(^ECX(ECFILE,JJ,0),U,27,29)=ECXATT_U_ECXWPRV_U
|
---|
| 148 | I '$D(^ECX(ECFILE,JJ,1)) S ^ECX(727.812,JJ,1)="^^^^^"
|
---|
| 149 | S $P(^ECX(ECFILE,JJ,1),U,1,4)=ECXMPI_U_ECASPR_U_U_ECCLAS2
|
---|
| 150 | S STR=ECXPHI_U_ECXDOM_U_ECXCAT_U_ECXSTAT_U_$S(ECXLOGIC<2005:ECXPRIOR,1:"")_U_ECXPOS_U
|
---|
| 151 | S STR=STR_ECXOBS_U_ECXENC_U_ECXAOL_U_ECXDOB_U_ECXPDIV_U_ECXDEPT_U
|
---|
| 152 | S STR=STR_ECXHNCI_U_ECXETH_U_ECXRC1_U
|
---|
| 153 | I ECXLOGIC>2004 S STR=STR_U_ECXPRIOR_ECXSBGRP_U_ECXUESTA_U_ECXDIV_U_ECXPTYPE_U_ECXCVE_U_ECXCVEDT_U_ECXCVENC_U_ECXNPRFI
|
---|
| 154 | I ECXLOGIC>2005 S STR=STR_U_ECXATTPC_U_ECXWPRPC
|
---|
| 155 | S $P(^ECX(ECFILE,JJ,1),U,8,22)=STR
|
---|
| 156 | I ECXLOGIC>2006 S $P(^ECX(ECFILE,JJ,1),U,34)=ECXAST_U
|
---|
| 157 | I ECXLOGIC>2007 S $P(^ECX(ECFILE,JJ,1),U,35)=ECASNPI_U_ECATTNPI_U_ECPTNPI_U D
|
---|
| 158 | . S ^ECX(ECFILE,JJ,2)=ECPRNPI_U_ECWPRNPI
|
---|
| 159 | S DA=JJ,DIK="^ECX("_ECFILE_"," D IX1^DIK K DIK,DA
|
---|
| 160 | S ECRN=ECRN+1
|
---|
| 161 | I $D(ZTQUEUED),$$S^%ZTLOAD S QFLG=1
|
---|
| 162 | Q
|
---|
| 163 | ;
|
---|
| 164 | SETUP ;Set required input for ECXTRAC
|
---|
| 165 | S ECHEAD="MTL"
|
---|
| 166 | D ECXDEF^ECXUTL2(ECHEAD,.ECPACK,.ECGRP,.ECFILE,.ECRTN,.ECPIECE,.ECVER)
|
---|
| 167 | Q
|
---|
| 168 | ;
|
---|
| 169 | QUE ;Entry point for the background requeuing handled by ECXTAUTO.
|
---|
| 170 | D SETUP,QUE^ECXTAUTO,^ECXKILL
|
---|
| 171 | Q
|
---|