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

IBCEF80.m

Go to the documentation of this file.
IBCEF80 ;ALB/TAZ - Provider ID functions ;13 Feb 2006
 ;;2.0;INTEGRATED BILLING;**432,592**;21-MAR-94;Build 58
 ;;Per VA Directive 6402, this routine should not be modified.
 ;
 G AWAY
AWAY Q
 ;
LPRV(IBIFN,IBXSAVE,IBSTRIP,SEG) ; Return array of Line Providers
 N IBCARE,IBCURR,IBFRMTYP,IBINSCO,IBLIMIT,IBPRTYP,IBXIEN,IBXDATA,IBZ,Z,SLC,CPLNK
 ;
 I '$D(IBSTRIP) S IBSTRIP=0
 I '$D(SEG) S SEG=""
 S IBXIEN=IBIFN
 ;JWS;IB*2.0*592;add J430D form #7
 S IBFRMTYP=$$FT^IBCEF(IBXIEN),IBFRMTYP=$S(IBFRMTYP=2:2,IBFRMTYP=7:7,IBFRMTYP=3:1,1:0)
 I 'IBFRMTYP G LPRVX
 I IBFRMTYP=2 D OUTPT^IBCEF11(IBXIEN,0)
 I IBFRMTYP=1 D HOS^IBCEF22(IBXIEN)
 S IBCURR=$$COB^IBCEF(IBXIEN) ;current bill payer sequence
 S SLC=0
 F  S SLC=$O(IBXDATA(SLC)) Q:'SLC   S IBXSAVE("SLC")=+SLC D
 . S CPLNK=$G(IBXDATA(SLC,"CPLNK")) I 'CPLNK Q
 . K IBZ
 . D PROVIDER(IBXIEN,CPLNK,"C",.IBZ,IBCURR),PROVIDER(IBXIEN,CPLNK,"O",.IBZ,IBCURR)
 . M IBXSAVE("L-PROV",IBXIEN,SLC)=IBZ
 D EN^IBCEF81(.IBXSAVE)
 S SLC=0 F  S SLC=$O(IBXSAVE("L-PROV",IBXIEN,SLC)) Q:'SLC  D
 . F Z="C","O" I '$O(IBXSAVE("L-PROV",IBXIEN,SLC,Z,"")) K IBXSAVE("L-PROV",IBXIEN,SLC,Z)
 ;
LPRVX ;Exit Line Provider Setup
 Q
 ;
