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

BQIPTINS.m

Go to the documentation of this file.
BQIPTINS ;GDIT/HS/ALA-Patient Insurance ; 05 Jul 2006  3:31 PM
 ;;2.3;ICARE MANAGEMENT SYSTEM;**1,3,4**;Apr 18, 2012;Build 66
 ;
 Q
 ;
GET(DATA,DFN) ; EP -- BQI PATIENT INSURANCE
 NEW UID,II,INSCO,X,INSCO,IEN,MN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTINS",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTINS D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00100INSURANCE_COVERAGE^D00015EFFECTIVE_DATE"_$C(30)
 ;
 ;  Check for Medicare
 I $G(^AUPNMCR(DFN,0))'="" D
 . S INSCO=$$GET1^DIQ(9000003,DFN_",",.02,"E")
 . S IEN=0
 . F  S IEN=$O(^AUPNMCR(DFN,11,IEN)) Q:'IEN  D
 .. NEW DA,IENS,EFF,EXP
 .. S DA(1)=DFN,DA=IEN,IENS=$$IENS^DILF(.DA)
 .. S EFF=$$GET1^DIQ(9000003.11,IENS,.01,"I")
 .. S EXP=$$GET1^DIQ(9000003.11,IENS,.02,"I")
 .. I '$$ISACTIVE(EFF,EXP) Q
 .. S II=II+1,@DATA@(II)=INSCO_" "_$$GET1^DIQ(9000003.11,IENS,.03,"E")_"^"_$$FMTE^BQIUL1($$GET1^DIQ(9000003.11,IENS,.01,"I"))_$C(30)
 ;
 ;  Check for Railroad
 I $G(^AUPNRRE(DFN,0))'="" D
 . S INSCO=$$GET1^DIQ(9000005,DFN_",",.02,"E")
 . S IEN=0
 . F  S IEN=$O(^AUPNRRE(DFN,11,IEN)) Q:'IEN  D
 .. NEW DA,IENS,EFF,EXP
 .. S DA(1)=DFN,DA=IEN,IENS=$$IENS^DILF(.DA)
 .. S EFF=$$GET1^DIQ(9000005.11,IENS,.01,"I")
 .. S EXP=$$GET1^DIQ(9000005.11,IENS,.02,"I")
 .. I '$$ISACTIVE(EFF,EXP) Q
 .. S II=II+1,@DATA@(II)=INSCO_" "_$$GET1^DIQ(9000005.11,IENS,.03,"E")_"^"_$$FMTE^BQIUL1($$GET1^DIQ(9000005.11,IENS,.01,"I"))_$C(30)
 ;
 ;  Check for Medicaid
 S IEN=""
 F  S IEN=$O(^AUPNMCD("B",DFN,IEN)) Q:IEN=""  D
 . S INSCO=$$GET1^DIQ(9000004,IEN_",",.02,"E")
 . S MN=0
 . F  S MN=$O(^AUPNMCD(IEN,11,MN)) Q:'MN  D
 .. NEW DA,IENS,EFF,EXP
 .. S DA(1)=IEN,DA=MN,IENS=$$IENS^DILF(.DA)
 .. S EFF=$$GET1^DIQ(9000004.11,IENS,.01,"I")
 .. S EXP=$$GET1^DIQ(9000004.11,IENS,.02,"I")
 .. I '$$ISACTIVE(EFF,EXP) Q
 .. S II=II+1,@DATA@(II)=INSCO_" "_$$GET1^DIQ(9000004.11,IENS,.03,"E")_"^"_$$FMTE^BQIUL1($$GET1^DIQ(9000004.11,IENS,.01,"I"))_$C(30)
 ;
 ;  Check for Private Insurance
 N AGD S AGD=0
 F  S AGD=$O(^AUPNPRVT(DFN,11,AGD)) Q:'AGD  D
 . N DA,IENS,EFF,EXP,POLH,COV
 . S DA(1)=DFN,DA=AGD,IENS=$$IENS^DILF(.DA)
 . S EFF=$$GET1^DIQ(9000006.11,IENS,".06","I")
 . S EXP=$$GET1^DIQ(9000006.11,IENS,".07","I")
 . I '$$ISACTIVE(EFF,EXP) Q
 . S POLH=$$GET1^DIQ(9000006.11,IENS,".08","I")
 . S COV="" S:POLH]"" COV=$$GET1^DIQ(9000003.1,POLH_",",".05","E")
 . S II=II+1,@DATA@(II)=$$GET1^DIQ(9000006.11,IENS,".01","E")_" "_COV_"^"_$$FMTE^BQIUL1(EFF)_$C(30)
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
LYO(DFN) ;EP - Layout display
 NEW RESULT,INSCO,IEN,QFL,MN
 ;  Check for Medicare
 S RESULT=""
 I $G(^AUPNMCR(DFN,0))'="" D
 . S INSCO=$$GET1^DIQ(9000003,DFN_",",.02,"E")
 . S IEN=0
 . F  S IEN=$O(^AUPNMCR(DFN,11,IEN)) Q:'IEN  D
 .. NEW DA,IENS,EFF,EXP
 .. S DA(1)=DFN,DA=IEN,IENS=$$IENS^DILF(.DA)
 .. S EFF=$$GET1^DIQ(9000003.11,IENS,.01,"I")
 .. S EXP=$$GET1^DIQ(9000003.11,IENS,.02,"I")
 .. I '$$ISACTIVE(EFF,EXP) Q
 .. S RESULT=RESULT_INSCO_" "_$$GET1^DIQ(9000003.11,IENS,.03,"E")_"; "_$C(13)_$C(10)
 ;
 ;  Check for Medicaid
 S IEN="",QFL=0
 F  S IEN=$O(^AUPNMCD("B",DFN,IEN)) Q:IEN=""  D  Q:QFL
 . S INSCO=$$GET1^DIQ(9000004,IEN_",",.02,"E")
 . S MN=0
 . F  S MN=$O(^AUPNMCD(IEN,11,MN)) Q:'MN  D
 .. NEW DA,IENS,EFF,EXP
 .. S DA(1)=IEN,DA=MN,IENS=$$IENS^DILF(.DA)
 .. S EFF=$$GET1^DIQ(9000004.11,IENS,.01,"I")
 .. S EXP=$$GET1^DIQ(9000004.11,IENS,.02,"I")
 .. I '$$ISACTIVE(EFF,EXP) Q
 .. S RESULT=RESULT_INSCO_"; "_$C(13)_$C(10),QFL=1
 ;
 ;  Check for Railroad
 I $G(^AUPNRRE(DFN,0))'="" D
 . S INSCO=$$GET1^DIQ(9000005,DFN_",",.02,"E")
 . S IEN=0
 . F  S IEN=$O(^AUPNRRE(DFN,11,IEN)) Q:'IEN  D
 .. NEW DA,IENS,EFF,EXP
 .. S DA(1)=DFN,DA=IEN,IENS=$$IENS^DILF(.DA)
 .. S EFF=$$GET1^DIQ(9000005.11,IENS,.01,"I")
 .. S EXP=$$GET1^DIQ(9000005.11,IENS,.02,"I")
 .. I '$$ISACTIVE(EFF,EXP) Q
 .. S RESULT=RESULT_INSCO_" "_$$GET1^DIQ(9000005.11,IENS,.03,"E")_"; "_$C(13)_$C(10)
 ;
 ;  Check for Private Insurance
 S IEN=""
 F  S IEN=$O(^AUPN3PPH("C",DFN,IEN)) Q:IEN=""  D
 . ;I $$GET1^DIQ(9000003.1,IEN_",",.18,"I")'="" Q
 . S EFF=$$GET1^DIQ(9000003.1,IEN,.17,"I")
 . S EXP=$$GET1^DIQ(9000003.1,IEN,.18,"I")
 . I '$$ISACTIVE(EFF,EXP) Q
 . S INSCO=$$GET1^DIQ(9000003.1,IEN_",",.03,"E")
 . S RESULT=RESULT_INSCO_" "_$$GET1^DIQ(9000003.1,IEN_",",.05,"E")_"; "_$C(13)_$C(10)
 S RESULT=$$TKO^BQIUL1(RESULT,"; "_$C(13)_$C(10))
 Q RESULT
 ;
ISACTIVE(EFFDT,ENDDT) ;EP - POL. ACTIVE TODAY?
 N OPENEND
 I EFFDT="",(ENDDT="") Q 0
 S ENDDT=ENDDT
 S OPENEND=ENDDT=""
 I OPENEND I DT=EFFDT!(DT>EFFDT) Q 1
 I DT=EFFDT!(DT=ENDDT) Q 1
 I DT>EFFDT&(DT<ENDDT) Q 1
 Q 0