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

AGED42.m

Go to the documentation of this file.
AGED42 ; IHS/ASDS/EFG - EDIT - PAGE 4 NEW MEDICARE SCREEN - PG2 ;
 ;;7.1;PATIENT REGISTRATION;**1,2,10**;AUG 25, 2005;Build 7
 ;
EN(WD0,WD1,NEWENTRY,AGSELECT) ;EP -
 ;IF ITS A NEW ENTRY THEN DISPLAY THE SCREEN, DISPLAY MESSAGE, AUTO-
 ;MATICALLY ENTER A NEW PATIENT RECORD THEN ASK FOR THE DATE
 N MCRPTR
 S MCRPTR=$P($G(AGSELECT),U,2)  ;IF AGSELECT THEN SELECTION WAS MADE ON SUMMARY PAGE
 S:MCRPTR="" MCRPTR=$O(^AUTNINS("B","MEDICARE",""))  ;OTHERWISE DEFAULT TO MEDICARE
 I NEWENTRY D
 .D DRAW,WMSG,NEWENTRY I +$G(Y)<0 D CLEANZER(WD0) W !,"New entry not made" H 3 D END Q
 .D DTWC I +$G(Y)<0 D CLEANZER(WD0) W !,"New entry not made" H 3 D END Q
 .S COMPIEN=WD0_","_WD1
 .;S AGSELECT=$$UPDTSEL^AGUTILS("FINDMCR",.AGINS,COMPIEN)
 .S AGSELECT=$$UPDTSEL^AGUTILS(.AGINS,COMPIEN,AGELP("INS"))  ;AG*7.1*1 IM18549 ERROR IN ERROR MSG UPDATE
 .S NEWENTRY=0
