RCDMCR6B ;ALB/YG - 50-100 Percent SC Exempt Charge Reconciliation Report - Input/output; Apr 9, 2019@21:06
;;4.5;Accounts Receivable;**347**;Mar 20, 1995;Build 47
;;Per VA Directive 6402, this routine should not be modified.
;
; See RCDMCR6A for detailed description
;
COLLECT(STOPIT,ARTYPE) ; Get the report data
;Input
; STOPIT - Passed Variable to determine if process is to be terminated
; ARTYPE - AR Type 1:Active;2:Open;3:Suspended;4:Collected/Closed;5:On-Hold;6:Write Off;7:All
;Output
; STOPIT - Passed Variable set to 1 if process is to be terminated
; ^TMP($J,"RCDMCR6") with report data and summary data
;N RCDFN,DEBTOR,ARIEN,IBIEN,CTR,EOCOK,IBCNT,EOCDT,DFN,DMCELIG,EFFDT,NAME,SSN
;N STATUS,OPTDT,DISCHDT,RXDT,OPTDT,RXDT,CHGAMT,OCC,BILLNO,RXNUM,RXNAM,DSTATUS,IBDATA
;Get Rated Disability Data within passed RD change time frame
;*** call API to get all RD change data for given date period
N ZR,DEBTPT,WZH,DEBTCNT,DEBTOR,RCDFN,DFN,DMCELIG,ELIG,EXEMPTDT,SZH,VAERR,VADM,ARIEN,CTR
N BILLNO,IBDATA,IBCNT,IBIEN,NAME,SSN,OUT,STATUS
S DEBTPT=0,WZH=$H*86400+$P($H,",",2)+60,SZH=WZH W !
F DEBTCNT=0:1 S DEBTPT=$O(^RCD(340,"B",DEBTPT)) Q:DEBTPT="" I DEBTPT[";DPT(" D
. ;Get AR Debtor info from file 340
. S DEBTOR=0,RCDFN=$P(DEBTPT,";")
. F S DEBTOR=$O(^RCD(340,"B",DEBTPT,DEBTOR)) Q:DEBTOR'>0 D Q:$G(STOPIT)>0
. . S DFN=RCDFN
. . S DMCELIG=$$DMCELIG^RCDMCUT1(RCDFN)
. . Q:'DMCELIG
. . S ELIG=$S($P(DMCELIG,U,2)'="":"SC"_$P(DMCELIG,U,2),$P(DMCELIG,U,3)'="":"Pension",$P(DMCELIG,U,4)'="":"A&A",$P(DMCELIG,U,5)'="":"HouseBnd",1:"")
. . ; business decision for now is to only show SC%. A&A, Pension and HB are off the report.
. . Q:ELIG'?1"SC".E
. . ; business decision is to change from .3012 (SC AWARD DATE) to .3014 (EFF. DATE COMBINED SC% EVAL.)
. . S EXEMPTDT=$$GET1^DIQ(2,DFN_",",.3014,"I")
. . I DFN'>0 D KVAR^VADPT Q
. . D DEM^VADPT
. . I $G(VAERR)>0 D KVAR^VADPT Q
. . S NAME=$G(VADM(1))
. . I NAME']"" D KVAR^VADPT Q
. . S SSN=$P(VADM(2),U,1)
. . D KVAR^VADPT
. . ;I EXEMPTDT="" S ^TMP($J,"RCDMCR6","DETAIL",NAME,SSN," ",1)=U_U_U_"NODATE" Q
. . ;Get AR Bill Data that is within the last BEGDT time period
. . ;for Bill's with a current status of ACTIVE, OPEN, SUSPENDED, WRITE-OFF, COLLECTED/CLOSED, CANCELLATION or IB Status of ON-HOLD
. . K ^TMP($J,"RCDMCR6","ARIB")
. . I $H*86400+$P($H,",",2)>WZH S WZH=$H*86400+$P($H,",",2)+30,$X=0 W *13,$FN(DEBTCNT*100/$P(^RCD(340,0),U,4),",",2),"% done in ",WZH-SZH," seconds"
. . S ARIEN=0
. . I ARTYPE'=5 F S ARIEN=$O(^PRCA(430,"C",DEBTOR,ARIEN)) Q:ARIEN'>0 D Q:$G(STOPIT)>0
. . . S CTR=$G(CTR)+1 ;Counter
. . . I CTR#500=0 S STOPIT=$$STOPIT^RCDMCUT2() Q:STOPIT
. . . ; only look at 1st party bills - TBD
. . . I '$$FIRSTPAR^RCDMCUT1(ARIEN) Q
. . . ;IEN is from calling routine (for file 430)
. . . ;Bill Number
. . . S BILLNO=$$GET1^DIQ(430,ARIEN_",",.01)
. . . I BILLNO']"" Q
. . . S STATUS=$$GET1^DIQ(430,ARIEN_",",8,"E")
. . . I ARTYPE=1,STATUS'="ACTIVE" Q
. . . I ARTYPE=2,STATUS'="OPEN" Q
. . . I ARTYPE=3,STATUS'="SUSPENDED" Q
. . . I ARTYPE=4,STATUS'="COLLECTED/CLOSED" Q
. . . I ARTYPE=6,STATUS'="WRITE-OFF" Q
. . . I ARTYPE=7,"^ACTIVE^OPEN^SUSPENDED^WRITE-OFF^COLLECTED/CLOSED^CANCELLATION^"'[(U_STATUS_U) Q
. . . K IBDATA S IBDATA=0
. . . S IBIEN=""
. . . F S IBIEN=$O(^IB("ABIL",BILLNO,IBIEN)) Q:'IBIEN S OUT=$$GETIB^RCDMCR4B(IBIEN,0) I OUT,$P(OUT,U,5)'=10 S IBDATA=IBDATA+1,IBDATA(IBDATA)=OUT
. . . I 'IBDATA Q
. . . M ^TMP($J,"RCDMCR6","ARIB",BILLNO,"IBDATA")=IBDATA
. . . S ^TMP($J,"RCDMCR6","ARIB",BILLNO,"STATUS")=STATUS
. . S IBIEN=""
. . I ARTYPE=5!(ARTYPE=7) F S IBIEN=$O(^IB("AH",RCDFN,IBIEN)) Q:IBIEN="" D Q:$G(STOPIT)>0
. . . K IBDATA S IBDATA=0
. . . S CTR=$G(CTR)+1 ;Counter
. . . I CTR#500=0 S STOPIT=$$STOPIT^RCDMCUT2() Q:STOPIT
. . . S BILLNO="/"_IBIEN
. . . S OUT=$$GETIB^RCDMCR4B(IBIEN,1) Q:'OUT
. . . S IBDATA=1,IBDATA(1)=OUT
. . . M ^TMP($J,"RCDMCR6","ARIB",BILLNO,"IBDATA")=IBDATA
. . . S ^TMP($J,"RCDMCR6","ARIB",BILLNO,"STATUS")="ON HOLD"
. . S BILLNO=""
. . F S BILLNO=$O(^TMP($J,"RCDMCR6","ARIB",BILLNO)) Q:BILLNO="" D
. . . K IBDATA M IBDATA=^TMP($J,"RCDMCR6","ARIB",BILLNO,"IBDATA")
. . . S STATUS=^TMP($J,"RCDMCR6","ARIB",BILLNO,"STATUS")
. . . F IBCNT=1:1:IBDATA D
. . . . N OPTDT,DISCHDT,SERVDT,RXDT,RXNUM,RXNAM,DSTATUS,EOCDT
. . . . ;IBDATA - Array of 1 ^ Outpatient Date ^ Discharge Date ^ RX/Refill Date ^ IB Status ^ RX NUM ^ RX Name ^ CHGAMT
. . . . S OPTDT=$P(IBDATA(IBCNT),U,2)
. . . . S DISCHDT=$P(IBDATA(IBCNT),U,3)
. . . . S SERVDT=$S(OPTDT>DISCHDT:OPTDT,DISCHDT>OPTDT:DISCHDT,1:"")
. . . . S RXDT=$P(IBDATA(IBCNT),U,4)
. . . . ;S IBSTATUS=$P(IBDATA(IBCNT),U,5)
. . . . S RXNUM=$P(IBDATA(IBCNT),U,6)
. . . . S RXNAM=$P(IBDATA(IBCNT),U,7)
. . . . S DSTATUS=STATUS
. . . . ; Get EOC date and verify that it is later than Patient Effective Date
. . . . S EOCDT=""
. . . . I OPTDT>EOCDT S EOCDT=OPTDT
. . . . I DISCHDT>EOCDT S EOCDT=DISCHDT
. . . . I RXDT>EOCDT S EOCDT=RXDT
. . . . I EXEMPTDT="" S ^TMP($J,"RCDMCR6","DETAIL",NAME,SSN," ",1)=U_U_ELIG_U_"NODATE" Q
. . . . I EOCDT'>EXEMPTDT Q
. . . . S DSTATUS=$S(DSTATUS="CANCELLATION":"ARCXLD",DSTATUS="COLLECTED/CLOSED":"C/C",1:DSTATUS)
. . . . S ^TMP($J,"RCDMCR6","DETAIL",NAME,SSN,BILLNO,IBCNT)=SERVDT_U_RXDT_U_ELIG_U_EXEMPTDT_U_RXNUM_U_RXNAM_U_DSTATUS
K ^TMP($J,"RCDMCR6","ARIB")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRCDMCR6B 5465 printed Dec 13, 2024@01:43:39 Page 2
RCDMCR6B ;ALB/YG - 50-100 Percent SC Exempt Charge Reconciliation Report - Input/output; Apr 9, 2019@21:06
+1 ;;4.5;Accounts Receivable;**347**;Mar 20, 1995;Build 47
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ; See RCDMCR6A for detailed description
+5 ;
COLLECT(STOPIT,ARTYPE) ; Get the report data
+1 ;Input
+2 ; STOPIT - Passed Variable to determine if process is to be terminated
+3 ; ARTYPE - AR Type 1:Active;2:Open;3:Suspended;4:Collected/Closed;5:On-Hold;6:Write Off;7:All
+4 ;Output
+5 ; STOPIT - Passed Variable set to 1 if process is to be terminated
+6 ; ^TMP($J,"RCDMCR6") with report data and summary data
+7 ;N RCDFN,DEBTOR,ARIEN,IBIEN,CTR,EOCOK,IBCNT,EOCDT,DFN,DMCELIG,EFFDT,NAME,SSN
+8 ;N STATUS,OPTDT,DISCHDT,RXDT,OPTDT,RXDT,CHGAMT,OCC,BILLNO,RXNUM,RXNAM,DSTATUS,IBDATA
+9 ;Get Rated Disability Data within passed RD change time frame
+10 ;*** call API to get all RD change data for given date period
+11 NEW ZR,DEBTPT,WZH,DEBTCNT,DEBTOR,RCDFN,DFN,DMCELIG,ELIG,EXEMPTDT,SZH,VAERR,VADM,ARIEN,CTR
+12 NEW BILLNO,IBDATA,IBCNT,IBIEN,NAME,SSN,OUT,STATUS
+13 SET DEBTPT=0
SET WZH=$HOROLOG*86400+$PIECE($HOROLOG,",",2)+60
SET SZH=WZH
WRITE !
+14 FOR DEBTCNT=0:1
SET DEBTPT=$ORDER(^RCD(340,"B",DEBTPT))
if DEBTPT=""
QUIT
IF DEBTPT[";DPT("
Begin DoDot:1
+15 ;Get AR Debtor info from file 340
+16 SET DEBTOR=0
SET RCDFN=$PIECE(DEBTPT,";")
+17 FOR
SET DEBTOR=$ORDER(^RCD(340,"B",DEBTPT,DEBTOR))
if DEBTOR'>0
QUIT
Begin DoDot:2
+18 SET DFN=RCDFN
+19 SET DMCELIG=$$DMCELIG^RCDMCUT1(RCDFN)
+20 if 'DMCELIG
QUIT
+21 SET ELIG=$SELECT($PIECE(DMCELIG,U,2)'="":"SC"_$PIECE(DMCELIG,U,2),$PIECE(DMCELIG,U,3)'="":"Pension",$PIECE(DMCELIG,U,4)'="":"A&A",$PIECE(DMCELIG,U,5)'="":"HouseBnd",1:"")
+22 ; business decision for now is to only show SC%. A&A, Pension and HB are off the report.
+23 if ELIG'?1"SC".E
QUIT
+24 ; business decision is to change from .3012 (SC AWARD DATE) to .3014 (EFF. DATE COMBINED SC% EVAL.)
+25 SET EXEMPTDT=$$GET1^DIQ(2,DFN_",",.3014,"I")
+26 IF DFN'>0
DO KVAR^VADPT
QUIT
+27 DO DEM^VADPT
+28 IF $GET(VAERR)>0
DO KVAR^VADPT
QUIT
+29 SET NAME=$GET(VADM(1))
+30 IF NAME']""
DO KVAR^VADPT
QUIT
+31 SET SSN=$PIECE(VADM(2),U,1)
+32 DO KVAR^VADPT
+33 ;I EXEMPTDT="" S ^TMP($J,"RCDMCR6","DETAIL",NAME,SSN," ",1)=U_U_U_"NODATE" Q
+34 ;Get AR Bill Data that is within the last BEGDT time period
+35 ;for Bill's with a current status of ACTIVE, OPEN, SUSPENDED, WRITE-OFF, COLLECTED/CLOSED, CANCELLATION or IB Status of ON-HOLD
+36 KILL ^TMP($JOB,"RCDMCR6","ARIB")
+37 IF $HOROLOG*86400+$PIECE($HOROLOG,",",2)>WZH
SET WZH=$HOROLOG*86400+$PIECE($HOROLOG,",",2)+30
SET $X=0
WRITE *13,$FNUMBER(DEBTCNT*100/$PIECE(^RCD(340,0),U,4),",",2),"% done in ",WZH-SZH," seconds"
+38 SET ARIEN=0
+39 IF ARTYPE'=5
FOR
SET ARIEN=$ORDER(^PRCA(430,"C",DEBTOR,ARIEN))
if ARIEN'>0
QUIT
Begin DoDot:3
+40 ;Counter
SET CTR=$GET(CTR)+1
+41 IF CTR#500=0
SET STOPIT=$$STOPIT^RCDMCUT2()
if STOPIT
QUIT
+42 ; only look at 1st party bills - TBD
+43 IF '$$FIRSTPAR^RCDMCUT1(ARIEN)
QUIT
+44 ;IEN is from calling routine (for file 430)
+45 ;Bill Number
+46 SET BILLNO=$$GET1^DIQ(430,ARIEN_",",.01)
+47 IF BILLNO']""
QUIT
+48 SET STATUS=$$GET1^DIQ(430,ARIEN_",",8,"E")
+49 IF ARTYPE=1
IF STATUS'="ACTIVE"
QUIT
+50 IF ARTYPE=2
IF STATUS'="OPEN"
QUIT
+51 IF ARTYPE=3
IF STATUS'="SUSPENDED"
QUIT
+52 IF ARTYPE=4
IF STATUS'="COLLECTED/CLOSED"
QUIT
+53 IF ARTYPE=6
IF STATUS'="WRITE-OFF"
QUIT
+54 IF ARTYPE=7
IF "^ACTIVE^OPEN^SUSPENDED^WRITE-OFF^COLLECTED/CLOSED^CANCELLATION^"'[(U_STATUS_U)
QUIT
+55 KILL IBDATA
SET IBDATA=0
+56 SET IBIEN=""
+57 FOR
SET IBIEN=$ORDER(^IB("ABIL",BILLNO,IBIEN))
if 'IBIEN
QUIT
SET OUT=$$GETIB^RCDMCR4B(IBIEN,0)
IF OUT
IF $PIECE(OUT,U,5)'=10
SET IBDATA=IBDATA+1
SET IBDATA(IBDATA)=OUT
+58 IF 'IBDATA
QUIT
+59 MERGE ^TMP($JOB,"RCDMCR6","ARIB",BILLNO,"IBDATA")=IBDATA
+60 SET ^TMP($JOB,"RCDMCR6","ARIB",BILLNO,"STATUS")=STATUS
End DoDot:3
if $GET(STOPIT)>0
QUIT
+61 SET IBIEN=""
+62 IF ARTYPE=5!(ARTYPE=7)
FOR
SET IBIEN=$ORDER(^IB("AH",RCDFN,IBIEN))
if IBIEN=""
QUIT
Begin DoDot:3
+63 KILL IBDATA
SET IBDATA=0
+64 ;Counter
SET CTR=$GET(CTR)+1
+65 IF CTR#500=0
SET STOPIT=$$STOPIT^RCDMCUT2()
if STOPIT
QUIT
+66 SET BILLNO="/"_IBIEN
+67 SET OUT=$$GETIB^RCDMCR4B(IBIEN,1)
if 'OUT
QUIT
+68 SET IBDATA=1
SET IBDATA(1)=OUT
+69 MERGE ^TMP($JOB,"RCDMCR6","ARIB",BILLNO,"IBDATA")=IBDATA
+70 SET ^TMP($JOB,"RCDMCR6","ARIB",BILLNO,"STATUS")="ON HOLD"
End DoDot:3
if $GET(STOPIT)>0
QUIT
+71 SET BILLNO=""
+72 FOR
SET BILLNO=$ORDER(^TMP($JOB,"RCDMCR6","ARIB",BILLNO))
if BILLNO=""
QUIT
Begin DoDot:3
+73 KILL IBDATA
MERGE IBDATA=^TMP($JOB,"RCDMCR6","ARIB",BILLNO,"IBDATA")
+74 SET STATUS=^TMP($JOB,"RCDMCR6","ARIB",BILLNO,"STATUS")
+75 FOR IBCNT=1:1:IBDATA
Begin DoDot:4
+76 NEW OPTDT,DISCHDT,SERVDT,RXDT,RXNUM,RXNAM,DSTATUS,EOCDT
+77 ;IBDATA - Array of 1 ^ Outpatient Date ^ Discharge Date ^ RX/Refill Date ^ IB Status ^ RX NUM ^ RX Name ^ CHGAMT
+78 SET OPTDT=$PIECE(IBDATA(IBCNT),U,2)
+79 SET DISCHDT=$PIECE(IBDATA(IBCNT),U,3)
+80 SET SERVDT=$SELECT(OPTDT>DISCHDT:OPTDT,DISCHDT>OPTDT:DISCHDT,1:"")
+81 SET RXDT=$PIECE(IBDATA(IBCNT),U,4)
+82 ;S IBSTATUS=$P(IBDATA(IBCNT),U,5)
+83 SET RXNUM=$PIECE(IBDATA(IBCNT),U,6)
+84 SET RXNAM=$PIECE(IBDATA(IBCNT),U,7)
+85 SET DSTATUS=STATUS
+86 ; Get EOC date and verify that it is later than Patient Effective Date
+87 SET EOCDT=""
+88 IF OPTDT>EOCDT
SET EOCDT=OPTDT
+89 IF DISCHDT>EOCDT
SET EOCDT=DISCHDT
+90 IF RXDT>EOCDT
SET EOCDT=RXDT
+91 IF EXEMPTDT=""
SET ^TMP($JOB,"RCDMCR6","DETAIL",NAME,SSN," ",1)=U_U_ELIG_U_"NODATE"
QUIT
+92 IF EOCDT'>EXEMPTDT
QUIT
+93 SET DSTATUS=$SELECT(DSTATUS="CANCELLATION":"ARCXLD",DSTATUS="COLLECTED/CLOSED":"C/C",1:DSTATUS)
+94 SET ^TMP($JOB,"RCDMCR6","DETAIL",NAME,SSN,BILLNO,IBCNT)=SERVDT_U_RXDT_U_ELIG_U_EXEMPTDT_U_RXNUM_U_RXNAM_U_DSTATUS
End DoDot:4
End DoDot:3
End DoDot:2
if $GET(STOPIT)>0
QUIT
End DoDot:1
+95 KILL ^TMP($JOB,"RCDMCR6","ARIB")
+96 QUIT