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

BHSINSUR.m

Go to the documentation of this file.
BHSINSUR ;IHS/CIA/MGH - Health Summary for Insurance ;09-Aug-2018 16:44;MGH
 ;;1.0;HEALTH SUMMARY COMPONENTS;**4,15**;Mar 17, 2006;Build 8
 ;===================================================================
 ;Taken from APCHS5A
 ; IHS/TUCSON/LAB - PART 5A OF APCHS5 -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS RPMS/PCC Health Summary;**3,6,8,9**;JUN 24, 1997
 ;VA health summary for IHS health summary insurance component
 ;Patch 15 changes for insurance (medicare and RR)
 ;
MAID ;ENTRY POINT
 ; MEDICAID
 K BHSITB,X
 ;<SETUP>
 S BHSPDN=0 F BHSQ=0:0 S BHSPDN=$O(^AUPNMCD("B",BHSPAT,BHSPDN)) Q:BHSPDN=""  D BMAID
 ;<DISPLAY>
 S BHSI=0 F BHSQ=0:0 S BHSI=$O(BHSITB(BHSI)) Q:BHSI=""  S BHSJ=$O(BHSITB(BHSI,0)) S BHSP=BHSITB(BHSI,BHSJ) S BHSPDN=$P(BHSP,";",1),BHSEDN=$P(BHSP,";",2) D DMAID
 ;<CLEANUP>
MAIDX K BHSCOV,BHSDTL,BHSDTN,BHSDTS,BHSEDN,BHSI,BHSIDN,BHSINS,BHSJ,BHSN,BHSPDN,BHSUFF,Y,BHSXDT,BHSNM,BHSP,BHSQ
 Q
BMAID Q:'$D(^AUPNMCD(BHSPDN))
 S BHSEDN=0 F BHSQ=0:0 S BHSEDN=$O(^AUPNMCD(BHSPDN,11,BHSEDN)) Q:'BHSEDN  D
 .S BHSP=$G(^AUPNMCD(BHSEDN,0)) S BHSI=$P(^AUPNMCD(BHSPDN,0),U,4)_"-"_$P(BHSP,U,3),BHSJ=9999999-$P(BHSP,U,1) S BHSITB(BHSI,BHSJ)=BHSPDN_";"_BHSEDN
 Q
DMAID ;
 S BHSN=^AUPNMCD(BHSPDN,0)
 S BHSINS=$S($P(BHSN,U,2):$P(^AUTNINS($P(BHSN,U,2),0),U,1),1:"???") ;IHS/CMI/LAB - patch 6 prevent sbscr
 S BHSNM=^AUPNMCD(BHSPDN,11,BHSEDN,0)
 S X=$P(BHSNM,U,1) D REGDT4^GMTSU S BHSDTL=X
 ;-- IHS/CMI/MAW add set of exp date variable, quit if not current
 S (BHSXDT,X)=$P(BHSNM,U,2) D REGDT4^GMTSU S BHSDTN=X
 I BHSXDT="" S BHSXDT=9999999
 Q:BHSXDT<DT
 ;-- IHS/CMI/MAW end of mods
 D CKP^GMTSUP Q:$D(GMTSQIT)  W:GMTSNPG "(Medicaid cont.)",!
 S X=$P($G(^DIC(5,+$P(BHSN,U,4),0)),U,2) W $S(X="":"??",1:X)," ",$E(BHSINS,1,23),?25,$P(BHSN,U,3)  ;IHS/ANMC/LJF 12/18/2002
 W ?40,$P(BHSNM,U,3),?48,BHSDTL,?70,BHSDTN,!
 I $P(BHSN,U,10)]"" W ?3,"Plan Name: ",$$VAL^XBDIQ1(9000004,BHSPDN,.11),!
 Q
