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

BDWIN1.m

Go to the documentation of this file.
BDWIN1 ; IHS/CMI/LAB - BDW Create Insurance Array for GIS DW1 Export ;
 ;;1.0;IHS DATA WAREHOUSE;**5**;JAN 23, 2006;Build 32
 ;
 ;       
 ;       
 ;       
 ;
 ;this routine will populate the IN1 segment of the HL IHS DW1 A31 message
 ;
MAIN ;-- this is the main routine driver
 K INDA("IN1")
 D MCD,MCR,RRE,PI
 Q
 ;
MCD ;-- get medicaid data for the message
 S BDWCNT=0
 Q:'$O(^AUPNMCD("B",DFN,0))
 S BDWDA=0 F  S BDWDA=$O(^AUPNMCD("B",DFN,BDWDA)) Q:'BDWDA  D
 . S BDWDATA=$G(^AUPNMCD(BDWDA,0))
 . S BDWMDA=0 F  S BDWMDA=$O(^AUPNMCD(BDWDA,11,BDWMDA)) Q:'BDWMDA  D
 .. S BDWMDATA=$G(^AUPNMCD(BDWDA,11,BDWMDA,0))
 .. S BDWCNT=BDWCNT+1
 .. S INDA("IN1",BDWCNT)=""
 .. S INA("BDW1IN13",BDWCNT)=$S($P(BDWDATA,U,2):$P(^AUTNINS($P(BDWDATA,U,2),0),U,7),1:"")
 .. S INA("BDW1IN147",BDWCNT)=$P(BDWMDATA,U,3)
 .. S INA("BDW1IN112",BDWCNT)=$$DATE^INHUT($P(BDWMDATA,U))
 .. S INA("BDW1IN115",BDWCNT)=$S($P(BDWDATA,U,4):$P($G(^DIC(5,$P(BDWDATA,U,4),0)),U,3),1:"")_U_$$GET1^DIQ(9000004,BDWDA,.11)  ;$P($G(^AUPNMCD(BDWDA,0)),U,10) ;IHS/CMI/LAB - changed state piece 2 to piece 3
 .. S INA("BDW1IN14",BDWCNT)="MCD"_U_$$GET1^DIQ(9000004,BDWDA,.02)
 .. S INA("BDW1IN113",BDWCNT)=$$DATE^INHUT($P(BDWMDATA,U,2))
 .. S INA("BDW1IN149",BDWCNT)=$P(BDWDATA,U,3)
 .. N BDWREL
 .. S BDWREL=$P(BDWDATA,U,6)
 .. S INA("BDW1IN117",BDWCNT)=$S(BDWREL:$P($G(^AUTTRLSH(BDWREL,0)),U,1),1:"")
 .. S BDWMNM=$P($G(^AUPNMCD(BDWDA,0)),U,5)
 .. S INA("BDW1IN116",BDWCNT)=$P(BDWMNM,",")_U_$P($P(BDWMNM,",",2)," ")_U_$P($P(BDWMNM,",",2)," ",2)
 .. ;S INA("BDW1IN117",BDWCNT)=$S($P(BDWMDATA,U,6):$P($G(^AUTTRLSH($P(BDWMDATA,U,5),0)),U),1:"")
 K BDWDATA,BDWDA,BDWMDATA,BDWMDA,BDAMNM
 Q
 ;
MCR ;-- get the medicare data for the message
 Q:'$D(^AUPNMCR(DFN,0))
 N BDWMNM,BDWMBI
 ;S BDWCNT=0
 S BDWDATA=$G(^AUPNMCR(DFN,0))
 Q:$P(BDWDATA,U,2)=""  ;no insurer pointer
 S BDWMDA=0 F  S BDWMDA=$O(^AUPNMCR(DFN,11,BDWMDA)) Q:'BDWMDA  D
 . S BDWMDATA=$G(^AUPNMCR(DFN,11,BDWMDA,0))
 . S BDWCNT=BDWCNT+1
 . S INDA("IN1",BDWCNT)=""
 . S INA("BDW1IN13",BDWCNT)=$P(^AUTNINS($P(BDWDATA,U,2),0),U,7)
 . S INA("BDW1IN147",BDWCNT)=$P(BDWMDATA,U,3)
 . S INA("BDW1IN112",BDWCNT)=$$DATE^INHUT($P(BDWMDATA,U))
 . S BDWMBI=$$GETMCR^AGUTL(DFN,DT)
 . S INA("BDW1IN149",BDWCNT)=$S($$HASMBI^AGUTL(DFN,DT):$P(BDWMBI,U),1:$P(BDWDATA,U,3)_U_$$GET1^DIQ(9000003,DFN,.04))  ;cmi/maw p5 05/04/2018
 . ;S INA("BDW1IN149",BDWCNT)=$P(BDWDATA,U,3)_U_$$GET1^DIQ(9000003,DFN,.04)  ;cmi/maw p5 05/04/2018
 . S INA("BDW1IN14",BDWCNT)="MCR"_U_$$GET1^DIQ(9000003,DFN,.02)
 . S INA("BDW1IN113",BDWCNT)=$$DATE^INHUT($P(BDWMDATA,U,2))
 . S BDWMNM=$P($G(^AUPNMCR(DFN,21)),U)
 . S INA("BDW1IN116",BDWCNT)=$P(BDWMNM,",")_U_$P($P(BDWMNM,",",2)," ")_U_$P($P(BDWMNM,",",2)," ",2)
 . N BDWREL
 . S BDWREL=$O(^AUTTRLSH("B","SELF",0))
 . S INA("BDW1IN117",BDWCNT)=$P($G(^AUTTRLSH(BDWREL,0)),U)  ;cmi/maw 4/28/04 changed back to text
 K BDWMDA,BDWDATA,BDWMDATA
 Q
 ;
