[613] | 1 | IMRDAT ; HCIOFO-FAI/SS - DATA EXTRACTION ; 2/14/03 9:41am
|
---|
| 2 | ;;2.1;IMMUNOLOGY CASE REGISTRY;**4,8,9,5,14,13,16,15,18,19,20**;Feb 09, 1998
|
---|
| 3 | ;
|
---|
| 4 | ;***** ENTRY TO DAILY EXTRACT
|
---|
| 5 | ENTRY ;
|
---|
| 6 | N IMRTRANS S U="^"
|
---|
| 7 | Q:'$D(^IMR(158.9,1,0)) ;quit if no site parameters
|
---|
| 8 | D ^IMRUTST
|
---|
| 9 | S IMRDTT=$$NOW^XLFDT()
|
---|
| 10 | S $P(^IMR(158.9,1,0),"^",9)=IMRDTT ; Last start time
|
---|
| 11 | K IMRC S IMRC=0 ; Message line counter
|
---|
| 12 | S IMRSET=0 ; Message counter
|
---|
| 13 | D STDTS()
|
---|
| 14 | EN1 ;--- Entry point from post-init. The following variables must be
|
---|
| 15 | ;--- defined: IMRSD,IMRED,IMRC,IMRSET,IMRDT.
|
---|
| 16 | S IMRTRANS=1 ; Tell the system that this is a transmit to national
|
---|
| 17 | D DOMAIN^IMRUTL ; Get the domain name for ICR
|
---|
| 18 | S IMRDOMN="S.IMRHDATA@"_IMRDOMN ; Append domain to server name
|
---|
| 19 | S IMRM90=$$FMADD^XLFDT($S($G(IMRSDBP(5.2)):IMRSDBP(5.2),1:DT),-90)
|
---|
| 20 | K ^TMP($J)
|
---|
| 21 | ;--- Set LAST START TIME if doesn't exist
|
---|
| 22 | I '$D(IMRDTT) S IMRDTT=$$NOW^XLFDT(),$P(^IMR(158.9,1,0),U,9)=IMRDTT
|
---|
| 23 | ;--- Get station number if it is not defined
|
---|
| 24 | I '$D(IMRSTN) D IMROPN^IMRXOR Q:'$D(IMRSTN)
|
---|
| 25 | ;--- Create the message
|
---|
| 26 | S X=10987654321 D XOR^IMRXOR S IMRCODE=X
|
---|
| 27 | D STARTSEG^IMRDAT1()
|
---|
| 28 | ;--- NEXT CASE node: piece #1=NEXT CASE, piece #2=LAST NEW CASE
|
---|
| 29 | S X=$G(^IMR(158.9,1,"NXT")) S:X="" ^("NXT")=0
|
---|
| 30 | S IMRNXT1=+X,IMRNXT2=+$P(X,U,2)
|
---|
| 31 | ;--- Process the entries
|
---|
| 32 | S IMRFN=0
|
---|
| 33 | F S IMRFN=$O(^IMR(158,IMRFN)) Q:IMRFN'>0 S IMRSEND=0 D NXT
|
---|
| 34 | D SEND^IMRDAT1()
|
---|
| 35 | D UPDPARMS()
|
---|
| 36 | ;--- Cleanup
|
---|
| 37 | KIL K IMRDENT,IMRRAD,IMRRX,IMRLAB,IMRMI,IMRSCH,IMRCODE,IMRT1,IMRT2,DFN,IMRDFN,IMRFN,IMRED,IMRDT,IMR101,IMRNXT1,IMRNXT2,IMROP,IMRSET,IMRSTN,X,X1,X2,IMRC,IMRSSN,%DT,Y,%H,%,IMRTRANS
|
---|
| 38 | K ^TMP($J),%T,DIC,IMRN,IMRSCH1,J,XCNP,XMZ,VAERR,D,DISYS,POP,IMRPAD,IMRADM,IMRDIS,IMRDOMN,IMRSEND,IMR5,IMRDTT,IMRL,IMRT,IMRTEST,IMRTRAN,IMRTSTI,IMRSD,IMRSDBP,IMRAD,IMRM90
|
---|
| 39 | K IMRDTRX,IMRSDBP
|
---|
| 40 | Q
|
---|
| 41 | ;
|
---|
| 42 | ;*****
|
---|
| 43 | NXT D CLEAR
|
---|
| 44 | ;--- Node 101 contains last dates noted for various services provided
|
---|
| 45 | S IMR101=$G(^IMR(158,IMRFN,101)),IMRI=+IMR101
|
---|
| 46 | ;--- Node 5 is the date of death node
|
---|
| 47 | S IMR5=$G(^IMR(158,IMRFN,5))
|
---|
| 48 | ;--- Data transmitted for deceased (1:YES,0:NO)
|
---|
| 49 | S IMRTRAN=$P(IMR5,U,21) Q:IMRTRAN
|
---|
| 50 | ;--- IMRT1 is used to calculate the number of seconds needed
|
---|
| 51 | ;--- to extract data for patient
|
---|
| 52 | S IMRT1=$P($H,",",2)
|
---|
| 53 | ;--- Decode patient id; quit if not in File 2
|
---|
| 54 | S X=+^IMR(158,IMRFN,0) D XOR^IMRXOR Q:'$D(^DPT(X,0))
|
---|
| 55 | S (DFN,IMRDFN)=X
|
---|
| 56 | ;--- Piece #2 = LAST SCHEDULING DATE NOTED
|
---|
| 57 | I $P(IMR101,U,2)="" D
|
---|
| 58 | . S IMRT2="NEW" D DEMOG,CDC
|
---|
| 59 | E S IMRT2="UPD" D DEMOG,CDC0^IMRDAT1()
|
---|
| 60 | ;---
|
---|
| 61 | I IMR101'="" S IMRT1=$P($H,",",2)-IMRT1 D D LCHK
|
---|
| 62 | . S:IMRT1<0 IMRT1=IMRT1+(24*60*60)
|
---|
| 63 | . S IMRC=IMRC+1,^TMP($J,"IMRX",IMRC)="TIME"_"^"_IMRT2_"^"_IMRT1
|
---|
| 64 | Q
|
---|
| 65 | ;
|
---|
| 66 | ;*****
|
---|
| 67 | LCHK I (IMRC-$G(IMRC(0)))'<5000 S IMRC(0)=IMRC D SEND^IMRDAT1()
|
---|
| 68 | Q
|
---|
| 69 | ;
|
---|
| 70 | ;*****
|
---|
| 71 | CDC ; Get Patient Data From File 158
|
---|
| 72 | I $D(^IMR(158,IMRFN,1)),$P(^(1),"^",6)>0,$P(IMR101,"^",14)<$P(^(1),"^",6) S IMRLD=$P(^IMR(158,IMRFN,1),"^",6),$P(IMR101,"^",14)=IMRLD K IMRLD ;piece 6=date cdc form completed, piece 14=last cdc form date
|
---|
| 73 | D MOVCDC0^IMRDAT1
|
---|
| 74 | Q
|
---|
| 75 | ;
|
---|
| 76 | ;*****
|
---|
| 77 | DEMOG Q:'$D(^DPT(DFN,0))
|
---|
| 78 | D SEGS^IMRDAT1(1,1,1,.VADM)
|
---|
| 79 | ;--- Race (IMR*2.1*19)
|
---|
| 80 | I $G(VADM(12))>0 D D LCHK
|
---|
| 81 | . N IMRIV,METHOD,RACE S IMRIV=""
|
---|
| 82 | . F S IMRIV=$O(VADM(12,IMRIV)) Q:IMRIV="" D D LCHK
|
---|
| 83 | . . S RACE=$$PTR2CODE^DGUTL4($P(VADM(12,IMRIV),U),1,2) Q:RACE=""
|
---|
| 84 | . . S METHOD=$$PTR2CODE^DGUTL4($P($G(VADM(12,IMRIV,1)),U),3,2)
|
---|
| 85 | . . S IMRC=IMRC+1,^TMP($J,"IMRX",IMRC)="DER^"_RACE_"^"_METHOD
|
---|
| 86 | ;--- Ethnicity (IMR*2.1*19)
|
---|
| 87 | I $G(VADM(11))>0 D D LCHK
|
---|
| 88 | . N ETHN,IMRIV,METHOD S IMRIV=""
|
---|
| 89 | . F S IMRIV=$O(VADM(11,IMRIV)) Q:IMRIV="" D D LCHK
|
---|
| 90 | . . S ETHN=$$PTR2CODE^DGUTL4($P(VADM(11,IMRIV),U),2,2) Q:ETHN=""
|
---|
| 91 | . . S METHOD=$$PTR2CODE^DGUTL4($P($G(VADM(11,IMRIV,1)),U),3,2)
|
---|
| 92 | . . S IMRC=IMRC+1,^TMP($J,"IMRX",IMRC)="DEE^"_ETHN_"^"_METHOD
|
---|
| 93 | ;--- Cleanup
|
---|
| 94 | K VADM S IMRFLG=0
|
---|
| 95 | ;--- Inpatient Data
|
---|
| 96 | IP D
|
---|
| 97 | . S IMRLD=+$P(IMR101,"^",3) ; LAST ADMIT DATE NOTED
|
---|
| 98 | . S IMRLD1=+$P(IMR101,"^",4) ; LAST DISCHARGE DATE NOTED
|
---|
| 99 | . S IMRLD2=+$P(IMR101,"^",5) ; LAST PTF ADMIT DATE NOTED
|
---|
| 100 | . ; Perform the backpull if the start date is defined
|
---|
| 101 | . I $G(IMRSDBP(5.2))>0 N IMRSD S IMRSD=$G(IMRSDBP(5.2))
|
---|
| 102 | . D ^IMRPTF
|
---|
| 103 | . S $P(IMR101,"^",3,5)=$S(IMRADM>IMRLD:IMRADM,1:IMRLD)_"^"_$S(IMRDIS>IMRLD1:IMRDIS,1:IMRLD1)_"^"_$S(IMRPAD>IMRLD2:IMRPAD,1:IMRLD2)
|
---|
| 104 | . K IMRLD,IMRLD1,IMRLD2
|
---|
| 105 | D GETDAT^IMRDAT1
|
---|
| 106 | Q
|
---|
| 107 | ;
|
---|
| 108 | ;*****
|
---|
| 109 | CLEAR ; Kill Variables
|
---|
| 110 | K IMRT1,IMRT2,DFN,IMRLD,IMRLD1,IMRLD2
|
---|
| 111 | Q
|
---|
| 112 | ASK ; Entry Point to Process Data Extract For A Given Date Range
|
---|
| 113 | K %DT S %DT="AQEXP",%DT("A")=" Start Date for Period: " D ^%DT K %DT G:Y'>0 KIL S IMRSD=Y,%DT="AQEXP",%DT("A")=" End Date for Period: " D ^%DT K %DT G:Y'>0 KIL S IMRED=Y
|
---|
| 114 | I IMRED<IMRSD W !,$C(7),"END CAN NOT BE BEFORE START",! G ASK
|
---|
| 115 | S X1=IMRED,X2=IMRSD D ^%DTC I 'X S X1=IMRSD,X2=-1 D C^%DTC S IMRSD=X
|
---|
| 116 | I X>180 W !,$C(7),"MORE THAN 180 DAYS OF DATA IS TOO MUCH TO TRANSMIT.",!,"TRY A SHORTER DATE RANGE." G ASK
|
---|
| 117 | S IMRED=IMRED+.3,IMRDT=IMRED
|
---|
| 118 | S $P(^IMR(158.9,1,0),"^",9)=$$NOW^XLFDT() ;LAST START TIME
|
---|
| 119 | S IMRC=0,IMRSET=0
|
---|
| 120 | DQ ; Queue Data Extract
|
---|
| 121 | K ZTUCI,ZTDTH,ZTIO,ZTSAVE
|
---|
| 122 | S ZTRTN="EN1^IMRDAT"
|
---|
| 123 | S ZTSAVE("IMRSD")="",ZTSAVE("IMRED")="",ZTSAVE("IMRC")="",ZTSAVE("IMRSET")="",ZTSAVE("IMRDT")=""
|
---|
| 124 | S ZTDTH=$$NOW^XLFDT()
|
---|
| 125 | S ZTIO="",ZTDESC="Process Data Extract for a Date Range"
|
---|
| 126 | D ^%ZTLOAD
|
---|
| 127 | K ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTIO,ZTSK
|
---|
| 128 | Q
|
---|
| 129 | ;
|
---|
| 130 | ;***** LOADS THE START DATES
|
---|
| 131 | ;
|
---|
| 132 | ; Initializes the variables: IMRDT, IMRED, IMRSD, IMRSDBP, IMRDTRX
|
---|
| 133 | STDTS() ;
|
---|
| 134 | N FLD,IENS,IMRBUF,IMRMSG,TMP
|
---|
| 135 | K IMRSDBP,IMRDTRX
|
---|
| 136 | S (IMRED,IMRDT)=$$NOW^XLFDT(),IMRSD=0
|
---|
| 137 | S IENS="1,"
|
---|
| 138 | D GETS^DIQ(158.9,IENS,".1;5.1;5.2;5.3","I","IMRBUF","IMRMSG")
|
---|
| 139 | S IMRSD=$G(IMRBUF(158.9,IENS,.1,"I"))\1
|
---|
| 140 | S:$G(IMRSD)'>0 IMRSD=$$FMADD^XLFDT($$DT^XLFDT,-1)
|
---|
| 141 | F FLD=5.1,5.2,5.3 D
|
---|
| 142 | . S TMP=$G(IMRBUF(158.9,IENS,FLD,"I"))\1
|
---|
| 143 | . S:TMP>0 IMRSDBP(FLD)=TMP
|
---|
| 144 | ;--- Dates for the Pharmacy data extraction
|
---|
| 145 | S IMRDTRX("S")=$$FMADD^XLFDT(IMRSD,-14)
|
---|
| 146 | S IMRDTRX("E")=$$FMADD^XLFDT(IMRED\1,-14)
|
---|
| 147 | I IMRDTRX("E")'>IMRDTRX("S") D
|
---|
| 148 | . S IMRDTRX("E")=$$FMADD^XLFDT(IMRDTRX("S"),1)
|
---|
| 149 | E S:IMRDTRX("E")>IMRSD IMRDTRX("E")=IMRSD
|
---|
| 150 | Q
|
---|
| 151 | ;
|
---|
| 152 | ;***** UPDATES SITE PARAMETERS
|
---|
| 153 | UPDPARMS() ;
|
---|
| 154 | N IENS,IMRFDA,IMRMSG
|
---|
| 155 | S IENS="1,"
|
---|
| 156 | S IMRFDA(158.9,IENS,.1)=$$NOW^XLFDT ; LAST COMPLETION TIME
|
---|
| 157 | S IMRFDA(158.9,IENS,5.1)="@" ; LAB BACKPULL START
|
---|
| 158 | S IMRFDA(158.9,IENS,5.2)="@" ; INPATIENT BACKPULL START
|
---|
| 159 | S IMRFDA(158.9,IENS,5.3)="@" ; PHARMACY BACKPULL START
|
---|
| 160 | S IMRFDA(158.9,IENS,21.01)=0 ; NEXT CASE
|
---|
| 161 | S IMRFDA(158.9,IENS,21.02)=IMRNXT2 ; LAST NEW CASE
|
---|
| 162 | D FILE^DIE(,"IMRFDA","IMRMSG")
|
---|
| 163 | Q
|
---|