MCARE ;ENTRY POINT
 ; MEDICARE
 Q:'$D(^AUPNMCR(BHSPAT))
 S BHSN=^AUPNMCR(BHSPAT,0)
 Q:'$D(^AUPNMCR(BHSPAT,0))  ;CMI/LAB
 S BHSINS=$S($P(BHSN,U,2):$P(^AUTNINS($P(BHSN,U,2),0),U,1),1:"???") ;IHS/CMI/LAB - prevent sbscr
 S BHSUFF=$P(BHSN,U,4) S:BHSUFF]"" BHSUFF=$P(^AUTTMCS(BHSUFF,0),U,1)
 K BHSITB
 S BHSEDN=0 F BHSQ=0:0 S BHSEDN=$O(^AUPNMCR(BHSPAT,11,BHSEDN)) Q:BHSEDN'=+BHSEDN  S BHSP=^(BHSEDN,0) S BHSI=$P(BHSN,U,2)_"-"_$P(BHSP,U,3),BHSJ=9999999-$P(BHSP,U,1) S BHSITB(BHSI,BHSJ)=BHSPAT_";"_BHSEDN
 S BHSI=0 F BHSQ=0:0 S BHSI=$O(BHSITB(BHSI)) Q:BHSI=""  D
 .S BHSJ=$O(BHSITB(BHSI,0)) S BHSP=BHSITB(BHSI,BHSJ)
 .S BHSPDN=$P(BHSP,";",1),BHSEDN=$P(BHSP,";",2) D DMCARE
 W:$X'=0 !
 Q
DMCARE ;
 N INS,DNAME
 S BHSNM=^AUPNMCR(BHSPDN,11,BHSEDN,0)
 S X=$P(BHSNM,U,1) D REGDT4^GMTSU S BHSDTL=X
 ;-- IHS/CMI/MAW add set of exp date variable, quit if not current
 S (BHSXDT,X)=$P(BHSNM,U,2) D REGDT4^GMTSU S BHSDTN=X
 I BHSXDT="" S BHSXDT=9999999
 Q:BHSXDT<DT
 ;-- IHS/CMI/MAW end of mods
 D CKP^GMTSUP Q:$D(GMTSQIT)  W:GMTSNPG "(Medicare cont.)",!
 S BHSIEN=$$GETMCR^AGUTL(BHSPAT)      ;IHS/MSC/MGH Patch 15
 I '+BHSIEN S BHSIEN=$P(BHSN,U,3)
 E  S BHSUFF=""
 S BHSCOV=$P(BHSNM,U,3)
 I BHSCOV="D" D
 .S INS=$$GET1^DIQ(9999999.18,$P(BHSNM,U,4),.01)
 .S DNUM=$P(BHSNM,U,6)
 .I DNUM'="" S BHSINS="MC/"_INS,BHSIEN=DNUM
 W $E(BHSINS,1,23),?25,BHSIEN,?37,$$GET1^DIQ(9999999.32,BHSUFF,.01)
 S BHSDTS="" I BHSCOV="B" S X=$P(^AUPNPAT(BHSPAT,0),U,4) D REGDT4^GMTSU S BHSDTS=X
 D CKP^GMTSUP Q:$D(GMTSQIT)  W:GMTSNPG "(Medicare cont.)",!
 W ?40,$E(BHSCOV,1,7),?48,BHSDTL,?59,BHSDTS,?70,BHSDTN,!
 K BHSXDT,BHSNM,BHSIEN
 Q
THIRD ;ENTRY POINT
 ; OTHER THIRD PARTY
 Q:$O(^AUPNPRVT(BHSPAT,11,0))=""
 K BHSITB
 S BHSIDN=0 F BHSQ=0:0 S BHSIDN=$O(^AUPNPRVT(BHSPAT,11,BHSIDN)) Q:BHSIDN'=+BHSIDN  S BHSP=^(BHSIDN,0) S BHSITB($P(BHSP,U,1)_"-"_$P(BHSP,U,3),9999999-$P(BHSP,U,6))=BHSIDN
 S BHSI="" F BHSQ=0:0 S BHSI=$O(BHSITB(BHSI)) Q:BHSI=""  D
 .S BHSJ="" F  S BHSJ=$O(BHSITB(BHSI,BHSJ)) Q:BHSJ=""  D
 ..S BHSIDN=BHSITB(BHSI,BHSJ) D DTHIRD
 Q
