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

DGMTU3.m

Go to the documentation of this file.
  1. DGMTU3 ;ALB/MLI/GN/LBD - Internal Entry Number Utility Calls ; 2/20/03 8:45am
  1. ;;5.3;Registration;**33,45,137,182,300,433,499,518**;Aug 13, 1993
  1. ;
  1. ; This routine will return the IENs for the primary income
  1. ; test from various files.
  1. ;
  1. MTIEN(TYPE,DFN,INVDT) ; get last primary income test for date
  1. ;
  1. ; Input -- TYPE as 1 for means test, 2 for copay test
  1. ; DFN as Patient IEN
  1. ; INVDT as inverse date for search
  1. ; Output -- Record IEN
  1. ;
  1. N I
  1. F I=0:0 S I=$O(^DGMT(408.31,"AID",TYPE,DFN,INVDT,I)) Q:'I I +$G(^DGMT(408.31,I,"PRIM")) Q
  1. Q I
  1. ;
  1. ;
  1. IAI(REL,YEAR,DGMTYPT) ; get individual annual income IEN for primary income test/pt relation
  1. ;
  1. ; Input -- REL as IEN of PATIENT RELATION file
  1. ; YEAR as income year in question
  1. ; DGMTYPT as type of test (optional if not defined means test
  1. ; will be assumed)
  1. ; Output -- Record IEN
  1. ;
  1. N DFN,I,IEN,INR,MTIEN,LAST,DGDT,LTCIEN
  1. S DFN=+$G(^DGPR(408.12,+REL,0)) I 'DFN G IAIQ
  1. ;
  1. ;DG*5.3*499, change to if structure and check for presence of DGMTI
  1. ; it is not defined when coming from Bene travel menus
  1. ;LTC Phase III (DG*5.3*518) - add setting of LTCIEN
  1. ;
  1. ; if user selects view option & DGMTI exists, set IEN=DGMTI
  1. I $G(DGMTACT)="VEW",$G(DGMTI) D
  1. . S (MTIEN,LTCIEN)=DGMTI
  1. E D
  1. . S DGDT=$E(YEAR,1,3)+1_"1231.99"
  1. . S MTIEN=$$LST^DGMTU(DFN,DGDT,$S($G(DGMTYPT):DGMTYPT,1:1))
  1. . S LTCIEN=$S($G(DGMTI):DGMTI,1:$$LST^EASECU(DFN,(YEAR+1231.99),3))
  1. ;
  1. I MTIEN S LAST=0 D
  1. . F I=0:0 S I=$O(^DGMT(408.21,"AI",+REL,-YEAR,I)) Q:'I S LAST=I,INR=$O(^DGMT(408.22,"AIND",I,"")) I +$G(^DGMT(408.22,+INR,"MT"))=+MTIEN Q
  1. . S IEN=LAST
  1. . ; The following was added for LTC Copay Phase II (DG*5.3*433)
  1. . ; If the IAI record is associated with a LTC Copay Test (type 3),
  1. . ; don't return it if DGMTYPT is not type 3.
  1. . Q:'$G(^DGMT(408.21,IEN,"MT"))
  1. . I $P($G(^DGMT(408.31,+^DGMT(408.21,IEN,"MT"),0)),U,19)=3,$G(DGMTYPT)'=3 S IEN=""
  1. . ; If DGMTYPT=3 make sure the IAI record is associated with the
  1. . ; correct LTC Copay test. Added for LTC Phase III (DG*5.3*518)
  1. . I $G(DGMTYPT)=3,+^DGMT(408.21,IEN,"MT")'=+LTCIEN S IEN=""
  1. ;
  1. ; if veteran doesn't have a mt
  1. I 'MTIEN D
  1. . ; The following was added for LTC Copay Phase II (DG*5.3*433)
  1. . ; If the IAI record is associated with a LTC Copay Test (type 3),
  1. . ; don't return it if DGMTYPT is not type 3.
  1. . S IEN="" F I=0:0 S I=$O(^DGMT(408.21,"AI",+REL,-YEAR,I)) Q:'I S IEN=I Q:'$G(^DGMT(408.21,IEN,"MT")) D Q:IEN
  1. .. I $P($G(^DGMT(408.31,+^DGMT(408.21,IEN,"MT"),0)),U,19)=3,$G(DGMTYPT)'=3 S IEN=""
  1. .. ; If DGMTYPT=3 make sure the IAI record is associated with the
  1. .. ; correct LTC Copay test. Added for LTC Phase III (DG*5.3*518)
  1. .. I $G(DGMTYPT)=3,+^DGMT(408.21,IEN,"MT")'=+LTCIEN S IEN=""
  1. IAIQ Q $G(IEN)
  1. ;
  1. ;
  1. MTIENLT(TYPE,DFN,INVDTL) ; get last primary income test on or before date
  1. ;
  1. ; Input -- TYPE as 1 for means test, 2 for copay test
  1. ; DFN as Patient IEN
  1. ; INVDTL as inverse date for search
  1. ; Output -- Record IEN
  1. ;
  1. N K
  1. S K=""
  1. F S INVDTL=$O(^DGMT(408.31,"AID",TYPE,DFN,INVDTL)) Q:'INVDTL S K=$$MTIEN(TYPE,DFN,INVDTL) Q:K
  1. Q K