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

AGEDERR1.m

Go to the documentation of this file.
AGEDERR1 ; IHS/SD/TPF - EDIT CHECK CALLS ; MAR 19, 2010 
 ;;7.1;PATIENT REGISTRATION;**1,2,3,4,5,7,8,10,12**;AUG 25, 2005;Build 1
 ;IHS/OIT/NKD AG*7.1*12 INSURER TYPE
 Q
 ;EDIT CHK #1
AOBMISS(DFN) ;EP
 ;Quit if AOB required
 I $$RQAOB^AGEDERR4(DUZ(2)) Q 0  ;AG*7.1*8
 ;
 Q:DFN="" 1
 N X
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,365) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 I '$$ISDEPEND^AGEDERR2(DFN) Q 0
 ;AOB CHECKED FOR PATIENTS W/ PRVT ONLY
 Q:'$D(^AUPNPRVT("B",DFN))
 S X=1_U_"PVT"_U
 Q:'$$ACTELIG^AGEDERR2(DFN,X)_U_X 0
 ;END NEW
 I $G(AGOPT("VERSION"))<7.1 Q $P($G(^AUPNPAT(DFN,0)),U,17)=""
 Q $O(^AUPNPAT(DFN,71,0))=""
 ;EDIT CHK #2 - EMPLOYER INFO INC.
 ;TRUE IF NO EMPL STATUS
EMPMISS(DFN) ;EP - PER ALPHA TEST AND ADRIAN - ONLY CHECK FOR EMPLOYER
 ;IF EMPL STATUS IS NOT "UNEMPLOYED", "RETIRED", OR "UNKNOWN"
 N X
 Q:DFN="" 1
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 Q:$P($G(^AUPNPAT(DFN,0)),U,21)="" 1    ;EMPLOYMENT STATUS
 S EMPSTAT=$P($G(^AUPNPAT(DFN,0)),U,21)
 ;IF EMPLOYMENT STATUS IS UNEMPLOYED, RETIRED, OR UNKNOWN DO NOT
 ;CHECK FOR EMPLOYER PTR
 Q:EMPSTAT=3!(EMPSTAT=5)!(EMPSTAT=9) 0
 S X=$P($G(^AUPNPAT(DFN,0)),U,19)
 Q:X="" 1
 S X=$G(^AUTNEMPL(X,0))
 Q:$P(X,U,2)="" 1
 Q:$P(X,U,3)="" 1
 Q:$P(X,U,4)="" 1
 Q:$P(X,U,5)="" 1
 Q 0
 ;EDIT CHK #3 - AOB COMP
 ;LAST DATE IS OLDER THAN ONE YEAR OR BEFORE AN ACTIVE BEGIN DATE
AOBDUE(DFN) ;EP
 ;Quit if AOB required
 I $$RQAOB^AGEDERR4(DUZ(2)) Q 0  ;AG*7.1*8
 ;
 Q:DFN="" 1
 N TARDT,X,X1,X2,X3
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END NEW
 ;ADRIAN 6/16/2005
 ;AOB SHOULD BE CHECKED FOR PRVT INS. ONLY
 Q:'$D(^AUPNPRVT("B",DFN)) 0
 S X=1_U_"PVT"_U
 Q:'$$ACTELIG^AGEDERR2(DFN,X)_U_X 0
 S TARDT=$$AOBCHEK^AGEDERR2(DFN)
 ;END
 I $G(AGOPT("VERSION"))<7.1 Q $$AOBDUE7(DFN)
 ;DON'T CHK IF NO AOB ENTRIES
 ;S X3=$O(^AUPNPAT(DFN,71,"B",""),-1)
 ;Q:X3="" 0
 S X2=$O(^AUPNPAT(DFN,71,"B",""),-1)
 Q:X2="" 0     ;DO NOT REPORT ON MISSING THATS FOR ERROR #1
 Q:X2<TARDT 1  ;AOB
 S X1=DT
 D ^%DTC
 Q X>365
 ;7.0 CHK FOR AOB OVERDUE
AOBDUE7(DFN) ;EP
 I $P($G(^AUPNPAT(DFN,0)),U,17)="" Q 1
 S X2=$P($G(^AUPNPAT(DFN,0)),U,17)
 S X1=DT
 D ^%DTC
 Q X>365
 ;EDIT CHK #4 - MSP MISSING
 ;RTNS T IF MISSING
