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

FBUTL.m

Go to the documentation of this file.
  1. FBUTL ;WCIOFO/SAB-FEE BASIS UTILITY ;4/8/2004
  1. ;;3.5;FEE BASIS;**16,78**;JAN 30, 1995
  1. Q
  1. ;
  1. AUTH(FBDA,FBCUT) ; FEE Authorization extrinsic function
  1. ; Determines if the patient has any FEE authorizations on file.
  1. ; An optional date can be specified to determine if the patient has
  1. ; any FEE authorizations in effect on or after the specified date.
  1. ; input
  1. ; FBDA - patient internal entry number (DFN)
  1. ; of the PATIENT (#2) and FEE BASIS PATIENT (#161) file
  1. ; FBCUT - (optional) cutoff date (fileman format)
  1. ; Default: none
  1. ; authorizations with a TO DATE prior to the
  1. ; cutoff date (if specified) will not be considered.
  1. ; returns a value of 1 or 0
  1. ; will be true (1) if patient has one or more FEE authorizations
  1. ;
  1. N FBDA1,FBRET,FBY0
  1. S FBCUT=$S($G(FBCUT)?7N:FBCUT,1:"")
  1. S FBRET=0 ; assume no authorizations will meet criteria
  1. ; reverse loop thru authorizations - stop when any one meets criteria
  1. S FBDA1=" " F S FBDA1=$O(^FBAAA(FBDA,1,FBDA1),-1) Q:'FBDA1 D Q:FBRET
  1. . Q:$P($G(^FBAAA(FBDA,1,FBDA1,"ADEL")),U)="Y" ; ignore Austin Deleted
  1. . S FBY0=$G(^FBAAA(FBDA,1,FBDA1,0))
  1. . I FBCUT]"",$P(FBY0,U,2)<FBCUT Q ; To Date before cutoff date
  1. . Q:$P(FBY0,U,3)="" ; FEE Program required
  1. . ; passed all checks
  1. . S FBRET=1
  1. ;
  1. Q FBRET
  1. ;
  1. AUTHL(FBDFN,FBSN,FBDT,FBAR) ; authorization list for patient
  1. ; Integration Agreement #4396
  1. ; This API returns authorization data for a specified patient.
  1. ; Authorizations that have been Austin Deleted will not be returned.
  1. ;
  1. ; input
  1. ; FBDFN - patient DFN (File #2 internal entry number), required
  1. ; FBSN - station number, optional
  1. ; If specified, the station number will be used to select
  1. ; authorizations from the national Fee Replacement system.
  1. ; Only authorizations whose issuing station Starts With this
  1. ; parameter value will be returned.
  1. ; This parameter will not be evaluated until the API is
  1. ; modified to obtain data from the fee replacement system.
  1. ; FBDT - cutoff date, optional, VA FileMan internal format
  1. ; If specified, only authorizations whose To Date is
  1. ; equal to or after the cutoff date will be returned.
  1. ; FBAR - name of output array, optional, default value "FBAUTH"
  1. ; closed root, must not equal variables newed by this API
  1. ; such as FBAR.
  1. ; examples: "FBAUTH", "DGAUTH(12)", "^TMP($J)"
  1. ; The array will be initialized by this API.
  1. ; output
  1. ; returns string value
  1. ; = count of authorizations in array
  1. ; OR
  1. ; = -1^exception number^exception text
  1. ;
  1. ; If an exception did not occur, then the output array will contain
  1. ; authorization data subscripted by sequential canonic
  1. ; numbers and a header node subscripted by 0.
  1. ; array(0) = count of authorizations in array
  1. ; array(#,"FDT") = authorization # From Date (internal format)
  1. ; array(#,"TDT") = authorization # To Date (internal format)
  1. ; OR
  1. ; Example if "FBAUTH" used as array name
  1. ; FBAUTH(0)=2
  1. ; FBAUTH(1,"FDT")=3011021
  1. ; FBAUTH(1,"TDT")=3011030
  1. ; FBAUTH(2,"FDT")=3000101
  1. ; FBAUTH(2,"TDT")=3031231
  1. ; Note that additional subscripts may be added in the future to
  1. ; provide more authorization data. The calling application should
  1. ; kill the entire output array so any added subscripts will be
  1. ; cleaned-up (e.g. K FBAUTH).
  1. ; List of exceptions
  1. ; 101^Patient DFN not specified.
  1. ; 104^ICN could not be determined for the specified patient.
  1. ; 105^Array name conflicts with a variable in the API.
  1. ; 110^Database Unavailable.
  1. ; The database unavailable exception will not occur until this API
  1. ; is modified to obtain data from the fee replacement system.
  1. ; However, calling applications should code to handle this exception
  1. ; now so appropriate action will be taken once the data is moved from
  1. ; the local VistA system to the remote fee replacement system.
  1. ;
  1. N FBC,FBDA,FBICN,FBRET,FBY
  1. ;
  1. S FBAR=$G(FBAR,"FBAUTH")
  1. S FBSN=$G(FBSN)
  1. S FBDT=$G(FBDT)
  1. S FBRET=""
  1. ;
  1. ; ensure input array name is not one of the newed variables.
  1. ; If conflict, then array will not be changed by this API.
  1. I "^FBDFN^FBAR^FBC^FBDA^FBDT^FBICN^FBRET^FBSN^FBY^"[(U_FBAR_U) S FBRET="-1^105^Array name conflicts with a variable in the API."
  1. ;
  1. ; initialize output array
  1. I FBRET'<0 K @FBAR
  1. ;
  1. ; check for required input
  1. I FBRET'<0,$G(FBDFN)="" S FBRET="-1^101^Patient DFN not specified."
  1. ;
  1. ; get patient ICN
  1. I FBRET'<0 D
  1. . I $$IFLOCAL^MPIF001(FBDFN) S FBRET="-1^104^ICN could not be determined for the specified patient." Q ; must not be local ICN
  1. . S FBICN=$$GETICN^MPIF001(FBDFN) I FBICN<0 S FBRET="-1^104^ICN could not be determined for the specified patient." Q
  1. ;
  1. ; if optional date passed then check if valid value
  1. I FBRET'<0,FBDT'="" D
  1. . I FBDT'?7N S FBRET="-1^101^Valid date not specified." Q
  1. . I $$FMTHL7^XLFDT(FBDT)<0 S FBRET="-1^101^Valid date not specified." Q
  1. ;
  1. ; get authorization data
  1. I FBRET'<0 D
  1. . S FBC=0 ; initialize count/subscript of authorizations in output array
  1. . ; loop thru AUTHORIZATION multiple of file #161
  1. . S FBDA=0 F S FBDA=$O(^FBAAA(FBDFN,1,FBDA)) Q:'FBDA D
  1. . . Q:$P($G(^FBAAA(FBDFN,1,FBDA,"ADEL")),U)="Y" ; skip Austin Deleted
  1. . . S FBY=$G(^FBAAA(FBDFN,1,FBDA,0))
  1. . . I FBDT,$P(FBY,U,2)<FBDT Q ; skip if To Date before optional Cutoff
  1. . . ; increment count and store authorization data in array
  1. . . S FBC=FBC+1
  1. . . S @FBAR@(FBC,"FDT")=$P(FBY,U)
  1. . . S @FBAR@(FBC,"TDT")=$P(FBY,U,2)
  1. . ;
  1. . ; set return value and header node of output array
  1. . S FBRET=FBC
  1. . S @FBAR@(0)=FBC
  1. ;
  1. Q FBRET
  1. ;
  1. ;FBUTL