DTHIRD S BHSN=^AUPNPRVT(BHSPAT,11,BHSIDN,0)
 Q:$P(BHSN,U,1)=""
 S BHSINS=$P(^AUTNINS($P(BHSN,U,1),0),U,1)
 S X=$P(BHSN,U,6) D REGDT4^GMTSU S BHSDTL=X
 ;-- IHS/CMI/MAW add set of exp date variable, quit if not current
 S (BHSXDT,X)=$P(BHSN,U,7) D REGDT4^GMTSU S BHSDTN=X
 I BHSXDT="" S BHSXDT=9999999
 Q:BHSXDT<DT
 ;-- IHS/CMI/MAW end of mods
 D CKP^GMTSUP Q:$D(GMTSQIT)  W:GMTSNPG "(3rd party cont.)",!
 ;IHS/CMI/GRL policy number field of Private Insurance Eligible is obsolete.  Per Adrian Lujan,
 ;following code looks at the Member Number field of Insurer multiple.
 ;from Policy Holder File
 S $P(BHSN,U,2)=$P($G(^AUPNPRVT(BHSPAT,11,BHSIDN,2)),U)  ;member number
 I $P($G(BHSN),U,2)']"",$P(BHSN,U,8) S $P(BHSN,U,2)=$P($G(^AUPN3PPH($P(BHSN,U,8),0)),U,4)  ;policy number
 ;IHS/CMI/GRL  end of patch
 W $E(BHSINS,1,24),?25,$P(BHSN,U,2),?40,$P(BHSN,U,3),?48,BHSDTL,?70,BHSDTN,!
 I $P(BHSN,U,8) W ?40,"Coverage Type: ",$$VAL^XBDIQ1(9000003.1,$P(BHSN,U,8),.05),!
 K BHSXDT
 Q
RR ;EP
 ; RAILROAD RETIREMENT
 Q:'$D(^AUPNRRE(BHSPAT))
 S BHSN=^AUPNRRE(BHSPAT,0)
 S BHSINS=$P(^AUTNINS($P(BHSN,U,2),0),U,1)
 S BHSUFF=$P(BHSN,U,3)
 K BHSITB
 S BHSEDN=0 F BHSQ=0:0 S BHSEDN=$O(^AUPNRRE(BHSPAT,11,BHSEDN)) Q:BHSEDN'=+BHSEDN  S BHSP=^(BHSEDN,0) S BHSI=$P(BHSN,U,2)_"-"_$P(BHSP,U,3),BHSJ=9999999-$P(BHSP,U,1) S BHSITB(BHSI,BHSJ)=BHSPAT_";"_BHSEDN
 S BHSI=0 F BHSQ=0:0 S BHSI=$O(BHSITB(BHSI)) Q:BHSI=""  D
 .S BHSJ=$O(BHSITB(BHSI,0)) S BHSP=BHSITB(BHSI,BHSJ)
 .S BHSPDN=$P(BHSP,";",1),BHSEDN=$P(BHSP,";",2) D DRR
 W:$X'=0 !
 Q
DRR ;
 S BHSNM=^AUPNRRE(BHSPDN,11,BHSEDN,0)
 S X=$P(BHSNM,U,1) D REGDT4^GMTSU S BHSDTL=X
 ;-- IHS/CMI/MAW add set of exp date variable, quit if not current
 S (BHSXDT,X)=$P(BHSNM,U,2) D REGDT4^GMTSU S BHSDTN=X
 I BHSXDT="" S BHSXDT=9999999
 Q:BHSXDT<DT
 ;-- IHS/CMI/MAW end of mods
 S BHSIEN=$$GETRRE^AGUTL(BHSPAT)       ;IHS/MSC/MGH Patch 15
 I BHSIEN="" S BHSIEN=$P(BHSN,U,4)
 S BHSCOV=$P(BHSNM,U,3)
 D CKP^GMTSUP Q:$D(GMTSQIT)  W:GMTSNPG "(Railroad Retirement cont.)",!
 W $E(BHSINS,1,23),?25,BHSIEN
 W ?40,$E(BHSCOV,1,7),?48,BHSDTL,?70,BHSDTN,!
 K BHSNM,BHSXDT
 Q