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

IVMCZMT.m

Go to the documentation of this file.
  1. IVMCZMT ;ALB/MLI/LD/CKN,TDM,EG,TDM,TGH,HM - Creation of HL7 ZMT (means test) segment ;7/19/06 4:41pm
  1. ;;2.0;INCOME VERIFICATION MATCH;**17,53,49,58,81,89,104,105,160,193**;21-OCT-94;Build 37
  1. ;
  1. ; This routine returns the ZMT segment which contains means test
  1. ; data for a selected patient. It differs from the standard segment
  1. ; builder in that it will add default values where needed for
  1. ; fields added by means test sharing - these fields may not have
  1. ; values for old tests, though for new tests the values should be there.
  1. ;
  1. ;
  1. ;
  1. EN(DFN,VAFSTR,VAFMTDT,VAFTYPE,SETID,DELETE,LIMIT) ; Entry point to get ZMT segment
  1. ;
  1. ; Input:
  1. ; DFN - as the IEN or corresponding patient in the PATIENT file
  1. ; VAFSTR - as string of segment fields needed separated by commas
  1. ; VAFMTDT - (optional) as date of desired means test (defaults to latest MT)
  1. ; VAFTYPE - (optional) as type of test: 1 - Means Test (default=1)
  1. ; 2 - Copay Test
  1. ; 4 - LTC Copay Exemption Test
  1. ; SETID - (optional) value to use for SEQ 1, the set id field (1 used
  1. ; as default if not passed.)
  1. ; DELETE - (optional, pass by reference) This array is used to
  1. ; indicate whether the segment is being used to notify of the
  1. ; the deletion of a means test, pharmacy copay test, or a
  1. ; hardship determinatin. If a means test or hardship is being
  1. ; deleted, then VAFTYPE must equal 1. If an Rx copay test is
  1. ; being deleted, then VAFTYPE must equal 2. The subscripts
  1. ; are as follows:
  1. ; DELETE("DATE OF TEST")=<date of test> - indicates
  1. ; the income year of the test that the deletion flags
  1. ; refer to
  1. ; DELETE("HARDSHIP") - if $G(DELETE("HARDSHIP"))=1 then the
  1. ; segment will be created to delete the hardship.
  1. ; DELETE("MT") - if $G(DELETE("MT"))=1 then
  1. ; the segment will be created to delete a means test.
  1. ; DELETE("RX")= if $G(DELETE("RX"))=1 then
  1. ; the segment will be created to delete a pharmacy
  1. ; copay test.
  1. ; DELETE("LTC")= if $G(DELETE("LTC"))=1 then
  1. ; the segment will be created to delete a Long term
  1. ; care copay exemption test.
  1. ; LIMIT - (optional) if $G(LIMIT)=1 then this indicates that a test in
  1. ; an income year other than indicated in the IVM Patient File
  1. ; should NOT be returned in the ZMT segment
  1. ;
  1. ; ****Also assumes all HL7 variables are defined as returned ****
  1. ; by the INIT^HLTRANS call
  1. ;
  1. ; Output - string in the form of the DHCP HL7 ZMT segment
  1. ;
  1. ;
  1. N NODE,PRIM,X,Y,VAFY,NODE2,MTIEN
  1. ;
  1. I '$G(DFN)!($G(VAFSTR)']"") G QUIT
  1. S $P(VAFY,HLFS,22)="",VAFSTR=","_VAFSTR_","
  1. S VAFTYPE=$S($G(VAFTYPE):VAFTYPE,1:1)
  1. S VAFMTDT=$S($G(VAFMTDT):VAFMTDT,1:DT)
  1. S $P(VAFY,HLFS,1)=$S($G(SETID):SETID,1:1)
  1. S (NODE,NODE2,PRIM)=""
  1. ;
  1. ;handle deletions of a test
  1. I ($G(DELETE("MT"))=1),VAFTYPE=1 D G QUIT
  1. .S $P(VAFY,HLFS,2)=$$HLDATE^HLFNC(DELETE("DATE OF TEST")) ; MT Date
  1. .S $P(VAFY,HLFS,3)=HLQ
  1. .I ($G(DELETE("HARDSHIP"))=1) S $P(VAFY,HLFS,24)=HLQ
  1. .S $P(VAFY,HLFS,17)=VAFTYPE ; Type Of Test
  1. ;
  1. I ($G(DELETE("RX"))=1),VAFTYPE=2 D G QUIT
  1. .S $P(VAFY,HLFS,2)=$$HLDATE^HLFNC(DELETE("DATE OF TEST")) ; MT Date
  1. .S $P(VAFY,HLFS,3)=HLQ
  1. .S $P(VAFY,HLFS,17)=VAFTYPE ; Type Of Test
  1. ;
  1. I ($G(DELETE("LTC"))=1),VAFTYPE=4 D G QUIT
  1. .S $P(VAFY,HLFS,2)=$$HLDATE^HLFNC(DELETE("DATE OF TEST")) ; MT Date
  1. .S $P(VAFY,HLFS,3)=HLQ
  1. .S $P(VAFY,HLFS,17)=VAFTYPE ; Type Of Test
  1. ;
  1. ; Income Year requiring transmission from IVM Patient File (301.5)
  1. S IVMIY=$S($D(IVMIY):IVMIY,1:(VAFMTDT-10000))
  1. ;
  1. ; Check for a future dated Income Test
  1. S MTIEN=""
  1. N EC S EC=0
  1. I VAFTYPE'=4 D
  1. . S MTIEN=+$$FUT^DGMTU(DFN,"",$S($G(VAFTYPE):VAFTYPE,1:1))
  1. . I MTIEN D
  1. . . S NODE=$G(^DGMT(408.31,MTIEN,0)),PRIM=$G(^("PRIM")),NODE2=$G(^DGMT(408.31,MTIEN,2))
  1. . . ;the FUT API works off the a XREF that is not deleted if the test
  1. . . ;is no longer future. As a result, you may pick up the wrong income
  1. . . ;year as a return. The check $E(IVMIY,1,3)+1'=$E(+NODE,1,3) must be
  1. . . ;performed here and after the current Primary icnome test section below
  1. . . I ($G(LIMIT)=1),($E(IVMIY,1,3)+1)'=$E(+NODE,1,3) S EC=1
  1. . . Q
  1. . Q
  1. I VAFTYPE'=4,EC S (NODE,NODE2,MTIEN,PRIM)="" ;Q "ZMT"_HLFS_$G(VAFY)
  1. ;
  1. ; Check for a current Primary Income Test
  1. I 'MTIEN S MTIEN=+$$LST^DGMTU(DFN,VAFMTDT,$S($G(VAFTYPE):VAFTYPE,1:1))
  1. S:(NODE="") NODE=$G(^DGMT(408.31,MTIEN,0)),PRIM=$G(^("PRIM")),NODE2=$G(^DGMT(408.31,MTIEN,2))
  1. ;
  1. ;if the wrong income yr, and told to ignore it ($G(LIMIT)=1,
  1. ;send blank means test
  1. I ($G(LIMIT)=1),($E(IVMIY,1,3)+1)'=$E(+NODE,1,3) S (NODE,NODE2,MTIEN,PRIM)="" Q "ZMT"_HLFS_$G(VAFY)
  1. ;
  1. ;
  1. I NODE'="" D
  1. .;add default values to new means test sharing fields
  1. .N STATUS,CODE,TDSTATUS,TDCODE,HARDSHIP,DATA,SOURCE,TIME
  1. .S TDSTATUS=$P(NODE2,"^",3)
  1. .S HARDSHIP=$P(NODE,"^",20)
  1. .I TDSTATUS="" D
  1. ..S STATUS=$P(NODE,"^",3)
  1. ..Q:'STATUS
  1. ..S CODE=$$GETCODE^DGMTH(STATUS)
  1. ..I CODE'="","ABCEGMP"[CODE D
  1. ...I VAFTYPE=1,HARDSHIP D
  1. ....I "AG"[CODE D Q
  1. .....I CODE="A",($P(NODE,"^",4)'>$P(NODE,"^",27)) S TDSTATUS=$$GETSTAT^DGMTH("G",1) Q ;Income <= GMT Threshold
  1. .....S TDSTATUS=$$GETSTAT^DGMTH("C",1)
  1. ....S TDSTATUS=STATUS
  1. ...S DATA(2.03)=TDSTATUS,$P(NODE2,"^",3)=TDSTATUS
  1. .S SOURCE=$P(NODE,"^",23)
  1. .I SOURCE=1 D
  1. ..S TIME=$P(NODE2,"^",2)
  1. ..I TIME="" S TIME=$$NOW^XLFDT,$P(NODE2,"^",2)=TIME,DATA(2.02)=TIME
  1. ..I $P(NODE2,"^",5)="",$P(NODE,"^",6) S $P(NODE2,"^",5)=$$GETSITE^DGMTU4($P(NODE,"^",6)),DATA(2.05)=$P(NODE2,"^",5)
  1. .I HARDSHIP,$P(NODE2,"^",4)="",$P(NODE,"^",22) S $P(NODE2,"^",4)=$$GETSITE^DGMTU4($P(NODE,"^",22)),DATA(2.04)=$P(NODE2,"^",4)
  1. .I $D(DATA),$$UPD^DGENDBS(408.31,MTIEN,.DATA)
  1. .;
  1. I VAFSTR[",2," S $P(VAFY,HLFS,2)=$S(+NODE:$$HLDATE^HLFNC(+NODE),1:HLQ) ; MT Date
  1. I VAFSTR[",3," S X=$P($G(^DG(408.32,+$P(NODE,"^",3),0)),"^",2),$P(VAFY,HLFS,3)=$S(X]"":X,1:"") ; MT Status
  1. I VAFSTR[",4," S $P(VAFY,HLFS,4)=$S($P(NODE,"^",4)]"":$P(NODE,"^",4),1:HLQ) ; Income
  1. I VAFSTR[",5," S $P(VAFY,HLFS,5)=$S($P(NODE,"^",5)]"":$P(NODE,"^",5),1:HLQ) ; Net Worth
  1. I VAFSTR[",6," S $P(VAFY,HLFS,6)=$S($P(NODE,"^",10):$$HLDATE^HLFNC($P(NODE,"^",10)),1:HLQ) ; Adjudication Date/Time
  1. I VAFSTR[",7," S $P(VAFY,HLFS,7)=$$YN^VAFHLFNC($P(NODE,"^",11)) ;Agreed To Pay
  1. I VAFSTR[",8," S $P(VAFY,HLFS,8)=$S($P(NODE,"^",12):$P(NODE,"^",12),1:HLQ) ; Threshold A
  1. I VAFSTR[",9," S $P(VAFY,HLFS,9)=$S($P(NODE,"^",15)]"":$P(NODE,"^",15),1:HLQ) ; Deductible Expenses
  1. I VAFSTR[",10," S $P(VAFY,HLFS,10)=$S($P(NODE,"^",7):$$HLDATE^HLFNC($P(NODE,"^",7)),1:HLQ) ; Date/Time Completed
  1. I VAFSTR[",11," S $P(VAFY,HLFS,11)=$$YN^VAFHLFNC($P(NODE,"^",16)) ;Previous Year Means Test Threshold Flag
  1. I VAFSTR[",12," S $P(VAFY,HLFS,12)=$S($P(NODE,"^",18)]"":$P(NODE,"^",18),1:HLQ) ; Total Dependents
  1. I VAFSTR[",13," S $P(VAFY,HLFS,13)=$$YN^VAFHLFNC($P(NODE,"^",20)) ;Hardship
  1. I VAFSTR[",14," S $P(VAFY,HLFS,14)=$S($P(NODE,"^",21):$$HLDATE^HLFNC($P(NODE,"^",21)),1:HLQ) ; Hardship Review Date
  1. I VAFSTR[",15," S $P(VAFY,HLFS,15)=$S($P(NODE,"^",24):$$HLDATE^HLFNC($P(NODE,"^",24)),1:HLQ) ; Date Vet Signed Test
  1. I VAFSTR[",16," S $P(VAFY,HLFS,16)=$$YN^VAFHLFNC($P(NODE,"^",14)) ;Declines To Give Income Info
  1. I VAFSTR[",17," S $P(VAFY,HLFS,17)=$S($P(NODE,"^",19):$P(NODE,"^",19),1:VAFTYPE) ; Type Of Test
  1. I VAFSTR[",18," S $P(VAFY,HLFS,18)=$S($P(NODE,"^",23)]"":$P(NODE,"^",23),1:HLQ) ; Source Of Test
  1. I VAFSTR[",19," S $P(VAFY,HLFS,19)=$$YN^VAFHLFNC(PRIM) ; Primary Test?
  1. I VAFSTR[",20," S $P(VAFY,HLFS,20)=$S($P(NODE,"^",25):$$HLDATE^HLFNC($P(NODE,"^",25)),1:HLQ) ; Date IVM Verified MT Completed
  1. I VAFSTR[",21," S $P(VAFY,HLFS,21)=$$YN^VAFHLFNC($P(NODE,"^",26)) ;Refused To Sign
  1. ;
  1. ;
  1. I VAFSTR[",22," S $P(VAFY,HLFS,22)=$P(NODE2,"^",5) ;Site Conducting Test
  1. I VAFSTR[",23," S $P(VAFY,HLFS,23)=$P(NODE2,"^",4) ;Site Granting Hardship
  1. I VAFSTR[",24," S $P(VAFY,HLFS,24)=$S($P(NODE2,"^"):$$HLDATE^HLFNC($P(NODE2,"^")),1:"") ;Hardship Effective Date
  1. I VAFSTR[",25," S $P(VAFY,HLFS,25)=$S($P(NODE2,"^",2):$$HLDATE^HLFNC($P(NODE2,"^",2)),1:"") ;Dt/Tm Test Last Edited
  1. I VAFSTR[",26," S $P(VAFY,HLFS,26)=$S($P(NODE2,"^",3):$$GETCODE^DGMTH($P(NODE2,"^",3)),1:"") ; Test Determined Status
  1. I VAFSTR[",28," S $P(VAFY,HLFS,28)=$P(NODE,"^",27) ;GMT Threshold
  1. I VAFSTR[",29," S $P(VAFY,HLFS,29)=$P(NODE2,"^",9) ;Hardship Reason
  1. I VAFSTR[",30," S $P(VAFY,HLFS,30)=+$P(NODE2,"^",11) ; Test Version
  1. I VAFSTR[",31," S $P(VAFY,HLFS,31)=$G(^DGMT(408.31,MTIEN,4)) ;Beneficiary Travel Financial Indicator - IVM*2.0*160
  1. I VAFSTR[",32," S $P(VAFY,HLFS,32)=$S($P(NODE2,"^",13):$$HLDATE^HLFNC($P(NODE2,"^",13)),1:"") ;Hardship Expiration Date IVM*2.0*193
  1. ;
  1. ;can only transmit the deletion of a hardship if the segment is for a means test - and the income years must match if there is a means test
  1. ;
  1. I VAFTYPE=1,($G(DELETE("HARDSHIP"))=1),('(+NODE)!($E(DELETE("DATE OF TEST"),1,3)=$E((+NODE),1,3))) S $P(VAFY,HLFS,24)=HLQ
  1. ;
  1. QUIT Q "ZMT"_HLFS_$G(VAFY)