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

AGEDERR.m

Go to the documentation of this file.
AGEDERR ; IHS/SD/TPF - MAIN EDIT CHECK 'DRIVERS'  
 ;;7.1;PATIENT REGISTRATION;**1,2**;JAN 31, 2007
 ;
 ;THIS CONTAINS EDIT CHECKS 26 - 36
 ;ALL CALLS HERE PERTAIN TO EDIT CHECKS SPECIFIED BY THE
 ;"PATIENT REGISTRATION REQUIREMENTS DOCUMENT JAN 29, 2004 FINAL VERSION"
 ;COMPILED BY ADRIAN LUJAN
 ;THESE ARE REFERRED TO AS "EDIT CHECKS" OR ERRORS OR WARNINGS
 ;
 ;THERE ARE TWO TYPES OF EDIT CHECK RESULTS - ERRORS AND WARNINGS.
 ;THE RESULT STRING WILL BE RETURNED. IN THE RESULT STRING OF "1^W^001" THE
 ;FIRST PIECE MEANS THE RESULT WAS TRUE (YES THERE IS AN ERROR OR WARNING),
 ;THE SECOND PIECE MEANS THIS IS A WARNING EDIT CHECK AND THE THIRD PIECE
 ;MEANS THE ERROR CODE IS 1. THE ERRORS/WARNINGS ARE STORED IN THE 'AG PATIENT
 ;REGISTRATION ERROR CODES' FILE #9009061.5
 ;
 W !,"ALL CALLS TO THIS ROUTINE SHOULD BE DONE VIA TAG EPs"
 Q       ;DO NOT CALL ROOT
 ;EDIT CHECK #29 - MEDICARE ELIGIBILITY DATA INCOMPLETE
