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

AGED6.m

Go to the documentation of this file.
AGED6 ; IHS/ASDS/EFG -EDIT PG 6 RAILROAD RETIREMENT;   
 ;;7.1;PATIENT REGISTRATION;**1,2,3,13**;AUG 25, 2005;Build 1
 ;IHS/OIT/NKD AG*7.1*13 MBI IMPLEMENTATION
 ;
EN(AGSELECT) ;EP
 S:$G(AGSELECT)="" AGSELECT="",NEWENTRY=1
VAR ;
 S AG("PG")="4RRA"
HDR ;
 S ROUTID=$P($T(+1)," ")
 W $$S^AGVDF("IOF"),!
 D PROGVIEW^AGUTILS(DUZ,$P(AGSELECT,U,11))
 W "IHS REGISTRATION ",$S($D(AGSEENLY):"VIEW SCREEN",1:"EDITOR")
 W ?30,"RAILROAD RETIREMENT"
 W ?80-$L($P($G(^DIC(4,DUZ(2),0)),U)),$P($G(^DIC(4,DUZ(2),0)),U)
 S AGLINE("-")=$TR($J(" ",80)," ","-")
 S AGLINE("EQ")=$TR($J(" ",80)," ","=")
 W !,AGLINE("EQ")
 W !,$E(AGPAT,1,23)
 W ?23,$$DTEST^AGUTILS(DFN)
 I $D(AGCHRT) W ?42,"HRN#:",AGCHRT
 ;GET ELIGIBILITY STATUS
 S AGELSTS=$P($G(^AUPNPAT(DFN,11)),U,12)
 W ?56,"(",$S(AGELSTS="C":"CHS & DIRECT",AGELSTS="I":"INELIGIBLE",AGELSTS="D":"DIRECT ONLY",AGELSTS="P":"PENDING VERIFICATION",1:"NONE"),")"
 ;W !,AGLINE("EQ")
 W "================================== RAILROAD PART A AND B DATA ONLY ======================="  ;IHS/SD/TPF 12/20/2005 AG*7.1*1 ITEM 2
 S DA=DFN
 K AG("EDIT")
 G DISP
NONE ;
 Q:$D(AGSEENLY)
 S AG("EDIT")=""
 ;AG/SD/TPF 12/20/2005 AG*7.1*1 ITEM 2
 I AGTYPE="MD" I $$NOPARTAB(DFN) W !,"PATIENT MUST HAVE RAILROAD PART A OR B BEFORE ADDING PART D" H 3 Q
 D ADDNEW^AG6
 I '$O(^AUPNRRE(DFN,11,0)) K ADDCHK W !,"No eligibility date was entered!" H 3 D CLEANZER(DFN) Q
 D UPDATE1^AGED(DUZ(2),DFN,4,"")
 S NEWENTRY=0
 G VAR
CLEANZER(WD0) ;EP - CLEAN ZERO NODE WITH NO DATES
 K DIK,DA
 S DIK="^AUPNRRE(",DA=WD0 D ^DIK
 Q
NOPARTAB(DFN) ;EP - DETERMINE IF PATIENT ALREADY HAS EITHER RR PART A OR B
 N DTREC,NOPARTAB
 S DTREC=0,NOPARTAB=1  ;ASSUME THEY DON'T HAVE IT
 F  S DTREC=$O(^AUPNRRE(DFN,11,DTREC)) Q:'DTREC  D  Q:'NOPARTAB
 .I $P($G(^AUPNRRE(DFN,11,DTREC,0)),U,3)="A" S NOPARTAB=0 Q
 .I $P($G(^AUPNRRE(DFN,11,DTREC,0)),U,3)="B" S NOPARTAB=0 Q
 Q NOPARTAB
