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

AGINS.m

Go to the documentation of this file.
AGINS ; IHS/ASDS/EFG - EXT ROUTINE TO BUILD AGINS ARRAY ;   
 ;;7.1;PATIENT REGISTRATION;**1,2,3,11,12,13**;AUG 25, 2005;Build 1
 ;IHS/OIT/NKD AG*7.1*11 ALLOW DISPLAY OF GUARANTOR IF THE ENTRY WAS DELETED
 ;IHS/OIT/NKD AG*7.1*12 INSURER TYPE
 ;IHS/OIT/NKD AG*7.1*13 MBI IMPLEMENTATION
 ;
EP ;
 K AGINS
 K AGINSN1,AGINSNN,MAX
 S SEL=0
 ;BEGIN IHS/SD/TPF 9/30/2005 AG*7.1*1 FIX BAD DATA CALL ITEM 16
 K FIXLIST
 S FIXLIST(DFN)="",NOMSG=1
 D FIXALL^AGDATA(.FIXLIST,NOMSG)
 K NOMSG
 ;END
 D FINDMCR(DFN)
 D FINDMCD(DFN)
 D FINDRRE(DFN)
 D FINDPVT(DFN)
 D FINDTPL(DFN)
 D FINDWC(DFN)
 D FINDGUAR(DFN)
 ;D ADDSEQNM
 D ADDSEQNM^AGINS1  ;AG*7.1*3
 I $D(AGINS) S MAX=SEL
 K INS,INSPTR,SEL,COV,COVPTR,EFF,END,MCRPTR,RECPTR,RREPTR,SUFPTR,TYPE,PH,PHPTR,POLNUM
 Q