VAR D DRAW
 I $D(AGSEENLY) K DIR S DIR(0)="E",DIR("A")="Press return" D ^DIR Q
 W !,AGLINE("EQ")
 ;PROMPT FOR MSP UPDATE
 I MSPALERT D
 .W !,"AN MSP MUST BE DONE EVERY 90 DAYS! ENTER ""A"" TO ADD ONE NOW"
 .W !
 K DIR
 S DIR("?")="Enter your choice now."
 S DIR("?",1)="You may enter the item number of the field you wish to edit,"
 S DIR("?",2)="OR you can enter 'P#' where P stands for 'page' and '#' stands for"
 S DIR("?",3)="the page you wish to jump to, OR enter '^' to go back one page"
 S DIR("?",4)="OR, enter '^^' to exit the edit screens, OR RETURN to go to the next screen."
 S DIR("A")="Press return to return to Page 4"
 D READ^AGED1
 I Y?1.N,(Y'="") W !,"EDITING OF COVERAGE TYPE PART A AND PART B MUST BE",!,"DONE THROUGH TABLE MAINTENANCE!" H 2 G VAR
 G END:$D(DLOUT)!(Y["N")!$D(DUOUT),VAR:$D(AG("ERR"))
 Q:$D(DFOUT)!$D(DTOUT)
 I $D(DQOUT)!(+Y<1)!(+Y>$G(AG("N")))&(Y'="A") W !!,"You must enter a number from 1 to ",$G(AG("N")) H 2 G VAR
 I Y["A" D ADDMSP G VAR
 G VAR:$G(AG("C"))=""
 S AGY=Y
 F AGI=1:1 S AG("SEL")=+$P(AGY,",",AGI) Q:AG("SEL")<1!(AG("SEL")>AG("N"))  D @($P(AG("C"),",",AG("SEL")))
 S AGSELECT=$$UPDTSEL^AGUTILS(.AGINS,COMPIEN,$P(AGSELECT,U,2))  ;AG*7.1*1 IM18549 ERROR IN ERROR MSG UPDATE
 D UPDATE1^AGED(DUZ(2),DFN,3,"")
 K AGI,AGY
 G VAR
CLEAN(WD0) ;CLEAN EMPTY RECORD. IF NO ELIGIBILITY DATES RECORD IS
 ;MEANINGLESS
 I $G(WD1)="" D CLEANZER(WD0)
 Q
CLEANZER(WD0) ;EP - CLEAN ZERO NODE WITH NO DATES
 K DIK,DA
 S DIK="^AUPNMCR(",DA=WD0 D ^DIK
 Q
END K AG,DLOUT,DTOUT,DFOUT,DQOUT,DA,DIC,DR,AGSCRN,Y,ADA,WDA,ADT,WDT,ADFN,WDFN,REC
 Q
DRAW ;EP
 S AG("PG")="4MCRB"
 S ROUTID=$P($T(+1)," ")  ;SET ROUTINE ID FOR PROGRAMMER VIEW
 D HDR
 D GETAW
 Q
HDR ;
 S AGPAT=$P($G(^DPT(DFN,0)),U)
 S AGCHRT=$S($D(^AUPNPAT(DFN,41,DUZ(2),0)):$P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,2),1:"xxxxx")
 S AG("AUPN")=""
 S:$D(^AUPNPAT(DFN,0)) AG("AUPN")=^(0)
 S AGLINE("-")=$TR($J(" ",78)," ","-")
 S AGLINE("EQ")=$TR($J(" ",78)," ","=")
 S $P(AGLINE("PGLN"),"=",81)=""
 W $$S^AGVDF("IOF"),!
 D PROGVIEW^AGUTILS(DUZ)
 W "IHS REGISTRATION ",$S($D(AGSEENLY):"VIEW SCREEN",1:"EDITOR")
 W ?36,"MEDICARE PAGE B"
 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")
 S DA=DFN
 K AG("EDIT")
 Q
GETAW ;DISPLAY
 W !,"MEDICARE SECONDARY PAYER  (Enter ""A"" to add a new MSP reason)"
 W !,AGLINE("-")
 W !,"DATE OBTAINED",?20,"STATUS",?30,"REASON"
 W !,AGLINE("-"),!
 D MSP
 W !,"PART A BENEFITS ",$E(AGLINE("-"),1,28)," PART B BENEFITS ",$E(AGLINE("-"),1,19)
 S PARTAIEN=$$PARTIEN(MCRPTR,"A")
 S PARTBIEN=$$PARTIEN(MCRPTR,"B")
 ;ACTIVATE NEXT THREE LINES IF CO-PAY/DED RATES ARE TO BE ENTERED THROUGH TABLE MAINT.
 S PARTAD0=$$CHKDATES(PARTAIEN) W:'PARTAD0 "NO ACTIVE 'CO-PAY/DED RATES'"
 S PARTBD0=$$CHKDATES(PARTBIEN) W:'PARTBD0 ?45,"NO ACTIVE 'CO-PAY/DED RATES'"
 Q:'PARTAD0&('PARTBD0)
 K AG("C")
 F AG=1:1 D  Q:$G(AGSCRN)[("*END*")
 . S AGSCRN=$P($T(@1+AG),";;",2,15)
 . Q:AGSCRN[("*END*")
 . S CAPTION=$P(AGSCRN,U)  ;FIELD CAPTION
 . S DIC=$P(AGSCRN,U,3)    ;FILE OR SUBFILE #
 . S DR=$P(AGSCRN,U,4)      ;FLD #
 . S NEWLINE=$P(AGSCRN,U,5)  ;NEWLINE OR INDENT
 . S CAPDENT=$P(AGSCRN,U,2)   ;CAPTION INDENT
 . S ITEMNUM=$P(AGSCRN,U,6)   ;ITEM #
 . S TAGCALL=$P(AGSCRN,U,7)   ;TAG TO CALL TO EDIT THIS FLD
 . S EXECUTE=$P(AGSCRN,"|",2)      ;USE TO DISP FLD WHICH IS DEPENDENT ON ANOTHER FLD
 . S PREEXEC=$P(AGSCRN,"|",3)
 . S:TAGCALL'="" $P(AG("C"),",",ITEMNUM)=TAGCALL   ;SELECTION STRING
 . W @NEWLINE,ITEMNUM,$S(ITEMNUM'="":". ",1:""),@CAPDENT,$S($G(CAPTION)'="":CAPTION_": ",$G(CAPTION)="":"",1:$P($G(^DD(DIC,DR,0)),U)_": ")
 . I DIC=9000003 D  Q
 .. S D0=DFN
 .. W $$GET1^DIQ(DIC,D0,DR)
 . I DR=.15!(DR=.16)!(DR=.17)!(DR=.18) W $J($$GET1^DIQ(DIC,PARTAD0,DR),10,2)
 . I DR=.19 W $$GET1^DIQ(DIC,PARTAD0,DR)
 . I DR=.21 W $J($$GET1^DIQ(DIC,PARTBD0,DR),10,2)
 . I DR=.22 W $J($$GET1^DIQ(DIC,PARTBD0,DR),10)," %"
 . K PARTAIEN,PARTBIEN
 S AG("N")=$L(AG("C"),",")
CONT ;
 K MYERRS,MYVARS
 D FETCHERR^AGEDERR(AG("PG"),.MYERRS)
 S MYVARS("DFN")=DFN,MYVARS("FINDCALL")="FINDMCR",MYVARS("SELECTION")=$G(AGSELECT),MYVARS("SITE")=DUZ(2)
 I '$G(NEWENTRY) D EDITCHEK^AGEDERR(.MYERRS,.MYVARS,1)
 W !,$G(AGLINE("-"))
 D VERIF^AGUTILS
 Q
WMSG ;DISPLAY THIS MSG IF THERE IS NO ENTRY IN THE MEDICARE ELIGIBILITY
 ;GLOBAL
 W !,"You must first enter the MEDICARE ELIGIBILITY"
 Q
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; MEDICARE ELIGIBILITY FIELDS
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;
DTWC ;
NEWENTRY ;NEW ENTRY
 W !!
 K DIC,DIE,DR,DA
 S DIC="^AUPNMCR("
 S DIC(0)="L"
 S X="`"_DFN
 K DD,DO
 D ^DIC
 Q:+Y'>0
 S WD0=+Y
 S NEWENTRY=0
 Q
MSP ;GET DATA FROM AUPNMSP
 N DIFF,X,X1,X2  ;AG*7.1*10 - Fixing bug (below)
 S AG("MSPDT")="",AG("CNT")=0
 ;IS LAST MSP DATE GREATER THAN 89 DAYS
 S MSPALERT=0
 S LASTMSP=$O(^AUPNMSP("C",DFN,AG("MSPDT")),-1)
 S X1=DT,X2=LASTMSP D ^%DTC S DIFF=X ;AG*7.1*10 - Fixing bug
 ;I (DT-LASTMSP)>89 S MSPALERT=1
 ;AG*7.1*10 - Commented out next line and replaced with the following 2 lines to fix bug
 ;I $$ACTELIG^AGEDERR2(DFN,"^MCR"),((DT-LASTMSP)>89) S MSPALERT=1  ;AG*7.1*1 IM19440 IF NO ACTIVE MEDICARE DON'T CHECK
 I $$ACTELIG^AGEDERR2(DFN,"^MCR"),'DIFF!(DIFF>89) S MSPALERT=1
 K DIFF,X,X1,X2
 ;
 F  S AG("MSPDT")=$O(^AUPNMSP("C",DFN,AG("MSPDT")),-1) Q:'AG("MSPDT")  D
 . S AG("REC")=0
 . F  S AG("REC")=$O(^AUPNMSP("C",DFN,AG("MSPDT"),AG("REC"))) Q:'AG("REC")!(AG("CNT")=4)  D
 .. W ?1,$$GET1^DIQ(9000037,AG("REC"),.01)
 .. W ?20,$$GET1^DIQ(9000037,AG("REC"),.03)
 .. W ?30,$$GET1^DIQ(9000037,AG("REC"),.04)
 .. W ?79,$S(MSPALERT:"A",1:"")
 .. W !
 .. S AG("CNT")=AG("CNT")+1
 K AG("MSPDT"),AG("REC"),AG("CNT")
 Q
ADDMSP ;
 K DIR,DIC,DIE,DA,DR,X,Y,D0,DD
 S DIC("DR")=""
 S DIC="^AUPNMSP("
 S DIC(0)="AELQMZ"
 S DIC("S")="I $P(^(0),U,2)=DFN&($P($G(^(7)),U)="""")"
 D ^DIC
 Q:Y<0
 S DIE=DIC
 S DA=+Y
 S DR=".02////^S X=WD0"
 D ^DIE
 S DR=".03R;S:X=""N"" Y=0;.04R"
 D ^DIE
 Q
INPDED ;INPATIENT DEDUCTIBLE
 K DIC,DR,DIE,DA,DD,D0
 S DA(1)=PARTAIEN
 S DIE="^AUTTPIC("_DA(1)_",19,"
 S DR=.15
 D ^DIE
 K DIC,DR,DIE,DA
 Q
COINS61 ;CO-INSURANCE (61-90)
 K DIC,DR,DIE,DA,DD,D0
 S DA(1)=PARTAIEN
 S DIE="^AUTTPIC("_DA(1)_",19,"
 S DR=.16
 D ^DIE
 K DIC,DR,DIE,DA
 Q
LIFRES ;LIFETIME RESERVE
 K DIC,DR,DIE,DA,DD,D0
 S DA(1)=PARTAIEN
 S DIE="^AUTTPIC("_DA(1)_",19,"
 S DR=.17
 D ^DIE
 K DIC,DR,DIE,DA
 Q
SNF ;SNF C0-INSURANCE
 K DIC,DR,DIE,DA,DD,D0
 S DA(1)=PARTAIEN
 S DIE="^AUTTPIC("_DA(1)_",19,"
 S DR=.18
 D ^DIE
 K DIC,DR,DIE,DA
 Q
DED ;PART B DEDUCTIBLE
 K DIC,DR,DIE,DA,DD,D0
 S DA(1)=PARTBIEN
 S DIE="^AUTTPIC("_DA(1)_",19,"
 S DR=.21
 D ^DIE
 K DIC,DR,DIE,DA
 Q
COINS ;PART B CO-INSURANCE
 K DIC,DR,DIE,DA,DD,D0
 S DA(1)=PARTBIEN
 S DIE="^AUTTPIC("_DA(1)_",19,"
 S DR=.22
 D ^DIE
 K DIC,DR,DIE,DA
 Q
MCRDAY ;MEDICARE DAYS
 K DIC,DR,DIE,DA,DD,D0
 S DA(1)=PARTAIEN
 S DIE="^AUTTPIC("_DA(1)_",19,"
 S DR=.19
 D ^DIE
 K DIC,DR,DIE,DA
 Q
 ;
 ;WILL USE THESE NEXT TWO SUBROUTINESS
 ;MAYBE IF CLERKS ARE ALLOWED TO EDIT THESE FIELDS
 ;THEY NEED TO BE RE WRITTEN
LSTAREC ;FIND LAST PART A RECORD
 S PARTAIEN=$$PARTIEN(MCRPTR,"A")
 ;I PARTAIEN="" w !,"NO ""PART A"" COVERAGE TYPE FOUND IN THE COVERAGE TYPE FILE","PLEASE ENTER A ""PART A"" COVERAGE TYPE WITH 'MEDICARE' AS THE INSURER" 
 S AG("COVDT")=$O(^AUTTPIC(MCRPTR,19,"B",""),-1)
 I AG("COVDT")="" D
 .K DIC
 .S DA(1)=PARTAIEN
 .S DIC="^AUTTPIC("_DA(1)_",19,"
 .S DIC(0)="AELMQ"
 .S DIC("P")=$P($G(^DD(9999999.65,19,0)),U,2)
 .S DIC("A")="Enter the start date for the Part A benefits "
 .D ^DIC
 .S:Y'=-1 AG("COVDT")=$P(Y,U,2)
 .Q:Y=-1
 I AG("COVDT")="" Q
 S AG("REC")=$O(^AUTTPIC(PARTAIEN,19,"B",AG("COVDT"),""),-1)
 S DA=AG("REC")
 Q
LSTBREC ;FIND LAST PART B RECORD
 S PARTBIEN=$$PARTIEN(MCRPTR,"B")
 I PARTBIEN="" W !,"NO ""PART B"" COVERAGE TYPE FOUND IN THE COVERAGE TYPE FILE","PLEASE ENTER A ""PART B"" COVERAGE TYPE WITH MEDICARE AS THE INSURER"
 S AG("COVDT")=$O(^AUTTPIC(PARTBIEN,19,"B",""),-1)
 I AG("COVDT")="" D
 .K DIC
 .S DA(1)=PARTBIEN
 .S DIC="^AUTTPIC("_DA(1)_",19,"
 .S DIC(0)="AELMQ"
 .S DIC("P")=$P($G(^DD(9999999.65,19,0)),U,2)
 .S DIC("A")="Enter the start date for the Part B benefits. "
 .D ^DIC
 .S:Y'=-1 AG("COVDT")=$P(Y,U,2)
 .Q:Y=-1
 I AG("COVDT")="" Q
 S AG("REC")=$O(^AUTTPIC(PARTBIEN,19,"B",AG("COVDT"),""),-1)
 S DA=AG("REC")
 Q
 ;RETURN PART IEN
PARTIEN(MCRPTR,PART) ;
 S FOUND=0,RETURN=0
 N PARTIEN
 S PARTIEN=""
 F  S PARTIEN=$O(^AUTTPIC("C",MCRPTR,PARTIEN)) Q:'PARTIEN!(FOUND)  D
 .I $P($G(^AUTTPIC(PARTIEN,0)),U)=("PART "_PART) S FOUND=1,RETURN=PARTIEN Q
 Q RETURN
 ;CHECK FOR WHICH 19 NODE WE NEED BASED ON THE START DATES ENTERED
 ;WHEN ACTIVE DATE FOUND RETURN D0 FOR USE IN GET1 CALL
CHKDATES(PARTIEN) ;
 N RETURN,DTREC
 S RETURN=0
 S EFFDT=""
 F  S EFFDT=$O(^AUTTPIC(PARTIEN,19,"B",EFFDT)) Q:'EFFDT  D
 .S ENDDT=$O(^AUTTPIC(PARTIEN,19,"B",EFFDT))
 .S ACTIVE=$$ISACTIVE^AGUTILS(EFFDT,ENDDT)
 .I ACTIVE S DTREC=$O(^AUTTPIC(PARTIEN,19,"B",EFFDT,"")) S RETURN=DTREC_","_PARTIEN_","
 Q RETURN
 ; ****************************************************************
 ; ON LINES BELOW:
 ; U "^" DELIMITED
 ; PIECE 1= FLD LBL
 ; PIECE 2= POSITION ON LINE TO DISP ITEM #
 ; PIECE 3= FILE #
 ; PIECE 4= FLD #
 ; PIECE 5= NEW LINE OR NOT (MUST BE EITHER A '!' OR '?#') USE THIS TO INDENT THE CAP
 ; PIECE 6= ITEM # OVERIDE. USE THIS TO OVERIDE THE ITEM # USED TO CHOOSE THIS
 ;          FLD ON THE SCREEN
 ; PIECE 7= TAG TO CALL WHEN THIS FLD IS CHOSEN TO EDIT
 ;
 ; BAR "|" DELIMITED
 ; 2      EXECUTE    EXECUTE CODE TO GET FLD THAT ANOTHER IS POINTING TO. EXECUTED AFTER FLD PRINT
 ; 3      PREEXEC    EXECUTE CODE TO DO BEFORE FLD PRINTS.
 ;                   USE TO SCREEN OUT PRINTING A FLD VALUE
 ; 4      PRECAPEX   EXECUTE CODE TO DO BEFORE PRINTING THE CAP OR FLD LBL.
 ;                   USE TO SCREEN OUT PRINTING A CAP/FLD LBL
 ; 5      POSTEXEC   EXECUTE CODE TO DO AFTER PRINTING THE FLD DATA
 ;QMB/SLMB...............^?3^9000003^.08^!^8^QMBSLMB
1 ;
 ;;Inpatient Deductible...^?3^9999999.6519^.15^!^1^INPDED
 ;;Deductible..^?40^9999999.6519^.21^?45^5^DED
 ;;Co-insurance (61-90)...^?3^9999999.6519^.16^!^2^COINS61
 ;;Co-insurance^?40^9999999.6519^.22^?45^6^COINS
 ;;Lifetime Reserve.......^?3^9999999.6519^.17^!^3^LIFRES
 ;;SNF Co-insurance.......^?3^9999999.6519^.18^!^4^SNF
 ;;Medicare Days..........^?3^9999999.6519^.19^!!^7^MCRDAY
 ;;*END*