| 1 | FBUTL ;WCIOFO/SAB-FEE BASIS UTILITY ;4/8/2004
 | 
|---|
| 2 |  ;;3.5;FEE BASIS;**16,78**;JAN 30, 1995
 | 
|---|
| 3 |  Q
 | 
|---|
| 4 |  ;
 | 
|---|
| 5 | AUTH(FBDA,FBCUT) ; FEE Authorization extrinsic function
 | 
|---|
| 6 |  ; Determines if the patient has any FEE authorizations on file.
 | 
|---|
| 7 |  ; An optional date can be specified to determine if the patient has
 | 
|---|
| 8 |  ;   any FEE authorizations in effect on or after the specified date.
 | 
|---|
| 9 |  ; input
 | 
|---|
| 10 |  ;    FBDA  - patient internal entry number (DFN)
 | 
|---|
| 11 |  ;            of the PATIENT (#2) and FEE BASIS PATIENT (#161) file
 | 
|---|
| 12 |  ;    FBCUT - (optional) cutoff date (fileman format)
 | 
|---|
| 13 |  ;            Default: none
 | 
|---|
| 14 |  ;            authorizations with a TO DATE prior to the
 | 
|---|
| 15 |  ;            cutoff date (if specified) will not be considered.
 | 
|---|
| 16 |  ; returns a value of 1 or 0
 | 
|---|
| 17 |  ;   will be true (1) if patient has one or more FEE authorizations
 | 
|---|
| 18 |  ;
 | 
|---|
| 19 |  N FBDA1,FBRET,FBY0
 | 
|---|
| 20 |  S FBCUT=$S($G(FBCUT)?7N:FBCUT,1:"")
 | 
|---|
| 21 |  S FBRET=0 ; assume no authorizations will meet criteria
 | 
|---|
| 22 |  ; reverse loop thru authorizations - stop when any one meets criteria
 | 
|---|
| 23 |  S FBDA1=" " F  S FBDA1=$O(^FBAAA(FBDA,1,FBDA1),-1) Q:'FBDA1  D  Q:FBRET
 | 
|---|
| 24 |  . Q:$P($G(^FBAAA(FBDA,1,FBDA1,"ADEL")),U)="Y"  ; ignore Austin Deleted
 | 
|---|
| 25 |  . S FBY0=$G(^FBAAA(FBDA,1,FBDA1,0))
 | 
|---|
| 26 |  . I FBCUT]"",$P(FBY0,U,2)<FBCUT Q  ; To Date before cutoff date
 | 
|---|
| 27 |  . Q:$P(FBY0,U,3)=""  ; FEE Program required
 | 
|---|
| 28 |  . ; passed all checks
 | 
|---|
| 29 |  . S FBRET=1
 | 
|---|
| 30 |  ;
 | 
|---|
| 31 |  Q FBRET
 | 
|---|
| 32 |  ;
 | 
|---|
| 33 | AUTHL(FBDFN,FBSN,FBDT,FBAR) ; authorization list for patient
 | 
|---|
| 34 |  ; Integration Agreement #4396
 | 
|---|
| 35 |  ; This API returns authorization data for a specified patient.
 | 
|---|
| 36 |  ; Authorizations that have been Austin Deleted will not be returned.
 | 
|---|
| 37 |  ;
 | 
|---|
| 38 |  ; input
 | 