MCRELINC(DFN,FINDCALL) ;EP
 N X,SEQ,MISSING,AGINS
 Q:DFN="" 1
 I '$$HASELIG^AGEDERR2(DFN) Q 0
 I '$$PTACTIVE^AGEDERR2(DFN) Q 0
 I '$$CURRUPD^AGEDERR2(DFN,1095) Q 0
 I $$DECEASED^AGEDERR2(DFN) Q 0
 S FINDCALL="FINDMCR"
 ;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 LETS 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(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 NEW SPECS REC'D 1/20/05
 .Q:'$$ISACTIVE^AGINS($P(AGINS(SEQ),U,5),$P(AGINS(SEQ),U,6))
 .;END NEW SPECS REC'D 1/20/05
 .S INNAME=$P(AGINS(SEQ),U)
 .S POLNUM=$P(AGINS(SEQ),U,9)
 .S MISSING=$P(AGINS(SEQ),U,9)="" Q:MISSING
 .S MISSING=$P(AGINS(SEQ),U,5)="" Q:MISSING
 .S MISSING=$P(AGINS(SEQ),U,4)="" Q:MISSING
 .N X
 .S X=$P($G(^AUPNMCR(DFN,21)),U,2)
 .S MISSING=X="" Q:MISSING
 .I $$AGE^AUPNPAT(DFN)>65 D
 ..S X=$O(^AUPNMSP("C",DFN,""))
 ..S MISSING=X="" Q:MISSING
 .N X
 .S X=$P($G(^AUPNPAT(DFN,0)),U,4)
 .S MISSING=X="" Q:MISSING
 .N X
 K AGINS
 Q MISSING_U_$$ERRDATA(29)_"|"_$G(POLNUM)_"|"_$G(INNAME)
 ;EDIT CHECK #30 - MEDICAID COVERAGE TYPE MISSING
MCDCOVMS(DFN,FINDCALL) ;EP
 N X,SEQ,MISSING,AGINS
 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
 S FINDCALL="FINDMCD"  ;THIS EDIT CHECK ONLY FOR MEDICAID
 ;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 LETS 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(DFN,.AGINS)
 .E  D @FINDCALL
 S MISSING=$$CHKAGINS(4,30,"","9,1")
 K AGINS,FORMAT
 Q MISSING
 ;EDIT CHECK #31 - MEDICAID RATE MISSING
MCGRTMS(DFN,FINDCALL) ;EP
 N X,SEQ,MISSING,AGINS
 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
 S FINDCALL="FINDMCD"  ;THIS EDIT CHECK ONLY FOR MEDICAID
 ;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 LETS 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(DFN,.AGINS)
 .E  D @FINDCALL
 ;NEW SPECS TO BE IN NEXT VERSION OR PATCH
 ;OVERRIRDE EDITCHECK DEPNEDING ON SOME OTHER FIELD E.G. IN INSURER FILE FIELD
 ;'MEDICAID RATE CODE REQUIRED
 S MISSING=$$CHKAGINS(15,31,"","9,1")
 K FORMAT
 K AGINS,FORMAT
 Q MISSING
 ;EDIT CHECK #32 - PATIENT BENEFITS INCOMPLETE
PATBENIN(DFN,FINDCALL) ;EP
 N X,SEQ,MISSING,AGINS
 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:FINDCALL'="FINDPVT" 0  ;THIS EDIT CHECK ONLY FOR 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 LETS 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(DFN,.AGINS)
 .E  D @FINDCALL
 S MISSING=$$CHKAGINS(26,32,"",9)&$$CHKAGINS(27,32,"",9) Q:MISSING MISSING
 S MISSING=$$CHKAGINS(28,32,"",9)!$$CHKAGINS(29,32,"",9) Q:MISSING MISSING
 K AGINS
 Q MISSING
 ;EDIT CHECK #33 - INSURER SEQUENCING REQUIRED
 ;ALSO LOCATED IN ^AGUTILS
SEQMAN(SITE) ;EP
 ;NEW SPECS REC'D 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 '$$FACCHK^AGEDERR2(DFN) Q 0
 ;Q $P($G(^AGFAC(SITE,21)),U)
 Q 1
 ;END NEW SPECS
 ;EDIT CHECK # 34 - PATIENT CASE OPEN TO BENEFITS COORDINATOR
 ;RETURNS TRUE IF PATIENT HAS AN OPEN CASE
PATREFBC(DFN) ;EP
 ;NEW SPECS REC'D 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 SPECS
 N X
 S X=$O(^AUPNBENR("B",DFN,""))
 Q:X="" 0
 S SUBREC=0,MISSING=0
 F  S SUBREC=$O(^AUPNBENR(X,11,SUBREC)) Q:+SUBREC=0  D  Q:MISSING
 .S CASEREC=$G(^AUPNBENR(X,11,SUBREC,0))
 .S Y=$P(CASEREC,U) D DD^%DT S DTREF=Y
 .S MISSING=$P(CASEREC,U,7)="O"!($P(CASEREC,U,7)="") Q:MISSING
 Q MISSING_U_$$ERRDATA(34)_"|"_$G(DTREF)
 ;EDIT CHECK # 35 - MOTHER AND FATHER'S EMPLOYER DATA MISSING
 ;IF PATIENT IS A MINOR
 ;RETURNS TRUE IF BOTH MISSING
PAREMPL(DFN) ;EP
 Q:'DFN 1
 ;NEW SPECS REC'D 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 SPECS
 Q:'$$ISMINOR(DFN) 0
 N X
 S X=$G(^AUPNPAT(DFN,27))
 Q:'$P(X,U)&('$P(X,U,2)) 1
 Q 0
 ;EDIT CHECK #36
 ;FOLLOWING CHECK ONLY APPLIES TO RAILROAD, MEDICAID AND MEDICARE NAME