RRE ;-- get the railroad data for the message
 Q:'$D(^AUPNRRE(DFN,0))
 N BDWMNM,BDWMBI
 ;S BDWCNT=0
 S BDWDATA=$G(^AUPNRRE(DFN,0))
 Q:$P(BDWDATA,U,2)=""  ;no insurer
 S BDWMDA=0 F  S BDWMDA=$O(^AUPNRRE(DFN,11,BDWMDA)) Q:'BDWMDA  D
 . S BDWMDATA=$G(^AUPNRRE(DFN,11,BDWMDA,0))
 . S BDWCNT=BDWCNT+1
 . S INDA("IN1",BDWCNT)=""
 . S INA("BDW1IN13",BDWCNT)=$P(^AUTNINS($P(BDWDATA,U,2),0),U,7)
 . S INA("BDW1IN147",BDWCNT)=$P(BDWMDATA,U,3)
 . S INA("BDW1IN112",BDWCNT)=$$DATE^INHUT($P(BDWMDATA,U))
 . ;S INA("BDW1IN149",BDWCNT)=$P(BDWDATA,U,3)_U_$P(BDWDATA,U,3)
 . S BDWMBI=$$GETRRE^AGUTL(DFN,DT)
 . S INA("BDW1IN149",BDWCNT)=$S($$HASMBI^AGUTL(DFN,DT):$P(BDWMBI,U),1:$$VAL^XBDIQ1(9000005,DFN,.04)_U_$$VAL^XBDIQ1(9000005,DFN,.03))  ;cmi/maw p5 05/04/2018
 . ;S INA("BDW1IN149",BDWCNT)=$$VAL^XBDIQ1(9000005,DFN,.04)_U_$$VAL^XBDIQ1(9000005,DFN,.03)  ;cmi/maw p5 05/04/2018
 . S INA("BDW1IN14",BDWCNT)="RRE"_U_$$GET1^DIQ(9000005,DFN,.02)
 . S INA("BDW1IN113",BDWCNT)=$$DATE^INHUT($P(BDWMDATA,U,2))
 . S BDWMNM=$P($G(^AUPNRRE(DFN,21)),U)
 . S INA("BDW1IN116",BDWCNT)=$P(BDWMNM,",")_U_$P($P(BDWMNM,",",2)," ")_U_$P($P(BDWMNM,",",2)," ",2)
 . N BDWREL
 . S BDWREL=$O(^AUTTRLSH("B","SELF",0))
 . S INA("BDW1IN117",BDWCNT)=$P($G(^AUTTRLSH(BDWREL,0)),U)  ;cmi/maw 4/28/04 changed back to text
 K BDWMDA,BDWDATA,BDWMDATA
 Q
 ;
PI ;-- get the private insurance data for the message
 Q:'$D(^AUPNPRVT(DFN,0))
 ;S BDWCNT=0
 S BDWDATA=$G(^AUPNPRVT(DFN,0))
 S BDWMDA=0 F  S BDWMDA=$O(^AUPNPRVT(DFN,11,BDWMDA)) Q:'BDWMDA  D
 . Q:$P(^AUPNPRVT(DFN,11,BDWMDA,0),U)=""
 . S BDWMDATA=$G(^AUPNPRVT(DFN,11,BDWMDA,0))
 . S BDWCNT=BDWCNT+1
 . S INDA("IN1",BDWCNT)=""
 . S INA("BDW1IN13",BDWCNT)=$P(^AUTNINS($P(BDWMDATA,U),0),U,7)
 . S INA("BDW1IN112",BDWCNT)=$$DATE^INHUT($P(BDWMDATA,U,6))
 . S INA("BDW1IN149",BDWCNT)=$S($P(BDWMDATA,U,8):$$GET1^DIQ(9000003.1,$P(BDWMDATA,U,8),.04,"E"),1:"")
 . S INA("BDW1IN14",BDWCNT)="PVT"_U_$P(^AUTNINS($P(BDWMDATA,U),0),U)
 . S INA("BDW1IN113",BDWCNT)=$$DATE^INHUT($P(BDWMDATA,U,7))
 . S BDWPNM=$S($P(BDWMDATA,U,8):$$GET1^DIQ(9000003.1,$P(BDWMDATA,U,8),.01,"E"),1:"")
 . S INA("BDW1IN116",BDWCNT)=$P(BDWPNM,",")_U_$P($P(BDWPNM,",",2)," ")_U_$P($P(BDWPNM,",",2)," ",2)
 . S INA("BDW1IN117",BDWCNT)=$S($P(BDWMDATA,U,5):$P($G(^AUTTRLSH($P(BDWMDATA,U,5),0)),U),1:"")  ;cmi/maw 4/28/04 changed back to text
 . S INA("BDW1IN147",BDWCNT)=$S($P(BDWMDATA,U,8):$$GET1^DIQ(9000003.1,$P(BDWMDATA,U,8),.05,"E"),1:"")
 K BDWMDA,BDWDATA,BDWMDATA,BDWPNM
 Q
 ;