FINDMCR(DFN) ;EP
 Q:'DFN
 N MCRSTR,SUF,POL,POLNUM,AGD1,MCRELIG,EFF,END,INS,COV,COVPTR,PHPTR,PH,INSPTR,SUFPTR,PCP,MCRPTR,TYPE
 S (SUF,POL,POLNUM,AGD1,MCRELIG,EFF,END,INS,COV,PHPTR,PH,INSPTR,SUFPTR,PCP,MCRPTR,TYPE,COVPTR)=""
 S MCRPTR=""
 F  S MCRPTR=$O(^AUPNMCR("B",DFN,MCRPTR)) Q:'MCRPTR  D
 . ;IHS/SD/TPF 4/11/2006 AG*7.1*2 IM20417
 . ;NEXT 14 LINES OF CODE MOVED TO NEXT FOR LOOP
 . S AGD1=0
 . F  S AGD1=$O(^AUPNMCR(DFN,11,AGD1)) Q:'AGD1  D
 .. ;BEGIN NEW CODE ;IHS/SD/TPF 4/11/2006 AG*7.1*2 IM20417
 .. S MCRSTR=$G(^AUPNMCR(MCRPTR,0))
 .. S PCP=$P(MCRSTR,U,14)
 .. S INSPTR=$P(MCRSTR,U,2)
 .. S INS=$S(INSPTR="":"",1:$P(^AUTNINS(INSPTR,0),U))
 .. ;S TYPE=$S(INSPTR="":"",1:$P(^AUTNINS(INSPTR,2),U))
 .. S TYPE=$$INSTYP^AGUTL(INSPTR)  ;IHS/OIT/NKD AG*7.1*12
 .. ;S TYPE="R"  AG*7.1*1 ITEM 2 IHS/SD/TPF 2/1/2006
 .. ;IHS/OIT/NKD AG*7.1*13
 .. ;S SUFPTR=$P(MCRSTR,U,4)
 .. ;S SUF=$S(SUFPTR="":"",1:$P(^AUTTMCS(SUFPTR,0),U))
 .. ;S POL=$P(MCRSTR,U,3)
 .. ;S:POL'="" POLNUM=POL_SUF
 .. S PHPTR="M"_MCRPTR
 .. S PH=$P($G(^AUPNMCR(DFN,21)),U)
 .. S RECPTR=MCRPTR,ISACTIVE="I",PLANNAME=""
 .. ;NEW CODE PATCH 2
 .. S MCRELIG=$G(^AUPNMCR(DFN,11,AGD1,0))
 .. S RECPTR=DFN_",11,"_AGD1_","_0
 .. S EFF=$P(MCRELIG,U)
 .. S END=$P(MCRELIG,U,2)
 .. S ISACTIVE=$$ISACTIVE(EFF,END)
 .. S POLNUM=$$GETMCR^AGUTL(MCRPTR)  ;IHS/OIT/NKD AG*7.1*13
 .. ;I $G(SHOWINAC)=1 Q:ISACTIVE  ;IHS/SD/TPF 6/27/2006 AG*7.1*2
 .. ;E  Q:'ISACTIVE
 .. I '$D(AGSEENLY),($G(SHOWINAC)=1) Q:ISACTIVE  ;AG*7.1*2 IM23575
 .. E  I '$D(AGSEENLY) Q:'ISACTIVE
 .. S COVPTR=""
 .. S COV=$P(MCRELIG,U,3)
 ..;BEGIN NEW CODE IHS/SD/TPF 12/5/05 AG*7.1*1
 ..;I COV="D" D
 ..I $P(MCRELIG,U,4)'="" D  ;IHS/SD/TPF 4/11/2006 AG*7.1*2 IM20417
 ...S PLANNAME=$P(MCRELIG,U,4)
 ...S POLNUM=$P(MCRELIG,U,6)
 ...S INSPTR=$P(MCRELIG,U,4)
 ...S INS=$S(INSPTR="":"",1:$P(^AUTNINS(INSPTR,0),U))
 ...;S TYPE=$S(INSPTR="":"",1:$P(^AUTNINS(INSPTR,2),U))
 ...S TYPE=$$INSTYP^AGUTL(INSPTR)  ;IHS/OIT/NKD AG*7.1*12
 ..;END NEW CODE
 .. D LOAD^AGINS1
 . I '$O(^AUPNMCR(MCRPTR,11,0)) D
 .. S COV="",COVPTR="",EFF="",END=""
 .. S ISACTIVE=$$ISACTIVE(EFF,END)
 .. ;I $G(SHOWINAC)=1 Q:ISACTIVE  ;IHS/SD/TPF 6/27/2006 AG*7.1*2
 .. ;E  Q:'ISACTIVE
 .. I '$D(AGSEENLY),($G(SHOWINAC)=1) Q:ISACTIVE  ;AG*7.1*2 IM23575
 .. E  I '$D(AGSEENLY) Q:'ISACTIVE
 .. S RECPTR=MCRPTR
 .. D LOAD^AGINS1
 K MCRSTR,SUF,POL,POLNUM,AGD1,MCRELIG,EFF,END,INS,COV,PHPTR,PH
 Q