PHNAME(DFN,FINDCALL) ;EP
 N X,SEQ,MISSING,AGINS
 Q:DFN="" 1
 Q:FINDCALL="FINDMCD" 0  ;DOES NOT APPLY TO MEDICAID AG*7.1*1 IM19436
 S MISSING=0
 ;NEW SPECS REC'D 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 SPECS
 ;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 LETS CREATE OUR OWN AGINS
 ;.;ARRAY BASED ON VALUE OF 'FINDCALL'
 ;.I FINDCALL'="" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 ;.S SEL=0
 ;.I FINDCALL="" F FINDCALL="FINDMCR","FINDMCD","FINDRRE" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")" D @FINDCALL
 ;.E  D @FINDCALL
 ;CHECK TO SEE IF MCR NAME, MCD NAME, RR NAME EXISTS
 ;S MISSING=$$CHKAGINS(8,36,"","9,1") Q:MISSING MISSING
 ;CHECK TO SEE IF MCR NAME, MCD NAME, RR NAME IS IN CORRECT FORMAT
 ;S MISSING=$$CHKAGINS(8,36,"D NAME^AUPNPED S X=$G(X)=""""","9,1")
 ;K AGINS
 ;Q MISSING
 ;I $G(AGSELECT)'="" S AGINS(1)=AGSELECT S MISSING=$$PHNMCHK(.AGINS) Q MISSING
 ;BUG POINTED OUT BY ADRIAN DURING PATCH 1 TESTING
 I $G(AGSELECT)'="" Q:$P(AGSELECT,U,10)'="R"&($P(AGSELECT,U,10)'="D") 0 S AGINS(1)=AGSELECT S MISSING=$$PHNMCHK(.AGINS) Q MISSING
 E  D
 .;USER HAS NOT SELECTED FROM AGED4A SO LETS CREATE OUR OWN AGINS
 .;ARRAY BASED ON VALUE OF 'FINDCALL'
 .I FINDCALL'="" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 .S SEL=0
 .;I FINDCALL="" F FINDCALL="FINDMCR","FINDMCD","FINDRRE" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")" D @FINDCALL Q:MISSING
 .I FINDCALL="" F FINDCALL="FINDMCR","FINDRRE" S FINDCALL=FINDCALL_U_"AGINS("_DFN_")" D @FINDCALL Q:MISSING   ;AG*7.1*1 IM19436
 .E  D @FINDCALL
 .;CHECK TO SEE IF MCR NAME, MCD NAME, RR NAME EXISTS
 . S MISSING=$$PHNMCHK(.AGINS)
 K AGINS
 Q MISSING
PHNMCHK(AGINS) ;EP
 ;CHECK TO SEE IF THE NAME IS POPULATED
 S MISSING=$$CHKAGINS(8,36,"","9,1") Q:MISSING MISSING
 ;CHECK TO SEE IF MCR NAME, MCD NAME, RR NAME IS IN CORRECT FORMAT
 S MISSING=$$CHKAGINS(8,36,"D NAME^AUPNPED S X=$G(X)=""""","9,1")
 Q MISSING
 ;NO ERROR # ASSIGNED AT THIS TIME
CHKDEATH(DFN) ;EP - CHECK IF DATE OF DEATH FIELD IS POPULATED
 I $P($G(^DPT(DFN,.35)),U) Q 1
 Q 0
 ;IS PATIENT A MINOR <18
ISMINOR(DFN) ;EP - CHECK IF PATIENT IS A MINOR AGE PER SANDRI LAHI
 Q:'DFN 1
 ;NEW SPECS REC'D 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 SPECS
 S D0=DFN
 X $P($G(^DD(2,.033,0)),U,5,299)
 Q X<18  ;HARD CODED PER SANDRI LAHI
 ;BUILD AGINS ARRAY CALLING ALL FIND TAGS WITHIN ROUTINE AGINS
FINDALL(DFN,AGINS) ;EP
 N SEL
 S SEL=0
 F FINDCALL="FINDMCR","FINDMCD","FINDRRE","FINDPVT","FINDTPL","FINDWC","FINDGUAR" D
 .;DO NOT DO CALLS TO WORKMAN'S COMP OR THIRD PARTY OR GURANTOR WHEN VERSION NOT 7.1
 .Q:($G(AGOPT("VERSION"))<7.1)&((FINDCALL="FINDTPL")!(FINDCALL="FINDWC")!(FINDCALL="FINDGUAR"))
 .S FINDCALL=FINDCALL_U_"AGINS("_DFN_")"
 .D @FINDCALL
 Q
 ;CALL WHEN CHECKING THE AGINS ARRAY FOR SOMETHING MISSING
 ;PASS THE 'ERROR' NUMBER THIS IS CHECKING
 ;PASS THE 'PIECE' IN THE AGINS ARRAY NODE YOUR CHECKING FOR MISSING
 ;DATA RETURNS TRUE IF THE PIECE IS MISSING IN ANY NODE OF THE AGINS
 ;ARRAY PLUS THE ERROR INFO. IF YOU ARE CHECKING FOR A PATTERN ETC
 ;SEND IT AS 'FORMAT' ELSE THE CHECK IS ONLY FOR MISSING DATA.
 ;'RETPIECE' IS THE PIECES OF INFO YOU WANT RETURNED IF THE DATA IS
 ;MISSING OR IMPROPERLY FORMATTED (USED TO HELP IDENTIFY WHERE TO
 ;CORRECT THE DATA)\ 'FORMAT'- SEND AS XECUTABLE M CODE THAT RETURNS
 ;X AS TRUE IF WRONG PATTERN OR INCORRECT IN SOME WAY
