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

AGUND18.m

Go to the documentation of this file.
AGUND18 ; IHS/ASDS/TPF - PRINT ALL PATS UNDER 18 WITH MEDICAID/PRIVATE/SOC SEC NUMBERS ;  
 ;;7.1;PATIENT REGISTRATION;**2,4**;JAN 31, 2007
 ;TASK REQUESTS REPORT BE SIMILAR TO OVER 65 REPORT - TEMPPLATE USED FROM AGOV64
 S AGIO=IO,AG("HAT")=""
 W !!
 K DIR
 S DIR(0)="Y"
 S DIR("A")="Include inactive patients?"
 S DIR("B")="N"
 D ^DIR
 Q:$D(DUOUT)!$D(DTOUT)
 S AGINACT=+Y
 K DTOUT,DUOUT,DIR
 W !!
DEV S %ZIS="OPQ" D ^%ZIS I POP S IOP=ION D ^%ZIS Q
 G:'$D(IO("Q")) START K IO("Q") I $D(IO("S"))!($E(IOST)'="P") W *7,!,"Please queue to system printers." D ^%ZISC G DEV
 ;X ^%ZOSF("UCI") S ZTRTN="START^AGUND18",ZTUCI=Y,ZTIO="",ZTDESC="PATIENTS UNDER 18 for "_$P(^AUTTLOC(DUZ(2),0),U,2)_".",AGQIO=IO F G="AGQIO","DUZ" S ZTSAVE(G)=""
 X ^%ZOSF("UCI") S ZTRTN="START^AGUND18",ZTUCI=Y,ZTIO="",ZTDESC="PATIENTS UNDER 18 for "_$P(^AUTTLOC(DUZ(2),0),U,2)_".",AGQIO=IO F G="AGINACT","AGQIO","DUZ" S ZTSAVE(G)=""  ;AG*7.1*4 HEAT1653
 D ^%ZTLOAD G:'$D(ZTSK) DEV K AG,AGIO,ZTDESC,ZTIO,ZTRTN,ZTSK,ZTUCI D ^%ZISC
 Q
START ;EP - From TaskMan.
 S AG("18")=DT-180000,(AGTOT,AGTOTMCD,AGTOTPRV,AGPGPG)=0
 K ^TMP($J),AG("LOC"),AG("USR")
 S I=AG("18")
 F  S I=$O(^DPT("ADOB",I)) Q:I=""  D
 .;S J=$O(^(I,""))
 .S J=$O(^DPT("ADOB",I,""))  ;AG*1.8*4 SAC:TOOK OUT NAKED REFERENCE
 .Q:($P($G(^AUPNPAT(J,41,DUZ(2),0)),U,3)'="")&('AGINACT)
 .I $D(^AUPNPAT(J,41,DUZ(2))),$D(^DPT(J,0)),'$P($G(^DPT(J,.35)),U) S NAME=$P($G(^DPT(J,0)),U) S ^TMP($J,NAME)=J
 I $D(AGQIO) F AGZ("I")=1:1 S IOP=AGQIO D ^%ZIS Q:'POP
 S AG("LOC")=$P(^DIC(4,DUZ(2),0),U),AG("USR")=$P(^VA(200,DUZ,0),U)
 S AG("USRLOC")=AG("USR")_$J("",40-($L(AG("LOC"))\2)-$L(AG("USR")))_AG("LOC"),AGBM=IOSL-10
 I $D(AGIO),AGIO=IO S AGBM=IOSL-4
 K AG("LOC"),AG("USR")
 U IO
 D LINES^AG,NOW^AG
 S X="Report date: "_AGTIME D CTR^AG S AGTIME=X D HDR
 ;MAIN LOOP
 K DUOUT,DFOUT,DTOUT
 S NAME=""
 F  S NAME=$O(^TMP($J,NAME)) Q:NAME=""  D  Q:$D(DUOUT)!$D(DFOUT)!$D(DTOUT)
 .S DFN=$G(^TMP($J,NAME))
 .S AGRRESW="N"
 .S MCDREC=""
 .S PRVTREC=0
 .D PRINT
 .I $Y>AGBM D RTRN^AG Q:$D(DUOUT)!$D(DFOUT)!$D(DTOUT)  D HDR
 K AG("HAT")
 Q:$D(DUOUT)!$D(DFOUT)!$D(DTOUT)
 D RTRN^AG W !!,"Total patients 18 yrs or younger: ",AGTOT,!!,"Total patients 18 or younger with Medicaid: ",AGTOTMCD,!! D RTRN^AG W $$S^AGVDF("IOF")
END D ^%ZISC K ^TMP($J),A,AG,AGIO,AGTIME,AGBM,DA,DIC,DLOUT,DR,G,AGL,I,J,AG("LKDATA"),AG("LKPRINT"),AGPCC,AGPGPG,AGRRESW,AGTOT,AGTOTM,AGTOTR,AG("USRLOC"),X,Y D:$D(ZTQUEUED) KILL^%ZTLOAD
 Q