PROVIDER(IB399,IBCPIEN,IBPROV,IBRES,IBCURR) ;
 N IBZ,IBRESARR
 S IBRESARR=""
 Q:IBPROV="A"  ;PATIENT's bill
 I IBPROV="C" D
 . D:$$ISINSUR^IBCEF71(IBCURR,IB399) PROVINF(IB399,$S(IBCURR="T":3,IBCURR="S":2,IBCURR="P":1,1:1),.IBRESARR,1,IBPROV,IBCPIEN)
 I IBPROV="O" D
 . I IBCURR="P" D:$$ISINSUR^IBCEF71("S",IB399) PROVINF(IB399,2,.IBRESARR,1,IBPROV,IBCPIEN) D:$$ISINSUR^IBCEF71("T",IB399) PROVINF(IB399,3,.IBRESARR,2,IBPROV,IBCPIEN)
 . I IBCURR="S" D:$$ISINSUR^IBCEF71("P",IB399) PROVINF(IB399,1,.IBRESARR,1,IBPROV,IBCPIEN) D:$$ISINSUR^IBCEF71("T",IB399) PROVINF(IB399,3,.IBRESARR,2,IBPROV,IBCPIEN)
 . I IBCURR="T" D:$$ISINSUR^IBCEF71("P",IB399) PROVINF(IB399,1,.IBRESARR,1,IBPROV,IBCPIEN) D:$$ISINSUR^IBCEF71("S",IB399) PROVINF(IB399,2,.IBRESARR,2,IBPROV,IBCPIEN)
 M IBRES(IBPROV)=IBRESARR
 Q
 ;
  ;-- PROVINF --
 ;Create array with prov info
 ;Input:
 ; IB399 - ien #399
 ; IBPRNUM - 1=prim ins, 2= sec, 3 -tert
 ; IBRES - for results (IBRESARR passed by reference)
 ; IBSORT - to sort OTHER INSURANCE data 
 ;  if PROVINF is called for "C" mode of PROVIDER subroutine then 
 ;    IBSORT can be any (say 1)
 ;  if PROVINF is called for "O" mode then can be more than set of data
 ;    - need to sort array to use it (like IBXDATA(1) and IBXDATA(2))
 ;    for mode "O" it should be 1 or 2 (see PROVIDER section)
 ;IBINSTP -  "C" -current ins, "O"-other
 ;IBCPPTR - Pointer to the Procedure Global
 ;Output:
 ; IBRES(PRNUM,PRTYPE,SEQ#)=PROV^INSUR^IDTYPE^ID^FORMTYP^CARETYP
 ; where:(see PROVIDER)
PROVINF(IB399,IBPRNUM,IBRES,IBSORT,IBINSTP,IBCPPTR) ;
 I $G(IB399)="" Q
 I +$G(IBSORT)=0 S IBSORT=$G(IBPRNUM)
 N IBPRTYP,IBINSCO,IBPRVPTR,IBCARE,IB35591,IBN,IBCURR,IBEXC,IBALLSSN,IBSSNIEN,IBLIMIT,IBSSN,I
 S IBN=0
 S IBINSCO=+$P($G(^DGCR(399,IB399,"M")),"^",IBPRNUM) ;Current insurance company ien
 S IBCARE=$S($$ISRX^IBCEF1(IB399):3,1:0) ;if an Rx refill bill
 S:IBCARE=0 IBCARE=$$INPAT^IBCEF(IB399,1) S:'IBCARE IBCARE=2 ;1-inp,2-out
 S IBLIMIT=$S($G(IBINSTP)="C":5,1:3)  ; Limits on secondary IDs
 S IBCURR=$$COB^IBCEF(IB399) ; current insurance company position (P,S,T)
 F IBPRTYP=1:1:9 D
 . N Z,IB355OV,IBNPI,IBSSN,IBTAXID
 . S IBPRVPTR=$$PROVPTR(IB399,IBPRTYP,IBCPPTR) Q:'+IBPRVPTR
 . S $P(IBSSN,U,IBPRTYP)=$$GETSSN^IBCEF72(IBPRVPTR) I '$P(IBSSN,U,IBPRTYP)="" S $P(IBSSN,U,IBPRTYP)=$$TAX3559^IBCEF73(IBPRVPTR)
 . N IBRETARR S IBRETARR=0
 . ;params: ins co ien, form type, inpt/outpt/rx, prov ptr, return array, provider type, Current/Other
 . D PRACT^IBCEF71(IBINSCO,IBFRMTYP,IBCARE,IBPRVPTR,.IBRETARR,IBPRTYP,$G(IBINSTP))
 . S IB355OV="",IBEXC=""
 . S Z=$O(^DGCR(399,IB399,"CP",IBCPPTR,"LNPRV","B",IBPRTYP,0))
 . I Z S Z=$G(^DGCR(399,IB399,"CP",IBCPPTR,"LNPRV",Z,0)) D
 .. I $P(Z,U,IBPRNUM+4)'="",$P(Z,U,IBPRNUM+11)'="" S IB355OV=$P(Z,U,IBPRNUM+4)_U_$P(Z,U,IBPRNUM+11)
 . S IBN=0,IB35591=$$CH35591^IBCEF72(IBINSCO,IBFRMTYP,IBCARE)
 . I $G(IBINSTP)="C",$G(IBPRNUM)=1,"34"[$G(IBPRTYP),"P"[$G(IBCURR),$G(IBFRMTYP)=2,$$MCRONBIL^IBEFUNC(IB399) S IB355OV=$$MCR24K^IBCEU3(IB399)_"^12"
 . I $G(IBINSTP)="O","34"[$G(IBPRTYP),"ST"[$G(IBCURR),$G(IBFRMTYP)=2,$$MCRONBIL^IBEFUNC(IB399) S IB355OV=$$MCR24K^IBCEU3(IB399)_"^12" ;Calculate MEDICARE (WNR) specific provider qualifier and ID for CMS-1500 secondary claims
 . I $P(IB355OV,U,2) D
 .. ;params: form type, provider type, current/other
 .. I $$CHCKSEC^IBCEF73(IBFRMTYP,IBPRTYP,$G(IBINSTP),$P($G(^IBE(355.97,+$P(IB355OV,U,2),0)),U,3)) D
 ... S IBEXC=$P(IB355OV,U,2),IBN=IBN+1,IBRES(IBSORT,IBPRTYP,IBN)="OVERRIDE^"_IBINSCO_U_$P($G(^IBE(355.97,+IBEXC,0)),U,3)_U_$P(IB355OV,U)_"^^^^^"_+IBEXC
 . I IB35591'="",IBEXC'=$P(IB35591,U,3) S:$$CHCKSEC^IBCEF73(IBFRMTYP,IBPRTYP,$G(IBINSTP),$P(IB35591,"^")) IBN=IBN+1,IBRES(IBSORT,IBPRTYP,IBN)="DEFAULT^"_IBINSCO_"^"_IB35591_"^^",$P(IBRES(IBSORT,IBPRTYP,IBN),U,9)=$P(IB35591,U,3)
 . D SORT(IBSORT,IBPRTYP,IB399,.IBRETARR,.IBRES,IBN,IBEXC,IBPRNUM,IBLIMIT,IBSSN,IBCPPTR)
 . S IBRES(IBSORT,IBPRTYP)=IBPRVPTR
 . S IBNPI=$$GETNPI^IBCEF73A(IBPRVPTR)
 . S IBRES(IBSORT,IBPRTYP,0)="PRIMARY"_U_U_$$STRIP^IBCEF76($S(IBNPI]"":"XX",1:"")_U_IBNPI,1,U,IBSTRIP)
 . F I=1:1 Q:'$D(IBRES(IBSORT,IBPRTYP,I))  D
 .. S $P(IBRES(IBSORT,IBPRTYP,I),U,3,4)=$$STRIP^IBCEF76($P(IBRES(IBSORT,IBPRTYP,I),U,3,4),1,U,IBSTRIP)
 I $O(IBRES(IBSORT,"")) S IBRES(IBSORT)=$S(IBPRNUM=3:"T",IBPRNUM=2:"S",1:"P")
 Q
 ;
PROVPTR(IBIEN399,IBFUNC,IBCP) ;
 N IBN
 S IBN=$O(^DGCR(399,IBIEN399,"CP",IBCP,"LNPRV","B",IBFUNC,0))
 I +IBN=0 Q 0
 Q $P($G(^DGCR(399,IBIEN399,"CP",IBCP,"LNPRV",+IBN,0)),U,2)
 ;
 ;SORT
 ; Input
 ;  IBPRNUM - 1 or 2
 ;  IBPRTYP - Provide Type
 ;  IB399   - IEN of Bill/Claim file
 ;  IBSRC   - Source Array - IBRETARR passed by reference
 ;  IBDST   - Destination Array - IBRES passed by reference
 ;  IBN     - 
 ;  IBEXC   - Override the ID
 ;  IBSEQ   - 
 ;  IBLIMIT - Limits on secondary ID's
 ;  IBZ     - String containing SSN/EIN for the line providers
 ;  IBCPPTR - Pointer to the Procedure Global
SORT(IBPRNUM,IBPRTYP,IB399,IBSRC,IBDST,IBN,IBEXC,IBSEQ,IBLIMIT,IBZ,IBCPPTR) ;
 N IBXIEN,IBXDATA,IBNET,IBTRI,IB1,IB2,IBID,Z,IBZ1,IBSVP
 S (IB1,IB2,IBZ1,IBTRI)=""
 ;IBZ1=All policy types on Bill
 S IBZ1=$$ALLPTYP^IBCEF3(IB399)
 F Z=1:1:3 S $P(IBZ1,U,Z)=$S($P(IBZ1,U,Z)="CH":1,1:"") S:$P(IBZ1,U,Z) IBTRI=1
 S IBNET=$$NETID^IBCEP() ; netwrk id type
 I $G(IBN) D
 . S Z=0 F  S Z=$O(IBDST(IBPRNUM,IBPRTYP,Z)) Q:'Z  S IBID(+$P(IBDST(IBPRNUM,IBPRTYP,Z),U,9))=""
 F  S IB1=$O(IBSRC(IB1)) Q:IB1=""  D  Q:IBN=IBLIMIT
 . N OK,IBSTLIC
 . S IBSTLIC=""
 . F  S IB2=$O(IBSRC(IB1,IB2)) Q:IB2=""  D  Q:IBN=IBLIMIT
 . . S IBSVP=$P(IBSRC(IB1,IB2),U)
 . . ; If ID overridden, output no others of this type
 . . I $G(IBEXC),$P($G(IBSRC(IB1,IB2)),U,9)=IBEXC Q
 . . ; Ck state of care/lic match if st lic#
 . . I $P($G(IBSRC(IB1,IB2)),U,3)="0B" S OK=1 D  Q:'OK
 . . . I +$$CAREST^IBCEP2A(IB399)'=$P(IBSRC(IB1,IB2),U,7) S IBSTLIC=1 Q
 . . . I $G(IBSTLIC(0))'="" S OK=0 Q
 . . . S IBSTLIC(0)=$G(IBSRC(IB1,IB2)),OK=0
 . . ; Exclude SSN from sec ids unless required
 . . I $P($G(IBSRC(IB1,IB2)),U,3)="SY" Q
 . . ; Only 1 of each prov id type
 . . Q:$D(IBID(+$P($G(IBSRC(IB1,IB2)),U,9)))
 . . S IBN=IBN+1,IBID(+$P($G(IBSRC(IB1,IB2)),U,9))=""
 . . S IBDST(IBPRNUM,IBPRTYP,IBN)=$G(IBSRC(IB1,IB2))
 . I IBN'=IBLIMIT,'$G(IBSTLIC),$G(IBSTLIC(0))'="" S IBN=IBN+1,IBDST(IBPRNUM,IBPRTYP,IBN)=IBSTLIC(0)
 I $$FT^IBCEF(IB399)=2,$G(IBID(IBNET))="",IBTRI,$P(IBZ1,U,IBSEQ) D    ; WCJ 02/13/2006
 . Q:$P(IBZ,U,IBPRTYP)=""
 . ; here, no network id & TRICARE ins co.
 . N Z
 . S Z=+$O(^DGCR(399,IB399,"CP",IBCPPTR,"LNPRV","B",IBPRTYP,0)),Z=$P($G(^DGCR(399,IB399,"CP",IBCPPTR,"LNPRV",Z,0)),U,2)
 . S IBN=IBN+1,IBDST(IBPRNUM,IBPRTYP,IBN)=Z_U_+$$POLICY^IBCEF(IB399,1,IBSEQ)_U_$P($G(^IBE(355.97,IBNET,0)),U,3)_U_$P(IBZ,U,IBPRTYP)_U_"0^0^^^"_IBNET
 Q