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