VistA-WorldVistAEHR/r/DSS_EXTRACTS-ECX/ECXPAI.m

54 lines
2.2 KiB
Mathematica
Raw Permalink Normal View History

2009-11-29 13:37:14 -05:00
ECXPAI ;ALB/JAP,BIR/DMA,PTD-PAI Extract from File 45.9 ; 10/30/96 14:25
;;3.0;DSS EXTRACTS;**8,20,24,33**;Dec 22, 1997
BEG ;entry point from option
D SETUP I ECFILE="" Q
D ^ECXTRAC,^ECXKILL
Q
;
START ; start package specific extract
N OK
S QFLG=0
S ECED=ECED+.3,ECD=ECSD1
F S ECD=$O(^DG(45.9,"AA",ECD)),ECF=0 Q:'ECD Q:ECD>ECED Q:QFLG F S ECF=$O(^DG(45.9,"AA",ECD,ECF)) Q:'ECF I $D(^DG(45.9,ECF,0)) S EC=^(0),ECXDFN=+EC,ECTD=$P(EC,U,7) D Q:QFLG
.K ECXPAT S OK=$$PAT^ECXUTL3(ECXDFN,$P(ECD,"."),"1;",.ECXPAT)
.Q:'OK
.S X=$$INP^ECXUTL2(ECXDFN,$P(ECD,"."))
.S ECXA=$P(X,U),ECXDOM=$P(X,U,10),ECXPNM=ECXPAT("NAME")
.S ECXSSN=ECXPAT("SSN"),ECXMPI=ECXPAT("MPI"),ECXRACE=ECXPAT("RACE")
.S ECXDSSD="",ECDA=0
.F S ECDA=+$O(^DGPM("APCA",ECXDFN,ECDA)),ECTD1=ECTD-.0001 Q:'ECDA I $D(^DGPM(ECDA,0)) F S ECTD1=+$O(^DGPM("APCA",ECXDFN,ECDA,ECTD1)) Q:'ECTD1 Q:ECTD1>(ECTD+.3) D Q:QFLG
..S EC1=0 F S EC1=+$O(^DGPM("APCA",ECXDFN,ECDA,ECTD1,EC1)) Q:'EC1 I $D(^DGPM(EC1,0)),$P(^(0),U,2)'=3 S ECADM=$P(^DGPM(ECDA,0),U) D Q:QFLG
...D FILE
Q
;
FILE ;file record
;^dfn^ssn^name^i/o (ECXA)^day^admission date^admission time^
;admission/transfer date^admission/transfer time^race
;node1
;mpi^dss dept^dom^extended out patient
N DA,DIK
S EC7=$O(^ECX(ECFILE,999999999),-1)
S ECODEZ="" I EC7>0 S ECODEZ=^ECX(ECFILE,EC7,0)
S ECODE=U_U_ECXDFN_U_ECXSSN_U_ECXPNM_U_3_U
S ECODE=ECODE_$$ECXDATE^ECXUTL(ECD,ECXYM)_U
S ECODE=ECODE_$$ECXDATE^ECXUTL(ECADM,ECXYM)_U
S ECODE=ECODE_$$ECXTIME^ECXUTL(ECADM)_U_$$ECXDATE^ECXUTL(ECTD1,ECXYM)_U
S ECODE=ECODE_$$ECXTIME^ECXUTL(ECTD1)_U_ECXRACE_U
S ECODE1=ECXMPI_U_ECXDSSD_U_ECXDOM_U_$G(ECXEOP)
Q:$P(ECODE,U,4,14)=$P(ECODEZ,U,4,14)
I $P(ECODE,U,3,7)=$P(ECODEZ,U,5,9),$P(ECODE,U,10)=$P(ECODEZ,U,12),$P(ECODE,U,8,9)'=$P(ECODEZ,10,11) D Q
.S $P(^ECX(ECFILE,EC7,0),U,10,11)=$P(ECODE,U,8,9)
S EC7=EC7+1
S ^ECX(ECFILE,EC7,0)=EC7_U_EC23_ECODE,^ECX(ECFILE,EC7,1)=ECODE1,ECRN=ECRN+1
S DA=EC7,DIK="^ECX("_ECFILE_"," D IX1^DIK K DIK,DA
I $D(ZTQUEUED),$$S^%ZTLOAD S QFLG=1
Q
;
SETUP ;Set required input for ECXTRAC
S ECHEAD="PAS"
D ECXDEF^ECXUTL2(ECHEAD,.ECPACK,.ECGRP,.ECFILE,.ECRTN,.ECPIECE,.ECVER)
Q
;
QUE ; entry point for the background requeuing handled by ECXTAUTO
D SETUP,QUE^ECXTAUTO,^ECXKILL Q