FBRXUTL ;WIOFO/SAB-FEE BASIS PHARMACY UTILITY ;4/8/2004
;;3.5;FEE BASIS;**78**;JAN 30, 1995
Q
;
RXSUM(FBDT,FBSN) ; fee prescription costs extrinsic function
; Integration Agreement #4395
; This API returns the count and cost of prescriptions paid
; through the fee software for a specified date.
;
; Usage: S X=$$FEERX(FBDT,FBSN)
; input
; FBDT - date, required, VA FileMan internal format
; Used to select prescriptions based on Date Certified for
; Payment.
; FBSN - station number, required, 3 digit value
; Used to select prescriptions based on the VAMC that approved
; payment when querying the national Fee Replacement system.
; Prescriptions will be included when the approving station
; number Starts With this 3 digit value so satellite
; station 688A1 would be included when FBSN = 688.
; This parameter will not be evaluated until the API is
; modified to obtain data from the Fee Replacement system.
; Return value is a string
; string value = count ^ total amount paid
; where
; count = the number of prescriptions for the date and station
; total amount paid = sum of the Amount Paid for the prescriptions
; in dollars and cents
; OR
; X = -1 ^ exception number ^ exception text
;
; Examples S var=$$FEERX^FBZSAB9(DT,688) could return values like
; 8^10.54
; 0^0.00
; -1^110^Database Unavailable
;
; List of Exceptions
; 101^Valid date not specified.
; 102^Valid station number not specified.
; 110^Database Unavailable.
; The database unavailable exception will not occur until this API
; is modified to obtain data from the fee replacement system.
; However, calling applications should code to handle this exception
; now so appropriate action will be taken once the data is moved from
; the local VistA system to the remote fee replacement system.
;
N FBDFN,FBC,FBDA,FBDA1,FBRET,FBTAMT
S FBDT=$G(FBDT)
S FBSN=$G(FBSN)
S FBRET=""
;
; check for required input
I FBRET'<0 D
. I FBDT'?7N S FBRET="-1^101^Valid date not specified." Q
. I $$FMTHL7^XLFDT(FBDT)<0 S FBRET="-1^101^Valid date not specified." Q
. I FBSN'?3N S FBRET="-1^102^Valid station number not specified." Q
. I $$IEN^XUAF4(FBSN)'>0 S FBRET="-1^102^Valid station number not specified." Q
;
; get count and total amount
I FBRET'<0 D
. S FBC=0 ; initialize count
. S FBTAMT=0 ; initialize total amount paid
. ;
. ; find prescriptions using File #162.1 "AA" cross-reference
. ; loop thru patient within date certified
. S FBDFN=""
. F S FBDFN=$O(^FBAA(162.1,"AA",FBDT,FBDFN)) Q:FBDFN="" D
. . ; loop thru invoice ien
. . S FBDA1=0
. . F S FBDA1=$O(^FBAA(162.1,"AA",FBDT,FBDFN,FBDA1)) Q:'FBDA1 D
. . . ; loop thru prescription ien
. . . S FBDA=0
. . . F S FBDA=$O(^FBAA(162.1,"AA",FBDT,FBDFN,FBDA1,FBDA)) Q:'FBDA D
. . . . ; add prescription to count and total amount paid
. . . . S FBC=FBC+1
. . . . S FBTAMT=FBTAMT+$P($G(^FBAA(162.1,FBDA1,"RX",FBDA,0)),U,16)
. ;
. S FBRET=FBC_U_$FN(FBTAMT,"",2)
;
Q FBRET
;
;FBRXUTL
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFBRXUTL 3208 printed Dec 13, 2024@01:59:55 Page 2
FBRXUTL ;WIOFO/SAB-FEE BASIS PHARMACY UTILITY ;4/8/2004
+1 ;;3.5;FEE BASIS;**78**;JAN 30, 1995
+2 QUIT
+3 ;
RXSUM(FBDT,FBSN) ; fee prescription costs extrinsic function
+1 ; Integration Agreement #4395
+2 ; This API returns the count and cost of prescriptions paid
+3 ; through the fee software for a specified date.
+4 ;
+5 ; Usage: S X=$$FEERX(FBDT,FBSN)
+6 ; input
+7 ; FBDT - date, required, VA FileMan internal format
+8 ; Used to select prescriptions based on Date Certified for
+9 ; Payment.
+10 ; FBSN - station number, required, 3 digit value
+11 ; Used to select prescriptions based on the VAMC that approved
+12 ; payment when querying the national Fee Replacement system.
+13 ; Prescriptions will be included when the approving station
+14 ; number Starts With this 3 digit value so satellite
+15 ; station 688A1 would be included when FBSN = 688.
+16 ; This parameter will not be evaluated until the API is
+17 ; modified to obtain data from the Fee Replacement system.
+18 ; Return value is a string
+19 ; string value = count ^ total amount paid
+20 ; where
+21 ; count = the number of prescriptions for the date and station
+22 ; total amount paid = sum of the Amount Paid for the prescriptions
+23 ; in dollars and cents
+24 ; OR
+25 ; X = -1 ^ exception number ^ exception text
+26 ;
+27 ; Examples S var=$$FEERX^FBZSAB9(DT,688) could return values like
+28 ; 8^10.54
+29 ; 0^0.00
+30 ; -1^110^Database Unavailable
+31 ;
+32 ; List of Exceptions
+33 ; 101^Valid date not specified.
+34 ; 102^Valid station number not specified.
+35 ; 110^Database Unavailable.
+36 ; The database unavailable exception will not occur until this API
+37 ; is modified to obtain data from the fee replacement system.
+38 ; However, calling applications should code to handle this exception
+39 ; now so appropriate action will be taken once the data is moved from
+40 ; the local VistA system to the remote fee replacement system.
+41 ;
+42 NEW FBDFN,FBC,FBDA,FBDA1,FBRET,FBTAMT
+43 SET FBDT=$GET(FBDT)
+44 SET FBSN=$GET(FBSN)
+45 SET FBRET=""
+46 ;
+47 ; check for required input
+48 IF FBRET'<0
Begin DoDot:1
+49 IF FBDT'?7N
SET FBRET="-1^101^Valid date not specified."
QUIT
+50 IF $$FMTHL7^XLFDT(FBDT)<0
SET FBRET="-1^101^Valid date not specified."
QUIT
+51 IF FBSN'?3N
SET FBRET="-1^102^Valid station number not specified."
QUIT
+52 IF $$IEN^XUAF4(FBSN)'>0
SET FBRET="-1^102^Valid station number not specified."
QUIT
End DoDot:1
+53 ;
+54 ; get count and total amount
+55 IF FBRET'<0
Begin DoDot:1
+56 ; initialize count
SET FBC=0
+57 ; initialize total amount paid
SET FBTAMT=0
+58 ;
+59 ; find prescriptions using File #162.1 "AA" cross-reference
+60 ; loop thru patient within date certified
+61 SET FBDFN=""
+62 FOR
SET FBDFN=$ORDER(^FBAA(162.1,"AA",FBDT,FBDFN))
if FBDFN=""
QUIT
Begin DoDot:2
+63 ; loop thru invoice ien
+64 SET FBDA1=0
+65 FOR
SET FBDA1=$ORDER(^FBAA(162.1,"AA",FBDT,FBDFN,FBDA1))
if 'FBDA1
QUIT
Begin DoDot:3
+66 ; loop thru prescription ien
+67 SET FBDA=0
+68 FOR
SET FBDA=$ORDER(^FBAA(162.1,"AA",FBDT,FBDFN,FBDA1,FBDA))
if 'FBDA
QUIT
Begin DoDot:4
+69 ; add prescription to count and total amount paid
+70 SET FBC=FBC+1
+71 SET FBTAMT=FBTAMT+$PIECE($GET(^FBAA(162.1,FBDA1,"RX",FBDA,0)),U,16)
End DoDot:4
End DoDot:3
End DoDot:2
+72 ;
+73 SET FBRET=FBC_U_$FNUMBER(FBTAMT,"",2)
End DoDot:1
+74 ;
+75 QUIT FBRET
+76 ;
+77 ;FBRXUTL