|---|
| 39 |  ;   FBDFN - patient DFN (File #2 internal entry number), required
 | 
|---|
| 40 |  ;   FBSN  - station number, optional
 | 
|---|
| 41 |  ;           If specified, the station number will be used to select
 | 
|---|
| 42 |  ;           authorizations from the national Fee Replacement system.
 | 
|---|
| 43 |  ;           Only authorizations whose issuing station Starts With this
 | 
|---|
| 44 |  ;           parameter value will be returned. 
 | 
|---|
| 45 |  ;           This parameter will not be evaluated until the API is
 | 
|---|
| 46 |  ;           modified to obtain data from the fee replacement system.
 | 
|---|
| 47 |  ;   FBDT  - cutoff date, optional, VA FileMan internal format
 | 
|---|
| 48 |  ;           If specified, only authorizations whose To Date is
 | 
|---|
| 49 |  ;           equal to or after the cutoff date will be returned.
 | 
|---|
| 50 |  ;   FBAR  - name of output array, optional, default value "FBAUTH"
 | 
|---|
| 51 |  ;           closed root, must not equal variables newed by this API
 | 
|---|
| 52 |  ;           such as FBAR.
 | 
|---|
| 53 |  ;           examples: "FBAUTH", "DGAUTH(12)", "^TMP($J)"
 | 
|---|
| 54 |  ;           The array will be initialized by this API.
 | 
|---|
| 55 |  ; output
 | 
|---|
| 56 |  ;   returns string value
 | 
|---|
| 57 |  ;     = count of authorizations in array
 | 
|---|
| 58 |  ;   OR
 | 
|---|
| 59 |  ;     = -1^exception number^exception text
 | 
|---|
| 60 |  ;
 | 
|---|
| 61 |  ;   If an exception did not occur, then the output array will contain 
 | 
|---|
| 62 |  ;   authorization data subscripted by sequential canonic
 | 
|---|
| 63 |  ;   numbers and a header node subscripted by 0.
 | 
|---|
| 64 |  ;     array(0) = count of authorizations in array
 | 
|---|
| 65 |  ;     array(#,"FDT") = authorization # From Date (internal format)
 | 
|---|
| 66 |  ;     array(#,"TDT") = authorization # To Date (internal format)
 | 
|---|
| 67 |  ;       OR
 | 
|---|
| 68 |  ;   Example if "FBAUTH" used as array name
 | 
|---|
| 69 |  ;     FBAUTH(0)=2
 | 
|---|
| 70 |  ;     FBAUTH(1,"FDT")=3011021
 | 
|---|
| 71 |  ;     FBAUTH(1,"TDT")=3011030
 | 
|---|
| 72 |  ;     FBAUTH(2,"FDT")=3000101
 | 
|---|
| 73 |  ;     FBAUTH(2,"TDT")=3031231
 | 
|---|
| 74 |  ;   Note that additional subscripts may be added in the future to
 | 
|---|
| 75 |  ;   provide more authorization data. The calling application should
 | 
|---|
| 76 |  ;   kill the entire output array so any added subscripts will be
 | 
|---|
| 77 |  ;   cleaned-up (e.g. K FBAUTH).
 | 
|---|
| 78 |  ;   List of exceptions
 | 
|---|
| 79 |  ;     101^Patient DFN not specified.
 | 
|---|
| 80 |  ;     104^ICN could not be determined for the specified patient.
 | 
|---|
| 81 |  ;     105^Array name conflicts with a variable in the API.
 | 
|---|
| 82 |  ;     110^Database Unavailable.
 | 
|---|
| 83 |  ;   The database unavailable exception will not occur until this API
 | 
|---|
| 84 |  ;   is modified to obtain data from the fee replacement system.
 | 
|---|
| 85 |  ;   However, calling applications should code to handle this exception
 | 
|---|
| 86 |  ;   now so appropriate action will be taken once the data is moved from
 | 
|---|
| 87 |  ;   the local VistA system to the remote fee replacement system.
 | 
|---|
| 88 |  ;
 | 
|---|
| 89 |  N FBC,FBDA,FBICN,FBRET,FBY
 | 
|---|
| 90 |  ;
 | 
|---|
| 91 |  S FBAR=$G(FBAR,"FBAUTH")
 | 
|---|
| 92 |  S FBSN=$G(FBSN)
 | 
|---|
| 93 |  S FBDT=$G(FBDT)
 | 
|---|
| 94 |  S FBRET=""
 | 
|---|
| 95 |  ;
 | 
|---|
| 96 |  ; ensure input array name is not one of the newed variables.
 | 
|---|
| 97 |  ; If conflict, then array will not be changed by this API.
 | 
|---|
| 98 |  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."
 | 
|---|
| 99 |  ;
 | 
|---|
| 100 |  ; initialize output array
 | 
|---|
| 101 |  I FBRET'<0 K @FBAR
 | 
|---|
| 102 |  ;
 | 
|---|
| 103 |  ; check for required input
 | 
|---|
| 104 |  I FBRET'<0,$G(FBDFN)="" S FBRET="-1^101^Patient DFN not specified."
 | 
|---|
| 105 |  ;
 | 
|---|
| 106 |  ; get patient ICN
 | 
|---|
| 107 |  I FBRET'<0 D
 | 
|---|
| 108 |  . I $$IFLOCAL^MPIF001(FBDFN) S FBRET="-1^104^ICN could not be determined for the specified patient." Q  ; must not be local ICN
 | 
|---|
| 109 |  . S FBICN=$$GETICN^MPIF001(FBDFN) I FBICN<0 S FBRET="-1^104^ICN could not be determined for the specified patient." Q
 | 
|---|
| 110 |  ;
 | 
|---|
| 111 |  ; if optional date passed then check if valid value
 | 
|---|
| 112 |  I FBRET'<0,FBDT'="" D
 | 
|---|
| 113 |  . I FBDT'?7N S FBRET="-1^101^Valid date not specified." Q
 | 
|---|
| 114 |  . I $$FMTHL7^XLFDT(FBDT)<0 S FBRET="-1^101^Valid date not specified." Q
 | 
|---|
| 115 |  ;
 | 
|---|
| 116 |  ; get authorization data
 | 
|---|
| 117 |  I FBRET'<0 D
 | 
|---|
| 118 |  . S FBC=0 ; initialize count/subscript of authorizations in output array
 | 
|---|
| 119 |  . ; loop thru AUTHORIZATION multiple of file #161
 | 
|---|
| 120 |  . S FBDA=0 F  S FBDA=$O(^FBAAA(FBDFN,1,FBDA)) Q:'FBDA  D
 | 
|---|
| 121 |  . . Q:$P($G(^FBAAA(FBDFN,1,FBDA,"ADEL")),U)="Y"  ; skip Austin Deleted
 | 
|---|
| 122 |  . . S FBY=$G(^FBAAA(FBDFN,1,FBDA,0))
 | 
|---|
| 123 |  . . I FBDT,$P(FBY,U,2)<FBDT Q  ; skip if To Date before optional Cutoff
 | 
|---|
| 124 |  . . ; increment count and store authorization data in array
 | 
|---|
| 125 |  . . S FBC=FBC+1
 | 
|---|
| 126 |  . . S @FBAR@(FBC,"FDT")=$P(FBY,U)
 | 
|---|
| 127 |  . . S @FBAR@(FBC,"TDT")=$P(FBY,U,2)
 | 
|---|
| 128 |  . ;
 | 
|---|
| 129 |  . ; set return value and header node of output array
 | 
|---|
| 130 |  . S FBRET=FBC
 | 
|---|
| 131 |  . S @FBAR@(0)=FBC
 | 
|---|
| 132 |  ;
 | 
|---|
| 133 |  Q FBRET
 | 
|---|
| 134 |  ;
 | 
|---|
| 135 |  ;FBUTL
 | 
|---|