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

AGOV64.m

Go to the documentation of this file.
AGOV64 ; IHS/ASDS/EFG - PRINT ALL PATS OVER 64 WITH MEDICARE/RAILROAD/SOC SEC NUMBERS ;  
 ;;7.1;PATIENT REGISTRATION;**2,4,9,11,14**;AUG 25, 2005;Build 1
 ;IHS/OIT/NKD AG*7.1*11 REMOVED DEBUG DISPLAY
 ;IHS/OIT/NKD AG*7.1*14 MBI PHASE 2, FIXED BUG WITH ONLY DISPLAYING ONE PATIENT PER DOB
 ;
 S AGIO=IO,AG("HAT")=""
 ;AG*7.1*2 IM 21608
 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 !!
 ;END
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^AGOV64",ZTUCI=Y,ZTIO="",ZTDESC="PATIENTS OVER 64 for "_$P(^AUTTLOC(DUZ(2),0),U,2)_".",AGQIO=IO F G="AGQIO","DUZ","AGINACT" S ZTSAVE(G)=""
 D ^%ZTLOAD G:'$D(ZTSK) DEV K AG,AGIO,ZTDESC,ZTIO,ZTRTN,ZTSK,ZTUCI D ^%ZISC
 Q
START ;EP - From TaskMan.
 S AG("64")=DT-640000,(AGTOT,AGTOTM,AGTOTR,AGPGPG)=0
 K ^TMP($J),AG("LOC"),AG("USR")
 ;F I=0:0 S I=$O(^DPT("ADOB",I)) Q:+I=0!(+I>AG("64"))  S J=$O(^(I,"")) I $D(^AUPNPAT(J,41,DUZ(2))),$D(^DPT(J,0)),'$P($G(^DPT(J,.35)),"^",1) S ^TMP($J,J)=""
 ;F I=0:0 S I=$O(^DPT("ADOB",I)) Q:+I=0!(+I>AG("64"))  S J=$O(^(I,"")) 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)),"^",1) S ^TMP($J,J)=""  ;AG*7.1*2 IM21608
 F I=0:0 S I=$O(^DPT("ADOB",I)) Q:+I=0!(+I>AG("64"))  D
 .;S J=$O(^(I,""))
 . ;IHS/OIT/NKD AG*7.1*14 START OLD CODE - BUF FIX TO ALLOW MULTIPLE PATIENTS WITH THE SAME DOB
 . ;S J=$O(^DPT("ADOB",I,""))  ;AG*1.8*4 SAC:TOOK OUT NAKED REFERENCE
 . ;IHS/OIT/NKD AG*7.1*11 REMOVED DEBUG DISPLAY
 . ;I ($P($G(^AUPNPAT(J,41,DUZ(2),0)),U,3)'="")&('AGINACT) W !,J,"    ",$P($G(^DPT(J,0)),U)
 . ;Q:($P($G(^AUPNPAT(J,41,DUZ(2),0)),U,3)'="")&('AGINACT)
 . ;Q:((I+650000)>DT)  ;IHS/SD/SDR 11/4/10 HEAT20844
 . ;I $D(^AUPNPAT(J,41,DUZ(2))),$D(^DPT(J,0)),'$P($G(^DPT(J,.35)),"^",1) S NAME=$P($G(^DPT(J,0)),U) S ^TMP($J,NAME)=J  ;AG*7.1*2 IM21608
 . ;IHS/OIT/NKD AG*7.1*14 END OLD CODE - START NEW CODE
 . S J="" F  S J=$O(^DPT("ADOB",I,J)) Q:'J  D
 . . Q:($P($G(^AUPNPAT(J,41,DUZ(2),0)),U,3)'="")&('AGINACT)
 . . Q:((I+650000)>DT)  ;IHS/SD/SDR 11/4/10 HEAT20844
 . . I $D(^AUPNPAT(J,41,DUZ(2))),$D(^DPT(J,0)),'$P($G(^DPT(J,.35)),"^",1) S NAME=$P($G(^DPT(J,0)),U) S ^TMP($J,NAME)=J  ;AG*7.1*2 IM21608
 . ;IHS/OIT/NKD AG*7.1*14 END NEW CODE
 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),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 IM21608
 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)
 ;F DFN=0:0 S DFN=$O(^TMP($J,DFN)) Q:'DFN  S AGRRESW="N" D PRINT I $Y>AGBM D RTRN^AG G:$D(DUOUT)!$D(DFOUT)!$D(DTOUT) END D HDR
 K AG("HAT") D RTRN^AG W !!,"Total patients 65 yrs or older: ",AGTOT,!!,"Total patients 65 or older with Medicare: ",AGTOTM,!!,"Total patients 65 or older with Railroad Ret: ",AGTOTR D RTRN^AG W $$S^AGVDF("IOF")
END D ^%ZISC K ^TMP($J),A,AG,AGIO,AGTIME,AGBM,DA,DIC,DFN,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(^DPT(DFN,0),U)," (",$P(^AUPNPAT(DFN,41,DUZ(2),0),U,2),")"
 W $S($P(^AUPNPAT(DFN,41,DUZ(2),0),U,3)'="":"*",1:"")
 I $D(^DPT(DFN,.13)) S AGPHONE=$P(^(.13),U),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
 ;IHS/OIT/NKD AG*7.1*14 - START OLD CODE
 ;MCR G:'$D(^AUPNMCR(DFN,0)) RRE1 S AGMCRNO=$P(^AUPNMCR(DFN,0),U,3) S:$L(AGMCRNO)=9 AGMCRNO=$E(AGMCRNO,1,3)_"-"_$E(AGMCRNO,4,5)_"-"_$E(AGMCRNO,6,9) W ?49,"M=",AGMCRNO,"-"
 ;W:(AGMCRNO)="" ?49,"NO NUMBER " W:$P(^AUPNMCR(DFN,0),U,4)]"" $P(^AUTTMCS($P(^AUPNMCR(DFN,0),U,4),0),U) S AGTOTM=AGTOTM+1 K AGMCRNO G SSN
 ;IHS/OIT/NKD AG*7.1*14 - END OLD CODE - START NEW CODE