CHKAGINS(PIECE,ERROR,FORMAT,RETPIECE) ;EP
 S RETPIECE=$G(RETPIECE)
 N SEQ,MISSING,X
 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 NEW SPECS REC'D 1/20/05
 .;ERROR 18 IS CHECKED REGARDLESS OF WHETHER THE POLICY IS INACTIVE OR NOT
 .;PER ADRIAN 2/4/2005
 .;ALMOST TIME TO ADD A CALL FOR "ERROR OVERRIDES"
 .I ERROR'=18 Q:'$$ISACTIVE^AGINS($P(AGINS(SEQ),U,5),$P(AGINS(SEQ),U,6))
 .;END NEW SPECS REC'D 1/20/05
 .;NEW REQUEST OF APRIL 15,2005 PER ADRIAN
 .;CHECK TO SEE IF OVERRIDES EXIST IN THE 'AG PATIENT REGISTRATION ERROR CODES
 .;FILE FOR A PARTICULAR ERROR
 .I $$OVERRIDE(ERROR,AGINS(SEQ)) S MISSING=0 Q
 .I FORMAT="" S MISSING=$P(AGINS(SEQ),U,PIECE)=""
 .E  S X=$P(AGINS(SEQ),U,PIECE) X FORMAT S MISSING=X
 .S:MISSING MISSING=MISSING_U_$$ERRDATA(ERROR)
 I MISSING F P=1:1 Q:$P(RETPIECE,",",P)=""  S RET=$P(RETPIECE,",",P) S MISSING=MISSING_"|"_$P(AGINS(SEQ),U,RET)
 Q MISSING
 ;
OVERRIDE(ERROR,RECORD) ;
 N OVERRIDE,RETURN
 Q:$G(^AGEDERRS(ERROR,12))="" 0
 X $G(^AGEDERRS(ERROR,12))
 Q RETURN
 ;CALL THIS WITH ERROR NUMBERS YOU WISH TO CHECK IN FOLLOWING
 ;MANNER. 'ERRORS' IS AN ARRAY DEFINED WITH THE FIRST SUBSCRIPT
 ;EQUAL TO THE ERROR NUMBER YOU WISH TO CHECK. YOU CAN CHECK
 ;MULTIPLE ERRORS. PASS IN ARRAY(1)="" TO CHECK ERROR #1
 ;'VARS' IS AN ARRAY OF VALUES IN THE FORM VAR("DFN")=3456 THE
 ;SUBSCRIPT IN THE ARRAY SHOULD MATCH THE VARIABLE NAME OF THE
 ;ERROR CALL I.E. DFN,SITE,FINDCALL ARE ALL POSSIBLE SUBSCRIPTS
 ;TO SET VARIABLES USED TO PASS INFO TO THE FUNCTIONS
 ;PASS 'DISPLAY' AS TRUE IF YOU WANT THIS ROUTINE TO DISPLAY THE
 ;ERRORS
EDITCHEK(ERRORS,VARS,DISPLAY) ;EP
 ;LOAD VARIABLES
 S VAR=""
 F  S VAR=$O(VARS(VAR)) Q:VAR=""  N @VAR S X1="@VAR=VARS(VAR)",@X1
 S ERRORNUM=0
 F  S ERRORNUM=$O(ERRORS(ERRORNUM)) Q:ERRORNUM=""  D
 .S AGERRCAL=$P($G(^AGEDERRS(ERRORNUM,0)),U,4,5)
 .I $P(AGERRCAL,U)=""!($P(AGERRCAL,U,2)="") S ERRORS(ERRORNUM)="0^Routine or tag not defined." Q
 .S AGERNODE=$G(^AGEDERRS(ERRORNUM,0))
 .S AGERRTYP=$P($G(^AGEDERRS(ERRORNUM,0)),U,2)
 .S AGERRMSG=$P($G(^AGEDERRS(ERRORNUM,0)),U,3)
 .S AGERRSOL=$$GET1^DIQ(9009061.5,ERRORNUM,501,"Z","AGERRSOL","ERRMSG")
 .I 1 D
 ..S AGERRCAL="S MISSING=$$"_AGERRCAL
 ..X AGERRCAL
 ..I MISSING S ERRORS(ERRORNUM)=MISSING M ERRORS(ERRORNUM,"SOLUTION")=AGERRSOL S ERRORS("C",AGERRTYP,ERRORNUM)=""
 ..E  S ERRORS(ERRORNUM)=0
 I DISPLAY D DISPLAY(.ERRORS)
 Q
