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

IBCNEUT3.m

Go to the documentation of this file.
  1. IBCNEUT3 ;DAOU/AM - eIV MISC. UTILITIES ;12-JUN-2002
  1. ;;2.0;INTEGRATED BILLING;**184,252,271,416,601,713**;21-MAR-94;Build 12
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; The purpose of the INSERROR utility is to identify a legitimate
  1. ; Insurance Company name, returning the associated Payer IEN and
  1. ; National ID. This extrinsic function can receive either Insurance or
  1. ; Buffer data, identified as TYPE I or B, respectively.
  1. ;
  1. ; The former is the simpler case. The IEN, in this case the Insurance
  1. ; IEN, is validated using the following criteria (some of which is
  1. ; validated in routine IBCNEUT4) :
  1. ;
  1. ; [1] Does it have a National ID?
  1. ; [2] Does the National ID have eIV defined?
  1. ; [3] Is the Payer active (i.e. the deactivated flag is turned off)
  1. ; [4] Is the national connection enabled?
  1. ; [5] Is the National ID blocked by VISTA?
  1. ;
  1. ; If all 5 criteria are met, the Payer IEN and National ID are
  1. ; returned. If not, an error is generated and returned in ARRAY with
  1. ; information specific to the type of problem encountered.
  1. ;
  1. ; If the TYPE passed is B for Buffer, the IEN is the Buffer IEN.
  1. ; The Insurance Company name is retrieved from the Buffer file and
  1. ; leading and trailing spaces are stripped. This value is compared to
  1. ; the entries in the "B" cross reference of the Insurance Company file
  1. ; (whose values have also been stripped of leading and trailing spaces).
  1. ; If a match (or several matches) is found,and a unique National ID is
  1. ; identified, confirm the 5 set of insurance validation criteria and
  1. ; process as above.
  1. ;
  1. ; If no match in the Insurance Company could be made, check the Auto
  1. ; Match file. If a unique IEN is identified, confirm the 5 set of
  1. ; criteria stated above and process in kind.
  1. ;
  1. ; If no match could be established in both the Insurance Company and the
  1. ; Auto Match files, check the insurance company synonym file (stripping
  1. ; off leading and trailing spaces) while preserving case sensitivity.
  1. ; If a unique Insurance Company could be identified, confirm the 5 set
  1. ; of validation criteria and process as above.
  1. ;
  1. ;
  1. ; Can't be called from the top
  1. Q
  1. ;
  1. ;
  1. INSERROR(TYPE,IEN,ERRFLG,ARRAY) ;
  1. ; Formal parameters:
  1. ; TYPE: Type of IEN passed in the second parameter.
  1. ; Either "B" for "Buffer" or "I" for "Insurance".
  1. ; Mandatory, passed by value.
  1. ; IEN: IEN to perform a lookup for. Mandatory, passed by value.
  1. ; ERRFLG: Error flag. "" or 0 if no extended error information is
  1. ; requested, 1 if extended error information is requested.
  1. ; Optional (the default is 0), passed by value.
  1. ; ARRAY: Array of error messages returned by the function.
  1. ; Optional, passed by reference. Whatever is passed in will be
  1. ; KILLed by the function. The structure of the return array is
  1. ; as follows:
  1. ; ARRAY # of error messages passed back
  1. ; ARRAY(error#) Data for this error number, including error
  1. ; number 1 present in the value returned by the function.
  1. ; [1] IEN of the error code in the symbol file
  1. ; [2] # of lines in the error message text
  1. ; ARRAY(error #,line #) - One line of error message text
  1. ; up to 70 characters long
  1. ;
  1. ; Returned value consists of the following "^"-delimited pcs:
  1. ; [1] The IEN of the IIV SYMBOL File (#365.15) entry for
  1. ; the first error condition encountered by the function.
  1. ; This is only present if a valid Payer was not found.
  1. ; [2] Payer IEN if a Payer was found, "" otherwise
  1. ; [3] National ID if a Payer was found
  1. ;
  1. ; Initialize all variables used in this program
  1. N INSIEN,INSNAME,NAMEARR,PAYID,PAYIEN,SYMIEN
  1. ; Initialize return variables
  1. S (PAYID,PAYIEN,SYMIEN)=""
  1. ; If the calling program didn't pass the Extended Error flag, init it
  1. S ERRFLG=+$G(ERRFLG)
  1. ; Initialize array of extended error info to be returned
  1. K ARRAY
  1. ; Validate input parameters
  1. I $G(TYPE)'="B",$G(TYPE)'="I" S SYMIEN=$$ERROR^IBCNEUT8("B9","IEN type "_$G(TYPE)_" passed to the insurance match algorithm is neither 'B' nor 'I'.") G EXIT
  1. I $G(IEN)="" S SYMIEN=$$ERROR^IBCNEUT8("B9","IEN is not passed to the insurance match algorithm.") G EXIT
  1. I TYPE="B",'$D(^IBA(355.33,IEN)) S SYMIEN=$$ERROR^IBCNEUT8("B9","Invalid Buffer IEN "_IEN_" has been passed to the insurance match algorithm.") G EXIT
  1. I TYPE="B",$$MBICHK^IBCNEUT7(IEN) Q $$PAYER^IBCNEUT4($$GET1^DIQ(350.9,"1,","MBI PAYER","I")) ; IB*2*601/DM
  1. I TYPE="B",$$MANUAL(IEN) G EXIT
  1. I TYPE="I",'$D(^DIC(36,IEN)) S SYMIEN=$$ERROR^IBCNEUT8("B9","Invalid Insurance Company IEN "_IEN_" has been passed to the insurance match algorithm.") G EXIT
  1. ;
  1. ; If the IEN is an Insurance Company IEN, validate it
  1. I TYPE="I" D G EXIT
  1. . N TMP
  1. . ; Check to see if ins co is ACTIVE
  1. . S TMP=$$ACTIVE^IBCNEUT4(IEN)
  1. . I 'TMP S SYMIEN=$$ERROR^IBCNEUT8("B10","Insurance Company "_$P(TMP,U,2)_" is not active.") Q
  1. . D VALID^IBCNEUT4(IEN,.PAYIEN,.PAYID,.SYMIEN)
  1. ;
  1. ; Retrieve the ins co name from the Ins Buffer
  1. S INSNAME=$$TRIM^XLFSTR($P($G(^IBA(355.33,IEN,20)),U,1))
  1. I INSNAME="" S SYMIEN=$$ERROR^IBCNEUT8("B13") G EXIT
  1. ; Retrieve all ins co IENs matching this ins co name
  1. D INSIEN^IBCNEUT8(INSNAME,.INSIEN)
  1. ;
  1. ; If one or more ins. co. name matches found, retrieve Payer info
  1. I $D(INSIEN) D G EXIT
  1. . ; If there is one INSIEN - make sure it is ACTIVE
  1. . I $O(INSIEN(""))=$O(INSIEN(""),-1),'$$ACTIVE^IBCNEUT4($O(INSIEN(""))) S SYMIEN=$$ERROR^IBCNEUT8("B10","Insurance company "_INSNAME_" is not active.") Q
  1. . ; Find National IDs for these ins co IENs
  1. . D FINDPAY^IBCNEUT8(.INSIEN,.PAYID)
  1. . ; There were Multiple INSIENs - if none exist ALL were INACTIVE
  1. . I '$D(INSIEN) S SYMIEN=$$ERROR^IBCNEUT8("B10","All insurance companies named "_INSNAME_" are not active.") Q
  1. . ; Quit with an error if no Payer is found for these ins cos
  1. . I $O(PAYID(""))="" S SYMIEN=$$ERROR^IBCNEUT8("B4","Insurance company "_INSNAME_" is not linked to a Payer.") Q
  1. . ; Quit with an error if more than one Payer found
  1. . I $O(PAYID(""))'=$O(PAYID(""),-1) S SYMIEN=$$ERROR^IBCNEUT8("B3","There are multiple Insurance companies named "_INSNAME_" in the Insurance Company file that are linked to more than one Payer",.PAYID),PAYID="" Q
  1. . ; Validate the found unique Payer
  1. . D VALID^IBCNEUT4(PAYID($O(PAYID(""))),.PAYIEN,.PAYID,.SYMIEN)
  1. ;
  1. ; If no exact ins co name match was found, check AutoMatch file
  1. ; No need to filter out inactives as the AMLOOK will handle it
  1. I $$AMLOOK^IBCNEUT1(INSNAME,1,.NAMEARR) D I $D(INSIEN) G EXIT
  1. . N NAME
  1. . ; Based on the array of ins cos returned by the AutoMatch
  1. . ; build an array of ins co IENs that they point to
  1. . S NAME="" F S NAME=$O(NAMEARR(NAME)) Q:NAME="" D INSIEN^IBCNEUT8($$TRIM^XLFSTR(NAME),.INSIEN)
  1. . ; If nothing found in the Insurance Co x-ref, quit w/o validation
  1. . I '$D(INSIEN) Q
  1. . ; Check if there is more than one ins co IEN that matches
  1. . ; the entered name, in which case exit with an error
  1. . I $O(INSIEN(""))'=$O(INSIEN(""),-1) S SYMIEN=$$ERROR^IBCNEUT8("B2","Insurance company name "_INSNAME_" in the Insurance Buffer matched more than one insurance company in the Auto Match file",.NAMEARR) Q
  1. . ; Validate the found unique ins co IEN
  1. . D VALID^IBCNEUT4($O(INSIEN("")),.PAYIEN,.PAYID,.SYMIEN)
  1. ;
  1. ; If the first two lookups failed, check the Ins Co Synonym file:
  1. ; Retrieve all ins co IENs that match in the Synonym file
  1. M INSIEN=^DIC(36,"C",INSNAME)
  1. ;
  1. ; If nothing found in the Synonym file, error out
  1. I '$D(INSIEN) S SYMIEN=$$ERROR^IBCNEUT8("B1","Insurance company "_INSNAME_" could not be matched to a valid entry in the Insurance Company file.") G EXIT
  1. ; Loop thru the ins co IENs that matched in the Synonym file
  1. S INSIEN=0 F S INSIEN=$O(INSIEN(INSIEN)) Q:'INSIEN D
  1. . N NAME
  1. . ; Retrieve the ins co name for this IEN
  1. . S NAME=$$TRIM^XLFSTR($P($G(^DIC(36,INSIEN,0)),U,1))
  1. . I NAME'="" S NAMEARR(NAME)=""
  1. ;
  1. ; If more than one ins co name was found, error out
  1. I $O(NAMEARR(""))'=$O(NAMEARR(""),-1) D G EXIT
  1. . S SYMIEN=$$ERROR^IBCNEUT8("B2","Insurance company name "_INSNAME_" in the Insurance Buffer matched more than one insurance company name in the Synonym cross-reference of the Insurance Company file",.NAMEARR)
  1. ;
  1. ; If there is one INSIEN - make sure it is ACTIVE
  1. I $O(INSIEN(""))=$O(INSIEN(""),-1),'$$ACTIVE^IBCNEUT4($O(INSIEN(""))) S SYMIEN=$$ERROR^IBCNEUT8("B10","Insurance company "_INSNAME_" is not active.") G EXIT
  1. ; Find Payers for these ins co IENs
  1. D FINDPAY^IBCNEUT8(.INSIEN,.PAYID)
  1. ;
  1. ; There were Multiple INSIENs - if none exist ALL were INACTIVE
  1. I '$D(INSIEN) S SYMIEN=$$ERROR^IBCNEUT8("B10","All insurance companies named "_INSNAME_" are not active."),PAYID="" G EXIT
  1. ; If no Payer was found, error out
  1. I $O(PAYID(""))="" S SYMIEN=$$ERROR^IBCNEUT8("B4","Insurance company "_$O(NAMEARR(""))_" is not linked to a Payer.") G EXIT
  1. ; If multiple Payers were found, error out
  1. I $O(PAYID(""))'=$O(PAYID(""),-1) S SYMIEN=$$ERROR^IBCNEUT8("B3","Insurance company "_$O(NAMEARR(""))_" is linked to more than one Payer",.PAYID),PAYID="" G EXIT
  1. ; Validate the found unique Payer
  1. D VALID^IBCNEUT4(PAYID($O(PAYID(""))),.PAYIEN,.PAYID,.SYMIEN)
  1. ;
  1. EXIT ; Main function exit point
  1. Q SYMIEN_U_PAYIEN_U_PAYID
  1. ;
  1. MANUAL(IEN) ; Need to do a manual insurance verification?
  1. N MANUAL,STIEN
  1. S MANUAL=0
  1. S STIEN=$$FIND1^DIC(365.15,,"X","B17","B")
  1. I $$GET1^DIQ(355.33,IEN_",",.12,"I")=STIEN S MANUAL=1,SYMIEN=STIEN
  1. Q MANUAL