source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGMTU3.m@ 1141

Last change on this file since 1141 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.1 KB
RevLine 
[613]1DGMTU3 ;ALB/MLI/GN/LBD - Internal Entry Number Utility Calls ; 2/20/03 8:45am
2 ;;5.3;Registration;**33,45,137,182,300,433,499,518**;Aug 13, 1993
3 ;
4 ; This routine will return the IENs for the primary income
5 ; test from various files.
6 ;
7MTIEN(TYPE,DFN,INVDT) ; get last primary income test for date
8 ;
9 ; Input -- TYPE as 1 for means test, 2 for copay test
10 ; DFN as Patient IEN
11 ; INVDT as inverse date for search
12 ; Output -- Record IEN
13 ;
14 N I
15 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
16 Q I
17 ;
18 ;
19IAI(REL,YEAR,DGMTYPT) ; get individual annual income IEN for primary income test/pt relation
20 ;
21 ; Input -- REL as IEN of PATIENT RELATION file
22 ; YEAR as income year in question
23 ; DGMTYPT as type of test (optional if not defined means test
24 ; will be assumed)
25 ; Output -- Record IEN
26 ;
27 N DFN,I,IEN,INR,MTIEN,LAST,DGDT,LTCIEN
28 S DFN=+$G(^DGPR(408.12,+REL,0)) I 'DFN G IAIQ
29 ;
30 ;DG*5.3*499, change to if structure and check for presence of DGMTI
31 ; it is not defined when coming from Bene travel menus
32 ;LTC Phase III (DG*5.3*518) - add setting of LTCIEN
33 ;
34 ; if user selects view option & DGMTI exists, set IEN=DGMTI
35 I $G(DGMTACT)="VEW",$G(DGMTI) D
36 . S (MTIEN,LTCIEN)=DGMTI
37 E D
38 . S DGDT=$E(YEAR,1,3)+1_"1231.99"
39 . S MTIEN=$$LST^DGMTU(DFN,DGDT,$S($G(DGMTYPT):DGMTYPT,1:1))
40 . S LTCIEN=$S($G(DGMTI):DGMTI,1:$$LST^EASECU(DFN,(YEAR+1231.99),3))
41 ;
42 I MTIEN S LAST=0 D
43 . 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
44 . S IEN=LAST
45 . ; The following was added for LTC Copay Phase II (DG*5.3*433)
46 . ; If the IAI record is associated with a LTC Copay Test (type 3),
47 . ; don't return it if DGMTYPT is not type 3.
48 . Q:'$G(^DGMT(408.21,IEN,"MT"))
49 . I $P($G(^DGMT(408.31,+^DGMT(408.21,IEN,"MT"),0)),U,19)=3,$G(DGMTYPT)'=3 S IEN=""
50 . ; If DGMTYPT=3 make sure the IAI record is associated with the
51 . ; correct LTC Copay test. Added for LTC Phase III (DG*5.3*518)
52 . I $G(DGMTYPT)=3,+^DGMT(408.21,IEN,"MT")'=+LTCIEN S IEN=""
53 ;
54 ; if veteran doesn't have a mt
55 I 'MTIEN D
56 . ; The following was added for LTC Copay Phase II (DG*5.3*433)
57 . ; If the IAI record is associated with a LTC Copay Test (type 3),
58 . ; don't return it if DGMTYPT is not type 3.
59 . 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
60 .. I $P($G(^DGMT(408.31,+^DGMT(408.21,IEN,"MT"),0)),U,19)=3,$G(DGMTYPT)'=3 S IEN=""
61 .. ; If DGMTYPT=3 make sure the IAI record is associated with the
62 .. ; correct LTC Copay test. Added for LTC Phase III (DG*5.3*518)
63 .. I $G(DGMTYPT)=3,+^DGMT(408.21,IEN,"MT")'=+LTCIEN S IEN=""
64IAIQ Q $G(IEN)
65 ;
66 ;
67MTIENLT(TYPE,DFN,INVDTL) ; get last primary income test on or before date
68 ;
69 ; Input -- TYPE as 1 for means test, 2 for copay test
70 ; DFN as Patient IEN
71 ; INVDTL as inverse date for search
72 ; Output -- Record IEN
73 ;
74 N K
75 S K=""
76 F S INVDTL=$O(^DGMT(408.31,"AID",TYPE,DFN,INVDTL)) Q:'INVDTL S K=$$MTIEN(TYPE,DFN,INVDTL) Q:K
77 Q K
Note: See TracBrowser for help on using the repository browser.