AGELUPNM ;IHS/SET/GTH - INITIAL PROCESS OF NM MEDICAID FILE ;
;;7.1;PATIENT REGISTRATION;**2**;JAN 31, 2007
;
;This is the start point, that's called from option
;AG TM ELI UPLOAD, on the Eligibility menu (AG TM ELIGIBILITY).
;
TXT ;
;;This process takes the State of New Mexico's data file for Medicaid
;;and reformats it into single eligibility records for distribution
;;to specific sites in the State.
;;
;;This process only exists at Albuquerque. For now....
;;
;;This processing is specific to the format of Medicaid data provided
;;by the State of New Mexico.
;;###
;
START ;start
NEW AG,AGFILE,AGPATH,AGCNT,DIR
KILL ^TMP($J,"AGELUPNM")
D HELP^XBHELP("TXT","AGELUPNM")
Q:'$$DIR^XBDIR("E")
D OPEN
Q:$D(DIRUT)
;I POP W !,"Could not open host file",! Q
I POP W !,"Could not open host file",! H 3 Q ;AG*7.1*2
D CLOSE^%ZISH("AGNMFILE")
D READIN,WRITEOUT
KILL ^TMP($J,"AGELUPNM")
U IO(0)
W !!,"D O N E",!!
I $$DIR^XBDIR("E","Press RETURN")
Q
OPEN ;open host file
NEW AGLIST
KILL AGFILE,DIR
S AGPATH=$P($G(^AGFAC(DUZ(2),2)),U,2)
I AGPATH="" S AGPATH=$S($P(^%ZOSF("OS"),U,1)["UNIX":"/usr/spool/uucppublic/",1:$P($G(^AUTTSITE(1,1)),U,1))
S AGPATH=$$DIR^XBDIR("F","Enter directory containing file with NM Medicaid info",AGPATH,"","","",1)
Q:$D(DIRUT)
I '$$LIST^%ZISH(AGPATH,"IHS"_"*",.AGLIST) D I $G(AGFILE) S AGFILE=AGLIST(AGFILE)
. NEW AG
. S AG=0
. F S AG=$O(AGLIST(AG)) Q:'AG D I $D(DIRUT) KILL AGFILE Q
.. W !,$J(AG,3),". ",AGLIST(AG)
.. S:(('(AG#5))!('$D(AGLIST(AG+1)))) AGFILE=$$DIR^XBDIR("NO^1:"_AG,"Process which file (or '^' to specify file)")
.. Q:$G(AGFILE)
..Q
.Q
I '$L($G(AGFILE)) S AGFILE=$$DIR^XBDIR("F","Enter name of file","","","","",2)
Q:$D(DIRUT)
D OPEN^%ZISH("AGNMFILE",AGPATH,AGFILE,"R")
Q
READIN ;read through file
U IO(0)
W !,"Processing NM Medicaid file..."
D WAIT^DICD
W !
S AGCNT=0
F %=1:1:5 S AGCNT(%)=0
D OPEN^%ZISH("AGNMFILE",AGPATH,AGFILE,"R")
U IO
KILL P
F R X:DTIME Q:$$STATUS^%ZISH D
. I '(AGCNT#1000) U IO(0) W $J(AGCNT,8) U IO
. S AGCNT=AGCNT+1,AGCNT(+X)=AGCNT(+X)+1
. Q:'("12"[$E(X))
. ;remove leading "0"s
. F S P=$F(X,"^0") Q:'P S X=$E(X,1,P-2)_$E(X,P,$L(X))
. ;remove trailing blanks
. F S P=$F(X," ^") Q:'P S X=$E(X,1,P-3)_$E(X,P-1,$L(X))
. ;remove insignifant times
. F S P=$F(X," 0:00:00") Q:'P S X=$E(X,1,P-9)_$E(X,P,$L(X))
. ;remove open-ended end dates
. F S P=$F(X,"12/31/9999") Q:'P S X=$E(X,1,P-11)_$E(X,P,$L(X))
. ;Keep all eligibility records (2) at the same node.
. I $E(X)="2" S X=$P(X,U,1,5) I $D(^TMP($J,"AGELUPNM",$P(X,U,2),2)) S ^(2)=^(2)_U_$P(X,U,3,5) Q
. S ^TMP($J,"AGELUPNM",$P(X,U,2),$P(X,U,1))=$P(X,U,3,999)
.Q
KILL P
D CLOSE^%ZISH("AGNMFILE")
U IO(0)
W !!,AGCNT," records found in file:",!
F %=1:1:5 W !?5,%,". : ",AGCNT(%)
Q
WRITEOUT ;
NEW AGSYSID
S AGFILE="cmsd"_$$LTR^AGELUP3(3)_"."_$E(DT,2,5)
U IO(0)
W !,"Writing to file ",AGPATH,AGFILE,"...."
D WAIT^DICD
W !
D OPEN^%ZISH("AGNMFILE",AGPATH,AGFILE,"W")
Q:POP
U IO
S (AGCNT,AGSYSID)=0
F S AGSYSID=$O(^TMP($J,"AGELUPNM",AGSYSID)) Q:'AGSYSID D
. S AGCNT=AGCNT+1
. I '(AGCNT#1000) U IO(0) W AGCNT," of ",AGCNT(1)," / " U IO
. Q:'$D(^TMP($J,"AGELUPNM",AGSYSID,2))
. Q:'$D(^TMP($J,"AGELUPNM",AGSYSID,1))
. S X=^TMP($J,"AGELUPNM",AGSYSID,1)_"^^^^^^^"_^(2)
. W X,!
.Q
D CLOSE^%ZISH("AGNMFILE")
Q
AGELUPNM ;IHS/SET/GTH - INITIAL PROCESS OF NM MEDICAID FILE ;
+1 ;;7.1;PATIENT REGISTRATION;**2**;JAN 31, 2007
+2 ;
+3 ;This is the start point, that's called from option
+4 ;AG TM ELI UPLOAD, on the Eligibility menu (AG TM ELIGIBILITY).
+5 ;
TXT ;
+1 ;;This process takes the State of New Mexico's data file for Medicaid
+2 ;;and reformats it into single eligibility records for distribution
+3 ;;to specific sites in the State.
+4 ;;
+5 ;;This process only exists at Albuquerque. For now....
+6 ;;
+7 ;;This processing is specific to the format of Medicaid data provided
+8 ;;by the State of New Mexico.
+9 ;;###
+10 ;
START ;start
+1 NEW AG,AGFILE,AGPATH,AGCNT,DIR
+2 KILL ^TMP($JOB,"AGELUPNM")
+3 DO HELP^XBHELP("TXT","AGELUPNM")
+4 IF '$$DIR^XBDIR("E")
QUIT
+5 DO OPEN
+6 IF $DATA(DIRUT)
QUIT
+7 ;I POP W !,"Could not open host file",! Q
+8 ;AG*7.1*2
IF POP
WRITE !,"Could not open host file",!
HANG 3
QUIT
+9 DO CLOSE^%ZISH("AGNMFILE")
+10 DO READIN
DO WRITEOUT
+11 KILL ^TMP($JOB,"AGELUPNM")
+12 USE IO(0)
+13 WRITE !!,"D O N E",!!
+14 IF $$DIR^XBDIR("E","Press RETURN")
+15 QUIT
OPEN ;open host file
+1 NEW AGLIST
+2 KILL AGFILE,DIR
+3 SET AGPATH=$PIECE($GET(^AGFAC(DUZ(2),2)),U,2)
+4 IF AGPATH=""
SET AGPATH=$SELECT($PIECE(^%ZOSF("OS"),U,1)["UNIX":"/usr/spool/uucppublic/",1:$PIECE($GET(^AUTTSITE(1,1)),U,1))
+5 SET AGPATH=$$DIR^XBDIR("F","Enter directory containing file with NM Medicaid info",AGPATH,"","","",1)
+6 IF $DATA(DIRUT)
QUIT
+7 IF '$$LIST^%ZISH(AGPATH,"IHS"_"*",.AGLIST)
Begin DoDot:1
+8 NEW AG
+9 SET AG=0
+10 FOR
SET AG=$ORDER(AGLIST(AG))
IF 'AG
QUIT
Begin DoDot:2
+11 WRITE !,$JUSTIFY(AG,3),". ",AGLIST(AG)
+12 IF (('(AG#5))!('$DATA(AGLIST(AG+1))))
SET AGFILE=$$DIR^XBDIR("NO^1:"_AG,"Process which file (or '^' to specify file)")
+13 IF $GET(AGFILE)
QUIT
+14 QUIT
End DoDot:2
IF $DATA(DIRUT)
KILL AGFILE
QUIT
+15 QUIT
End DoDot:1
IF $GET(AGFILE)
SET AGFILE=AGLIST(AGFILE)
+16 IF '$LENGTH($GET(AGFILE))
SET AGFILE=$$DIR^XBDIR("F","Enter name of file","","","","",2)
+17 IF $DATA(DIRUT)
QUIT
+18 DO OPEN^%ZISH("AGNMFILE",AGPATH,AGFILE,"R")
+19 QUIT
READIN ;read through file
+1 USE IO(0)
+2 WRITE !,"Processing NM Medicaid file..."
+3 DO WAIT^DICD
+4 WRITE !
+5 SET AGCNT=0
+6 FOR %=1:1:5
SET AGCNT(%)=0
+7 DO OPEN^%ZISH("AGNMFILE",AGPATH,AGFILE,"R")
+8 USE IO
+9 KILL P
+10 FOR
READ X:DTIME
IF $$STATUS^%ZISH
QUIT
Begin DoDot:1
+11 IF '(AGCNT#1000)
USE IO(0)
WRITE $JUSTIFY(AGCNT,8)
USE IO
+12 SET AGCNT=AGCNT+1
SET AGCNT(+X)=AGCNT(+X)+1
+13 IF '("12"[$EXTRACT(X))
QUIT
+14 ;remove leading "0"s
+15 FOR
SET P=$FIND(X,"^0")
IF 'P
QUIT
SET X=$EXTRACT(X,1,P-2)_$EXTRACT(X,P,$LENGTH(X))
+16 ;remove trailing blanks
+17 FOR
SET P=$FIND(X," ^")
IF 'P
QUIT
SET X=$EXTRACT(X,1,P-3)_$EXTRACT(X,P-1,$LENGTH(X))
+18 ;remove insignifant times
+19 FOR
SET P=$FIND(X," 0:00:00")
IF 'P
QUIT
SET X=$EXTRACT(X,1,P-9)_$EXTRACT(X,P,$LENGTH(X))
+20 ;remove open-ended end dates
+21 FOR
SET P=$FIND(X,"12/31/9999")
IF 'P
QUIT
SET X=$EXTRACT(X,1,P-11)_$EXTRACT(X,P,$LENGTH(X))
+22 ;Keep all eligibility records (2) at the same node.
+23 IF $EXTRACT(X)="2"
SET X=$PIECE(X,U,1,5)
IF $DATA(^TMP($JOB,"AGELUPNM",$PIECE(X,U,2),2))
SET ^(2)=^(2)_U_$PIECE(X,U,3,5)
QUIT
+24 SET ^TMP($JOB,"AGELUPNM",$PIECE(X,U,2),$PIECE(X,U,1))=$PIECE(X,U,3,999)
+25 QUIT
End DoDot:1
+26 KILL P
+27 DO CLOSE^%ZISH("AGNMFILE")
+28 USE IO(0)
+29 WRITE !!,AGCNT," records found in file:",!
+30 FOR %=1:1:5
WRITE !?5,%,". : ",AGCNT(%)
+31 QUIT
WRITEOUT ;
+1 NEW AGSYSID
+2 SET AGFILE="cmsd"_$$LTR^AGELUP3(3)_"."_$EXTRACT(DT,2,5)
+3 USE IO(0)
+4 WRITE !,"Writing to file ",AGPATH,AGFILE,"...."
+5 DO WAIT^DICD
+6 WRITE !
+7 DO OPEN^%ZISH("AGNMFILE",AGPATH,AGFILE,"W")
+8 IF POP
QUIT
+9 USE IO
+10 SET (AGCNT,AGSYSID)=0
+11 FOR
SET AGSYSID=$ORDER(^TMP($JOB,"AGELUPNM",AGSYSID))
IF 'AGSYSID
QUIT
Begin DoDot:1
+12 SET AGCNT=AGCNT+1
+13 IF '(AGCNT#1000)
USE IO(0)
WRITE AGCNT," of ",AGCNT(1)," / "
USE IO
+14 IF '$DATA(^TMP($JOB,"AGELUPNM",AGSYSID,2))
QUIT
+15 IF '$DATA(^TMP($JOB,"AGELUPNM",AGSYSID,1))
QUIT
+16 SET X=^TMP($JOB,"AGELUPNM",AGSYSID,1)_"^^^^^^^"_^(2)
+17 WRITE X,!
+18 QUIT
End DoDot:1
+19 DO CLOSE^%ZISH("AGNMFILE")
+20 QUIT