FINDMCD(DFN) ;EP
 Q:'DFN
 N MCDPTR,MCDSTR,INSPTR,INS,COVPTR,COV,POL,PHPTR,PHSTR,PH,AGD1,MCDELIG,EFF,END,PLANPTR,PCP,GRPNAME,PLANNAME,MCDRATE,ISACTIVE
 S (MCDPTR,MCDSTR,INSPTR,INS,COVPTR,COV,POL,PHPTR,PHSTR,PH,AGD1,MCDELIG,EFF,END,PLANPTR)=""
 S (PCP,GRPNAME,PLANNAME,MCDRATE,ISACTIVE)=""
 S MCDPTR=0,PHSTR=""
 F  S MCDPTR=$O(^AUPNMCD("B",DFN,MCDPTR)) Q:'MCDPTR  D
 . S MCDSTR=$G(^AUPNMCD(MCDPTR,0))
 . S PLANPTR=$P(MCDSTR,U,10)
 . S PLANNAME=PLANPTR
 . S INSPTR=$P(MCDSTR,U,2)
 . S MCDRATE=$P(MCDSTR,U,11)
 . S PCP=$P(MCDSTR,U,14)
 . S GRPNAME=$P(MCDSTR,U,17)
 . S:GRPNAME'="" GRPNUMB=$P($G(^AUTNEGRP(GRPNAME,0)),U,2)
 . I $P(MCDSTR,U,10)'="" D
 .. S INS=$S(INSPTR="":"",1:$P(^AUTNINS(INSPTR,0),U))
 .. S TYPE="D"
 . I $P(MCDSTR,U,10)="" S INS="MEDICAID",INSPTR=$P(MCDSTR,U,2),TYPE="D"
 . S POLNUM=$P(MCDSTR,U,3)
 . S PH=$P($G(^AUPNMCD(MCDPTR,21)),U)
 . S PHPTR="D"_MCDPTR
 . S RECPTR=MCDPTR
 . S ISACTIVE="I"
 . S AGD1=0
 . F  S AGD1=$O(^AUPNMCD(MCDPTR,11,AGD1)) Q:'AGD1  D
 .. S MCDELIG=$G(^AUPNMCD(MCDPTR,11,AGD1,0))
 .. S RECPTR=MCDPTR_",11,"_AGD1_","_0
 .. S EFF=$P(MCDELIG,U)
 .. S END=$P(MCDELIG,U,2)
 .. S ISACTIVE=$$ISACTIVE(EFF,END)
 .. S COVPTR=""
 .. S COV=$P(MCDELIG,U,3)
 . ;I $G(SHOWINAC)=1 Q:ISACTIVE  ;IHS/SD/TPF 6/27/2006 AG*7.1*2 ATTACHMENT VIII.1
 . ;E  Q:'ISACTIVE
 . I '$D(AGSEENLY),($G(SHOWINAC)=1) Q:ISACTIVE  ;AG*7.1*2 IM23575
 . E  I '$D(AGSEENLY) Q:'ISACTIVE
 . D LOAD^AGINS1
 K MCDPTR,MCDSTR,INSPTR,INS,COVPTR,COV,POL,PHPTR,PHSTR,PH,AGD1,MCDELIG,EFF,END,PLANPTR
 K PCP,GRPNAME,PLANNAME,MCDRATE,POLNUM,ISACTIVE
 Q