MSPMISS(DFN) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 I '$$OVER65^AGEDERR2(DFN) Q 0
 ;Q:'$$ACTELIG^AGEDERR2(DFN,"^MCR") 0  ;AG*7.1*1 IM19440 IF NO ACTIVE MEDICARE DON'T CHECK
 ;BEGIN AG*7.1*3 IM23545
 I $P($G(AGSELECT),U,2)=2 Q:$$HASELIG^AGEDERR2(DFN)'[("MCR") 0  Q:'$$ACTELIG^AGEDERR2(DFN,"^MCR") 0
 ;E  Q:$$HASELIG^AGEDERR2(DFN)'[("RRE") 0  Q:'$$ACTELIG^AGEDERR2(DFN,"^RRE") 0
 ;END AG*7.1*3 IM23545
 ;AG*7.1*3 IM25531
 E  I $P($G(AGSELECT),U,2)=1 Q:$$HASELIG^AGEDERR2(DFN)'[("RRE") 0  Q:'$$ACTELIG^AGEDERR2(DFN,"^RRE") 0
 ;END 1/20/05
 I $G(AGOPT("VERSION"))<7.1 Q $P($G(^AUPNMCR(DFN,0)),U,5)=""
 Q $O(^AUPNMSP("C",DFN,""),-1)=""
 ;EDIT CHK #5 - MSP EXPIRED
 ;TRUE IF PERIOD IS PAST 90 DAYS
MSPEXP(DFN) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 ;I $$HASELIG^AGEDERR2(DFN)'[("MCR") Q 0  ;NO MEDICARE
 ;Q:'$$ACTELIG^AGEDERR2(DFN,"^MCR") 0  ;AG*7.1*1 IM19440 IF NO ACTIVE MEDICARE DON'T CHECK
 ;Q:'$$ACTELIG^AGEDERR2(DFN,"^MCR") 0  ;AG*7.1*5 H2771 ASKED TO PUT THIS CHECK BACK;AG*7.1*10 Removed check
 ;Q:'$$ACTELIG^AGEDERR2(DFN,"^RRE") 0  ;AG*7.1*5 H2771 ASKED TO PUT THIS CHECK BACK;AG*7.1*10 Removed check
 ;BEGIN AG*7.1*3 IM23545
 I $P($G(AGSELECT),U,2)=2 Q:$$HASELIG^AGEDERR2(DFN)'[("MCR") 0  Q:'$$ACTELIG^AGEDERR2(DFN,"^MCR") 0
 ;E  Q:$$HASELIG^AGEDERR2(DFN)'[("RRE") 0  Q:'$$ACTELIG^AGEDERR2(DFN,"^RRE") 0
 ;END AG*7.1*3 IM23545
 ;AG*7.1*3 IM25531
 E  I $P($G(AGSELECT),U,2)=1 Q:$$HASELIG^AGEDERR2(DFN)'[("RRE") 0  Q:'$$ACTELIG^AGEDERR2(DFN,"^RRE") 0
 ;END
 I $G(AGOPT("VERSION"))<7.1 Q $$MSPEXP7(DFN)  ;DO PRE 7.1 CHK
 ;DON'T CHK IF NO MCR ENTRIES
 N X3
 S X3=$O(^AUPNMCR("B",DFN,""),-1)
 Q:X3="" 0
 N X3
 S X3=$O(^AUPNMSP("C",DFN,""),-1)
 Q:X3="" 0
 N X,X1,X2
 S X2=$O(^AUPNMSP("C",DFN,""),-1)
 Q:X2="" 1
 S X1=DT
 D ^%DTC
 Q X>89
 ;PRE 7.1 CHK FOR EXP MSP DT
MSPEXP7(DFN) ;EP
 S X2=$P($G(^AUPNMCR(DFN,0)),U,5)
 S X1=DT
 D ^%DTC
 Q X>89
 ;EDIT CHK # 6 - PAT ADDR INC
PADDRINC(DFN) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 N X
 S X=$G(^DPT(DFN,.11))
 Q:X="" 1
 Q:$P(X,U)="" 1
 Q:$P(X,U,4)="" 1
 Q:$P(X,U,5)="" 1
 Q:$P(X,U,6)="" 1
 Q 0
 ;EDIT CHK #7 - PAT DOB IS INC
PDOBINC(DFN) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 Q $P($G(^DPT(DFN,0)),U,3)=""
 ;EDIT CHK #8 - PT MARITAL STAT MISS
PMARMISS(DFN) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 Q $P($G(^DPT(DFN,0)),U,5)=""
 ;EDIT CHK #9 - PAT SEX MISSING
 ;RTNS T IF MISSING
PSEXMISS(DFN) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 Q $P($G(^DPT(DFN,0)),U,2)=""
 ;EDIT CHK #10 - PH ADDR MISSING
