Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BZXBPNA

BZXBPNA.m

Go to the documentation of this file.
BZXBPNA ;IHS/PHXAO/AEF - FIND BAD PATIENT NAMES
 ;;1.0;ANNE'S SPECIAL ROUTINES;;JUNE 10, 2004
 ;
 ;Some of the code in this routine was written by Jim Gray at PIMC,
 ;and rewritten by Anne Fugatt at PHXAO
 ;
BADPTNAM ;Find bad names
 W !,"PATIENT NAME",?25,"MEDICAID NAME",?50,"MEDICARE NAME"
 S DFN=0
 F  S DFN=$O(^DPT(DFN)) Q:'DFN  D
 .Q:'$D(^DPT(DFN,0))
 .S BZXDONE=0
 .S VIEN=0
 .F  S VIEN=$O(^AUPNVSIT("AC",DFN,VIEN)) Q:'VIEN  D  Q:BZXDONE
 ..Q:(+$G(^AUPNVSIT(VIEN,0)))<3020214
 ..S FLG=0
 ..K NAME,MCAIDNAM,MCARNAM
 ..S NAME=$P(^DPT(DFN,0),U,1)
 ..S BZXGOOD=$$CHKNAM(NAME)
 ..I BZXGOOD<1 W !,NAME S FLG=1
 ..S MCAIDIEN=0
 ..F  S MCAIDIEN=$O(^AUPNMCD("B",DFN,MCAIDIEN)) Q:'MCAIDIEN  D
 ...S MCAIDNAM=$P($G(^AUPNMCD(MCAIDIEN,21)),U,1)
 ...I $$CHKNAM(MCAIDNAM)<1 D
 ....I FLG=0 W !,NAME S FLG=1
 ....I (MCAIDNAM="")!(MCAIDNAM?1." ") S MCAIDNAM="BLANK"
 ....W ?25,MCAIDNAM
 ..I $D(^AUPNMCR(DFN,21)) D
 ...S MCARNAM=$P(^AUPNMCR(DFN,21),U,1)
 ...I $$CHKNAM(MCARNAM)<1 D
 ....I FLG=0 W !,NAME S FLG=1
 ....I (MCARNAM="")!(MCARNAM?1." ") S MCARNAM="BLANK"
 ....W ?50,MCARNAM
 ..S BZXDONE=1
 Q
 ;
CHKNAM(NAM) ;CHECK NAME FORMAT
 I NAM?2.A.1(1" ",1"-").A1" "1(1"JR",1"SR",1"II",1"III",1"IV",1"V")1","2.A.1" ".A.1"." Q -1  ;BAD
 I NAM?2.A.1(1" ",1"-").A1","1.A.1" ".A.1".".1",".3A.1"." Q 1  ;GOOD
 Q 0
 ;
BADADR ;EP
 ;----- FIND BAD ADDRESSES
 ;
 N BZXDT,BZXOUT,DIR,X,Y
 D ^XBKVAR
 D HOME^%ZIS
 ;
 W !,"THIS REPORT PRINTS A LISTING OF BAD ADDRESSES IN THE VA PATIENT FILE"
 W !
 ;
 S BZXOUT=0
 D CUTOFF(.BZXDT,.BZXOUT)
 Q:BZXOUT
 ;
 D PRINTA(BZXDT)
 ;
 D QUIT
 ;
 Q
PRINTA(BZXDT) ;
 ;
 N BZXTITLE,ZTDESC,ZTRTN,ZTSAVE
 ;
 S BZXTITLE="BAD ADDRESS REPORT"
 S ZTRTN="DQ1^BZXBPNA"
 S ZTDESC=BZXTITLE
 S ZTSAVE("BZXTITLE")=""
 S ZTSAVE("BZXDT")=""
 D QUE^BZXBPNA(ZTRTN,.ZTSAVE,ZTDESC)
 Q
DQ1 ;----- QUEUED JOB STARTS HERE
 ;
 N BZXDONE,BZXOUT,BZXPAGE,BZXVIEN,DFN
 ;
 S (BZXOUT,BZXPAGE)=0
 D HDR(.BZXPAGE,.BZXOUT,.BZXTITLE)
 Q:BZXOUT
 ;
 S DFN=0
 F  S DFN=$O(^DPT(DFN)) Q:'DFN  D  Q:BZXOUT
 . S BZXDONE=0
 . S BZXVIEN=0
 . F  S BZXVIEN=$O(^AUPNVSIT("AC",DFN,BZXVIEN)) Q:'BZXVIEN  D  Q:BZXOUT  Q:BZXDONE
 . . Q:(+$G(^AUPNVSIT(BZXVIEN,0)))<BZXDT
 . . S BZXDONE=1
 . . I $Y>(IOSL-5) D HDR(.BZXPAGE,.BZXOUT,.BZXTITLE)
 . . Q:BZXOUT
 . . D ONE(DFN)
 ;
 D ^%ZISC
 Q