DISP ;
 K AGMSPDT,AGMSPIEN,AGMSP,AGMSPR
 S AGMSPDT=$O(^AUPNMSP("C",AUPNPAT,""),-1)
 I $G(AGMSPDT)'="" S AGMSPIEN=$O(^AUPNMSP("C",AUPNPAT,AGMSPDT,""),-1)
 I $G(AGMSPIEN)'="" S AGMSP=$G(^AUPNMSP(AGMSPIEN,0))
 ;MSP patient
 W !,"1.MSP Patient(Y/N) : "
 W $P($G(AGMSP),U,3)
 W ?30,"Date signature obtained: "
 S Y=$P($G(AGMSP),U)
 D DD^%DT
 W Y
 W !,?2,"MSP Reason       : "
 S AGMSPR=$P($G(AGMSP),U,4)
 S AGMSPFLG=0,AGMSPRT=0
 F AGMSPRT=1:1 Q:AGMSPFLG=1  D
 . S AGTEST=$P($T(AGREASON+AGMSPRT),";",3)
 . I AGTEST="Q" S AGMSPFLG=1 Q
 . I AGTEST=AGMSPR S AGMSPR=$P($T(AGREASON+AGMSPRT),";",4),AGMSPFLG=1
 W AGMSPR
 K AGTEST,AGMSPFLG,AGMSPRT
 ;QMB/SLMB
 S DIC=9000005,DR=.08
 W !,"2.QMB/SLMB         : "
 D ^AGDICLK
 I '$D(AG("LKERR")) W AG("LKPRINT")
 S DIC=9000001,DR=.04
 W !,"3.Med. Release Date: "
 D ^AGDICLK
 I '$D(AG("LKERR")) W AG("LKPRINT")
 W !
 ;F AG("CTR")=1:1:80 W "."
 W "........................ RAILROAD PART A AND B DATA ONLY ........................"  ;IHS/SD/TPF 12/20/2005 AG*7.1*1 ITEM 2
 ;railroad name
 S DIC=9000005,DR=2101
 D ^AGDICLK
 W ?4,"4.Railroad Name : ",$G(AG("LKPRINT"))
 ;;prefix
 ;S DIC=9000005,DR=.03
 ;W ?49,"5.Railroad Number: "
 ;D ^AGDICLK
 ;I '$D(AG("LKERR")) W AG("LKPRINT")
 ;;railroad number
 ;S DIC=9000005,DR=.04
 ;D ^AGDICLK
 ;I '$D(AG("LKERR")) W AG("LKPRINT")
 W ?49,"5.Railroad Number: ",$$GETRRE^AGUTL(AGPATDFN)  ;IHS/OIT/NKD AG*7.1*13
 W !
 ;primary care provider
 S DIC=9000005,DR=.14
 W ?4,"6.Prim. Care Prv: "
 D ^AGDICLK
 I '$D(AG("LKERR")) W AG("LKPRINT")
 ;
 ;railroad dob
 S DIC=9000005
 I $$ISREQ^AGFLDREQ(9000005,.2102) S DIE("NO^")="",DR="2102R"
 E  S DR="2102"
 D ^AGDICLK
 W ?49,"7.Date of Birth  : "
 I '$D(AG("LKERR")) W AG("LKPRINT")
 W !
 ;cc on file
 S DIC=9000005,DR=.15
 W ?4,"8.CC on file    : "
 D ^AGDICLK
 I '$D(AG("LKERR")) W AG("LKPRINT")
 I $G(AG("LKPRINT"))["Y" D
 .S DIC=9000005,DR=.16      ;date cc obtained
 .W ?28,"Date obtained: "
 .D ^AGDICLK
 .I '$D(AG("LKERR")) W AG("LKPRINT")
 W !!
 ;W ?5,"ELIG DATE BEGIN",?29,"(updated)",?48,"Coverage",?65,"ELIG END",!
 W ?5,"ELIG DATE BEGIN",?29,"(updated)",?42,"Cov",?47,"Plan Name",?70,"ELIG END",!  ;IHS/SD/TPF 12/2/2005 AG*7.1*1
 F AG("CTR")=1:1:80 W "."
 ;W !
ELIG ;
 ;REPLACE THIS OLD CODE
 ;S DIC=9000005.11
 ;S AG("TOTAL")=0
 ;S AG("N")=9
 ;F AG("I")=1:1 D  Q:$D(AG("LKERR"))
 ;. S AG("DRENT")=AG("I"),DR=.02
 ;. D ^AGDICLK
 ;. Q:$D(AG("LKERR"))
 ;. S AG("TOTAL")=AG("TOTAL")+1
 ;. S AG(AG("TOTAL"))=$P(AGL,",",3)
 ;I AG("TOTAL")>0 D
 ;. F AG("I")=1:1:AG("TOTAL") D
 ;.. D PRINT
 ;.. S AG("N")=AG("I")+8
 ;W AGLINE("-")
 ;REPLACE OLD CODE
 ;BEGIN NEW CODE AG*7.1*3 IM23591
 S AG("N")=8  ;THERE ARE 8 ITEMS IN DISPLAY ABOVE
 S REC=0
 F CNT=1:1 S REC=$O(^AUPNRRE(AGPATDFN,11,REC)) Q:'REC  D
 .S IENS=REC_","_AGPATDFN_","
 .W !,CNT+8,".",?6,$$GET1^DIQ(9000005.11,IENS,.01,"E")
 .I CNT=1 D
 ..I $$GET1^DIQ(9000005,AGPATDFN_",",.07,"E")'="" W ?26,$$GET1^DIQ(9000005,AGPATDFN_",",.07,"E")
 .W ?43,$$GET1^DIQ(9000005.11,IENS,.03,"E")
 .W ?48,$$GET1^DIQ(9000005.11,IENS,.04,"E")
 .W ?68,$$GET1^DIQ(9000005.11,IENS,.02,"E")
 .S AG(CNT)=REC
 S AG("N")=AG("N")+CNT-1
 W !,AGLINE("-")
 ;END NEW CODE
 ;AFTER EDITING THE SELECTION MUST BE UPDATED SO ANY ERRORS
 ;CORRECTED WILL BE REFLECTED ON THE REDRAWN SCREEN
 ;S:$G(AGSELECT)'="" AGSELECT=$$FINDRRE^AGINSUPD(AGSELECT)
 I '$G(NEWENTRY),($G(COMPIEN)'="") S AGSELECT=$$UPDTSEL^AGUTILS(.AGINS,COMPIEN,$P(AGSELECT,U,2))  ;AG*7.1*1 IM18549 ERROR IN ERROR UPDATE
 K MYERRS,MYVARS
 D FETCHERR^AGEDERR(AG("PG"),.MYERRS)
 S MYVARS("DFN")=$S($G(AUPNPAT)'="":AUPNPAT,1:$G(DFN)),MYVARS("FINDCALL")="FINDRRE",MYVARS("SELECTION")=$G(AGSELECT),MYVARS("SITE")=DUZ(2)
 D EDITCHEK^AGEDERR(.MYERRS,.MYVARS,1)
 I $D(AGSEENLY) D ^DIR,READ^AGED1 G END
 G:$G(NEWENTRY) NONE
EDIT K DIR
 W !
 I $D(^XUSEC("AGZMGR",DUZ))  D
 . S DIR("A")="(Edit = ""E""  Add = ""A""  Delete = ""D"")  Type E, A, or D"
 I '$D(^XUSEC("AGZMGR",DUZ))  D
 . S DIR("A")="Edit = ""E""  Add = ""A"")  Type E or A"
 K DFOUT,DTOUT,DUOUT,DQOUT,DLOUT,DIROUT
 S DIR(0)="FO"
 D ^DIR
 I $D(^XUSEC("AGZMGR",DUZ))&(Y="D") G KILL
 I '$D(^XUSEC("AGZMGR",DUZ))&(Y="D") G EDIT
 Q:$D(DTOUT)
 S:Y="/.,"!(Y="^^") DFOUT=""
 S:Y="" DLOUT=""
 S:Y="^" (DUOUT,Y)=""
 S:Y?1"?".E!(Y["^") (DQOUT,Y)=""
 G L6:Y="A"
 W !
 G END:$D(DLOUT)!(Y["N")!$D(DUOUT)!($D(DIROUT)),VAR:$D(AG("ERR"))
 G EDIT:Y'="E"&(Y'="A")&(Y'="D")
L5 Q:$D(DFOUT)!$D(DTOUT)
L5A I Y="E" D
 .S DIR("A")="Enter field number to edit"
 .D ^DIR
 Q:Y=AGOPT("ESCAPE")
 G:Y="" VAR
 S AG("SEL")=+Y,AG("INDEX")=+Y-8
 S AGBILL=$$USED^AGED51(DFN,$P($G(^AUPNRRE(DFN,0)),U,2),4,AG("SEL")-8)
 I $L(AGBILL) D
 . S X="IORVON;IORVOFF"
 . D ENDR^%ZISS,HELP^XBHELP("USED","AGED51"),KILL^%ZISS
 . KILL AGBILL
 . G:'$$DIR^XBDIR("Y","Proceed with edit of Date Record","N") VAR
 KILL AGBILL
 G END:$D(DUOUT)!$D(DFOUT)
 I $D(DQOUT)!(+$G(Y)<1)!(+$G(Y)>$G(AG("N"))) W !,"You must enter from 1 - ",$G(AG("N"))  G EDIT
 ;L6 I Y="A" S AG("EDIT")="" D:$P($G(^AUPNRRE(DFN,0)),U,3)="" E3^AGED61 D:$P($G(^AUPNRRE(DFN,0)),U,4)="" E4^AGED61 D ADDCOV^AG6,UPDATE1^AGED(DUZ(2),DFN,4,"") G VAR
L6 I Y="A" S (AG("EDIT"),AG("COV"),COVTYP)="" D:$$GETRRE^AGUTL(DFN)="" E5^AGED61  D ADDCOV^AG6,UPDATE1^AGED(DUZ(2),DFN,4,"") G VAR  ;IHS/OIT/NKD AG*7.1*13
L6A G L7:AG("SEL")<9
 ;BEGIN NEW CODE IHS/SD/TPF 12/5/05 AG*7.1*1 ITEM 1
 ;CHECK FOR COVTYP="D" IF IT IS GO TO THE MEDICARE PHARMACY PAGE
 S COMPIEN=AUPNPAT_",11,"_(AG(AG("SEL")-8))_",0"
 S COVTYP=$P($G(@("^AUPNRRE("_COMPIEN_")")),U,3)
 I COVTYP="D" D EN^AGED6PD(COMPIEN) G VAR
 ;END NEW CODE
 S DIC=9000005.11
 I $G(AG(AG("SEL")-8))="" S Y="E" W !,"Use ""A"" to Add an eligibility date." G L5A
 F DR=.01,.03,.02 D
 . S AG("DRENT1")=$G(AG(AG("SEL")-8))
 . W !,$S(DR=.01:" 9. ELIGIBILITY DATE: ",DR=.03:"10.    COVERAGE TYPE: ",DR=.02:"11.  ELIG. END DATE : ")
 . D ^AGDICLK
 . I '$D(AG("LKERR")) W AG("LKPRINT")
L6B K DIR
 W !!
 S DIR("A")="  Change which? (9-11) "
 K DFOUT,DTOUT,DUOUT,DQOUT,DLOUT,DIROUT
 S DIR(0)="FO"
 D ^DIR
 G:$D(DTOUT) VAR
 S:Y="/.,"!(Y="^^") DFOUT=""
 S:Y="" DLOUT=""
 S:Y="^" (DUOUT,Y)=""
 S:Y?1"?".E!(Y["^") (DQOUT,Y)=""
 G:$D(DFOUT)!$D(DLOUT)!$D(DUOUT) VAR
 G:$D(DTOUT) VAR
 I +$G(Y)<9!(+$G(Y)>11) W !,"Use the numbers 9, 10, or 11.",! G L6B
 S AG("SEL")=+$G(Y)
L7 D ^AGED61,UPDATE1^AGED(DUZ(2),DFN,4,"")
 G VAR
END ;EP
 I $D(DTOUT) S AGTOUT=""
 I '$D(AGSEENLY),('$O(^AUPNRRE(DFN,11,0))) S DIK="^AUPNRRE(",DA=DFN D ^DIK K ADDCHK Q
 I '$D(AGSEENLY) I ($D(MYERRS("C","E"))&(Y'?1N.N)),(Y'["V"),(Y'=AGOPT("ESCAPE")) W !,"ERRORS ON THIS PAGE. PLEASE FIX BEFORE EXITING!!" H 3 G VAR
 Q:Y=$G(AGOPT("ESCAPE"))
 K AG,DFOUT,DTOUT,DQOUT,DLOUT,DA,DIC,DIE,DR,DRENT,AG("DRENT1"),AGL
 K AG("LKERR"),AG("LKPRINT"),Y
 Q:$D(AGXTERN)
 I $D(DIROUT)!$D(DUOUT) K DUOUT,DIROUT Q
 K DIR
 Q
PRINT ;
 S AG("DRENT1")=AG(AG("I"))
 ;elig date
 S DIC=9000005.11
 S DA=DFN,DR=.01
 D ^AGDICLK
 W AG("I")+8,".",?6,AG("LKPRINT")
 ;last updated
 ;S DIC=9000005
 ;S DA=DFN,DR=.07
 ;D ^AGDICLK
 ;I $G(AG("LKPRINT"))'="" W ?26,"("_AG("LKPRINT")_")"
 I AG("I")=1 D
 .S DIC=9000005
 .S DA=DFN,DR=.07
 .D ^AGDICLK
 .I $G(AG("LKPRINT"))'="" W ?26,"("_AG("LKPRINT")_")"
 ;END NEW CODE
 ;coverage type
 S DIC=9000005.11
 S AG("DRENT1")=AG(AG("I")),DR=.03
 D ^AGDICLK
 ;W ?41,$J(AG("LKPRINT"),11)
 W ?43,AG("LKPRINT")  ;IHS/SD/TPF 12/2/2005 AG*7.1*1
 ;BEGIN NEW CODE ADD AG/SD/TPF 12/2/2005 AG*7.1*1
 ;DISPLAY PLAN NAME
 S AG("DRENT1")=AG(AG("I")),DR=.04
 D ^AGDICLK
 W ?48,$E($G(AG("LKPRINT")),1,18)
 ;END NEW CODE  
 ;elig end date
 S AG("DRENT1")=AG(AG("I")),DR=.02
 D ^AGDICLK
 ;W ?65,$J(AG("LKPRINT"),11),!
 W ?68,AG("LKPRINT"),!  ;IHS/SD/TPF 12/2/2005 AG*71.*1
 Q
KILL ;
 K DIR
 S AG("I")=CNT-1  ;GET TOTAL NUMBER OF ELIG DATES FROM NEW DISPLAY AG*7.1*3 IM23591
 I AG("I")=1 S DIR("A")="Are you sure you want to DELETE the COMPLETE record ? (Y/N) " S DIR(0)="Y",DIR("B")="NO" D ^DIR I Y'=1 K DIR G VAR
 I AG("I")=1 S Y=11 D PATCH S DA=DFN,DIK="^AUPNRRE(" D ^DIK W !!,"The COMPLETE eligibility record has been deleted" H 2 G END
 W !!,"Delete which of these coverages? (9 - ",AG("I")+8,") " D READ^AGED1 G END:$D(DTOUT)!$D(DFOUT)!$D(DLOUT)!$D(DUOUT)
 I $D(DQOUT)!(+Y<9)!(+Y>(AG("I")+8)) W !!,"To delete an eligibility record, enter a number from 9 to ",AG("I")+8,". (Press RETURN for ""NO DELETE"".)" D READ^AGED1 G KILL
 K DIR
 S DA(1)=DFN,AG("COUNT")=0,AG("SEL")=0,AG("DELELIG")=0
 F  S AG("SEL")=$O(^AUPNRRE(DA(1),11,AG("SEL"))) Q:AG("COUNT")>(Y-8)  D
 . S AG("COUNT")=AG("COUNT")+1
 . I AG("COUNT")=(Y-8) S AG("DELELIG")=AG("SEL")
 K AG("SEL"),AG("COUNT")
 I +Y>8&(+Y<(AG("I")+8)+1) S DIR("A")="Are you sure you want to DELETE this eligibility record ? (Y/N) " S DIR(0)="Y",DIR("B")="NO" D ^DIR I Y'=1 K DIR G VAR
 S AG("I")=AG("DELELIG")
 K AG("DELELIG")
 ;IHS/SD/TPF 8/2/2006 AG*7.1*2 IM21544
 ;I $P($G(^AUPNMCR(AGPATDFN,11,AG("I"),0)),U,3)="" D  G VAR  ;IHS/OIT/NKD AG*7.1*13 BUG FIX
 I $P($G(^AUPNRRE(DA(1),11,AG("I"),0)),U,3)="" D  G VAR
 .W !,"COVERAGE TYPE FIELD IS NOT POPULATED"
 .W !,"AN UPDATE TO NPIRS CAN NOT BE DONE PROPERLY"
 .W !,"UNLESS THIS FIELD IS POPULATED"
 .K DIR
 .S DIR(0)="E"
 .D ^DIR
 D PATCH
 S DA(1)=DFN,DA=AG("I"),DIK="^AUPNRRE("_DA(1)_",11,"
 D ^DIK
 W !!,"That eligibility record is deleted." H 2
 G VAR
PATCH D NOW^%DTC S AGDTS=%
 S:'$D(^AGPATCH(AGDTS,DUZ(2),DFN)) ^(DFN)=""
 Q:'$D(^AUPNRRE(DFN,11,0))  Q:'$O(^AUPNRRE(DFN,11,0))
 Q:$P($G(^AUPNRRE(DFN,11,AG("I"),0)),U,3)=""
 ;S ^AGPATCH(AGDTS,DUZ(2),DFN,$P(^AUPNRRE(DFN,11,AG("I"),0),U,3))="RROAD^"_$P($G(^AUPNRRE(DFN,0)),U,3,4)_U_$G(^AUPNRRE(DFN,11,AG("I"),0))  ;IHS/OIT/NKD AG*7.1*13
 S ^AGPATCH(AGDTS,DUZ(2),DFN,$P(^AUPNRRE(DFN,11,AG("I"),0),U,3))="RROAD^"_$$GETRRE^AGUTL(DFN)_U_$G(^AUPNRRE(DFN,11,AG("I"),0))
 S:$P($G(^AUPNRRE(DFN,11,AG("I"),0)),U,2)="" $P(^AGPATCH(AGDTS,DUZ(2),DFN,$P(^AUPNRRE(DFN,11,AG("I"),0),U,3)),U,5)=DT
 K AGDTS Q
AGREASON ;
 ;;E;EMPLOYER GROUP HEALTH PLAN (EGHP)
 ;;L;LARGE GROUP HEALTH PLAN (LGHP)
 ;;D;END STAGE RENAL DISEASE (ESRD)
 ;;V;VETERANS ADMINSTRATION (VA)
 ;;W;WORKMANS COMPENSATION
 ;;B;BLACK LUNG
 ;;A;AUTOMOBILE/NO-FAULT
 Q