BMENED ; IHS/PHXAO/TMJ - ACTUAL UPDATES OF AHCCCS MEDICAID RECORDS [ 06/11/03 4:10 PM ]
;AZAGMED Global established by Routine AZAGMED.
;This Sets Every Record in AHCCCS File to AZAGMED(Global
;
;This Routine $0's through Global ^AZAGMED(
;This Routine completes the ACTUAL RPMS DOWNLOAD
;by updated the RPMS MEDICAID ELIGIBILITY File, the
;RPMS Master Control File and the Monthly No Match File
;
;
VARIABLE ;Establish Date/Time/Count Variables
;Establish Run Counters
;
;S FILE="MED0120001.TXT" ;Hard Set for Testing Only on just this routine
;
S AZAMNEW=0 ;New Adds to Med Eligibility File
S AZAMUPDT=0 ;Updates to Med Eligibility File
S SSNCT=0 ;SSN Matches Only in No Match File
S KIDCT=0 ;KID's Care Counter in No Match File
S TOTALCT=0 ;Total Records Actually Processed - New or Update
S NOCOUNT=0 ; Variable used to not count News & Updates twice
S GRANDTOT=0 ;Grand Total all Records regardless of action
S BEGTIME=$$NOW^XLFDT
;
INS ;GET ARIZONA MEDICAID INTERNAL NUMBER FROM THE INSURER FILE-PHX AREA
S DIC="^AUTNINS(",DIC(0)="XZIMO",X="MEDICAID" D ^DIC
I Y'=-1 S INS=$P(Y,"^",1)
E G END2 ;Quit if no Insurer - don't write message
;
D START
S ENDTIME=$$NOW^XLFDT
D LOG
D END
Q
;
START ;BEGIN $O THRU ^AZAGMED( -created by Routine AZAGMED
;which reads all records in AHCCCS File 1-420 Position &
;sets full record in ^AZAGMED(Global
;S MRATE=""
;
I '$D(ZTQUEUED) U IO(0) ;IHS/ANMC/FBD-2/17/98-ADDED LINE-TRYING TO AVOID <MODER> ERRORS
K ^TMP($J),^AZAMED ;Kill off $Job and Previous Month's AZAMED Global
;
S ^AZAMED(0)="AZA MEDICAID ELIGIBLE (NO SSN)^1180001DI"
A ; -- BEGIN $O THRU AZAGMED(GLOBAL CREATED BY AZAGMED
S IFN=0 F S IFN=$O(^AZAGMED(IFN)) Q:'IFN D
. S N=^AZAGMED(IFN),MSSN=$E(N,65,73),MFNAME=$E(N,2,32),MDOB=$E(N,36,44),MSEX=$E(N,34,34)
. Q:$E(N,1,2)="XX" ;Quit -Last IFN Record is end of File
. S MLNAME=$P(MFNAME,",",1) ;Last Name
. S MFNAME=$P(MFNAME,",",2) ;First Name
.;S MLNAME=$P(MLNAME," ",1) ; Strip out spaces on Medicaid Last Name
. S MFNAME=$P(MFNAME," ",1) ;Strip out spaces on Medicaid First Name
. S MFULNAME=MLNAME_","_MFNAME ;Medicaid Full Name
. S MRATE="" S MKID="" S SSNMATCH="" S NOCOUNT=0 S GRANDTOT=GRANDTOT+1
. D MEDNUM ;Check the Med Elig Number before SSN
. I MNUMMAT=0 S DFN=$O(^DPT("SSN",+MSSN,0)) I 'DFN N N,MSSN,MNUM D ^AZANED0 Q
. D MEDNAME ;Check Medicaid Elig File's Medicaid Name (if exists)
. S SDOB=$P(^DPT(DFN,0),U,3) ;VA PT DOB
. S MDOB=$$DOB ; AHCCCS DOB
. S SSEX=$P(^DPT(DFN,0),U,2),FULLNAME=$P(^(0),U) ; VA PT SEX
. S SLNAME=$P(FULLNAME,",",1) ; VA PT FULL LAST NAME
. S MRATE=$E(N,355,358) ;AHCCCS Rate Code-Ck for Kids Care
. S EED=$$EED,EBD=$$EBD ;AHCCCS PAYMENT TO/FROM DT
. ;Q:EED<$$EHIS
. S ERD=$$ERD,CT=$E(N,106,107) ;Enrollment Dt - CT=Coverage Type)
. S NOCOUNT=0 ;Variable for Not counting New & Updates twice
. I MRATE>5999&(MRATE<7000) S MKID="Y" S KIDCT=KIDCT+1 N N,MSSN,MNUM D ^AZANED0 Q ;Quit if KIDS CARE-Per J. Hathcoat 1/25/01
. I MLNAME'=SLNAME&(MNAMEMAT'=1) S SSNCT=SSNCT+1 S SSNMATCH="Y" N N,MSSN,MNUM D ^AZANED0 Q ; Quit if no match on Med Name or Last Name
. I MDOB'=SDOB S SSNCT=SSNCT+1 S SSNMATCH="Y" N N,MSSN,MNUM D ^AZANED0 Q ; Quit on DOB No Match
. I MSEX'=SSEX S SSNCT=SSNCT+1 S SSNMATCH="Y" N N,MSSN,MNUM D ^AZANED0 Q ; Quit if no match on Sex
. D NEW,UP0,MED
. S TOTALCT=TOTALCT+1 ;Total Record Count - Regardless of action
Q
;
MED ; -- add eligiblity date(s)/data
S IEN=$O(^AUPNMCD("B",DFN,0)) Q:'IEN
Q:$P($G(^AUPNMCD(IEN,11,EBD,0)),U,2)=EED ;Quit if Both Beg/End Match already
S:'$D(^AUPNMCD(IEN,11,0)) $P(^(0),U,2)="9000004.11D"
S LSTEBD=$P($G(^AUPNMCD(IEN,11,0)),U,3) ;Last Beg Date entered
I LSTEBD="" D
. S $P(^AUPNMCD(IEN,11,0),U,3)=EBD
. S $P(^AUPNMCD(IEN,11,0),U,4)=$P(^(0),U,4)+1
. S DR=".01///"_EBD_"" ;.03////"_CT ; Add Beginning DT Only
. S DIE="^AUPNMCD("_IEN_",11,",DA(1)=IEN,DA=EBD D ^DIE K DIE,DR,DA,DINUM
. I NOCOUNT=0 S AZAMUPDT=AZAMUPDT+1 D UPDATES^AZANSTR ;Update Count-Update Master List
I LSTEBD'="" D
. S SENDDT=$P($G(^AUPNMCD(IEN,11,LSTEBD,0)),U,2)
. I SENDDT'="" S $P(^AUPNMCD(IEN,11,0),U,3)=EBD
. I SENDDT'="" S $P(^AUPNMCD(IEN,11,0),U,4)=$P(^(0),U,4)+1
. I SENDDT'="" S DR=".01///"_EBD_";03////"_CT ; Add Beg DT Only
. I SENDDT'="" S DIE="^AUPNMCD("_IEN_",11,",DA(1)=IEN,DA=EBD D ^DIE K DIE,DR,DA,DINUM I NOCOUNT=0 S AZAMUPDT=AZAMUPDT+1 D UPDATES^AZANSTR Q
. D STILLACT^AZANSTR ;Existing Patient fell through-Still Active Only/no Update
Q
;
NEW ; -- create new entry in medicaid eligible
Q:$O(^AUPNMCD("B",+DFN,0)) ;Quit if already in Medicaid Eligibility File
D ^XBFMK K DIADD,DINUM
S X=DFN,DIC="^AUPNMCD(",DIC(0)="L",DLAYGO=9000004
S DIC("DR")=".02////"_INS_";.03////"_MNUM_";.04////3;2101////"_MFULNAME
S DIC("DR")=DIC("DR")_";.07////"_SSEX_";.08////"_DT_";.12////"_MRATE
;K DD,DO
D FILE^DICN S IEN=+Y D ^XBFMK K DIADD,DINUM
S AZAMNEW=AZAMNEW+1 ;Counter for New Adds to Medicaid Eligibility file
S NOCOUNT=1 ;Don't count again on Date Updates UP0
D NEW^AZANSTR
Q
;
UP0 ; -- update 0th node - Patient Demographics Only
S IEN=$O(^AUPNMCD("B",DFN,0)) Q:'IEN
S:'$P(^AUPNMCD(IEN,0),U,2) $P(^AUPNMCD(IEN,0),U,2)=INS
S:'$P(^AUPNMCD(IEN,0),U,3) $P(^AUPNMCD(IEN,0),U,3)=MNUM
S:'$P(^AUPNMCD(IEN,0),U,4) $P(^AUPNMCD(IEN,0),U,4)=3
S DIE="^AUPNMCD(",DA=IEN,DR="2101////"_MFULNAME_";.08////"_DT_";.12////"_MRATE
D ^DIE K DIE,DR,DA
;I NOCOUNT=0 S AZAMUPDT=AZAMUPDT+1 ;Counter for Updates only to Medicaid Eligibility File
Q
;
END ; -- cleanup
S GRANDTOT=GRANDTOT-1
;W !!,"End of Download Update!!!",!
;W !!
;W "Total Records Processed: "_GRANDTOT
;W !,"Total Action Records Process: "_TOTALCT
;W !,"Total New Records Added: "_AZAMNEW
;W !,"Total Updated Records: "_AZAMUPDT
;W !,"Total Records with SSN Match Only: "_SSNCT
;W !!,"Total KID's Care: "_KIDCT
;
K IFN,DFN,IEN,EED,EBD,CT,MNUM,MSEX,N,NAME,CNT,MFULNAME,MFNAME,MNAMEMAT,MEDNAME,MIEN,MFNAME,MDOB,MRATE
K AZAMNEW,AZAMUPDT,SSNCT,TOTALCT,NOCOUNT,GRANDTOT,BEGTIME,MKID,KIDCT,ENDTIME
Q
;
EED() ; -- eligibility end date
;N X,Y S X=$E(N,412,419) D ^%DT Q Y
N X,Y S YYYY=$E(N,412,415),MMDD=$E(N,416,419)
S EED=MMDD_YYYY
S X=EED D ^%DT Q Y
;
EBD() ; -- eligibility beg date
;N X,Y S X=$E(N,404,411) D ^%DT Q Y
N X,Y S YYYY=$E(N,347,350),MMDD=$E(N,351,354)
S EBD=MMDD_YYYY
S X=EBD D ^%DT Q Y
;
EHIS() ; -- eligibilities after date/flag
N X1,X2,X S X1=DT,X2=-180 D C^%DTC Q X
;
HRCN() ;EP; -- IHS health record number
Q $P($G(^AUPNPAT(+$G(DFN),41,+$G(DUZ(2)),0)),"^",2)
;
ERD() ;EP -- Eligibility Enrollment Dt (Same as Beg Date on Roster)
;Roster Positions 347-354
N X,Y S YYYY=$E(N,347,350),MMDD=$E(N,351,354)
S ERD=MMDD_YYYY
S X=ERD D ^%DT Q Y
;N X,Y S X=$E(N,404,411) D ^%DT Q Y
;
DOB() ;EP - Date of AHCCCS Birth Date Conversion
N X,Y S YYYY=$E(N,143,146),MMDD=$E(N,147,150)
S MDOB=MMDD_YYYY
S X=MDOB D ^%DT Q Y
;
LOG ;Update AZA MEDICAL ELIGIBLE DOWNLOAD LOG
;W !!,"The Download Process is Now Complete!!"
;W !!,"I will now update the Download Log with the final run documentation",!
;S BEGTIME=$$NOW^XLFDT,ENDTIME=$$NOW^XLFDT,GRANDTOT=100,TOTALCT=50,SSNCT=5,AZAMNEW=10,AZAMUPDT=8
;The .01 Entry is Today's Date at time of run - BEGTIME Variable
D ^XBFMK K DIADD,DINUM
S X=BEGTIME,DIC="^AZAMEDLG(",DIC(0)="L",DLAYGO=1180006
S DIC("DR")=".02////"_ENDTIME_";.03////"_GRANDTOT_";.04///"_TOTALCT_";.05////"_SSNCT_";1///"_KIDCT
S DIC("DR")=DIC("DR")_";.06////"_AZAMNEW_";.07////"_AZAMUPDT_";.08////"_FILE
;ADD THE FILE NAME PROCESSED FIELD .08 HERE
;S DIC("DR")=DIC("DR")_";1////"_SSN_";2////"_RESCE
D FILE^DICN S IEN=+Y D ^XBFMK K DIADD,DINUM
;
;W !!,"Log File Updated",!
;
Q
;
END2 ;Abnormal Termination - Medicaid Insurer missing from Insurer File
;W !,"The Insurer - ARIZONA MEDICAID - is missing from the Insurer File",!
;W !,"The Initial Process of creating the AZAGMED Global is complete",!
;W "however, the Update Run (AZAMED) cannot be ran - See your Site Manager",!!
Q
;
MEDNAME ;Check Med Elig Medicaid Name-If exists for match
;
S MNAMEMAT=0
S MIEN=$O(^AUPNMCD("B",+DFN,0))
Q:'MIEN
S MEDNAME=$P($G(^AUPNMCD(MIEN,21)),U,1)
Q:MEDNAME=""
I MEDNAME=MFULNAME S MNAMEMAT=1
Q
;
MEDNUM ;Check Med Elig Number against RPMS
;
S MNUMMAT=0
Q ;No MIEN Medicaid # comes from Nevada File
S MIEN=$O(^AUPNMCD("AE",MNUM,0))
Q:'MIEN
S MEDNUM=$P($G(^AUPNMCD(MIEN,0)),U,3)
Q:MEDNUM=""
I MEDNUM=MNUM S MNUMMAT=1 S DFN=$P($G(^AUPNMCD(MIEN,0)),U,1)
Q
;
BMENED ; IHS/PHXAO/TMJ - ACTUAL UPDATES OF AHCCCS MEDICAID RECORDS [ 06/11/03 4:10 PM ]
+1 ;AZAGMED Global established by Routine AZAGMED.
+2 ;This Sets Every Record in AHCCCS File to AZAGMED(Global
+3 ;
+4 ;This Routine $0's through Global ^AZAGMED(
+5 ;This Routine completes the ACTUAL RPMS DOWNLOAD
+6 ;by updated the RPMS MEDICAID ELIGIBILITY File, the
+7 ;RPMS Master Control File and the Monthly No Match File
+8 ;
+9 ;
VARIABLE ;Establish Date/Time/Count Variables
+1 ;Establish Run Counters
+2 ;
+3 ;S FILE="MED0120001.TXT" ;Hard Set for Testing Only on just this routine
+4 ;
+5 ;New Adds to Med Eligibility File
SET AZAMNEW=0
+6 ;Updates to Med Eligibility File
SET AZAMUPDT=0
+7 ;SSN Matches Only in No Match File
SET SSNCT=0
+8 ;KID's Care Counter in No Match File
SET KIDCT=0
+9 ;Total Records Actually Processed - New or Update
SET TOTALCT=0
+10 ; Variable used to not count News & Updates twice
SET NOCOUNT=0
+11 ;Grand Total all Records regardless of action
SET GRANDTOT=0
+12 SET BEGTIME=$$NOW^XLFDT
+13 ;
INS ;GET ARIZONA MEDICAID INTERNAL NUMBER FROM THE INSURER FILE-PHX AREA
+1 SET DIC="^AUTNINS("
SET DIC(0)="XZIMO"
SET X="MEDICAID"
DO ^DIC
+2 IF Y'=-1
SET INS=$PIECE(Y,"^",1)
+3 ;Quit if no Insurer - don't write message
IF '$TEST
GOTO END2
+4 ;
+5 DO START
+6 SET ENDTIME=$$NOW^XLFDT
+7 DO LOG
+8 DO END
+9 QUIT
+10 ;
START ;BEGIN $O THRU ^AZAGMED( -created by Routine AZAGMED
+1 ;which reads all records in AHCCCS File 1-420 Position &
+2 ;sets full record in ^AZAGMED(Global
+3 ;S MRATE=""
+4 ;
+5 ;IHS/ANMC/FBD-2/17/98-ADDED LINE-TRYING TO AVOID <MODER> ERRORS
IF '$DATA(ZTQUEUED)
USE IO(0)
+6 ;Kill off $Job and Previous Month's AZAMED Global
KILL ^TMP($JOB),^AZAMED
+7 ;
+8 SET ^AZAMED(0)="AZA MEDICAID ELIGIBLE (NO SSN)^1180001DI"
A ; -- BEGIN $O THRU AZAGMED(GLOBAL CREATED BY AZAGMED
+1 SET IFN=0
FOR
SET IFN=$ORDER(^AZAGMED(IFN))
IF 'IFN
QUIT
Begin DoDot:1
+2 SET N=^AZAGMED(IFN)
SET MSSN=$EXTRACT(N,65,73)
SET MFNAME=$EXTRACT(N,2,32)
SET MDOB=$EXTRACT(N,36,44)
SET MSEX=$EXTRACT(N,34,34)
+3 ;Quit -Last IFN Record is end of File
IF $EXTRACT(N,1,2)="XX"
QUIT
+4 ;Last Name
SET MLNAME=$PIECE(MFNAME,",",1)
+5 ;First Name
SET MFNAME=$PIECE(MFNAME,",",2)
+6 ;S MLNAME=$P(MLNAME," ",1) ; Strip out spaces on Medicaid Last Name
+7 ;Strip out spaces on Medicaid First Name
SET MFNAME=$PIECE(MFNAME," ",1)
+8 ;Medicaid Full Name
SET MFULNAME=MLNAME_","_MFNAME
+9 SET MRATE=""
SET MKID=""
SET SSNMATCH=""
SET NOCOUNT=0
SET GRANDTOT=GRANDTOT+1
+10 ;Check the Med Elig Number before SSN
DO MEDNUM
+11 IF MNUMMAT=0
SET DFN=$ORDER(^DPT("SSN",+MSSN,0))
IF 'DFN
NEW N,MSSN,MNUM
DO ^AZANED0
QUIT
+12 ;Check Medicaid Elig File's Medicaid Name (if exists)
DO MEDNAME
+13 ;VA PT DOB
SET SDOB=$PIECE(^DPT(DFN,0),U,3)
+14 ; AHCCCS DOB
SET MDOB=$$DOB
+15 ; VA PT SEX
SET SSEX=$PIECE(^DPT(DFN,0),U,2)
SET FULLNAME=$PIECE(^(0),U)
+16 ; VA PT FULL LAST NAME
SET SLNAME=$PIECE(FULLNAME,",",1)
+17 ;AHCCCS Rate Code-Ck for Kids Care
SET MRATE=$EXTRACT(N,355,358)
+18 ;AHCCCS PAYMENT TO/FROM DT
SET EED=$$EED
SET EBD=$$EBD
+19 ;Q:EED<$$EHIS
+20 ;Enrollment Dt - CT=Coverage Type)
SET ERD=$$ERD
SET CT=$EXTRACT(N,106,107)
+21 ;Variable for Not counting New & Updates twice
SET NOCOUNT=0
+22 ;Quit if KIDS CARE-Per J. Hathcoat 1/25/01
IF MRATE>5999&(MRATE<7000)
SET MKID="Y"
SET KIDCT=KIDCT+1
NEW N,MSSN,MNUM
DO ^AZANED0
QUIT
+23 ; Quit if no match on Med Name or Last Name
IF MLNAME'=SLNAME&(MNAMEMAT'=1)
SET SSNCT=SSNCT+1
SET SSNMATCH="Y"
NEW N,MSSN,MNUM
DO ^AZANED0
QUIT
+24 ; Quit on DOB No Match
IF MDOB'=SDOB
SET SSNCT=SSNCT+1
SET SSNMATCH="Y"
NEW N,MSSN,MNUM
DO ^AZANED0
QUIT
+25 ; Quit if no match on Sex
IF MSEX'=SSEX
SET SSNCT=SSNCT+1
SET SSNMATCH="Y"
NEW N,MSSN,MNUM
DO ^AZANED0
QUIT
+26 DO NEW
DO UP0
DO MED
+27 ;Total Record Count - Regardless of action
SET TOTALCT=TOTALCT+1
End DoDot:1
+28 QUIT
+29 ;
MED ; -- add eligiblity date(s)/data
+1 SET IEN=$ORDER(^AUPNMCD("B",DFN,0))
IF 'IEN
QUIT
+2 ;Quit if Both Beg/End Match already
IF $PIECE($GET(^AUPNMCD(IEN,11,EBD,0)),U,2)=EED
QUIT
+3 IF '$DATA(^AUPNMCD(IEN,11,0))
SET $PIECE(^(0),U,2)="9000004.11D"
+4 ;Last Beg Date entered
SET LSTEBD=$PIECE($GET(^AUPNMCD(IEN,11,0)),U,3)
+5 IF LSTEBD=""
Begin DoDot:1
+6 SET $PIECE(^AUPNMCD(IEN,11,0),U,3)=EBD
+7 SET $PIECE(^AUPNMCD(IEN,11,0),U,4)=$PIECE(^(0),U,4)+1
+8 ;.03////"_CT ; Add Beginning DT Only
SET DR=".01///"_EBD_""
+9 SET DIE="^AUPNMCD("_IEN_",11,"
SET DA(1)=IEN
SET DA=EBD
DO ^DIE
KILL DIE,DR,DA,DINUM
+10 ;Update Count-Update Master List
IF NOCOUNT=0
SET AZAMUPDT=AZAMUPDT+1
DO UPDATES^AZANSTR
End DoDot:1
+11 IF LSTEBD'=""
Begin DoDot:1
+12 SET SENDDT=$PIECE($GET(^AUPNMCD(IEN,11,LSTEBD,0)),U,2)
+13 IF SENDDT'=""
SET $PIECE(^AUPNMCD(IEN,11,0),U,3)=EBD
+14 IF SENDDT'=""
SET $PIECE(^AUPNMCD(IEN,11,0),U,4)=$PIECE(^(0),U,4)+1
+15 ; Add Beg DT Only
IF SENDDT'=""
SET DR=".01///"_EBD_";03////"_CT
+16 IF SENDDT'=""
SET DIE="^AUPNMCD("_IEN_",11,"
SET DA(1)=IEN
SET DA=EBD
DO ^DIE
KILL DIE,DR,DA,DINUM
IF NOCOUNT=0
SET AZAMUPDT=AZAMUPDT+1
DO UPDATES^AZANSTR
QUIT
+17 ;Existing Patient fell through-Still Active Only/no Update
DO STILLACT^AZANSTR
End DoDot:1
+18 QUIT
+19 ;
NEW ; -- create new entry in medicaid eligible
+1 ;Quit if already in Medicaid Eligibility File
IF $ORDER(^AUPNMCD("B",+DFN,0))
QUIT
+2 DO ^XBFMK
KILL DIADD,DINUM
+3 SET X=DFN
SET DIC="^AUPNMCD("
SET DIC(0)="L"
SET DLAYGO=9000004
+4 SET DIC("DR")=".02////"_INS_";.03////"_MNUM_";.04////3;2101////"_MFULNAME
+5 SET DIC("DR")=DIC("DR")_";.07////"_SSEX_";.08////"_DT_";.12////"_MRATE
+6 ;K DD,DO
+7 DO FILE^DICN
SET IEN=+Y
DO ^XBFMK
KILL DIADD,DINUM
+8 ;Counter for New Adds to Medicaid Eligibility file
SET AZAMNEW=AZAMNEW+1
+9 ;Don't count again on Date Updates UP0
SET NOCOUNT=1
+10 DO NEW^AZANSTR
+11 QUIT
+12 ;
UP0 ; -- update 0th node - Patient Demographics Only
+1 SET IEN=$ORDER(^AUPNMCD("B",DFN,0))
IF 'IEN
QUIT
+2 IF '$PIECE(^AUPNMCD(IEN,0),U,2)
SET $PIECE(^AUPNMCD(IEN,0),U,2)=INS
+3 IF '$PIECE(^AUPNMCD(IEN,0),U,3)
SET $PIECE(^AUPNMCD(IEN,0),U,3)=MNUM
+4 IF '$PIECE(^AUPNMCD(IEN,0),U,4)
SET $PIECE(^AUPNMCD(IEN,0),U,4)=3
+5 SET DIE="^AUPNMCD("
SET DA=IEN
SET DR="2101////"_MFULNAME_";.08////"_DT_";.12////"_MRATE
+6 DO ^DIE
KILL DIE,DR,DA
+7 ;I NOCOUNT=0 S AZAMUPDT=AZAMUPDT+1 ;Counter for Updates only to Medicaid Eligibility File
+8 QUIT
+9 ;
END ; -- cleanup
+1 SET GRANDTOT=GRANDTOT-1
+2 ;W !!,"End of Download Update!!!",!
+3 ;W !!
+4 ;W "Total Records Processed: "_GRANDTOT
+5 ;W !,"Total Action Records Process: "_TOTALCT
+6 ;W !,"Total New Records Added: "_AZAMNEW
+7 ;W !,"Total Updated Records: "_AZAMUPDT
+8 ;W !,"Total Records with SSN Match Only: "_SSNCT
+9 ;W !!,"Total KID's Care: "_KIDCT
+10 ;
+11 KILL IFN,DFN,IEN,EED,EBD,CT,MNUM,MSEX,N,NAME,CNT,MFULNAME,MFNAME,MNAMEMAT,MEDNAME,MIEN,MFNAME,MDOB,MRATE
+12 KILL AZAMNEW,AZAMUPDT,SSNCT,TOTALCT,NOCOUNT,GRANDTOT,BEGTIME,MKID,KIDCT,ENDTIME
+13 QUIT
+14 ;
EED() ; -- eligibility end date
+1 ;N X,Y S X=$E(N,412,419) D ^%DT Q Y
+2 NEW X,Y
SET YYYY=$EXTRACT(N,412,415)
SET MMDD=$EXTRACT(N,416,419)
+3 SET EED=MMDD_YYYY
+4 SET X=EED
DO ^%DT
QUIT Y
+5 ;
EBD() ; -- eligibility beg date
+1 ;N X,Y S X=$E(N,404,411) D ^%DT Q Y
+2 NEW X,Y
SET YYYY=$EXTRACT(N,347,350)
SET MMDD=$EXTRACT(N,351,354)
+3 SET EBD=MMDD_YYYY
+4 SET X=EBD
DO ^%DT
QUIT Y
+5 ;
EHIS() ; -- eligibilities after date/flag
+1 NEW X1,X2,X
SET X1=DT
SET X2=-180
DO C^%DTC
QUIT X
+2 ;
HRCN() ;EP; -- IHS health record number
+1 QUIT $PIECE($GET(^AUPNPAT(+$GET(DFN),41,+$GET(DUZ(2)),0)),"^",2)
+2 ;
ERD() ;EP -- Eligibility Enrollment Dt (Same as Beg Date on Roster)
+1 ;Roster Positions 347-354
+2 NEW X,Y
SET YYYY=$EXTRACT(N,347,350)
SET MMDD=$EXTRACT(N,351,354)
+3 SET ERD=MMDD_YYYY
+4 SET X=ERD
DO ^%DT
QUIT Y
+5 ;N X,Y S X=$E(N,404,411) D ^%DT Q Y
+6 ;
DOB() ;EP - Date of AHCCCS Birth Date Conversion
+1 NEW X,Y
SET YYYY=$EXTRACT(N,143,146)
SET MMDD=$EXTRACT(N,147,150)
+2 SET MDOB=MMDD_YYYY
+3 SET X=MDOB
DO ^%DT
QUIT Y
+4 ;
LOG ;Update AZA MEDICAL ELIGIBLE DOWNLOAD LOG
+1 ;W !!,"The Download Process is Now Complete!!"
+2 ;W !!,"I will now update the Download Log with the final run documentation",!
+3 ;S BEGTIME=$$NOW^XLFDT,ENDTIME=$$NOW^XLFDT,GRANDTOT=100,TOTALCT=50,SSNCT=5,AZAMNEW=10,AZAMUPDT=8
+4 ;The .01 Entry is Today's Date at time of run - BEGTIME Variable
+5 DO ^XBFMK
KILL DIADD,DINUM
+6 SET X=BEGTIME
SET DIC="^AZAMEDLG("
SET DIC(0)="L"
SET DLAYGO=1180006
+7 SET DIC("DR")=".02////"_ENDTIME_";.03////"_GRANDTOT_";.04///"_TOTALCT_";.05////"_SSNCT_";1///"_KIDCT
+8 SET DIC("DR")=DIC("DR")_";.06////"_AZAMNEW_";.07////"_AZAMUPDT_";.08////"_FILE
+9 ;ADD THE FILE NAME PROCESSED FIELD .08 HERE
+10 ;S DIC("DR")=DIC("DR")_";1////"_SSN_";2////"_RESCE
+11 DO FILE^DICN
SET IEN=+Y
DO ^XBFMK
KILL DIADD,DINUM
+12 ;
+13 ;W !!,"Log File Updated",!
+14 ;
+15 QUIT
+16 ;
END2 ;Abnormal Termination - Medicaid Insurer missing from Insurer File
+1 ;W !,"The Insurer - ARIZONA MEDICAID - is missing from the Insurer File",!
+2 ;W !,"The Initial Process of creating the AZAGMED Global is complete",!
+3 ;W "however, the Update Run (AZAMED) cannot be ran - See your Site Manager",!!
+4 QUIT
+5 ;
MEDNAME ;Check Med Elig Medicaid Name-If exists for match
+1 ;
+2 SET MNAMEMAT=0
+3 SET MIEN=$ORDER(^AUPNMCD("B",+DFN,0))
+4 IF 'MIEN
QUIT
+5 SET MEDNAME=$PIECE($GET(^AUPNMCD(MIEN,21)),U,1)
+6 IF MEDNAME=""
QUIT
+7 IF MEDNAME=MFULNAME
SET MNAMEMAT=1
+8 QUIT
+9 ;
MEDNUM ;Check Med Elig Number against RPMS
+1 ;
+2 SET MNUMMAT=0
+3 ;No MIEN Medicaid # comes from Nevada File
QUIT
+4 SET MIEN=$ORDER(^AUPNMCD("AE",MNUM,0))
+5 IF 'MIEN
QUIT
+6 SET MEDNUM=$PIECE($GET(^AUPNMCD(MIEN,0)),U,3)
+7 IF MEDNUM=""
QUIT
+8 IF MEDNUM=MNUM
SET MNUMMAT=1
SET DFN=$PIECE($GET(^AUPNMCD(MIEN,0)),U,1)
+9 QUIT
+10 ;