FINDRRE(DFN) ;EP
 Q:'DFN
 N PCP,INSPTR,RREPTR,PLANNAME,INS,TYPE,PRE,POL,POLNUM,PHPTR,AGD1,RREELIG,RECPTR,EFF,END,ISACTIVE,COVPTR,COV
 S (PCP,INSPTR,RREPTR,PLANNAME,INS,TYPE,PRE,POL,POLNUM,PHPTR,AGD1,RREELIG,RECPTR)=""
 S (EFF,END,ISACTIVE,COVPTR,COV)=""
 S RREPTR=""
 F  S RREPTR=$O(^AUPNRRE("B",DFN,RREPTR)) Q:'RREPTR  D
 . ;IHS/SD/TPF 4/11/2006 AG*7.1*2 IM20417
 . ;NEXT 11 LINES OF CODE MOVED TO NEXT FOR LOOP
 . S AGD1=0
 . F  S AGD1=$O(^AUPNRRE(DFN,11,AGD1)) Q:'AGD1  D
 .. ;BEGIN NEW CODE ;IHS/SD/TPF 4/11/2006 AG*7.1*2 IM20417
 .. S RRESTR=$G(^AUPNRRE(DFN,0))
 .. S INSPTR=$P(RRESTR,U,2)
 .. S PCP=$P(RRESTR,U,14)
 .. S PLANNAME=$P(RRESTR,U,4)
 .. S INS=$S(INSPTR="":"",1:$P($G(^AUTNINS(INSPTR,0)),U))
 .. S TYPE="R"
 .. ;IHS/OIT/NKD AG*7.1*13
 .. ;S PRE=$S($P(RRESTR,U,3)="":"",1:$P($G(^AUTTRRP($P(RRESTR,U,3),0)),U))
 .. ;S POL=$P(RRESTR,U,4)
 .. ;S POLNUM=PRE_POL
 .. S PHPTR="R"_RREPTR
 .. S PH=$P($G(^AUPNRRE(DFN,21)),U)
 .. S RREELIG=$G(^AUPNRRE(DFN,11,AGD1,0))
 .. S RECPTR=DFN_",11,"_AGD1_","_0
 .. S EFF=$P(RREELIG,U)
 .. S END=$P(RREELIG,U,2)
 .. S ISACTIVE=$$ISACTIVE(EFF,END)
 .. S POLNUM=$$GETRRE^AGUTL(RREPTR)  ;IHS/OIT/NKD AG*7.1*13
 .. S PLANNAME=""
 .. S COVPTR=""
 .. S COV=$P(RREELIG,U,3)
 ..I $P(RREELIG,U,4)'="" D  ;IHS/SD/TPF 4/11/2006 AG*7.1*2 IM20417
 ...S PLANNAME=$P(RREELIG,U,4)
 ...S POLNUM=$P(RREELIG,U,6)
 ...S INSPTR=$P(RREELIG,U,4)
 ...S INS=$S(INSPTR="":"",1:$P(^AUTNINS(INSPTR,0),U))
 ...;S TYPE=$S(INSPTR="":"",1:$P(^AUTNINS(INSPTR,2),U))
 ...S TYPE=$$INSTYP^AGUTL(INSPTR)  ;IHS/OIT/NKD AG*7.1*12
 ..;END NEW CODE
 .. ;I $G(SHOWINAC)=1 Q:ISACTIVE  ;IHS/SD/TPF 6/27/2006 AG*7.1*2 ATTACHMENT VIII.1
 .. ;E  Q:'ISACTIVE
 .. I '$D(AGSEENLY),($G(SHOWINAC)=1) Q:ISACTIVE  ;AG*7.1*2 IM23575
 .. E  I '$D(AGSEENLY) Q:'ISACTIVE
 .. D LOAD^AGINS1
 . I '$O(^AUPNRRE(RREPTR,11,0)) D
 .. S COV=""
 .. S COVPTR=""
 .. S EFF=""
 .. S END=""
 .. S ISACTIVE=$$ISACTIVE(EFF,END)
 .. S RECPTR=RREPTR
 .. ;I $G(SHOWINAC)=1 Q:ISACTIVE  ;IHS/SD/TPF 6/27/2006 AG*7.1*2 ATTACHMENT VIII.1
 .. ;E  Q:'ISACTIVE
 .. I '$D(AGSEENLY),($G(SHOWINAC)=1) Q:ISACTIVE  ;AG*7.1*2 IM23575
 .. E  I '$D(AGSEENLY) Q:'ISACTIVE
 .. D LOAD^AGINS1
 K PCP,INSPTR,RREPTR,PLANNAME,INS,TYPE,PRE,POL,POLNUM,PHPTR,AGD1,RREELIG,RECPTR
 K EFF,END,ISACTIVE,COVPTR,COV
 Q
