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

IBECEA31.m

Go to the documentation of this file.
  1. IBECEA31 ;ALB/CPM - Cancel/Edit/Add... Handle Events ; 02-APR-93
  1. ;;Version 2.0 ; INTEGRATED BILLING ;; 21-MAR-94
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. EVF(DFN,IBFR,IBTO,IBNH) ; Find the matching event for a copay or per diem.
  1. ; Input: DFN -- Pointer to the patient in file #2
  1. ; IBFR -- Charge 'Bill From' date
  1. ; IBTO -- Charge 'Bill To' date
  1. ; IBNH -- 1 - NHCU charge, 0 - Hospital charge
  1. ; Output: >1 -- ien of event ^ admission date ^ discharge date
  1. ; 0 -- an event is not found
  1. ; -1 -- an event is found, but can't be billed
  1. I '$G(DFN)!'$G(IBFR)!'$G(IBTO) Q 0
  1. S IBNH=$S($G(IBNH):"NHCU",1:"HOSPITAL")
  1. N DIS,EVD,IBN,Y S EVD="",(IBN,Y)=0
  1. F S EVD=$O(^IB("AFDT",DFN,EVD)) Q:'EVD I -EVD'>IBFR F S IBN=$O(^IB("AFDT",DFN,EVD,IBN)) Q:'IBN S IBND=$G(^IB(IBN,0)) I $P(IBND,"^",8)[IBNH D EVS G EVFQ
  1. EVFQ Q Y
  1. ;
  1. EVS ; Set the output variable Y for the most recent (applicable) event.
  1. S DIS=$$DIS(IBND)
  1. S Y=$S(IBXA=3&(IBTO>DIS):-1,IBXA=2&(IBTO'<DIS):-1,1:IBN)_"^"_-EVD_"^"_DIS
  1. Q
  1. ;
  1. DIS(X) ; Find the discharge date for an admission.
  1. ; Input: X -- Zeroth node of an entry in #350
  1. ; Output: Discharge date (if discharged), or 9999999 (still admitted)
  1. N DIS
  1. S DIS=+$G(^DGPM(+$P($G(^DGPM(+$P($P($G(X),"^",4),":",2),0)),"^",17),0))
  1. Q $S(DIS:DIS\1,1:9999999)
  1. ;
  1. ADSEL(DFN) ; Select an admission to use to build an event.
  1. ; Input: DFN -- Pointer to the patient in file #2
  1. ; Output: >1 -- ien of pt movement (in file #405) to link event
  1. ; 0 -- no admissions for the patient, or
  1. ; -1 -- user decided to quit.
  1. I '$D(^DGPM("ATID1",+$G(DFN))) Q 0
  1. N ARR,DG,IBD,IBQ,J,SEL,X S IBQ=0,IBD=""
  1. F J=1:1 S IBD=$O(^DGPM("ATID1",DFN,IBD)) Q:'IBD S DG=+$O(^(IBD,0)) I $D(^DGPM(DG,0)) W:J=1 !!," Please select one of the following admissions:" S ARR(J)=DG_"^"_(+^(0)\1)_"^"_+$P(^(0),"^",17) W !?3,J D DISEL,ASKAD:'(J#5) G:IBQ!($D(SEL)) ADSELQ
  1. I '$D(ARR) G ADSELQ
  1. I '((J-1)#5) W !!?3,"End of list.",!
  1. S J=J-1 D ASKAD
  1. ADSELQ Q $S('$D(ARR):0,IBQ!'$D(SEL):-1,1:SEL)
  1. ;
  1. DISEL ; Display admission data.
  1. N DGPM S DGPM=$G(^DGPM(DG,0))
  1. W ?7,$$DAT2^IBOUTL(+DGPM),?28,"to: ",$E($P($G(^DIC(42,+$P(DGPM,"^",6),0)),"^"),1,18)
  1. I $P(DGPM,"^",17) W ?52,"(Discharged: ",$$DAT2^IBOUTL(+$G(^DGPM(+$P(DGPM,"^",17),0))\1),")"
  1. Q
  1. ;
  1. ASKAD ; Prompt the user to select an admission.
  1. W !," Select 1-",J," or type '^' to quit: " R X:DTIME S:'$T!(X["^") IBQ=1 I IBQ!(X="") G ASKADQ
  1. I '$D(ARR(+X)) W !!?3,*7,"Enter a NUMBER from 1-",J,".",! G ASKAD
  1. S IBDIS=+$G(^DGPM(+$P(ARR(+X),"^",3),0))\1 S:'IBDIS IBDIS=DT
  1. I IBFR'<$P(ARR(+X),"^",2),IBTO'>IBDIS S SEL=ARR(+X) G ASKADQ
  1. W !!?3,*7,"The bill dates fall outside the admissions dates!",! G ASKAD
  1. ASKADQ K IBDIS
  1. Q
  1. ;
  1. ADEV ; Add a new event entry in file #350.
  1. W !!,"I have to build the event record first... "
  1. N DIE,DR,DA,IBLAST
  1. D EVADD^IBAUTL3 K IBN,IBEVDT Q:IBY<0 W "done."
  1. S IBLAST=$S(IBXA=2:IBTO,IBFR=IBTO:IBTO,1:$$FMADD^XLFDT(IBTO,-1))
  1. W !,"Updating the Date Last Calculated to ",$$DAT1^IBOUTL(IBLAST),"... "
  1. S DIE="^IB(",DA=IBEVDA,DR=".18////"_IBLAST D ^DIE W "done."
  1. I $P(IBDG,"^",3) W !,"Since the patient has been discharged, let me 'close' the IB event... " S DIE="^IB(",DA=IBEVDA,DR=".05////2" D ^DIE W "done."
  1. Q
  1. ;
  1. NOEV ; No event in Integrated Billing - ask user to select an admission
  1. W !! I IBEVDA<0 D UNAB W !,"Tried to link the charge to an admission on ",$$DAT1^IBOUTL($P(IBEVDA,"^",2)),", but the Bill To date",!,"(",$$DAT1^IBOUTL(IBTO),") exceeds the discharge date of ",$$DAT1^IBOUTL($P(IBEVDA,"^",3)),"."
  1. D:'IBEVDA UNAB
  1. W !,"You may link this charge to one of the patient's admissions..."
  1. S IBDG=$$ADSEL(DFN)
  1. I 'IBDG W !!,"This patient has no admissions -- this charge cannot be added." S IBY=-1 Q
  1. I IBDG=-1 W !!,"No admission selected -- transaction cannot be completed." S IBY=-1 Q
  1. W !!,"I will need to build an event record in Integrated Billing for this charge."
  1. ;
  1. ; - check for special inpatient billing case
  1. D SPEC^IBECEA32(1,$O(^IBE(351.2,"AC",+IBDG,0)))
  1. ;
  1. ; - build softlink and set event date
  1. S IBSL="405:"_+IBDG,IBEVDT=$P(IBDG,"^",2)
  1. Q
  1. ;
  1. UNAB W "Unable to link this charge to an event in Integrated Billing!"
  1. Q