PHADDMIS(DFN,FINDCALL) ;EP
 N X,SEQ,MISSING,AGINS,PHPTR,PH,INS
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 S FINDCALL="FINDPVT"  ;ONLY CHK PRVT INS. AT THIS TIME.
 ;IF SELECTION IS DEFINED WE'RE COMING FROM AGED4A AND THE USER HAS
 ;SELECTED AN INSURER FROM THE AGINS ARRAY
 I $G(AGSELECT)'="" S AGINS(1)=AGSELECT
 E  D
 .;USER HAS NOT SELECTED FROM AGED4A SO CREATE OUR OWN AGINS
 .;ARRAY BASED ON VALUE OF 'FINDCALL'
 .I FINDCALL'="" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 .S SEL=0
 .I FINDCALL="" D FINDALL^AGEDERR(DFN,.AGINS)
 .E  D @FINDCALL
 S SEQ=0,MISSING=0
 F  S SEQ=$O(AGINS(SEQ)) Q:SEQ=""  D  Q:MISSING
 .;DO NOT CHECK FOR ERRORS ON INSURANCE THAT IS INACTIVE 1/20/05
 .Q:'$$ISACTIVE^AGINS($P(AGINS(SEQ),U,5),$P(AGINS(SEQ),U,6))
 .;END 1/20/05
 .S INS=$P(AGINS(SEQ),U)
 .S PHPTR=$E($P(AGINS(SEQ),U,7),2,10)
 .S PH=$P(AGINS(SEQ),U,8)
 .S POLNUM=$P(AGINS(SEQ),U,9)
 .S MISSING=PHPTR=""
 .S:MISSING MISSING=MISSING_U_$$ERRDATA^AGEDERR(10)_"|"_$G(POLNUM)_"|"_$G(PH)_"|"_$G(INS) Q:MISSING
 .S X=$G(^AUPN3PPH(PHPTR,0))
 .S:$P(X,U,9)="" MISSING=1_U_$$ERRDATA^AGEDERR(10)_"|"_$G(POLNUM)_"|"_$G(PH)_"|"_$G(INS)
 .S:$P(X,U,11)="" MISSING=1_U_$$ERRDATA^AGEDERR(10)_"|"_$G(POLNUM)_"|"_$G(PH)_"|"_$G(INS)
 .S:$P(X,U,12)="" MISSING=1_U_$$ERRDATA^AGEDERR(10)_"|"_$G(POLNUM)_"|"_$G(PH)_"|"_$G(INS)
 .S:$P(X,U,13)="" MISSING=1_U_$$ERRDATA^AGEDERR(10)_"|"_$G(POLNUM)_"|"_$G(PH)_"|"_$G(INS)
 K AGINS
 Q MISSING
 ;EDIT CHK #11 - POL IS SUPPLEMENTAL TO MEDICARE
MEDSUP(DFN,FINDCALL) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 S FINDCALL="FINDPVT"  ;ONLY CHK PRVT INS. AT THIS TIME
 N X,AGINS,MISSING
 ;IF SELECTION IS DEFINED WE'RE COMING FROM AGED4A AND THE USER HAS
 ;SELECTED AN INSURER FROM THE AGINS ARRAY
 I $G(AGSELECT)'="" S AGINS(1)=AGSELECT
 E  D
 .;USER HAS NOT SELECTED FROM AGED4A SO CREATE OUR OWN AGINS
 .;ARRAY BASED ON VALUE OF 'FINDCALL'
 .I FINDCALL'="" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 .S SEL=0
 .I FINDCALL="" D FINDALL^AGEDERR(DFN,.AGINS)
 .E  D @FINDCALL
 Q:'$D(AGINS) 0  ;NO AGINS ENTRY SO ALL WERE DELETED
 S SEQ=0
 S MISSING=0
 F  S SEQ=$O(AGINS(SEQ)) Q:SEQ=""  D  Q:MISSING
 .;DO NOT CHECK FOR ERRORS ON INSURANCE THAT IS INACTIVE 1/20/05
 .Q:'$$ISACTIVE^AGINS($P(AGINS(SEQ),U,5),$P(AGINS(SEQ),U,6))
 .;END 1/20/05
 .S INSPTR=$P(AGINS(SEQ),U,2)
 .S MISSING=INSPTR="" Q:MISSING
 .S X=$G(^AUTNINS(INSPTR,0))
 .S MISSING=X="" Q:MISSING
 .S INS=$P(X,U)
 .;S MISSING=$P($G(^AUTNINS(INSPTR,2)),U)="M" Q:MISSING
 .S MISSING=$$INSTYP^AGUTL(INSPTR)="M" Q:MISSING  ;IHS/OIT/NKD AG*7.1*12
 K AGINS
 Q MISSING_U_$$ERRDATA(11)_"|"_$G(INS)
 ;EDIT CHK #12 - GUARAN NAME AND ADDR MISSING
