IBCNBES ;ALB/ARH-Ins Buffer: stuff new entries/data into buffer ;1 Jun 97
;;2.0;INTEGRATED BILLING;**82,184,345,438,497,743**;21-MAR-94;Build 18
;;Per VHA Directive 6402, this routine should not be modified.
;
;
ADDSTF(IBSOURCE,DFN,IBDATA) ; add new entry to Insurance Buffer file (355.33) and stuff the data passed in, no user interaction
; IBSOURCE = source of information (required)
; 1 = interview 2 = data match
; 3 = ivm 4 = pre-registration
; 5 = eIV etc., refer to file #365.12 for full list of sources ;IB*743/CKB
; DFN = patient's ifn in file 2 (required)
; IBDATA = data to file in Buffer in an array subscripted by field number of the data field in 355.33
; ex: IBDATA(20.01)="Insurance Company Name", etc,
; returns ien of new entry or 0 followed by error if entry not added
;
; example of call: $$ADDBUF^IBCNBES(2,DFN,.IBDATA) where IBDATA(field #) = value
;
N X,Y,IBBUFDA,IBERROR
;
; verify source of information and data exists to store
I $G(IBSOURCE)="" S IBERROR="SOURCE OF INFORMATION INCORRECT" G EXIT
I $G(^DPT(+$G(DFN),0))="" S IBERROR="NO PATIENT DEFINED" G EXIT
I $D(IBDATA)<10 S IBERROR="NO DATA TO STORE" G EXIT
;
; add new entry to Buffer file (355.33)
S IBBUFDA=+$$ADD^IBCNBEE(IBSOURCE) I 'IBBUFDA S IBERROR="COULD NOT CREATE A NEW BUFFER ENTRY" G EXIT
;
S IBDATA(60.01)=+DFN
;
; Set up DUZ (interface user) so 60.01 field check can find 'valid reason' for sensitive
; patients and not set 60.01 to '0' with an error in tag FLDCHK
I '$G(DUZ) D DUZ^XUP(.5)
;
D EDITSTF(+IBBUFDA,.IBDATA)
;
; delete leftover ESGHP data if ESGHP? is not Yes
I +$G(IBBUFDA),$D(^IBA(355.33,$G(IBBUFDA),61)),'$G(^IBA(355.33,$G(IBBUFDA),61)) D DELEMP^IBCNBEE($G(IBBUFDA))
;
EXIT Q +$G(IBBUFDA)_"^"_$G(IBERROR)
;
EDITSTF(IBBUFDA,IBDATA) ; loop though data array and stuff each buffer field, no user interaction
;
N IBFIELD,IBVALUE,IBARR,IBERR Q:'$G(^IBA(355.33,$G(IBBUFDA),0))
;
S IBFIELD=0 F S IBFIELD=$O(IBDATA(IBFIELD)) Q:'IBFIELD D
. ; ** have to file subscriber id last in order for real-time verification inquiry triggers to work properly **
. I IBFIELD=90.03!(IBFIELD=60.04) Q
. S IBVALUE=$$FLDCHK(355.33,IBFIELD,IBDATA(IBFIELD)) Q:'IBVALUE
. S IBARR(355.33,IBBUFDA_",",IBFIELD)=$P(IBVALUE,U,2)
I $D(IBARR)>9 D FILE^DIE("E","IBARR","IBERR")
; file subscriber id
; needs to work with new and old subscriber id field until transition to the new field is complete.
I $G(IBDATA(90.03))'=""!($G(IBDATA(60.04))'="") D
.N IBSUBIDF
.S IBSUBIDF=$S($G(IBDATA(90.03))'="":90.03,1:60.04)
.S IBVALUE=$$FLDCHK(355.33,IBSUBIDF,IBDATA(IBSUBIDF)) Q:'IBVALUE
.K IBARR S IBARR(355.33,IBBUFDA_",",IBSUBIDF)=$P(IBVALUE,U,2)
.D FILE^DIE("E","IBARR","IBERR")
.Q
Q
;
FLDCHK(FILE,FIELD,VALUE) ; minor checks on data: truncate if length too long, if pointer add ' so can be processed as external format
N IBATTR,IBERR,IBX S IBX="1^"_VALUE
I VALUE="" S IBX="0^No data value." G FLDCHKQ
D FIELD^DID(FILE,FIELD,"N","FIELD LENGTH;SPECIFIER","IBATTR","IBERR")
I $D(IBERR) S IBX="0^"_$G(IBERR("DIERR",1,"TEXT",1)) G FLDCHKQ
I $G(IBATTR("SPECIFIER"))["P" S IBX="1^`"_VALUE G FLDCHKQ
I $D(IBATTR("FIELD LENGTH")) S IBX="1^"_$E(VALUE,1,+IBATTR("FIELD LENGTH"))
FLDCHKQ Q IBX
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCNBES 3401 printed Oct 16, 2024@18:14:37 Page 2
IBCNBES ;ALB/ARH-Ins Buffer: stuff new entries/data into buffer ;1 Jun 97
+1 ;;2.0;INTEGRATED BILLING;**82,184,345,438,497,743**;21-MAR-94;Build 18
+2 ;;Per VHA Directive 6402, this routine should not be modified.
+3 ;
+4 ;
ADDSTF(IBSOURCE,DFN,IBDATA) ; add new entry to Insurance Buffer file (355.33) and stuff the data passed in, no user interaction
+1 ; IBSOURCE = source of information (required)
+2 ; 1 = interview 2 = data match
+3 ; 3 = ivm 4 = pre-registration
+4 ; 5 = eIV etc., refer to file #365.12 for full list of sources ;IB*743/CKB
+5 ; DFN = patient's ifn in file 2 (required)
+6 ; IBDATA = data to file in Buffer in an array subscripted by field number of the data field in 355.33
+7 ; ex: IBDATA(20.01)="Insurance Company Name", etc,
+8 ; returns ien of new entry or 0 followed by error if entry not added
+9 ;
+10 ; example of call: $$ADDBUF^IBCNBES(2,DFN,.IBDATA) where IBDATA(field #) = value
+11 ;
+12 NEW X,Y,IBBUFDA,IBERROR
+13 ;
+14 ; verify source of information and data exists to store
+15 IF $GET(IBSOURCE)=""
SET IBERROR="SOURCE OF INFORMATION INCORRECT"
GOTO EXIT
+16 IF $GET(^DPT(+$GET(DFN),0))=""
SET IBERROR="NO PATIENT DEFINED"
GOTO EXIT
+17 IF $DATA(IBDATA)<10
SET IBERROR="NO DATA TO STORE"
GOTO EXIT
+18 ;
+19 ; add new entry to Buffer file (355.33)
+20 SET IBBUFDA=+$$ADD^IBCNBEE(IBSOURCE)
IF 'IBBUFDA
SET IBERROR="COULD NOT CREATE A NEW BUFFER ENTRY"
GOTO EXIT
+21 ;
+22 SET IBDATA(60.01)=+DFN
+23 ;
+24 ; Set up DUZ (interface user) so 60.01 field check can find 'valid reason' for sensitive
+25 ; patients and not set 60.01 to '0' with an error in tag FLDCHK
+26 IF '$GET(DUZ)
DO DUZ^XUP(.5)
+27 ;
+28 DO EDITSTF(+IBBUFDA,.IBDATA)
+29 ;
+30 ; delete leftover ESGHP data if ESGHP? is not Yes
+31 IF +$GET(IBBUFDA)
IF $DATA(^IBA(355.33,$GET(IBBUFDA),61))
IF '$GET(^IBA(355.33,$GET(IBBUFDA),61))
DO DELEMP^IBCNBEE($GET(IBBUFDA))
+32 ;
EXIT QUIT +$GET(IBBUFDA)_"^"_$GET(IBERROR)
+1 ;
EDITSTF(IBBUFDA,IBDATA) ; loop though data array and stuff each buffer field, no user interaction
+1 ;
+2 NEW IBFIELD,IBVALUE,IBARR,IBERR
if '$GET(^IBA(355.33,$GET(IBBUFDA),0))
QUIT
+3 ;
+4 SET IBFIELD=0
FOR
SET IBFIELD=$ORDER(IBDATA(IBFIELD))
if 'IBFIELD
QUIT
Begin DoDot:1
+5 ; ** have to file subscriber id last in order for real-time verification inquiry triggers to work properly **
+6 IF IBFIELD=90.03!(IBFIELD=60.04)
QUIT
+7 SET IBVALUE=$$FLDCHK(355.33,IBFIELD,IBDATA(IBFIELD))
if 'IBVALUE
QUIT
+8 SET IBARR(355.33,IBBUFDA_",",IBFIELD)=$PIECE(IBVALUE,U,2)
End DoDot:1
+9 IF $DATA(IBARR)>9
DO FILE^DIE("E","IBARR","IBERR")
+10 ; file subscriber id
+11 ; needs to work with new and old subscriber id field until transition to the new field is complete.
+12 IF $GET(IBDATA(90.03))'=""!($GET(IBDATA(60.04))'="")
Begin DoDot:1
+13 NEW IBSUBIDF
+14 SET IBSUBIDF=$SELECT($GET(IBDATA(90.03))'="":90.03,1:60.04)
+15 SET IBVALUE=$$FLDCHK(355.33,IBSUBIDF,IBDATA(IBSUBIDF))
if 'IBVALUE
QUIT
+16 KILL IBARR
SET IBARR(355.33,IBBUFDA_",",IBSUBIDF)=$PIECE(IBVALUE,U,2)
+17 DO FILE^DIE("E","IBARR","IBERR")
+18 QUIT
End DoDot:1
+19 QUIT
+20 ;
FLDCHK(FILE,FIELD,VALUE) ; minor checks on data: truncate if length too long, if pointer add ' so can be processed as external format
+1 NEW IBATTR,IBERR,IBX
SET IBX="1^"_VALUE
+2 IF VALUE=""
SET IBX="0^No data value."
GOTO FLDCHKQ
+3 DO FIELD^DID(FILE,FIELD,"N","FIELD LENGTH;SPECIFIER","IBATTR","IBERR")
+4 IF $DATA(IBERR)
SET IBX="0^"_$GET(IBERR("DIERR",1,"TEXT",1))
GOTO FLDCHKQ
+5 IF $GET(IBATTR("SPECIFIER"))["P"
SET IBX="1^`"_VALUE
GOTO FLDCHKQ
+6 IF $DATA(IBATTR("FIELD LENGTH"))
SET IBX="1^"_$EXTRACT(VALUE,1,+IBATTR("FIELD LENGTH"))
FLDCHKQ QUIT IBX