BZDMCDAZ ;IHS/BAO/DMH load mcaid elg. from ARIZONA STATE [ 09/14/2000 4:25 PM ]
; dmh 8/21/2000
; revised copy of BZDMCDNV
;
; dmh 3/21/2000
; revised copy of AZBMESTU
;
;
;ROUTINE TO AUTOMATICALLY STUFF THE MEDICAID ELIGIBLE [ 01/02/96 10:19 AM ]
;FILE AT THE SERVICE UNITS USING THE AZMEDDL GLOBAL CREATED AT THE
;AREA B SYSTEM. THE DATA CAME FROM THE MASTER GLOBAL AFTER ALL THE
;MEDICAID ELIGABLE DATA WAS DOWNLOADED FROM THE STATE TAPES.
;THIS WILL NEED TO BE DONE ON A MONTHLY BASIS IN ORDER TO GET ALL THE
;UPDATE DATES THAT THE STATE SENDS EACH MONTH.
;^BZDMTEMP(0) HOLDS LAST ACCESSED HRN FROM MED UNIX FILE IF NEED
;TO DO RESET.
;AMH-BAO 7/12/91
;K ^BZDMTEMP
K ^BZDMTEMP("SSN")
K ^BZDMTEMP("NEW")
K ^BZDMTEMP("UPDATE")
K ^BZDMTEMP("MEDNO")
K ^BZDMTEMP("MNO")
K ^BZDMTEMP("INDX") ;for creating own index 9/8/2000
;K ^BZDMERST("A")
K ^BZDM("MEDNO")
K AZBM
;
D INDX^BZDMUT
I '$D(^BZDMTEMP("INDX")) U 0 W *7,!!,"Index is not set!!" H 2 Q
;
ST1 ;
U 0 W ! D ^%T
I '$D(DUZ(2)) D ^XBKVAR
I +DUZ(2)=0 K DUZ(2) D ^XBKVAR
S ORGDUZ(2)=DUZ(2)
S NEW=0
S UPDATE=0
S SSNCT=0
S COUNT=0
S CT=0
S ER(1)=0,ER(2)=0,ER("P")=0,ER("HR")=0
S %DT="",X="T" D ^%DT S TODAY=Y
D ^%ZIS
;S FACNAME=$P(^DIC(4,ORGDUZ(2),0),"^",1)
;U IO(0) W !,"DOWNLOAD FOR--",FACNAME
U IO(0) W !!!!!,"DOWNLOAD FOR--MEDICAID ELIGIBILITY"
U IO(0) W !,TODAY
;
;
SSNQ ;U IO(0) R !!,"STUFF VALID SSN'S? (Y or N) ",SSNQ
;I (SSNQ'="N")&(SSNQ'="Y") W *7," ??" H 2 G SSNQ
;
;
S FAC=$P(^AUTTLOC(DUZ(2),0),"^",10)
I '$D(^AUPNMCD(0)) S ^AUPNMCD(0)="MEDICAID ELIGIBLE^9000004PI^0^0"
;
INS ;GET MEDICAID INTERNAL NUMBER FOR EACH RECORD
S DIC="^AUTNINS(",DIC(0)="XZIMO",X="MEDICAID" D ^DIC
I Y'=-1 S INS=$P(Y,"^",1)
E U IO(0) W !!,*7,"ERROR IN INSURER FILE..." G ABNEND
S DIC="^AUTNINS(",DIC(0)="XZIMO",X="ARIZONA MEDICAID" D ^DIC
I Y'=-1 S PLAN=$P(Y,"^",1)
E U IO(0) W !!,*7,"ERROR IN INSURER FILE (PLAN)..." G ABNEND
;
STATE ;GET STATE NUMBER
;U IO(0) R !!,"ENTER MEDICAID STATE CODE 1=MONTANA 2=WYOMING : ",ST
;I ST="^" G ABNEND
;I (ST'=1)&(ST'=2) U IO(0) W *7," ??" H 2 G STATE
;I ST=1 S X="MONTANA"
;I ST=2 S X="WYOMING"
;S ST=2,X="WYOMING"
;
;
S ST=4,X="ARIZONA"
S DIC="^DIC(5,",DIC(0)="ZM" D ^DIC
I Y'=-1 S STATE=$P(Y,"^",1)
E U IO(0) W !!,*7,"ERROR IN STATE CODE..." G ABNEND
;
A ;
;I '$D(FAC) U IO(0) W !!,"ERROR IN FAC. CODE..." G ABEND
S FILEN=54
U IO(0) R !!,"Enter Month_Year of file to Load: eg. 101999: ",MY
I MY'?6N W *7," ??" H 2 G A
;S FILENAME="/pub/nevelg."_MY
S FILENAME="/usr/spool/uucppublic/azelg."_MY
O FILEN:(FILENAME:"R"):1
E U IO(0) W *7," NO DATA FILE FOR SAID MONTH-YEAR!!" G ABNEND
S X=$E(MY,1,2)_"-"_$E(MY,3,6),%DT="" D ^%DT S UPMONTH=Y
I $D(^BZDMCDDL(UPMONTH)) U IO(0) W *7,"That month is already loaded.." H 2 G ABNEND
;
;
K ^BZDMTEMP("CT",MY)
;
;D DATES
;D LOADMEDN
K ^ZZDINA(MY)
;
JUMP ;
; use this if don't want to recreate the temp file & start with st1
;G DATA
;
;
D TIME^BZDMUT
S ^BZDMTEMP("TIME","SSN","MNO")=BZDTIME1
U IO(0) W !!,"Reading data from file. Please hold.....",!
F I=1:1 U FILEN R AZBM("REC") Q:(AZBM("REC")="")!(AZBM("REC")="**") D
.S CT=CT+1
.;S ^BZDMTEMP(CT)=AZBM("REC") ;dmh don't need this 4/6/2000
.S MSSN=$E(AZBM("REC"),27,35)
.S MNO=$E(AZBM("REC"),18,26)
.S MDOB=$E(AZBM("REC"),143,150) ;9-6-2000
.;I $D(^BZDM("MEDNO",MNO)) S ^BZDMTEMP("MEDNO",MNO)=""
.;S ^BZDMTEMP("SSN",MSSN)=AZBM("REC") ;dmh only set if in dpt 4/6
.;I $D(^AUPNMCD("AB",MNO)) S ^BZDMTEMP("MNO",MNO)=AZBM("REC")
.;E I $D(^DPT("SSN",MSSN)) S ^BZDMTEMP("SSN",MSSN)=AZBM("REC") ;added 4/6/2000
.I CT#1000=0 U 0 W "."
.D MNOCK I MNOFL="Y" Q
.E D SSNCK ;9-6-2000
.Q
D TIME^BZDMUT
S $P(^BZDMTEMP("TIME","SSN","MNO"),"^",2)=BZDTIME1
DATA ;
;Q ;put quit here for test 9-6-2000
;
B
D TIME^BZDMUT
S $P(^BZDMTEMP("TIME","SSN"),"^",1)=BZDTIME1
;
U IO(0) W !!,"Matching and uploading data to Registration now...."
S AZBM("MSSN")=0
;
; next f is for test only 9-6-2000
;
;F S AZBM("MSSN")=$O(^BZDMTEMP("SSN",AZBM("MSSN"))) Q:AZBM("MSSN")="" D
S SCT=0
F S AZBM("MSSN")=$O(^BZDMTEMP("SSN",AZBM("MSSN"))) Q:AZBM("MSSN")="" D
.S SSNDFN=0
.; SSNDFN is the ien for the patient in dpt
.F S SSNDFN=$O(^BZDMTEMP("SSN",AZBM("MSSN"),SSNDFN)) Q:SSNDFN="" D
..S ^BZDMTEMP("LAST READ","SSN")=AZBM("MSSN")_","_SSNDFN
..S SCT=SCT+1
..I SCT#100=0 U IO(0) W "."
..;S PATDFN=$O(^DPT("SSN",AZBM("MSSN"),0)) Q:+PATDFN=0
..; commented out and added the next set 9-6-2000
..;
..S PATDFN=SSNDFN
..D DUZHRN I '$D(HRN) S ^BZDMERST(TODAY,"INACT",PATDFN)="",ER(10)=$G(ER(10))+1 Q
..S MREC=^BZDMTEMP("SSN",AZBM("MSSN"),SSNDFN)
..D STUFF
..Q
D TIME^BZDMUT
S $P(^BZDMTEMP("TIME","SSN"),"^",2)=BZDTIME1
G DATA1
;
DATA1 ;
;Q ;put quit here for test 9-6-2000
;
;
D TIME^BZDMUT
S $P(^BZDMTEMP("TIME","MNO"),"^",1)=BZDTIME1
;
S MNOCT=0
S AZBM("MNO")=0
F S AZBM("MNO")=$O(^BZDMTEMP("MNO",AZBM("MNO"))) Q:AZBM("MNO")="" D
.S MCDDFN=0
.F S MCDDFN=$O(^BZDMTEMP("MNO",AZBM("MNO"),MCDDFN)) Q:MCDDFN="" D
..S ^BZDMTEMP("LAST READ","MNO")=AZBM("MNO")_","_MCDDFN
..S MNOCT=MNOCT+1
..I MNOCT#100=0 U IO(0) W ":"
..S DFN=MCDDFN Q:+DFN=0
..S PATDFN=$P(^AUPNMCD(DFN,0),"^",1)
..D DUZHRN I '$D(HRN) S ^BZDERST(TODAY,"INACT",PATDFN)="",ER(10)=$G(ER(10))+1 Q
..S MREC=^BZDMTEMP("MNO",AZBM("MNO"),MCDDFN)
..D STUFF
..Q
D TIME^BZDMUT
S $P(^BZDMTEMP("TIME","MNO"),"^",2)=BZDTIME1
G END
STUFF ;STUFF DATA
;
;
S LN=$E(MREC,108,130)
S FN=$E(MREC,131,140)
S MI=$E(MREC,141)
F Q:$E(LN,1)'=" " S LN=$E(LN,2,30) ;strip leading spaces
F S L=$L(LN) Q:$E(LN,L)'=" " S LN=$E(LN,1,L-1) ;strip trailing spaces
;S FN=$P(MREC,",",2)
F Q:$E(FN,1)'=" " S FN=$E(FN,2,30) ;strip leading spaces
F S L=$L(FN) Q:$E(FN,L)'=" " S FN=$E(FN,1,L-1) ;strip trailing spaces
S MEDNAME=LN_","_FN
;
;
S MEDNO=$E(MREC,18,26)
S RATECD=$E(MREC,355,358)
ELDTS ; set start and end dates
S X=$E(MREC,404,411)
S X=$E(X,5,6)_$E(X,7,8)_$E(X,1,4) D ^%DT S STDT=Y
I +STDT<1 Q
S X=$E(MREC,412,419)
S X=$E(X,5,6)_$E(X,7,8)_$E(X,1,4) D ^%DT S ENDDT=Y
I +ENDDT<1 Q
DOB ;
S MEDDOB=$E(MREC,143,150)
I $L(MEDDOB)=8 D
.S MEDDOB=$E(MEDDOB,5,6)_$E(MEDDOB,7,8)_$E(MEDDOB,1,4)
E S MEDDOB=""
;
;
;
I '$D(^AUPNMCD("B",PATDFN)) S NEW=NEW+1 S ^BZDMTEMP("NEW",PATDFN)="",NU="N"
E S UPDATE=UPDATE+1 S ^BZDMTEMP("UPDATE",PATDFN)="",NU="U"
;
;
;S DIC="^AUPNMCD(",DIC(0)="ZLM",X=PATDFN,DLAYGO=9000004 D ^DIC
S DIC="^AUPNMCD(",DIC(0)="ZLM",X=HRN,DLAYGO=9000004 D ^DIC
I Y'=-1 S MEDDFN=$P(Y,"^",1)
E S ^BZDMERST(TODAY,2,PATDFN)="" S ER(2)=$G(ER(2))+1 Q
S $P(^AUPNMCD(MEDDFN,0),"^",2)=INS
S $P(^AUPNMCD(MEDDFN,0),"^",4)=STATE
S $P(^AUPNMCD(MEDDFN,0),"^",10)=PLAN
S $P(^AUPNMCD(MEDDFN,0),"^",11)=RATECD
S DR=".03////"_MEDNO_";.08////"_TODAY_";.05////"_MEDNAME,DIE="^AUPNMCD(",DA=MEDDFN
S DR=DR_";2101////"_MEDNAME
I MEDDOB'="" S DR=DR_";2102///"_MEDDOB
D ^DIE
S COUNT=COUNT+1
S ^ZZDINA(MY,MEDDFN)=PATDFN
ELIG S E=0
ELIG1 ;
D NOENDCK
S FL=0
I $D(^AUPNMCD(MEDDFN,11,STDT)) D CKDT Q ;I FL=1 G ELIG1
;
S FL=0 D DTCONT I FL=1 Q
;
S DIC="^AUPNMCD(MEDDFN,11,",DIC(0)="ZLM"
S DA(1)=MEDDFN
S X=STDT
S DINUM=X
S DIC("DR")=".02////"_ENDDT
K DD,DO
S:'$D(@(DIC_"0)")) @(DIC_"0)")="^9000004.11"
D FILE^DICN
S NEWCHG(NU)=$G(NEWCHG(NU))+1
Q
ABNEND ;ABNORMAL END OF JOB
U IO(0) W !!,"CONTACT PROGRAMMER!!"
D ^%ZISC
Q
;
NOENDCK ; check to see if no ending date on any of the records on a patient
; that just got updated 9/7/2000
S NOENDFL="N"
S NOEND=0
F S NOEND=$O(^AUPNMCD(MEDDFN,11,NOEND)) Q:NOEND="" D Q:NOENDFL="Y"
.S RECORD=$G(^AUPNMCD(MEDDFN,11,NOEND,0))
.Q:RECORD=""
.I $P(RECORD,"^",2)="" D
..S ^BZDERST(TODAY,"NOEND",PATDFN)=""
..S ER(20)=$G(ER(20))+1
..S NOENDFL="Y"
Q
;
SSNCK ; 9-6-2000
; check if ssn is onfile also check the dob; per Glen the state
; file has the same ssn on multiple people
S SSNFL="N"
K SSNDFN
Q:'$D(MDOB)
Q:MDOB=""
S X=$E(MDOB,5,6)_$E(MDOB,7,8)_$E(MDOB,1,4)
D ^%DT
S MDOB=Y
I $D(^DPT("SSN",MSSN))
E Q
S SSNDFN=0
F S SSNDFN=$O(^DPT("SSN",MSSN,SSNDFN)) Q:+SSNDFN=0 D Q:SSNFL="Y"
.I MDOB=$P(^DPT(SSNDFN,0),"^",3) S SSNFL="Y"
;I (SSNFL="Y"),(+SSNDFN'=0) S ^BZDMTEMP("SSN",MSSN,SSNDFN)=AZBM("REC")
I (SSNFL="Y"),(+SSNDFN'=0) S ^BZDMTEMP("SSN",MSSN,SSNDFN)=$E(AZBM("REC"),1,500)
I (SSNFL="Y"),(+SSNDFN'=0) S ^BZDMTEMP("CT",MY,"SSN")=$G(^BZDMTEMP("CT",MY,"SSN"))+1
Q
;
MNOCK ;
S MNOFL="N"
;S X=MNO
;S DIC="^AUPNMCD(",DIC(0)="MZ" D ^DIC
;I Y'="-1" S MCDDFN=$P(Y,"^",1) S MNOFL="Y"
;;I MNOFL="Y" S ^BZDMTEMP("MNO",MNO,MCDDFN)=AZBM("REC")
I $D(^BZDMTEMP("INDX",MNO)) D
.S MCDDFN=$O(^BZDMTEMP("INDX",MNO,0))
.S MNOFL="Y"
I MNOFL="Y" S ^BZDMTEMP("MNO",MNO,MCDDFN)=$E(AZBM("REC"),1,500)
I MNOFL="Y" S ^BZDMTEMP("CT",MY,"MNO")=$G(^BZDMTEMP("CT",MY,"MNO"))+1
Q
DATES ;
S X=$E(MY,1,2)_"01"_$E(MY,3,6) D ^%DT S STDT=Y
S EMO=$E(MY,1,2)
I (EMO="01")!(EMO="03")!(EMO="05")!(EMO="07")!(EMO="08")!(EMO="10")!(EMO="12") S ENDDAY=31
I (EMO="04")!(EMO="06")!(EMO="09")!(EMO="11") S ENDDAY=30
I (EMO="02") S ENDDAY=28
S X=$E(MY,1,2)_ENDDAY_$E(MY,3,6) D ^%DT S ENDDT=Y
Q
SSNSET ;STUFF SSN FROM THE MEDICAID DOWNLOAD TO THE DPT FILE
;I (DPTSSN="")!($E(DPTSSN,1,3)=999)!($E(DPTSSN,1,3)="000")
I (ST=1),((MEDNO=999999999)!(MEDNO="000000000")) Q
I (ST=2),((WYSSN=999999999)!(WYSSN="000000000")) Q
I (DPTSSN="")!(DPTSSN="999999999")!(DPTSSN="999-99-9999")!(DPTSSN="000000000")!(DPTSSN="000-00-0000")
E Q
S DIE="^DPT(",DA=PATDFN,DR=".09////"_MEDNO
D ^DIE
S SSNCT=SSNCT+1
I '$D(^AZMEDSSN(TODAY,0)) S ^AZMEDSSN(TODAY,0)=$P(^AZMEDDL(FAC,0),"^",1)_"^0"
S ^AZMEDSSN(TODAY,PATDFN)=$S(ST=1:MEDNO,ST=2:WYSSN)_"^"_DPTSSN,$P(^AZMEDSSN(TODAY,0),"^",2)=$P(^AZMEDSSN(TODAY,0),"^",2)+1
S ^AGPATCH(TODAY,DUZ(2),PATDFN)=""
Q
CKDT ;CHECK IF THE START DATE IS ALREADY ON FILE
S OLD=^AUPNMCD(MEDDFN,11,STDT,0)
I $P(OLD,"^",2)'=ENDDT D
.S $P(^AUPNMCD(MEDDFN,11,STDT,0),"^",2)=ENDDT
.S STDTCHG(NU)=$G(STDTCHG(NU))+1
.S FL=1
.Q
Q
DTCONT ;
; check on the multiples already onfile to see if this new date range
; can be a continuation of a record already on file
; instead of recreating a new record for each new month.
S X1=STDT,X2="-1" D C^%DTC S DTBFR=X ;set date before start dt
I +DTBFR<1 Q
S LOOP=0
F S LOOP=$O(^AUPNMCD(MEDDFN,11,LOOP)) Q:LOOP="" D Q:FL=1
.S LOOPREC=$G(^AUPNMCD(MEDDFN,11,LOOP,0))
.Q:LOOPREC=""
.S LOOPEND=$P(LOOPREC,"^",2)
.Q:LOOPEND'=DTBFR
.I LOOPEND=DTBFR D
..S ^ZZDINA("ENDCHG",MEDDFN,LOOP)=LOOPEND_"^"_ENDDT
..S ENDCHG(NU)=$G(ENDCHG(NU))+1
..S FL=1
..S $P(^AUPNMCD(MEDDFN,11,LOOP,0),"^",2)=ENDDT
..Q
.Q
Q
;
;
Q
END ;
;
U IO(0) W !!,"TOTAL NUMBER OF MEDICAID ELIG. STUFFED: ",COUNT
U IO(0) W !!,"TOTAL NEW OF MEDICAID PATIENTS: ",NEW
W !,?10,"Total new nodes: ",$G(NEWCHG("N"))
W !,?10,"Total w/start node there with end chg: ",$G(STDTCHG("N"))
W !,?10,"Total end dt chg of existing node: ",$G(ENDCHG("N"))
U IO(0) W !!,"TOTAL MEDICAID ELIG. PATIENTS UPDATED: ",UPDATE
W !,?10,"Total new nodes: ",$G(NEWCHG("U"))
W !,?10,"Total w/start node there with end chg: ",$G(STDTCHG("U"))
W !,?10,"Total end dt chg of existing node: ",$G(ENDCHG("U"))
U IO(0) W !!,"TOTAL PATIENTS (that were updated) with NO end date=",$G(ER(20))
U IO(0) W !!,"TOTAL INACTIVE HRN ERRORS= ",$G(ER(10))
U IO(0) W !!,"TOTAL MEDICAID ELIG. STUFF ERRORS= ",$G(ER(2))
;S FACNAME=$P(^DIC(4,ORGDUZ(2),0),"^",1)
U IO(0) W !,"DOWNLOAD FOR--MEDICAID IS DONE!!!!"
U IO(0) W !,TODAY
;K ER
S ^BZDMCDLG(UPMONTH)=UPMONTH_"^"_TODAY
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(COUNT)
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(NEW)
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(NEWCHG("N"))
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(STDTCHG("N"))
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(ENDCHG("N"))
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(UPDATE)
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(NEWCHG("U"))
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(STDTCHG("U"))
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(ENDCHG("U"))
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(ER(20))
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(ER(10))
S ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$G(ER(2))
K AZBM
;S DIC="^BZDMCDNV(",DIC(0)="ZLM",X=UPMONTH D ^DIC
S DIC="^BZDMCDDL(",DIC(0)="ZLM",X=+$E(MY,1,2)_"-"_$E(MY,3,6),DIC("DR")=".02///"_TODAY
S DIC("DR")=DIC("DR")_";.03///"_+$G(COUNT)
S DIC("DR")=DIC("DR")_";.04///"_+$G(NEW)
S DIC("DR")=DIC("DR")_";.05///"_+$G(NEWCHG("N"))
S DIC("DR")=DIC("DR")_";.06///"_+$G(STDTCHG("N"))
S DIC("DR")=DIC("DR")_";.07///"_+$G(ENDCHG("N"))
S DIC("DR")=DIC("DR")_";.08///"_+$G(UPDATE)
S DIC("DR")=DIC("DR")_";.09///"_+$G(NEWCHG("U"))
S DIC("DR")=DIC("DR")_";10///"_+$G(STDTCHG("U"))
S DIC("DR")=DIC("DR")_";11///"_+$G(ENDCHG("U"))
S DIC("DR")=DIC("DR")_";12///"_+$G(ER(20))
S DIC("DR")=DIC("DR")_";13///"_+$G(ER(10))
S DIC("DR")=DIC("DR")_";14///"_+$G(ER(2))
D ^DIC
U 0 W !! D ^%T
D ^%ZISC
Q
DUZHRN ;
K HRN
S DUZ(2)=0
F S DUZ(2)=$O(^AUPNPAT(PATDFN,41,DUZ(2))) Q:+DUZ(2)=0 D Q:$D(HRN)
.S HRNREC=$G(^AUPNPAT(PATDFN,41,DUZ(2),0))
.I $P(HRNREC,"^",3)="" S HRN=$P(HRNREC,"^",2)
Q
LOADMEDN ;load the medno from aupnmcd file to BZDMTEMP("MEDNO") to match on this
;maybe
; don't need 4/6/2000 dmh
Q
K ^BZDM("MEDNO")
S GLOB="^AUPNMCD(""AB"")"
F S GLOB=$Q(@GLOB) Q:GLOB'["^AUPNMCD(""AB""" Q:GLOB="" D
.I $P(GLOB,",",1)["AUPNMCD" S MN=$P(GLOB,",",4),^BZDM("MEDNO",MN)=""
BZDMCDAZ ;IHS/BAO/DMH load mcaid elg. from ARIZONA STATE [ 09/14/2000 4:25 PM ]
+1 ; dmh 8/21/2000
+2 ; revised copy of BZDMCDNV
+3 ;
+4 ; dmh 3/21/2000
+5 ; revised copy of AZBMESTU
+6 ;
+7 ;
+8 ;ROUTINE TO AUTOMATICALLY STUFF THE MEDICAID ELIGIBLE [ 01/02/96 10:19 AM ]
+9 ;FILE AT THE SERVICE UNITS USING THE AZMEDDL GLOBAL CREATED AT THE
+10 ;AREA B SYSTEM. THE DATA CAME FROM THE MASTER GLOBAL AFTER ALL THE
+11 ;MEDICAID ELIGABLE DATA WAS DOWNLOADED FROM THE STATE TAPES.
+12 ;THIS WILL NEED TO BE DONE ON A MONTHLY BASIS IN ORDER TO GET ALL THE
+13 ;UPDATE DATES THAT THE STATE SENDS EACH MONTH.
+14 ;^BZDMTEMP(0) HOLDS LAST ACCESSED HRN FROM MED UNIX FILE IF NEED
+15 ;TO DO RESET.
+16 ;AMH-BAO 7/12/91
+17 ;K ^BZDMTEMP
+18 KILL ^BZDMTEMP("SSN")
+19 KILL ^BZDMTEMP("NEW")
+20 KILL ^BZDMTEMP("UPDATE")
+21 KILL ^BZDMTEMP("MEDNO")
+22 KILL ^BZDMTEMP("MNO")
+23 ;for creating own index 9/8/2000
KILL ^BZDMTEMP("INDX")
+24 ;K ^BZDMERST("A")
+25 KILL ^BZDM("MEDNO")
+26 KILL AZBM
+27 ;
+28 DO INDX^BZDMUT
+29 IF '$DATA(^BZDMTEMP("INDX"))
USE 0
WRITE *7,!!,"Index is not set!!"
HANG 2
QUIT
+30 ;
ST1 ;
+1 USE 0
WRITE !
DO ^%T
+2 IF '$DATA(DUZ(2))
DO ^XBKVAR
+3 IF +DUZ(2)=0
KILL DUZ(2)
DO ^XBKVAR
+4 SET ORGDUZ(2)=DUZ(2)
+5 SET NEW=0
+6 SET UPDATE=0
+7 SET SSNCT=0
+8 SET COUNT=0
+9 SET CT=0
+10 SET ER(1)=0
SET ER(2)=0
SET ER("P")=0
SET ER("HR")=0
+11 SET %DT=""
SET X="T"
DO ^%DT
SET TODAY=Y
+12 DO ^%ZIS
+13 ;S FACNAME=$P(^DIC(4,ORGDUZ(2),0),"^",1)
+14 ;U IO(0) W !,"DOWNLOAD FOR--",FACNAME
+15 USE IO(0)
WRITE !!!!!,"DOWNLOAD FOR--MEDICAID ELIGIBILITY"
+16 USE IO(0)
WRITE !,TODAY
+17 ;
+18 ;
SSNQ ;U IO(0) R !!,"STUFF VALID SSN'S? (Y or N) ",SSNQ
+1 ;I (SSNQ'="N")&(SSNQ'="Y") W *7," ??" H 2 G SSNQ
+2 ;
+3 ;
+4 SET FAC=$PIECE(^AUTTLOC(DUZ(2),0),"^",10)
+5 IF '$DATA(^AUPNMCD(0))
SET ^AUPNMCD(0)="MEDICAID ELIGIBLE^9000004PI^0^0"
+6 ;
INS ;GET MEDICAID INTERNAL NUMBER FOR EACH RECORD
+1 SET DIC="^AUTNINS("
SET DIC(0)="XZIMO"
SET X="MEDICAID"
DO ^DIC
+2 IF Y'=-1
SET INS=$PIECE(Y,"^",1)
+3 IF '$TEST
USE IO(0)
WRITE !!,*7,"ERROR IN INSURER FILE..."
GOTO ABNEND
+4 SET DIC="^AUTNINS("
SET DIC(0)="XZIMO"
SET X="ARIZONA MEDICAID"
DO ^DIC
+5 IF Y'=-1
SET PLAN=$PIECE(Y,"^",1)
+6 IF '$TEST
USE IO(0)
WRITE !!,*7,"ERROR IN INSURER FILE (PLAN)..."
GOTO ABNEND
+7 ;
STATE ;GET STATE NUMBER
+1 ;U IO(0) R !!,"ENTER MEDICAID STATE CODE 1=MONTANA 2=WYOMING : ",ST
+2 ;I ST="^" G ABNEND
+3 ;I (ST'=1)&(ST'=2) U IO(0) W *7," ??" H 2 G STATE
+4 ;I ST=1 S X="MONTANA"
+5 ;I ST=2 S X="WYOMING"
+6 ;S ST=2,X="WYOMING"
+7 ;
+8 ;
+9 SET ST=4
SET X="ARIZONA"
+10 SET DIC="^DIC(5,"
SET DIC(0)="ZM"
DO ^DIC
+11 IF Y'=-1
SET STATE=$PIECE(Y,"^",1)
+12 IF '$TEST
USE IO(0)
WRITE !!,*7,"ERROR IN STATE CODE..."
GOTO ABNEND
+13 ;
A ;
+1 ;I '$D(FAC) U IO(0) W !!,"ERROR IN FAC. CODE..." G ABEND
+2 SET FILEN=54
+3 USE IO(0)
READ !!,"Enter Month_Year of file to Load: eg. 101999: ",MY
+4 IF MY'?6N
WRITE *7," ??"
HANG 2
GOTO A
+5 ;S FILENAME="/pub/nevelg."_MY
+6 SET FILENAME="/usr/spool/uucppublic/azelg."_MY
+7 OPEN FILEN:(FILENAME:"R"):1
+8 IF '$TEST
USE IO(0)
WRITE *7," NO DATA FILE FOR SAID MONTH-YEAR!!"
GOTO ABNEND
+9 SET X=$EXTRACT(MY,1,2)_"-"_$EXTRACT(MY,3,6)
SET %DT=""
DO ^%DT
SET UPMONTH=Y
+10 IF $DATA(^BZDMCDDL(UPMONTH))
USE IO(0)
WRITE *7,"That month is already loaded.."
HANG 2
GOTO ABNEND
+11 ;
+12 ;
+13 KILL ^BZDMTEMP("CT",MY)
+14 ;
+15 ;D DATES
+16 ;D LOADMEDN
+17 KILL ^ZZDINA(MY)
+18 ;
JUMP ;
+1 ; use this if don't want to recreate the temp file & start with st1
+2 ;G DATA
+3 ;
+4 ;
+5 DO TIME^BZDMUT
+6 SET ^BZDMTEMP("TIME","SSN","MNO")=BZDTIME1
+7 USE IO(0)
WRITE !!,"Reading data from file. Please hold.....",!
+8 FOR I=1:1
USE FILEN
READ AZBM("REC")
IF (AZBM("REC")="")!(AZBM("REC")="**")
QUIT
Begin DoDot:1
+9 SET CT=CT+1
+10 ;S ^BZDMTEMP(CT)=AZBM("REC") ;dmh don't need this 4/6/2000
+11 SET MSSN=$EXTRACT(AZBM("REC"),27,35)
+12 SET MNO=$EXTRACT(AZBM("REC"),18,26)
+13 ;9-6-2000
SET MDOB=$EXTRACT(AZBM("REC"),143,150)
+14 ;I $D(^BZDM("MEDNO",MNO)) S ^BZDMTEMP("MEDNO",MNO)=""
+15 ;S ^BZDMTEMP("SSN",MSSN)=AZBM("REC") ;dmh only set if in dpt 4/6
+16 ;I $D(^AUPNMCD("AB",MNO)) S ^BZDMTEMP("MNO",MNO)=AZBM("REC")
+17 ;E I $D(^DPT("SSN",MSSN)) S ^BZDMTEMP("SSN",MSSN)=AZBM("REC") ;added 4/6/2000
+18 IF CT#1000=0
USE 0
WRITE "."
+19 DO MNOCK
IF MNOFL="Y"
QUIT
+20 ;9-6-2000
IF '$TEST
DO SSNCK
+21 QUIT
End DoDot:1
+22 DO TIME^BZDMUT
+23 SET $PIECE(^BZDMTEMP("TIME","SSN","MNO"),"^",2)=BZDTIME1
DATA ;
+1 ;Q ;put quit here for test 9-6-2000
+2 ;
+3 BREAK
+4 DO TIME^BZDMUT
+5 SET $PIECE(^BZDMTEMP("TIME","SSN"),"^",1)=BZDTIME1
+6 ;
+7 USE IO(0)
WRITE !!,"Matching and uploading data to Registration now...."
+8 SET AZBM("MSSN")=0
+9 ;
+10 ; next f is for test only 9-6-2000
+11 ;
+12 ;F S AZBM("MSSN")=$O(^BZDMTEMP("SSN",AZBM("MSSN"))) Q:AZBM("MSSN")="" D
+13 SET SCT=0
+14 FOR
SET AZBM("MSSN")=$ORDER(^BZDMTEMP("SSN",AZBM("MSSN")))
IF AZBM("MSSN")=""
QUIT
Begin DoDot:1
+15 SET SSNDFN=0
+16 ; SSNDFN is the ien for the patient in dpt
+17 FOR
SET SSNDFN=$ORDER(^BZDMTEMP("SSN",AZBM("MSSN"),SSNDFN))
IF SSNDFN=""
QUIT
Begin DoDot:2
+18 SET ^BZDMTEMP("LAST READ","SSN")=AZBM("MSSN")_","_SSNDFN
+19 SET SCT=SCT+1
+20 IF SCT#100=0
USE IO(0)
WRITE "."
+21 ;S PATDFN=$O(^DPT("SSN",AZBM("MSSN"),0)) Q:+PATDFN=0
+22 ; commented out and added the next set 9-6-2000
+23 ;
+24 SET PATDFN=SSNDFN
+25 DO DUZHRN
IF '$DATA(HRN)
SET ^BZDMERST(TODAY,"INACT",PATDFN)=""
SET ER(10)=$GET(ER(10))+1
QUIT
+26 SET MREC=^BZDMTEMP("SSN",AZBM("MSSN"),SSNDFN)
+27 DO STUFF
+28 QUIT
End DoDot:2
End DoDot:1
+29 DO TIME^BZDMUT
+30 SET $PIECE(^BZDMTEMP("TIME","SSN"),"^",2)=BZDTIME1
+31 GOTO DATA1
+32 ;
DATA1 ;
+1 ;Q ;put quit here for test 9-6-2000
+2 ;
+3 ;
+4 DO TIME^BZDMUT
+5 SET $PIECE(^BZDMTEMP("TIME","MNO"),"^",1)=BZDTIME1
+6 ;
+7 SET MNOCT=0
+8 SET AZBM("MNO")=0
+9 FOR
SET AZBM("MNO")=$ORDER(^BZDMTEMP("MNO",AZBM("MNO")))
IF AZBM("MNO")=""
QUIT
Begin DoDot:1
+10 SET MCDDFN=0
+11 FOR
SET MCDDFN=$ORDER(^BZDMTEMP("MNO",AZBM("MNO"),MCDDFN))
IF MCDDFN=""
QUIT
Begin DoDot:2
+12 SET ^BZDMTEMP("LAST READ","MNO")=AZBM("MNO")_","_MCDDFN
+13 SET MNOCT=MNOCT+1
+14 IF MNOCT#100=0
USE IO(0)
WRITE ":"
+15 SET DFN=MCDDFN
IF +DFN=0
QUIT
+16 SET PATDFN=$PIECE(^AUPNMCD(DFN,0),"^",1)
+17 DO DUZHRN
IF '$DATA(HRN)
SET ^BZDERST(TODAY,"INACT",PATDFN)=""
SET ER(10)=$GET(ER(10))+1
QUIT
+18 SET MREC=^BZDMTEMP("MNO",AZBM("MNO"),MCDDFN)
+19 DO STUFF
+20 QUIT
End DoDot:2
End DoDot:1
+21 DO TIME^BZDMUT
+22 SET $PIECE(^BZDMTEMP("TIME","MNO"),"^",2)=BZDTIME1
+23 GOTO END
STUFF ;STUFF DATA
+1 ;
+2 ;
+3 SET LN=$EXTRACT(MREC,108,130)
+4 SET FN=$EXTRACT(MREC,131,140)
+5 SET MI=$EXTRACT(MREC,141)
+6 ;strip leading spaces
FOR
IF $EXTRACT(LN,1)'=" "
QUIT
SET LN=$EXTRACT(LN,2,30)
+7 ;strip trailing spaces
FOR
SET L=$LENGTH(LN)
IF $EXTRACT(LN,L)'=" "
QUIT
SET LN=$EXTRACT(LN,1,L-1)
+8 ;S FN=$P(MREC,",",2)
+9 ;strip leading spaces
FOR
IF $EXTRACT(FN,1)'=" "
QUIT
SET FN=$EXTRACT(FN,2,30)
+10 ;strip trailing spaces
FOR
SET L=$LENGTH(FN)
IF $EXTRACT(FN,L)'=" "
QUIT
SET FN=$EXTRACT(FN,1,L-1)
+11 SET MEDNAME=LN_","_FN
+12 ;
+13 ;
+14 SET MEDNO=$EXTRACT(MREC,18,26)
+15 SET RATECD=$EXTRACT(MREC,355,358)
ELDTS ; set start and end dates
+1 SET X=$EXTRACT(MREC,404,411)
+2 SET X=$EXTRACT(X,5,6)_$EXTRACT(X,7,8)_$EXTRACT(X,1,4)
DO ^%DT
SET STDT=Y
+3 IF +STDT<1
QUIT
+4 SET X=$EXTRACT(MREC,412,419)
+5 SET X=$EXTRACT(X,5,6)_$EXTRACT(X,7,8)_$EXTRACT(X,1,4)
DO ^%DT
SET ENDDT=Y
+6 IF +ENDDT<1
QUIT
DOB ;
+1 SET MEDDOB=$EXTRACT(MREC,143,150)
+2 IF $LENGTH(MEDDOB)=8
Begin DoDot:1
+3 SET MEDDOB=$EXTRACT(MEDDOB,5,6)_$EXTRACT(MEDDOB,7,8)_$EXTRACT(MEDDOB,1,4)
End DoDot:1
+4 IF '$TEST
SET MEDDOB=""
+5 ;
+6 ;
+7 ;
+8 IF '$DATA(^AUPNMCD("B",PATDFN))
SET NEW=NEW+1
SET ^BZDMTEMP("NEW",PATDFN)=""
SET NU="N"
+9 IF '$TEST
SET UPDATE=UPDATE+1
SET ^BZDMTEMP("UPDATE",PATDFN)=""
SET NU="U"
+10 ;
+11 ;
+12 ;S DIC="^AUPNMCD(",DIC(0)="ZLM",X=PATDFN,DLAYGO=9000004 D ^DIC
+13 SET DIC="^AUPNMCD("
SET DIC(0)="ZLM"
SET X=HRN
SET DLAYGO=9000004
DO ^DIC
+14 IF Y'=-1
SET MEDDFN=$PIECE(Y,"^",1)
+15 IF '$TEST
SET ^BZDMERST(TODAY,2,PATDFN)=""
SET ER(2)=$GET(ER(2))+1
QUIT
+16 SET $PIECE(^AUPNMCD(MEDDFN,0),"^",2)=INS
+17 SET $PIECE(^AUPNMCD(MEDDFN,0),"^",4)=STATE
+18 SET $PIECE(^AUPNMCD(MEDDFN,0),"^",10)=PLAN
+19 SET $PIECE(^AUPNMCD(MEDDFN,0),"^",11)=RATECD
+20 SET DR=".03////"_MEDNO_";.08////"_TODAY_";.05////"_MEDNAME
SET DIE="^AUPNMCD("
SET DA=MEDDFN
+21 SET DR=DR_";2101////"_MEDNAME
+22 IF MEDDOB'=""
SET DR=DR_";2102///"_MEDDOB
+23 DO ^DIE
+24 SET COUNT=COUNT+1
+25 SET ^ZZDINA(MY,MEDDFN)=PATDFN
ELIG SET E=0
ELIG1 ;
+1 DO NOENDCK
+2 SET FL=0
+3 ;I FL=1 G ELIG1
IF $DATA(^AUPNMCD(MEDDFN,11,STDT))
DO CKDT
QUIT
+4 ;
+5 SET FL=0
DO DTCONT
IF FL=1
QUIT
+6 ;
+7 SET DIC="^AUPNMCD(MEDDFN,11,"
SET DIC(0)="ZLM"
+8 SET DA(1)=MEDDFN
+9 SET X=STDT
+10 SET DINUM=X
+11 SET DIC("DR")=".02////"_ENDDT
+12 KILL DD,DO
+13 IF '$DATA(@(DIC_"0)"))
SET @(DIC_"0)")="^9000004.11"
+14 DO FILE^DICN
+15 SET NEWCHG(NU)=$GET(NEWCHG(NU))+1
+16 QUIT
ABNEND ;ABNORMAL END OF JOB
+1 USE IO(0)
WRITE !!,"CONTACT PROGRAMMER!!"
+2 DO ^%ZISC
+3 QUIT
+4 ;
NOENDCK ; check to see if no ending date on any of the records on a patient
+1 ; that just got updated 9/7/2000
+2 SET NOENDFL="N"
+3 SET NOEND=0
+4 FOR
SET NOEND=$ORDER(^AUPNMCD(MEDDFN,11,NOEND))
IF NOEND=""
QUIT
Begin DoDot:1
+5 SET RECORD=$GET(^AUPNMCD(MEDDFN,11,NOEND,0))
+6 IF RECORD=""
QUIT
+7 IF $PIECE(RECORD,"^",2)=""
Begin DoDot:2
+8 SET ^BZDERST(TODAY,"NOEND",PATDFN)=""
+9 SET ER(20)=$GET(ER(20))+1
+10 SET NOENDFL="Y"
End DoDot:2
End DoDot:1
IF NOENDFL="Y"
QUIT
+11 QUIT
+12 ;
SSNCK ; 9-6-2000
+1 ; check if ssn is onfile also check the dob; per Glen the state
+2 ; file has the same ssn on multiple people
+3 SET SSNFL="N"
+4 KILL SSNDFN
+5 IF '$DATA(MDOB)
QUIT
+6 IF MDOB=""
QUIT
+7 SET X=$EXTRACT(MDOB,5,6)_$EXTRACT(MDOB,7,8)_$EXTRACT(MDOB,1,4)
+8 DO ^%DT
+9 SET MDOB=Y
+10 IF $DATA(^DPT("SSN",MSSN))
+11 IF '$TEST
QUIT
+12 SET SSNDFN=0
+13 FOR
SET SSNDFN=$ORDER(^DPT("SSN",MSSN,SSNDFN))
IF +SSNDFN=0
QUIT
Begin DoDot:1
+14 IF MDOB=$PIECE(^DPT(SSNDFN,0),"^",3)
SET SSNFL="Y"
End DoDot:1
IF SSNFL="Y"
QUIT
+15 ;I (SSNFL="Y"),(+SSNDFN'=0) S ^BZDMTEMP("SSN",MSSN,SSNDFN)=AZBM("REC")
+16 IF (SSNFL="Y")
IF (+SSNDFN'=0)
SET ^BZDMTEMP("SSN",MSSN,SSNDFN)=$EXTRACT(AZBM("REC"),1,500)
+17 IF (SSNFL="Y")
IF (+SSNDFN'=0)
SET ^BZDMTEMP("CT",MY,"SSN")=$GET(^BZDMTEMP("CT",MY,"SSN"))+1
+18 QUIT
+19 ;
MNOCK ;
+1 SET MNOFL="N"
+2 ;S X=MNO
+3 ;S DIC="^AUPNMCD(",DIC(0)="MZ" D ^DIC
+4 ;I Y'="-1" S MCDDFN=$P(Y,"^",1) S MNOFL="Y"
+5 ;;I MNOFL="Y" S ^BZDMTEMP("MNO",MNO,MCDDFN)=AZBM("REC")
+6 IF $DATA(^BZDMTEMP("INDX",MNO))
Begin DoDot:1
+7 SET MCDDFN=$ORDER(^BZDMTEMP("INDX",MNO,0))
+8 SET MNOFL="Y"
End DoDot:1
+9 IF MNOFL="Y"
SET ^BZDMTEMP("MNO",MNO,MCDDFN)=$EXTRACT(AZBM("REC"),1,500)
+10 IF MNOFL="Y"
SET ^BZDMTEMP("CT",MY,"MNO")=$GET(^BZDMTEMP("CT",MY,"MNO"))+1
+11 QUIT
DATES ;
+1 SET X=$EXTRACT(MY,1,2)_"01"_$EXTRACT(MY,3,6)
DO ^%DT
SET STDT=Y
+2 SET EMO=$EXTRACT(MY,1,2)
+3 IF (EMO="01")!(EMO="03")!(EMO="05")!(EMO="07")!(EMO="08")!(EMO="10")!(EMO="12")
SET ENDDAY=31
+4 IF (EMO="04")!(EMO="06")!(EMO="09")!(EMO="11")
SET ENDDAY=30
+5 IF (EMO="02")
SET ENDDAY=28
+6 SET X=$EXTRACT(MY,1,2)_ENDDAY_$EXTRACT(MY,3,6)
DO ^%DT
SET ENDDT=Y
+7 QUIT
SSNSET ;STUFF SSN FROM THE MEDICAID DOWNLOAD TO THE DPT FILE
+1 ;I (DPTSSN="")!($E(DPTSSN,1,3)=999)!($E(DPTSSN,1,3)="000")
+2 IF (ST=1)
IF ((MEDNO=999999999)!(MEDNO="000000000"))
QUIT
+3 IF (ST=2)
IF ((WYSSN=999999999)!(WYSSN="000000000"))
QUIT
+4 IF (DPTSSN="")!(DPTSSN="999999999")!(DPTSSN="999-99-9999")!(DPTSSN="000000000")!(DPTSSN="000-00-0000")
+5 IF '$TEST
QUIT
+6 SET DIE="^DPT("
SET DA=PATDFN
SET DR=".09////"_MEDNO
+7 DO ^DIE
+8 SET SSNCT=SSNCT+1
+9 IF '$DATA(^AZMEDSSN(TODAY,0))
SET ^AZMEDSSN(TODAY,0)=$PIECE(^AZMEDDL(FAC,0),"^",1)_"^0"
+10 SET ^AZMEDSSN(TODAY,PATDFN)=$SELECT(ST=1:MEDNO,ST=2:WYSSN)_"^"_DPTSSN
SET $PIECE(^AZMEDSSN(TODAY,0),"^",2)=$PIECE(^AZMEDSSN(TODAY,0),"^",2)+1
+11 SET ^AGPATCH(TODAY,DUZ(2),PATDFN)=""
+12 QUIT
CKDT ;CHECK IF THE START DATE IS ALREADY ON FILE
+1 SET OLD=^AUPNMCD(MEDDFN,11,STDT,0)
+2 IF $PIECE(OLD,"^",2)'=ENDDT
Begin DoDot:1
+3 SET $PIECE(^AUPNMCD(MEDDFN,11,STDT,0),"^",2)=ENDDT
+4 SET STDTCHG(NU)=$GET(STDTCHG(NU))+1
+5 SET FL=1
+6 QUIT
End DoDot:1
+7 QUIT
DTCONT ;
+1 ; check on the multiples already onfile to see if this new date range
+2 ; can be a continuation of a record already on file
+3 ; instead of recreating a new record for each new month.
+4 ;set date before start dt
SET X1=STDT
SET X2="-1"
DO C^%DTC
SET DTBFR=X
+5 IF +DTBFR<1
QUIT
+6 SET LOOP=0
+7 FOR
SET LOOP=$ORDER(^AUPNMCD(MEDDFN,11,LOOP))
IF LOOP=""
QUIT
Begin DoDot:1
+8 SET LOOPREC=$GET(^AUPNMCD(MEDDFN,11,LOOP,0))
+9 IF LOOPREC=""
QUIT
+10 SET LOOPEND=$PIECE(LOOPREC,"^",2)
+11 IF LOOPEND'=DTBFR
QUIT
+12 IF LOOPEND=DTBFR
Begin DoDot:2
+13 SET ^ZZDINA("ENDCHG",MEDDFN,LOOP)=LOOPEND_"^"_ENDDT
+14 SET ENDCHG(NU)=$GET(ENDCHG(NU))+1
+15 SET FL=1
+16 SET $PIECE(^AUPNMCD(MEDDFN,11,LOOP,0),"^",2)=ENDDT
+17 QUIT
End DoDot:2
+18 QUIT
End DoDot:1
IF FL=1
QUIT
+19 QUIT
+20 ;
+21 ;
+22 QUIT
END ;
+1 ;
+2 USE IO(0)
WRITE !!,"TOTAL NUMBER OF MEDICAID ELIG. STUFFED: ",COUNT
+3 USE IO(0)
WRITE !!,"TOTAL NEW OF MEDICAID PATIENTS: ",NEW
+4 WRITE !,?10,"Total new nodes: ",$GET(NEWCHG("N"))
+5 WRITE !,?10,"Total w/start node there with end chg: ",$GET(STDTCHG("N"))
+6 WRITE !,?10,"Total end dt chg of existing node: ",$GET(ENDCHG("N"))
+7 USE IO(0)
WRITE !!,"TOTAL MEDICAID ELIG. PATIENTS UPDATED: ",UPDATE
+8 WRITE !,?10,"Total new nodes: ",$GET(NEWCHG("U"))
+9 WRITE !,?10,"Total w/start node there with end chg: ",$GET(STDTCHG("U"))
+10 WRITE !,?10,"Total end dt chg of existing node: ",$GET(ENDCHG("U"))
+11 USE IO(0)
WRITE !!,"TOTAL PATIENTS (that were updated) with NO end date=",$GET(ER(20))
+12 USE IO(0)
WRITE !!,"TOTAL INACTIVE HRN ERRORS= ",$GET(ER(10))
+13 USE IO(0)
WRITE !!,"TOTAL MEDICAID ELIG. STUFF ERRORS= ",$GET(ER(2))
+14 ;S FACNAME=$P(^DIC(4,ORGDUZ(2),0),"^",1)
+15 USE IO(0)
WRITE !,"DOWNLOAD FOR--MEDICAID IS DONE!!!!"
+16 USE IO(0)
WRITE !,TODAY
+17 ;K ER
+18 SET ^BZDMCDLG(UPMONTH)=UPMONTH_"^"_TODAY
+19 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(COUNT)
+20 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(NEW)
+21 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(NEWCHG("N"))
+22 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(STDTCHG("N"))
+23 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(ENDCHG("N"))
+24 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(UPDATE)
+25 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(NEWCHG("U"))
+26 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(STDTCHG("U"))
+27 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(ENDCHG("U"))
+28 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(ER(20))
+29 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(ER(10))
+30 SET ^BZDMCDLG(UPMONTH)=^BZDMCDLG(UPMONTH)_"^"_+$GET(ER(2))
+31 KILL AZBM
+32 ;S DIC="^BZDMCDNV(",DIC(0)="ZLM",X=UPMONTH D ^DIC
+33 SET DIC="^BZDMCDDL("
SET DIC(0)="ZLM"
SET X=+$EXTRACT(MY,1,2)_"-"_$EXTRACT(MY,3,6)
SET DIC("DR")=".02///"_TODAY
+34 SET DIC("DR")=DIC("DR")_";.03///"_+$GET(COUNT)
+35 SET DIC("DR")=DIC("DR")_";.04///"_+$GET(NEW)
+36 SET DIC("DR")=DIC("DR")_";.05///"_+$GET(NEWCHG("N"))
+37 SET DIC("DR")=DIC("DR")_";.06///"_+$GET(STDTCHG("N"))
+38 SET DIC("DR")=DIC("DR")_";.07///"_+$GET(ENDCHG("N"))
+39 SET DIC("DR")=DIC("DR")_";.08///"_+$GET(UPDATE)
+40 SET DIC("DR")=DIC("DR")_";.09///"_+$GET(NEWCHG("U"))
+41 SET DIC("DR")=DIC("DR")_";10///"_+$GET(STDTCHG("U"))
+42 SET DIC("DR")=DIC("DR")_";11///"_+$GET(ENDCHG("U"))
+43 SET DIC("DR")=DIC("DR")_";12///"_+$GET(ER(20))
+44 SET DIC("DR")=DIC("DR")_";13///"_+$GET(ER(10))
+45 SET DIC("DR")=DIC("DR")_";14///"_+$GET(ER(2))
+46 DO ^DIC
+47 USE 0
WRITE !!
DO ^%T
+48 DO ^%ZISC
+49 QUIT
DUZHRN ;
+1 KILL HRN
+2 SET DUZ(2)=0
+3 FOR
SET DUZ(2)=$ORDER(^AUPNPAT(PATDFN,41,DUZ(2)))
IF +DUZ(2)=0
QUIT
Begin DoDot:1
+4 SET HRNREC=$GET(^AUPNPAT(PATDFN,41,DUZ(2),0))
+5 IF $PIECE(HRNREC,"^",3)=""
SET HRN=$PIECE(HRNREC,"^",2)
End DoDot:1
IF $DATA(HRN)
QUIT
+6 QUIT
LOADMEDN ;load the medno from aupnmcd file to BZDMTEMP("MEDNO") to match on this
+1 ;maybe
+2 ; don't need 4/6/2000 dmh
+3 QUIT
+4 KILL ^BZDM("MEDNO")
+5 SET GLOB="^AUPNMCD(""AB"")"
+6 FOR
SET GLOB=$QUERY(@GLOB)
IF GLOB'["^AUPNMCD(""AB"""
QUIT
IF GLOB=""
QUIT
Begin DoDot:1
+7 IF $PIECE(GLOB,",",1)["AUPNMCD"
SET MN=$PIECE(GLOB,",",4)
SET ^BZDM("MEDNO",MN)=""
End DoDot:1