PRINT ;
 S AGTOT=AGTOT+1
 W $P($G(^DPT(DFN,0)),U)," (",$P(^AUPNPAT(DFN,41,DUZ(2),0),U,2),")"
 ;AG*7.1*2 REQUESTED DURIGN TESTING
 S Y=$P($G(^DPT(DFN,0)),U,3)
 I Y'="" X ^DD("DD") S AGDOB=Y
 E  S AGDOB=""
 I $D(^DPT(DFN,.13)) D
 .S AGPHONE=$P($G(^DPT(DFN,.13)),U)
 .S AGPHONE=$S($L(AGPHONE)=10:$E(AGPHONE,1,3)_"-"_$E(AGPHONE,4,6)_"-"_$E(AGPHONE,7,10),$L(AGPHONE)=7:$E(AGPHONE,1,3)_"-"_$E(AGPHONE,4,7),1:AGPHONE)
 .W ?35,AGPHONE K AGPHONE
 D MCD I MCDREC="" D PRVT
 ;W ?69,$P(^DPT(DFN,0),U,9)  ;SSN
 W ?69,$$GET1^DIQ(9000001,DFN_",",1107.3)  ;IHS/SD/TPF AG*7.1*4
 S AGADDR=$G(^DPT(DFN,.11))
 W:$P(AGADDR,U)]"" !?10,$P(AGADDR,U)
 W ?35,AGDOB   ;AG*7.1*2 REQUEST DURING TESTING
 I MCDREC'="" D MCD G NEXT1
 D:PRVTREC&(MCDREC'="") PRVT
NEXT1 S AG("ADDR")=$P(AGADDR,U,4)_" "
 I $P(AGADDR,U,5)]"",$D(^DIC(5,$P(AGADDR,U,5),0)) D
 .;S AG("ADDR")=AG("ADDR")_$P(^(0),U,2)_" "
 .S AG("ADDR")=AG("ADDR")_$P($G(^DIC(5,$P(AGADDR,U,5),0)),U,2)_" " ;AG*1.8*4 SAC:TOOK OUT NAKED REFERENCE
 W !?10,AG("ADDR")
 I MCDREC'="" D MCD G NEXT2
 D:PRVTREC&(MCDREC="") PRVT
NEXT2 D MCDNM
 F  D:$G(MCDREC)'="" MCD D:$G(MCDREC)=""&($G(PRVTREC)) PRVT Q:$G(MCDREC)=""&('$G(PRVTREC))
 W !,AG("-"),!
 Q
HDR S AGPGPG=AGPGPG+1
 W $$S^AGVDF("IOF")
 W !,AG("USRLOC"),?70,"page ",AGPGPG
 W !?26,"PATIENTS <18 YRS OLD"
 W !,AGTIME
 W !!?35,"HOME PHONE",?51,"MEDICAID(M)",?69,"SOCIAL"
 W !,"NAME (CHART #)",?35,"DATE OF BIRTH",?51,"PRIVATE(P)",?66,"SECURITY NO."
 W !,AG("="),!
 Q
PRVT ;
 S PRVTREC=$O(^AUPNPRVT(DFN,11,PRVTREC)) Q:'PRVTREC
 S AGPRVTNM=$P($G(^AUPNPRVT(DFN,11,PRVTREC,2)),U)
 W:AGPRVTNM]"" ?49,"P=",AGPRVTNM K AGPRVTNM
 S AGTOTPRV=AGTOTPRV+1
 Q
MCD ;
 S MCDREC=$O(^AUPNMCD("B",DFN,MCDREC)) Q:MCDREC=""
 S AGMCDNO=$P($G(^AUPNMCD(MCDREC,0)),U,3)
 S:$L(AGMCDNO)=9 AGMCDNO=$E(AGMCDNO,1,3)_"-"_$E(AGMCDNO,4,5)_"-"_$E(AGMCDNO,6,9)
 W:AGMCDNO]"" ?49,"M=",AGMCDNO
 W:AGMCDNO="" ?49,"NO NUMBER "
 S AGTOTMCD=AGTOTMCD+1
 Q
MCDNM ;
 K AGMCRNM
 S MCDRECNO=""
 F  S MCDRECNO=$O(^AUPNMCD("B",DFN,MCDRECNO)) Q:MCDRECNO=""  D
 .S AGMCDNM=$P($G(^AUPNMCD(MCDRECNO,21)),U)
 .W:AGMCDNM]"" !,"(MCD) ",AGMCDNM K AGMDRNM
 .I MCDREC'="" D MCD Q
 .D:PRVTREC'="" PRVT
 S PRVTREC=0
 F  S PRVTREC=$O(^AUPNPRVT(DFN,11,PRVTREC)) Q:'PRVTREC  D
 .S AGPOLNM=$$GET1^DIQ(9000006.11,PRVTREC_","_DFN_",",.08,"E")
 .W:AGPOLNM'="" !,"(PRVT) ",AGPOLNM K AGPOLNM
 Q