MCR  ;
 G:'$D(^AUPNMCR(DFN,0)) RRE1
 S AGMCRNO=$$GETMCR^AGUTL(DFN),AGISMBI=$$ISMBI^AGUTL(AGMCRNO)
 I 'AGISMBI,AGISMBI["MCR" S AGMCRNO=$E(AGMCRNO,1,3)_"-"_$E(AGMCRNO,4,5)_"-"_$E(AGMCRNO,6,9)_"-"_$E(AGMCRNO,10,11)
 W ?49,$S($L(AGMCRNO):"M="_AGMCRNO,1:"NO NUMBER ")
 S AGTOTM=AGTOTM+1 K AGMCRNO,AGISMBI G SSN
 ;IHS/OIT/NKD AG*7.1*14 - END NEW CODE
RRE1 I '$D(^AUPNMCR(DFN,0)),$D(^AUPNRRE(DFN,0)) D WRRE S AGRRESW="Y"
SSN ;S DIC=2,DR=.09,DA=DFN D ^AGDICLK I $D(AG("LKDATA")) S:$L(AG("LKDATA"))=9 AG("LKDATA")=$E(AG("LKDATA"),1,3)_"-"_$E(AG("LKDATA"),4,5)_"-"_$E(AG("LKDATA"),6,99) W ?67,AG("LKDATA")
 W ?67,$$GET1^DIQ(9000001,DFN_",",1107.3)  ;IHS/SD/TPF AG*7.1*4
 G CKRRE:'$D(^DPT(DFN,.11))
 S AGA=^DPT(DFN,.11) W:$P(AGA,U)]"" !?10,$P(AGA,U) S AG("ADDR")=$P(AGA,U,4)_" " I $P(AGA,U,5)]"",$D(^DIC(5,$P(AGA,U,5),0)) S AG("ADDR")=AG("ADDR")_$P(^(0),U,2)_" " G RRE
CKRRE I $D(^AUPNRRE(DFN,0)),AGRRESW'="Y" W !
RRE G ADDR1:'$D(^AUPNRRE(DFN,0))!(AGRRESW="Y") D WRRE
ADDR1 I $D(^DPT(DFN,.11)) S AG("ADDR")=AG("ADDR")_$P(AGA,U,6) W:AG("ADDR")]"" !?10,AG("ADDR")
 D PMCNM,RRENM W !,AG("-"),!
 Q
HDR S AGPGPG=AGPGPG+1 W $$S^AGVDF("IOF"),!,AG("USRLOC"),?70,"page ",AGPGPG,!?26,"PATIENTS 65 YRS OLD AND OLDER",!,AGTIME,!!?51,"MEDICARE(M)",?69,"SOCIAL",!,"NAME (CHART #)",?35,"HOME PHONE",?51,"RAILROAD(R)",?66,"SECURITY NO.",!,AG("="),!
 Q
 ;WRRE S AGRRNO=$P(^AUPNRRE(DFN,0),U,4) S:$L(AGRRNO)=9 AGRRNO=$E(AGRRNO,1,3)_"-"_$E(AGRRNO,4,5)_"-"_$E(AGRRNO,6,9) W ?49,"R=" W:$P(^AUPNRRE(DFN,0),U,3) $P(^AUTTRRP($P(^AUPNRRE(DFN,0),U,3),0),U),"-" W AGRRNO S AGTOTR=AGTOTR+1 K AGRRNO  ;IHS/OIT/NKD AG*7.1*14
 ;IHS/OIT/NKD AG*7.1*14 - START NEW CODE
WRRE  ;
 S AGRRNO=$$GETRRE^AGUTL(DFN),AGISMBI=$$ISMBI^AGUTL(AGRRNO)
 I 'AGISMBI,AGISMBI["RRE" S AGRRNO=$S($L(AGRRNO)>9:$E(AGRRNO,1,$L(AGRRNO)-9)_"-",1:"")_$E(AGRRNO,$L(AGRRNO)-8,$L(AGRRNO)-6)_"-"_$E(AGRRNO,$L(AGRRNO)-5,$L(AGRRNO)-4)_"-"_$E(AGRRNO,$L(AGRRNO)-3,$L(AGRRNO))
 W ?49,$S($L(AGRRNO):"R="_AGRRNO,1:"NO NUMBER ")
 S AGTOTR=AGTOTR+1 K AGRRNO,AGISMBI
 Q
 ;IHS/OIT/NKD AG*7.1*14 - END NEW CODE
PMCNM K AGMCRNM I $D(^AUPNMCR(DFN,0)),$D(^AUPNMCR(DFN,21)) S AGMCRNM=$P(^AUPNMCR(DFN,21),U) W:AGMCRNM]"" !,"(MCR) ",AGMCRNM K AGMCRNM
 Q
RRENM K AGRRNM I $D(^AUPNRRE(DFN,0)),$D(^AUPNRRE(DFN,21)) S AGRRNM=$P(^AUPNRRE(DFN,21),U) W:AGRRNM]"" !,"(RR)  ",AGRRNM K AGRRNM
 Q