FINDPVT(DFN) ;EP
 Q:'DFN
 N PHPTR,PH,COVPTR,COV,POLNUM,PLANPTR,GRPNUMB,GRPNAME,PLANNAME,OPCOPAY,OPCOINS,FAMDEDUC,INDDEDUC,EFF
 S (PHPTR,PH,COVPTR,COV,POLNUM,PLANPTR,GRPNUMB,GRPNAME,PLANNAME,OPCOPAY,OPCOINS,FAMDEDUC,INDDEDUC,RELPOLHO,EFF)=""
 S AGSEL=0
 K AGPHFLAG
 S AGD1=0
 F  S AGD1=$O(^AUPNPRVT(DFN,11,AGD1)) Q:'AGD1  D
 . S PVTSTR=$G(^AUPNPRVT(DFN,11,AGD1,0))
 . S RECPTR=DFN_",11,"_AGD1_","_0
 . S INSPTR=$P(PVTSTR,U)
 . S RELPOLHO=$P(PVTSTR,U,5)
 . ;S INS=$S(INSPTR="":"",1:$P(^AUTNINS(INSPTR,0),U))
 . S INS=$S(INSPTR="":"",1:$P($G(^AUTNINS(INSPTR,0)),U))  ;AG*7.1*1 IM19391
 . S TYPE="P"
 . S PHPTR=TYPE_$P($G(^AUPNPRVT(DFN,11,AGD1,0)),U,8)
 . I $D(PHPTR)&(PHPTR'="")&($L(PHPTR)>1) D
 .. S PHREC=$G(^AUPN3PPH($E(PHPTR,2,10),0))
 .. S GRPNUMB=$P($G(^AUPN3PPH($E(PHPTR,2,9),0)),U,6)
 .. S GRPNAME=$S(GRPNUMB="":"",1:$P($G(^AUTNEGRP(GRPNUMB,0)),U))
 .. S INSGEND=$P(PHREC,U,8)
 .. S PH=$P(PHREC,U)
 .. S COVPTR=$P(PHREC,U,5)
 .. S (COV,DATEINEF,OPCOPAY,AOPCOINS,FAMDEDUC,INDDEDUC)=""
 .. I COVPTR'="" D
 ... S COV=$S(COVPTR="":"",1:$P(^AUTTPIC(COVPTR,0),U))
 ... S DATEINEF=DT+.01,DATEINEF=$O(^AUTTPIC(COVPTR,19,"B",DATEINEF),-1)
 ... I DATEINEF="" S (OPCOPAY,COINS,FAMDEDUC,INDDEDUC)="" Q
 ... S DATEINEF=$O(^AUTTPIC(COVPTR,19,"B",DATEINEF,""))
 ... S OPCOPAY=$P($G(^AUTTPIC(COVPTR,19,DATEINEF,0)),U,2)
 ... S OPCOINS=$P($G(^AUTTPIC(COVPTR,19,DATEINEF,0)),U,3)
 ... S FAMDEDUC=$P($G(^AUTTPIC(COVPTR,19,DATEINEF,0)),U,11)
 ... S INDDEDUC=$P($G(^AUTTPIC(COVPTR,19,DATEINEF,0)),U,12)
 .. S POLNUM=$P(PHREC,U,4)
 . I '$D(PHPTR) S PHPTR="P"
 . I $L(PHPTR)'>1 S (PHPTR,PH,COVPTR,COV,POLNUM)=""
 . S EFF=$P(PVTSTR,U,6)
 . S END=$P(PVTSTR,U,7)
 . S ISACTIVE=$$ISACTIVE(EFF,END)
 . ;I $G(SHOWINAC)=1 Q:ISACTIVE  ;IHS/SD/TPF 6/27/2006 AG*7.1*2 ATTACHMENT VIII.1
 . ;E  Q:'ISACTIVE
 . I '$D(AGSEENLY),($G(SHOWINAC)=1) Q:ISACTIVE  ;AG*7.1*2 IM23575
 . E  I '$D(AGSEENLY) Q:'ISACTIVE
 . D LOAD^AGINS1
 K PHPTR,PH,COVPTR,COV,POLNUM,PLANPTR,GRPNUMB,GRPNAME,PLANNAME,OPCOPAY,OPCOINS,FAMDEDUC,INDDEDUC,AGD1,PVTSTR,INS,PHEC,PHPAT
 Q
FINDTPL(DFN) ;EP
 Q:'DFN
 N PHPTR,PH,COVPTR,COV,POLNUM,INS,INSPTR,EFF,END,RECPTR,PLANPTR,GRPNAME,GRPNUMB,AGTPLDT,AGDATA0,AGDATA1
 S (PHPTR,PH,COVPTR,COV,POLNUM,INS,INSPTR,EFF,END,RECPTR,PLANPTR,GRPNAME,GRPNUMB,AGTPLDT,AGDATA0,AGDATA1)=""
 S AGTPLDT=0
 F  S AGTPLDT=$O(^AUPNTPL(DFN,1,AGTPLDT)) Q:'AGTPLDT  D
 .S AGDATA0=$G(^AUPNTPL(DFN,1,AGTPLDT,0))
 .S AGDATA1=$G(^AUPNTPL(DFN,1,AGTPLDT,1))
 .S GRPNAME=$P(AGDATA0,U,6)
 .;S GRPNUMB=$S(GRPNAME="":"",1:$P($G(^AUTNEGRP(GRPNAME,0)),2))
 .S GRPNUMB=$S(GRPNAME="":"",1:$P($G(^AUTNEGRP(GRPNAME,0)),U,2))  ;IM????? AG*7.1*2 FOUND BY DEVELOPER
 .S RECPTR=DFN_",1,"_AGTPLDT
 .S INSPTR=$P(AGDATA0,U,2)
 .S EFF=$P(AGDATA0,U,4)
 .S END=$P(AGDATA0,U,5)
 .S ISACTIVE=$$ISACTIVE(EFF,END)
 .S POLNUM=$P(AGDATA0,U,3)
 .S PH=$P(AGDATA1,U)
 .S PHPTR=""
 .S INS=$S(INSPTR'="":$P($G(^AUTNINS(INSPTR,0)),U),1:"UNDEFINED")
 .S INS=INS_"  [T]"
 .S (COV,TYPE)="T"
 . ;I $G(SHOWINAC)=1 Q:ISACTIVE  ;IHS/SD/TPF 6/27/2006 AG*7.1*2 ATTACHMENT VIII.1
 . ;E  Q:'ISACTIVE
 . I '$D(AGSEENLY),($G(SHOWINAC)=1) Q:ISACTIVE  ;AG*7.1*2 IM23575
 . E  I '$D(AGSEENLY) Q:'ISACTIVE
 .D LOAD^AGINS1
 K PHPTR,PH,COVPTR,COV,POLNUM,INS,INSPTR,EFF,END,RECPTR,PLANPTR,GRPNAME,GRPNUMB,AGTPLDT,AGDATA0,AGDATA1
 Q
FINDWC(DFN) ;EP
 Q:'DFN
 N PHPTR,PH,COVPTR,COV,POLNUM,INS,INSPTR,EFF,END,RECPTR,PLANPTR,GRPNAME,GRPNUMB
 S (PHPTR,PH,COVPTR,COV,POLNUM,INS,INSPTR,EFF,END,RECPTR,PLANPTR,GRPNAME,GRPNUMB)=""
 S AGTPLDT=0
 F  S AGTPLDT=$O(^AUPNWC(DFN,11,AGTPLDT)) Q:'AGTPLDT  D
 .S AGDATA0=$G(^AUPNWC(DFN,11,AGTPLDT,0))
 .S AGDATA1=$G(^AUPNWC(DFN,11,AGTPLDT,1))
 .S RECPTR=DFN_","_AGTPLDT
 .S GRPNAME=$P(AGDATA0,U,11)
 .S:GRPNAME'="" GRPNUMB=$P($G(^AUTNEGRP(GRPNAME,0)),U,2)
 .S ENTITY=$P(AGDATA0,U,10),INSPTR=ENTITY
 .S EFF=$P(AGDATA0,U,12)
 .S END=$P(AGDATA0,U,13)
 .S ISACTIVE=$$ISACTIVE(EFF,END)
 .S POLNUM=$P(AGDATA0,U,4)
 .S PHPTR=$P(AGDATA0,U,6)  ;EMPL PTR NOT PH PTR
 .;S PH=$S(PHPTR="":"",1:$E($P(^AUTNEMPL(PHPTR,0),U),1,23))
 .S PH=$S(PHPTR="":"",1:$E($P($G(^AUTNEMPL(PHPTR,0)),U),1,23))  ;IHS/SD/TPF AG*7.1*1 9/6/2005 IM18762
 .S INS=$S(ENTITY'="":$P($G(^AUTNINS(ENTITY,0)),U),1:"UNDEFINED")
 .S INS=INS_" [W]"
 .S (COV,TYPE)="W"
 . ;I $G(SHOWINAC)=1 Q:ISACTIVE  ;IHS/SD/TPF 6/27/2006 AG*7.1*2 ATTACHMENT VIII.1
 . ;E  Q:'ISACTIVE
 . I '$D(AGSEENLY),($G(SHOWINAC)=1) Q:ISACTIVE  ;AG*7.1*2 IM23575
 . E  I '$D(AGSEENLY) Q:'ISACTIVE
 .D LOAD^AGINS1
 K AGTPLDT,AGDATA0,AGDATA1,PHPTR,PH,COVPTR,COV,POLNUM,INS,INSPTR,EFF,END,RECPTR,PLANPTR,GRPNAME,GRPNUMB
 Q
FINDGUAR(DFN) ;EP
 Q:'DFN
 N PHPTR,PH,COVPTR,COV,POLNUM,INS,INSPTR,EFF,END,RECPTR,PLANPTR,INSGLORF,GSTREET,GCITY,GSTATE,GZIP
 S (PHPTR,PH,COVPTR,COV,POLNUM,INS,INSPTR,EFF,END,RECPTR,PLANPTR,INSGLORF,GSTREET,GCITY,GSTATE,GZIP)=""
 S AGGUAR=0
 F  S AGGUAR=$O(^AUPNGUAR(DFN,1,AGGUAR)) Q:'AGGUAR  D
 .S INSPTR=$P($P($G(^AUPNGUAR(DFN,1,AGGUAR,0)),U),";")_",0)"
 .S POLNUM=$P($G(^AUPNGUAR(DFN,1,AGGUAR,0)),U,3)
 .S INSGLO=U_$P($P($G(^AUPNGUAR(DFN,1,AGGUAR,0)),U),";",2)
 .S INSGLORF=INSGLO_INSPTR
 .;IHS/OIT/NKD AG*7.1*11 ALLOW DISPLAY OF GUARANTOR IF THE ENTRY WAS DELETED
 .;S INS=$P(@INSGLORF,U)
 .S INS=$P($G(@INSGLORF),U)
 .;S RECPTR=DFN_","_AGGUAR_","
 .S RECPTR=DFN_",1,"_AGGUAR  ;IHS/SD/TPF AG*7.1*1 9/7/2005
 .I INSGLORF[("AUPNPAT") D
 ..S GSTREET=$S($P($G(^DPT(INS,.11)),U)'="":1,1:"")
 ..S GCITY=$S($P($G(^DPT(INS,.11)),U,4)'="":1,1:"")
 ..S GSTATE=$S($P($G(^DPT(INS,.11)),U,5)'="":1,1:"")
 ..S GZIP=$S($P($G(^DPT(INS,.11)),U,6)'="":1,1:"")
 ..S INS=$P($G(^DPT(INS,0)),U)
 .E  D
 ..S GSTREET=$S($P($G(@INSGLORF),U,2)'="":1,1:"")
 ..S GCITY=$S($P($G(@INSGLORF),U,3)'="":1,1:"")
 ..S GSTATE=$S($P($G(@INSGLORF),U,4)'="":1,1:"")
 ..S GZIP=$S($P($G(@INSGLORF),U,5)'="":1,1:"")
 .S INSGLORF=$TR(INSGLORF,U)
 .S INS=INS_" [G]"
 .S (COV,TYPE)="G"
 .S AGGUARDT=0
 .F  S AGGUARDT=$O(^AUPNGUAR(DFN,1,AGGUAR,11,AGGUARDT)) Q:'AGGUARDT  D
 ..;S RECPTR=DFN_","_AGGUAR_","_AGGUARDT  ;IHS/SD/TPF AG*7.1*1 9/7/2005
 ..S EFF=$P($G(^AUPNGUAR(DFN,1,AGGUAR,11,AGGUARDT,0)),U)
 ..S END=$P($G(^AUPNGUAR(DFN,1,AGGUAR,11,AGGUARDT,0)),U,2)
 ..S ISACTIVE=$$ISACTIVE(EFF,END)
 ..S (COV,TYPE)="G"
 ..S INSPTR=INSGLORF  ;AG*71.*2 ADDED TO ACCOMODATE GUARNTOR IN ELIGIBLITY API ITEM 2 PAGE 11
 .. ;I $G(SHOWINAC)=1 Q:ISACTIVE  ;IHS/SD/TPF 6/27/2006 AG*7.1*2 ATTACHMENT VIII.1
 .. ;E  Q:'ISACTIVE
 .. I '$D(AGSEENLY),($G(SHOWINAC)=1) Q:ISACTIVE   ;AG*7.1*2 IM23575
 .. E  I '$D(AGSEENLY) Q:'ISACTIVE
 ..D LOAD^AGINS1
 K PHPTR,PH,COVPTR,COV,POLNUM,INS,INSPTR,EFF,END,RECPTR,PLANPTR,INSGLORF
 Q
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