GURANMIS(DFN,FINDCALL) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 N X,SEQ,MISSING,AGINS
 S FINDCALL="FINDGUAR"  ;ONLY APPROPRIATE FOR GUARAN
 ;IF SELECTION IS DEFINED WE'RE COMING FROM AGED4A AND THE USER HAS
 ;SELECTED AN INSURER FROM THE AGINS ARRAY
 I $G(AGSELECT)'="" S AGINS(1)=AGSELECT
 E  D
 .;USER HAS NOT SELECTED FROM AGED4A SO CREATE OUR OWN AGINS
 .;ARRAY BASED ON VALUE OF 'FINDCALL'
 .I FINDCALL'="" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 .S SEL=0
 .I FINDCALL="" D FINDALL^AGEDERR(DFN,.AGINS)
 .E  D @FINDCALL
 S MISSING=$$CHKAGINS^AGEDERR(21,12,"",9) Q:MISSING MISSING
 S MISSING=$$CHKAGINS^AGEDERR(22,12,"",9) Q:MISSING MISSING
 S MISSING=$$CHKAGINS^AGEDERR(23,12,"",9) Q:MISSING MISSING
 S MISSING=$$CHKAGINS^AGEDERR(24,12,"",9) Q:MISSING MISSING
 K AGINS
 Q MISSING
 ;EDIT CHK #13 - ROI MISSING
 ;WARNING VERSION (SEE EDIT CHK #46 FOR ERROR VERSION)
ROIMISS(DFN) ;EP
 ;Quit if ROI required
 I $$RQROI^AGEDERR4(DUZ(2)) Q 0  ;AG*7.1*8
 ;
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 ;1/20/05
 I '$$ISDEPEND^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,365) Q 0
 ;END 1/20/05
 I $G(AGOPT("VERSION"))<7.1 Q $P($G(^AUPNPAT(DFN,0)),U,4)=""
 Q $O(^AUPNPAT(DFN,36,"B",""),-1)=""
 ;EDIT CHK #14 - ROI EXPIRED
 ;WARNING VERSION (SEE EDIT CHK #47 FOR ERROR VERSION)
ROIEXP(DFN) ;EP
 ;Quit if ROI required
 I $$RQROI^AGEDERR4(DUZ(2)) Q 0  ;AG*7.1*8
 ;
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 I $G(AGOPT("VERSION"))<7.1 Q $$ROIEXP7(DFN)  ;DO PRE 7.1 CHK
 ;DON'T CHK IF NO ROI ENTRY
 N X3
 S X3=$O(^AUPNPAT(DFN,36,"B",""),-1)
 Q:X3="" 0
 N X,X1,X2
 S X2=$O(^AUPNPAT(DFN,36,"B",""),-1)
 Q:X2="" 1
 S X1=DT
 D ^%DTC
 Q X>365
 ;PRE 7.1 CHK FOR EXPIRED ROI
ROIEXP7(DFN) ;EP
 N X1,X2
 S X2=$P($G(^AUPNPAT(DFN,0)),U,4)
 S X1=DT
 D ^%DTC
 Q X>365
 ;EDIT CHK #15 - EC INFO INCOMPLETE
 ;RTNS T IF INCOMPLETE
EMERCONT(DFN) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 N X
 S X=$G(^AUPNPAT(DFN,31))  ;EC RELATIONSHIP
 Q:$P(X,U,2)="" 1
 S X=$G(^DPT(DFN,.33))      ;EC CONTACT INFO
 Q:X="" 1
 Q:$P(X,U,3)="" 1
 Q:$P(X,U,6)="" 1
 Q:$P(X,U,7)="" 1
 Q:$P(X,U,8)="" 1
 Q:$P(X,U,9)="" 1
 Q 0
 ;EDIT CHK #16 - RELATIONSHIP TO PH MISSING
 ;RTNS T IF MISSING
RELPHMIS(DFN,FINDCALL) ;EP
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 S FINDCALL="FINDPVT"  ;ONLY CHK PRVT INS. AT THIS TIME.
 N X,AGINS,MISSING
 ;IF SELECTION IS DEFINED WE'RE COMING FROM AGED4A AND THE USER HAS
 ;SELECTED AN INSURER FROM THE AGINS ARRAY
 I $G(AGSELECT)'="" S AGINS(1)=AGSELECT
 E  D
 .;USER HAS NOT SELECTED FROM AGED4A SO CREATE OUR OWN AGINS
 .;ARRAY BASED ON VALUE OF 'FINDCALL'
 .I FINDCALL'="" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 .S SEL=0
 .I FINDCALL="" D FINDALL^AGEDERR(DFN,.AGINS)
 .E  D @FINDCALL
 S MISSING=$$CHKAGINS^AGEDERR(16,16,"",9)
 K AGINS
 Q MISSING
 ;EDIT CHK #17 - COV TYPE NOT DEFINED(MISSING) FOR POL
 ;RTNS T IF MISSING
CVTYPMIS(DFN,FINDCALL) ;EP
 N X,SEQ,MISSING,AGINS
 Q:'DFN 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 ;IF SELECTION IS DEFINED WE'RE COMING FROM AGED4A AND THE USER HAS
 ;SELECTED AN INSURER FROM THE AGINS ARRAY
 I $G(AGSELECT)'="" S AGINS(1)=AGSELECT
 E  D
 .;USER HAS NOT SELECTED FROM AGED4A SO CREATE OUR OWN AGINS
 .;ARRAY BASED ON VALUE OF 'FINDCALL'
 .I FINDCALL'="" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 .S SEL=0
 .I FINDCALL="" D FINDALL^AGEDERR(DFN,.AGINS)
 .E  D @FINDCALL
 S MISSING=$$CHKAGINS^AGEDERR(4,17,"","9,1")
 K AGINS
 Q MISSING
 ;EDIT CHK #18 - MISSING EFF DT OF ELIG
 ;THIS LOOKS AT ALL INSURANCES
 ;RTNS T IF MISSING IN ANY OF THEM
ELGDTMIS(DFN,FINDCALL) ;EP
 N X,SEQ,MISSING,AGINS
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 ;IF SELECTION IS DEFINED WE'RE COMING FROM AGED4A AND THE USER HAS
 ;SELECTED AN INSURER FROM THE AGINS ARRAY
 I $G(AGSELECT)'="" S AGINS(1)=AGSELECT
 E  D
 .;USER HAS NOT SELECTED FROM AGED4A SO CREATE OUR OWN AGINS
 .;ARRAY BASED ON VALUE OF 'FINDCALL'
 .I FINDCALL'="" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 .S SEL=0
 .I FINDCALL="" D FINDALL^AGEDERR(DFN,.AGINS)
 .E  D @FINDCALL
 S MISSING=$$CHKAGINS^AGEDERR(5,18,"","9,1")
 K AGINS
 Q MISSING
 ;EDIT CHK #19 - MISSING PH'S EMPLOYMENT STATUS
 ;RTNS T IF MISSING
EMPSTAMS(DFN,FINDCALL) ;EP
 N X,SEQ,MISSING,AGINS,PHPTR
 Q:DFN="" 1
 ;1/20/05
 I $$DECEASED^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 ;END
 S FINDCALL="FINDPVT"  ;ONLY DO PRIVATE INSURANCE
 ;IF SELECTION IS DEFINED WE'RE COMING FROM AGED4A AND THE USER HAS
 ;SELECTED AN INSURER FROM THE AGINS ARRAY
 I $G(AGSELECT)'="" S AGINS(1)=AGSELECT
 E  D
 .;USER HAS NOT SELECTED FROM AGED4A SO CREATE OUR OWN AGINS
 .;ARRAY BASED ON VALUE OF 'FINDCALL'
 .I FINDCALL'="" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 .S SEL=0
 .I FINDCALL="" D FINDALL^AGEDERR(DFN,.AGINS)
 .E  D @FINDCALL
 S MISSING=$$CHKAGINS^AGEDERR(7,19,"",9)
 I MISSING K AGINS Q MISSING
 S SEQ=0
 S MISSING=0
 F  S SEQ=$O(AGINS(SEQ)) Q:SEQ=""  D  Q:MISSING
 .;DO NOT CHECK FOR ERRORS ON INSURANCE THAT IS INACTIVE 1/20/05
 .Q:'$$ISACTIVE^AGINS($P(AGINS(SEQ),U,5),$P(AGINS(SEQ),U,6))
 .;END 1/20/05
 .S PHPTR=$E($P(AGINS(SEQ),U,7),2,20)
 .I PHPTR="" S MISSING=1 Q:MISSING
 .S:$E(PHPTR)?1A PHPTR=$E($P(AGINS(SEQ),U,7),2,20)
 .S MISSING=$P($G(^AUPN3PPH(PHPTR,0)),U,15)="" Q:MISSING
 K AGINS
 Q MISSING
 ;RETURN ERROR DATA
ERRDATA(ERR) ;EP
 Q $P($G(^AGEDERRS(ERR,0)),U,1,3)