DISPLAY(ERRORS) ;EP
 N ERRNUM,ERRTYPE,ERRNODE,TRUE,X
 S ERRNUM=""
 F  S ERRNUM=$O(ERRORS(ERRNUM)) Q:'ERRNUM  D
 .S ERRNODE=ERRORS(ERRNUM)
 .S TRUE=$P(ERRNODE,U)
 .Q:'TRUE
 .I $P(ERRNODE,U,2)="" S ERRNODE=ERRNODE_U_$$ERRDATA(ERRNUM)
 .S ERRCODE=$P(ERRNODE,U,2)
 .S ERRTYPE=$P(ERRNODE,U,3)
 .S ERRMESG=$P($P(ERRNODE,U,4),"|")
 .S ERRINFO=$P(ERRNODE,"|",2,10)
 .I ERRMESG[("#") D
 ..S ERRMESG=$P(ERRMESG,"#")_ERRINFO_$P(ERRMESG,"#",2)
 .I ERRTYPE="E" W $$S^AGVDF("RVN")
 .W !,"***"_$S(ERRTYPE="E":"ERROR",ERRTYPE="W":"WARNING",ERRTYPE="F":"FATAL ERROR",ERRTYPE="A":"ALERT",1:"UNKNOWN")
 .S X=ERRCODE
 .S X="000"_X
 .W ?11,$E(X,$L(X)-2,$L(X))_":"
 .W ?16,ERRMESG
 .I ERRTYPE="E" W $$S^AGVDF("RVF")
 Q
 ;RETURN ARRAY OF EDIT CHECSK TO PERFORM BASED ON PAGE NUMBER
FETCHERR(PAGENUM,ARRAY) ;EP
 N ERRNUM
 I PAGENUM="ALL"!(PAGENUM="") D  Q
 .S ERRNUM=0
 .F  S ERRNUM=$O(^AGEDERRS(ERRNUM)) Q:'ERRNUM!(ERRNUM=999)  S ARRAY(ERRNUM)=""
 S ERRNUM=0
 F  S ERRNUM=$O(^AGEDERRS("AB",PAGENUM,ERRNUM)) Q:ERRNUM=""  S ARRAY(ERRNUM)=""
 Q
 ;VERIFY ROUTINE AND TAG ARE VALID
CHECKRTN(ERRCALL) ;EP
 S X=$P(ERRCALL,U,2)
 X ^%ZOSF("TEST")
 Q $T
 ;RETURN ERROR DATA
ERRDATA(ERR) ;EP
 Q $P($G(^AGEDERRS(ERR,0)),U,1,3)
 ;ERROR #?? NOT USED AT THIS TIME
 ;CLASSIFICATION/BENEFICIARY STATUS INDICATES NON-INDIAN
 ;RETURNS TRUE IF NON-INDIAN
NONIND(DFN) ;EP
 N CLASS,CLASSNAM
 Q:DFN="" 1
 S CLASS=$P($G(^AUPNPAT(DFN,11)),U,11)
 Q:'CLASS 0
 S CLASSNAM=$P($G(^AUTTBEN(CLASS,0)),U)
 Q CLASSNAM[("NON-INDIAN")
 ;CHECK GUARANTOR ADDRESS
GUARADD(GUARINFO) ;EP
 N MISSING
 Q:GUARINFO="" 1
 S MISSING=0
 S GUARPTR=U_$P(GUARINFO,U,14)
 I GUARPTR[("AUTNINS")!(GUARPTR[("AUTNEMPL")) D  Q MISSING
 .S X=$G(@GUARPTR)
 .S MISSING=X="" Q:MISSING
 .S MISSING=$P(X,U,2)="" Q:MISSING
 .S MISSING=$P(X,U,3)="" Q:MISSING
 .S MISSING=$P(X,U,4)="" Q:MISSING
 .S MISSING=$P(X,U,5)="" Q:MISSING
 I GUARPTR[("AUPNPAT") D  Q MISSING
 .S DPTPTR=$P($P(GUARINFO,U,2),",")
 .S:DPTPTR="" MISSING=1 Q:MISSING
 .S GUARPTR="^DPT("_DPTPTR_",.11)"
 .S X=$G(@GUARPTR)
 .S MISSING=X=""  Q:MISSING
 .S MISSING=$P(X,U)="" Q:MISSING
 .S MISSING=$P(X,U,4)="" Q:MISSING
 .S MISSING=$P(X,U,5)="" Q:MISSING
 .S MISSING=$P(X,U,6)="" Q:MISSING
 Q MISSING