ONE(DFN) ;
 ;----- CHECK ONE DFN
 ;
 N BZXADDR,BZXADDR2,BZXADDR3,BZXCITY,BZXDATA,BZXGOOD,BZXNAME,BZXSSN,BZXSTATE,BZXZIP,IENS
 ;
 I '$D(^DPT(DFN,0)) D  Q
 . W !,"DFN #"_DFN_" IS MISSING A ZERO NODE" 
 ;
 S BZXGOOD=1 ;START OUT AS A GOOD ONE
 S IENS=DFN_","
 S BZXADDR=$$GET1^DIQ(2,IENS,.111)
 I BZXADDR']"" S BZXADDR="<MISSING>",BZXGOOD=0
 S BZXGOOD=$$AD1CHK(BZXADDR)
 S BZXDATA=$G(^DPT(DFN,0))
 S BZXNAME=$P(BZXDATA,U)
 S BZXSSN=$P(BZXDATA,U,9)
 S BZXDATA=$G(^DPT(DFN,.11))
 S BZXADDR2=$P(BZXDATA,U,2)
 S BZXADDR3=$P(BZXDATA,U,3)
 S BZXCITY=$P(BZXDATA,U,4)
 I BZXCITY']"" S BZXCITY="<MISSING>",BZXGOOD=0
 S BZXSTATE=$$GET1^DIQ(2,IENS,.115)
 I BZXSTATE']"" S BZXSTATE="<MISSING>",BZXGOOD=0
 S BZXZIP=$P(BZXDATA,U,6)
 I BZXZIP']"" S BZXZIP="<MISSING>",BZXGOOD=0
 Q:BZXGOOD
 ;
 W !,"("_DFN_")"
 W ?12,BZXNAME,?37,BZXSSN
 W !,BZXADDR
 I BZXADDR2]"" W !,BZXADDR2
 I BZXADDR3]"" W !,BZXADDR3
 W !,BZXCITY_", "_BZXSTATE_"  "_BZXZIP
 W !
 Q
HDR(BZXPAGE,BZXOUT,BZXTITLE) ;
 ;
 N DIR,DIRUT,DTOUT,DUOUT,I,X,Y
 ;
 I $E(IOST)="C",$G(BZXPAGE) D
 . S DIR(0)="E"
 . D ^DIR
 . I 'Y S BZXOUT=1
 Q:BZXOUT
 S BZXPAGE=$G(BZXPAGE)+1
 W @IOF
 W !,BZXTITLE
 W ?49,$$NOW
 W "   PAGE ",BZXPAGE
 W !
 F I=1:1:IOM W "-"
 W !!
 Q
QUE(ZTRTN,ZTSAVE,ZTDESC) ;
 ;----- QUEUEING CODE
 ;
 N %ZIS,IO,POP,ZTIO,ZTSK
 S %ZIS="Q"
 D ^%ZIS
 Q:POP
 I $D(IO("Q")) D  Q
 . K IO("Q")
 . S ZTIO=ION_";"_IOST_";"_IOM_";"_IOSL
 . D ^%ZTLOAD
 . I $G(ZTSK) W !,"Task #",$G(ZTSK)," queued"
 D @ZTRTN
 Q
CUTOFF(BZXDT,BZXOUT) ;
 ;----- RETURNS VISIT CUT OFF DATE
 ;
 N DIR,DIRUT,DTOUT,DUOUT,X,Y
 S DIR(0)="D^::EX"
 S DIR("A")="Enter VISIT CUTOFF DATE"
 S DIR("?")="The earliest VISIT DATE to include in the report"
 D ^DIR
 I +Y'>0 S BZXOUT=1
 S BZXDT=+Y
 Q
NOW() ;
 ;----- RETURNS CURRENT DATE/TIME
 ;
 N %,%H,%I,X,Y
 D NOW^%DTC
 S Y=DT
 X ^DD("DD")
 Q Y_"  "_$E($P(%,".",2),1,2)_":"_$E($P(%,".",2),3,4)
 ;
AD1CHK(X) ;
 ;----- PATTERN MATCHES FOR ADDRESS LINE 1
 ;
 I X?1.5N1" ".5AP.1" "3.NA.AP.N." " Q 1
 I X?1"P".1".".1" "1"O".1".".1" ".1"BOX"1" ".1"#"1.8N Q 1
 Q 0
QUIT ;
 ;----- CLEAN UP, CLOSE DEVICE, QUIT JOB
 ;
 D ^%ZISC
 Q