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

IBCEMSRI.m

Go to the documentation of this file.
  1. IBCEMSRI ;EDE/JWS - RPC FOR IENS LIST AND CLAIM DATA FOR TAS PRINTED CLAIMS REPORT ;
  1. ;;2.0;INTEGRATED BILLING;**727,759**;21-MAR-94;Build 24
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. Q
  1. ;
  1. GET(RESULT,ARG) ;RPC ; PCR - get list of claim iens to extract
  1. ;
  1. N IBSAVE,IBY,IBDT,VARRAY,IBDT,IBIEN,IBDATA,IBRTN,IBDV,IBINS,IBTOP,IBRCX,IBRVCDS
  1. N IBRTDS,IBPTYP,INSCO,IBFTYP,IBTYPE,IBBLLR,CT,X,STOPCT,IBSTT
  1. D DTNOLF^DICRW
  1. S IBY=$E(DT,1,3)-$S(+$E(DT,4,5)<10:2,1:1),IBDT=IBY_1000 ; set
  1. ; Use the existing AP x-ref to narrow down the list of claims by date,
  1. ; then perform the same filtering as the VistA Printed Claims Report to determine if claim should be included in PCR report data
  1. ;
  1. D INIT
  1. S IBSAVE("site")=$P($$SITE^VASITE(),"^",3)
  1. ;JWS;EBILL-3063;11/17/22;issue with speed, added STOPCT and last date successfully run
  1. S X=$P($G(^IBE(350.9,1,8)),"^",22) I +X>IBDT S IBDT=X-1
  1. ;JWS;5/1/23;IB*2.0*759v2;EBILL-3377;set IBSTT = time stamp to check, needs to complete in < 30 seconds due to TAS-API express timeout
  1. S IBSTT=$P($H,",",2)
  1. ; Identify those claims within the selected date range
  1. F S IBDT=$O(^DGCR(399,"AP",IBDT)) Q:'IBDT S STOPCT=$G(STOPCT)+1 D I STOPCT>99 Q
  1. . ;5/2/23;EBILL-3377;IB*2.0*759v2;added Q:STOPCT>99;if processing is >25 seconds, setting STOPCT=100
  1. . S IBIEN=0 F S IBIEN=$O(^DGCR(399,"AP",IBDT,IBIEN)) Q:'IBIEN D Q:STOPCT>99
  1. .. ;5/2/23;IB*2.0*759v2;EBILL-3377;move check for already on PCR report up, in an attempt to make faster
  1. .. I $P($G(^DGCR(399,IBIEN,"S1")),"^",10)=1 Q ; claim is already on the report
  1. .. S IBDATA=$G(^DGCR(399,IBIEN,0))
  1. .. I $P(IBDATA,"^",13)'=4 Q ; don't include canceled claims
  1. .. I $P($G(^DGCR(399,IBIEN,"TX")),"^",8)'=1 Q ; Is the Bill "FORCE LOCAL PRINT"?
  1. .. ;;testing. W !,"IEN: ",IBIEN,?15,$P(^DGCR(399,IBIEN,0),"^") R !,"Change? ",x i x=1 S $P(^DGCR(399,IBIEN,"TX"),"^",8)=1
  1. .. ; don't include US Labor Dept claims
  1. .. ;;S IBINS=$$CURR^IBCEF2(IBIEN) Q:$D(VARRAY("IBULD",IBINS))
  1. .. ;;JWS;5/1/23;IB*2.0*759v2;EBILL-3381;Patient responsible claims don't seem to have insurance; found at Cleveland site#541;added Q:IBINS=""
  1. .. S IBINS=$$FINDINS^IBCEF1(IBIEN) Q:IBINS="" I $D(VARRAY("IBULD",IBINS)) Q
  1. .. ; don't count claims where EDI is inactive (user has to print those)
  1. .. I $$INSOK^IBCEF4(IBINS)'=1 Q
  1. .. S IBRTN=$P(IBDATA,"^",7),IBDV=+$P(IBDATA,"^",22) ; Get Rate Type and division
  1. .. I '$D(VARRAY("RTYPES",IBRTN)) Q ;Is this one of the selected Rate Types?
  1. .. S IBTOP=+$P($G(^IBA(355.3,+$$POLICY^IBCEF(IBIEN,18),0)),"^",9) ; Get Plan Type
  1. .. I '$D(VARRAY("IBTOP",IBTOP)) Q ;Is this one of the selected Plan Types?
  1. .. S IBRCX=0
  1. .. S (IBRVCDS,X)="" F S X=$O(^DGCR(399,IBIEN,"RC","B",X)) Q:X="" D Q:IBRCX
  1. ... I $D(VARRAY("XRVCDS",X)) S IBRCX=1 Q ; Bill contains a Revenue Code Exclusion.
  1. ... S IBRVCDS=$S(IBRVCDS="":X,1:IBRVCDS_","_X) ; Get Revenue Codes.
  1. .. I IBRCX=1 Q ; bill contains at least one of the excluded revenue codes
  1. .. S CT=$G(CT)+1,IBSAVE("PCRiens",CT,"ien")=IBIEN
  1. .. ;JWS;5/2/23;IB*2.0*742v11;EBILL-3377;checking for processing time. everything needs completed in 30 sec due to TAS-API express timeout
  1. .. I ($P($H,",",2)-IBSTT)>25 S STOPCT=100
  1. .. Q
  1. . ;JWS;5/2/23;IB*2.0*759v2;EBILL-3377;if no claims were found for a given date, set the last search date for PCR report
  1. . I '$D(IBSAVE("PCRiens")),+$G(IBDT)>+$P(^IBE(350.9,1,8),"^",22) S $P(^(8),"^",22)=IBDT
  1. . Q
  1. D ENCODE^XLFJSON("IBSAVE","RESULT")
  1. D FINISH
  1. Q
  1. ;
  1. ;
  1. FINISH ; enclose message in '[ ]' when a Bundle
  1. N X
  1. I $G(RESULT(1))=""!($G(RESULT(1))="{}") S RESULT(1)="[{}]" Q
  1. S RESULT(1)="["_RESULT(1)
  1. S X=$O(RESULT("A"),-1)
  1. S RESULT(X)=RESULT(X)_"]"
  1. Q
  1. ;
  1. INIT ; come here to set up search criteria
  1. ; Get ien of US Labor Department payer (cover all possible name variations)
  1. N IBULD,IBRVCD,IBRTN,IBTOPN,IBTOPD,IBRTD
  1. S IBULD=$O(^DIC(36,"B","US LABOR DEPARTMENT","")) S:IBULD'="" VARRAY("IBULD",IBULD)=""
  1. S IBULD=$O(^DIC(36,"B","US DEPT OF LABOR","")) S:IBULD'="" VARRAY("IBULD",IBULD)=""
  1. S IBULD=$O(^DIC(36,"B","US DEPARTMENT OF LABOR","")) S:IBULD'="" VARRAY("IBULD",IBULD)=""
  1. ; handle claims that do not have a type of plan
  1. S VARRAY("IBTOP",0)="UNKNOWN"
  1. ; Claim does not contain excluded revenue codes from IB Site parameters
  1. S IBRVCD="" F S IBRVCD=$O(^IBE(350.9,1,15,"B",IBRVCD)) Q:'IBRVCD S VARRAY("XRVCDS",IBRVCD)=""
  1. ; select all Rate Types that INSURER is responsible, [.07] = "i"
  1. S IBRTN=0 F S IBRTN=$O(^DGCR(399.3,IBRTN)) Q:IBRTN'=+IBRTN S IBRTD=$G(^(IBRTN,0)) I $P(IBRTD,"^",7)="i" S VARRAY("RTYPES",IBRTN)=$P(IBRTD,"^")
  1. ; select only active plan types
  1. S IBTOPN=0 F S IBTOPN=$O(^IBE(355.1,IBTOPN)) Q:IBTOPN'=+IBTOPN S IBTOPD=$G(^(IBTOPN,0)) I '+$P(IBTOPD,"^",4) S VARRAY("IBTOP",IBTOPN)=$P(IBTOPD,"^")
  1. Q
  1. ;
  1. GET1(RESULT,ARG) ;get claim data for PCR Power BI report
  1. ;
  1. N IBSAVE,IBY,IBDT,VARRAY,IBDT,IBIEN,IBDATA,IBRTN,IBDV,IBINS,IBTOP,IBRCX,IBRVCDS
  1. N IBRTDS,IBPTYP,INSCO,IBFTYP,IBTYPE,IBBLLR,CT,I,X,IBDATE,IBDIVD,IBILLNO,IBSN
  1. ;;I $G(ARG("IEN399"))="" S ARG("IEN399")=2122602 ;;TESTING;4/8/22;JWS
  1. K RESULT
  1. D DTNOLF^DICRW
  1. ; Get IEN for Claim File 399
  1. S IBIEN=ARG("IEN399")
  1. I IBIEN="" D FINISH Q
  1. I '$D(^DGCR(399,IBIEN,0)) D FINISH Q
  1. ; Collect Information
  1. S IBDATA=$G(^DGCR(399,IBIEN,0)),IBRTN=$P(IBDATA,U,7),IBDV=+$P(IBDATA,U,22) I IBDV S IBDIVD=$P($G(^DG(40.8,IBDV,0)),"^") ; Get Rate Type and division
  1. S IBINS=$$CURR^IBCEF2(IBIEN)
  1. S IBTOP=+$P($G(^IBA(355.3,+$$POLICY^IBCEF(IBIEN,18),0)),U,9) ; Get Plan Type
  1. S IBRCX=0
  1. S (IBRVCDS,X)="" F S X=$O(^DGCR(399,IBIEN,"RC","B",X)) Q:X="" D
  1. . S IBRVCDS=$S(IBRVCDS="":X,1:IBRVCDS_","_X) ; Get Revenue Codes.
  1. S IBRTDS=$G(VARRAY("RTYPES",IBRTN)) ; Get the Rate Type Description
  1. S IBPTYP=$G(VARRAY("IBTOP",IBTOP)) ; Get Plan Type name
  1. S IBILLNO=$$BN1^PRCAFN(IBIEN) ; Get external CLAIM # DBIA #380
  1. S INSCO=$P($G(^DIC(36,IBINS,0)),U) ; Get Insurance Company Name
  1. S IBFTYP=$P($G(^IBE(353,+$P(IBDATA,U,19),0)),U) I IBFTYP="" S IBFTYP="UNKNOWN" ; Get the Bill's Form Type.
  1. S IBTYPE=$S($P(IBDATA,U,5)>2:"O",1:"I")_"-"_$S($P(IBDATA,U,27)=1:"I",$P(IBDATA,U,27)=2:"P",1:"") ; Patient Status / Bill Charge Type
  1. S IBBLLR=$P($$BILLER^IBCIUT5(IBIEN),U,2) ; Get Biller
  1. S IBSN=$O(^DIC(4,"D",$P(IBILLNO,"-"),0)) I IBSN S IBSN=$$GET1^DIQ(4,IBSN_",",.01,"E")
  1. S IBSAVE("ien")=IBIEN
  1. S IBSAVE("site")=$P(IBILLNO,"-")
  1. S IBSAVE("claim")=$P(IBILLNO,"-",2)
  1. S IBSAVE("type")=IBTYPE
  1. S IBSAVE("authorizerLastName")=$S($F(IBBLLR,","):$P(IBBLLR,","),1:IBBLLR)
  1. S IBSAVE("authorizerFirstName")=$S($F(IBBLLR,","):$P(IBBLLR,",",2),1:"")
  1. S IBSAVE("rateType")=$$GET1^DIQ(399.3,IBRTN_",",.01)
  1. S IBSAVE("planType")=$$GET1^DIQ(355.1,IBTOP_",",.01)
  1. S IBSAVE("division")=$G(IBDIVD)
  1. F I=1:1 Q:$P(IBRVCDS,",",I)="" S IBSAVE("revenueCodes",I,":")="{""revenueCode"":"_$P(IBRVCDS,",",I)_"}"
  1. S IBSAVE("insuranceCompany")=INSCO
  1. ;JWS;12/5/2022;IB*2.0*727v16;should be field 14 Last Printed date, not field .14 Status Date
  1. S X=$$GET1^DIQ(399,IBIEN_",",14,"I") I X'="" S IBDATE=$S($E(X)=3:20,1:19)_$E(X,2,3)_"-"_$E(X,4,5)_"-"_$E(X,6,7)
  1. S IBSAVE("datePrinted")=IBDATE
  1. S IBSAVE("siteName")=IBSN
  1. S IBSAVE("formType")=IBFTYP
  1. S IBSAVE("mccf")=$S($D(^IBE(350.9,1,28,"B",IBRTN)):0,1:1)
  1. D ENCODE^XLFJSON("IBSAVE","RESULT")
  1. D FINISH
  1. Q
  1. ;
  1. PUT(RESULT,ARG) ; successful posting of claim data to Sql database for PowerBI PCR report
  1. ;; update data field in file 399
  1. N IBIEN,RES,IBFPDT
  1. K RESULT
  1. D DTNOLF^DICRW
  1. ; Get IEN for Claim File 399
  1. S IBIEN=$G(ARG("IEN399")) ;$G not necessary for VistaLink provides the parameters defined
  1. ; execute code to set claim status as received at FSC
  1. S RES=1
  1. I IBIEN="" S RES=0
  1. I '$D(^DGCR(399,IBIEN,0)) S RES=0
  1. I RES=1 D
  1. . N DA,D0,DR,DIE,DIC
  1. . S DA=IBIEN
  1. . S DR="37.1////1"
  1. . S DIE="^DGCR(399,"
  1. . D ^DIE
  1. . Q
  1. ;JWS;EBILL-3063;11/17/22;issue with speed;added last date searched
  1. ;JWS;5/2/23;IB*2.0*759v2;EBILL-3377;commented out the setting of last completed date for PCR until there no claims left for a given date
  1. ; this data will now be set in GET^IBCEMSRI when there are no claims left to process.
  1. ;;I +IBIEN D
  1. ;;. S IBFPDT=$P($G(^DGCR(399,IBIEN,"S")),"^",12)
  1. ;;. I +IBFPDT>+$P(^IBE(350.9,1,8),"^",22) S $P(^(8),"^",22)=IBFPDT
  1. S RES("ien")=IBIEN
  1. S RES("status")=RES ;result of update
  1. D ENCODE^XLFJSONE("RES","RESULT")
  1. D FINISH
  1. Q
  1. ;
  1. CL ;reset [10] of file 399 at ^DGCR(399,#,"S1")
  1. N A,B
  1. S A="" F S A=$O(^DGCR(399,"AP",A)) Q:'A D
  1. . S B=0 F S B=$O(^DGCR(399,"AP",A,B)) Q:'B D
  1. .. I $P($G(^DGCR(399,B,"S1")),"^",10) S $P(^("S1"),"^",10)=0 W !,B,?10,$P(^DGCR(399,B,0),"^")
  1. .. Q
  1. . Q
  1. Q
  1. ;