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

IBMHUT1.m

Go to the documentation of this file.
  1. IBMHUT1 ;YMG/EDE - IB Mental Health Utilities ;MAY 15 2023
  1. ;;2.0;Integrated Billing;**784**;21-MAR-94;Build 8
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. Q
  1. ;
  1. MHVST(IBSDT,IBEDT) ; loop through file 350 and populate file 351.83, as needed
  1. ;
  1. ; IBSDT - start date
  1. ; IBEDT - end date
  1. ;
  1. N DFN,IBATYP,IBATYPN,IBCANC,IBDT,IBENC,IBEVDT,IBIEN,IBMHPROC,IBMHTRK,IBOK,IBSTAT,IBSTATN,IENS,N0,Z
  1. I '+$G(IBSDT)!('+$G(IBEDT)) Q ; invalid date(s)
  1. S DFN=0 F S DFN=$O(^IB("AFDT",DFN)) Q:'DFN D
  1. .S IBDT=-(IBEDT+.01) F S IBDT=$O(^IB("AFDT",DFN,IBDT)) Q:'IBDT!(-IBDT<IBSDT) D
  1. ..S IBEVDT=-IBDT
  1. ..S IBIEN=0 F S IBIEN=$O(^IB("AFDT",DFN,IBDT,IBIEN)) Q:'IBIEN D
  1. ...S N0=$G(^IB(IBIEN,0)) ; file 350 entry, node 0
  1. ...S IBATYP=$P(N0,U,3) I 'IBATYP Q
  1. ...S IBATYPN=$P($G(^IBE(350.1,IBATYP,0)),U) I IBATYPN'["OPT" Q ; not an outpatient charge
  1. ...S IBSTAT=$P(N0,U,5) I 'IBSTAT Q
  1. ...S IBSTATN=$P($G(^IBE(350.21,IBSTAT,0)),U)
  1. ...S IBOK=$S(IBATYPN["CC MH":1,1:0)
  1. ...I 'IBOK S IBOK=$$ISCDCANC^IBECEAMH(IBIEN)
  1. ...I 'IBOK S Z=$P($P(N0,U,4),";") Q:$P(Z,":")'="409.68" S IBENC=$P(Z,":",2),IBOK=$$OECHK^IBECEAMH(IBENC,IBEVDT)
  1. ...I IBOK D
  1. ....; eligible for Cleland-Dole
  1. ....S IBMHTRK=+$O(^IBMH(351.83,"D",IBIEN,"")) ; file 351.83 ien, if entry already exists
  1. ....I IBSTATN="BILLED"!("^ON HOLD^HOLD - RATE^HOLD - REVIEW^"[(U_IBSTATN_U)),IBMHTRK>0,'$$ISBILLED(IBIEN) D ADDVST^IBECEAMH(DFN,IBEVDT,IBIEN,2)
  1. ....I IBSTATN="CANCELLED" D
  1. .....S IBCANC=+$P(N0,U,10) I 'IBCANC Q
  1. .....S IENS=IBCANC_",",IBMHPROC=$$GET1^DIQ(350.3,IENS,.07,"I") I 'IBMHPROC Q
  1. .....I '$$GET1^DIQ(350.3,IENS,.08,"I") Q ; cancellation reason can't cancel C-D charge
  1. .....I IBMHTRK>0 D UPDVST^IBECEAMH(IBIEN,IBMHPROC) Q
  1. .....I $P(^IBE(350.3,IBCANC,0),U)="CLELAND-DOLE",$$NUMVSTCK^IBECEAMH(DFN,IBEVDT) D ADDVST^IBECEAMH(DFN,IBEVDT,IBIEN,1,2)
  1. ....Q
  1. ...Q
  1. ..Q
  1. .Q
  1. Q
  1. ;
  1. ISBILLED(IBIEN) ; check if there's a "billed" entry in file 351.83 for a given charge
  1. ;
  1. ; IBIEN - file 350 ien
  1. ;
  1. ; returns 1 if there's a corresponding entry in file 351.83 with "billed" status, or 0 otherwise.
  1. ;
  1. N IBMHIEN,RES
  1. S (RES,IBMHIEN)=0 F S IBMHIEN=$O(^IBMH(351.83,"D",IBIEN,IBMHIEN)) Q:'IBMHIEN!RES I $P(^IBMH(351.83,IBMHIEN,0),U,4)=2 S RES=1
  1. Q RES