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

BARTRNS3.m

Go to the documentation of this file.
BARTRNS3 ; IHS/SD/SDR - Transaction Summary/Detail Report OVERFLOW CODE; 03/10/2009
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**28**;OCT 26, 2005;Build 92
 ;IHS/SD/POT - 1.8*28 - CR8397 HEAT155084 - OVERFLOW CODE OF BARTRNS2 NEW ROUTINE CLONED FROM BARTRNS1
 Q
TRANS ;EP Loop thru Trans File
 ; for checking Trans File data parms
 S BARTR(0)=$G(^BARTR(DUZ(2),BARTR,0))  ;A/R Trans 0 node
 S BARTR(1)=$G(^BARTR(DUZ(2),BARTR,1))  ;A/R Trans 1 node
 S BARTR("TTYP")=$P(BARTR(1),U)  ;Trans type
 S BARTR("ADJ CAT")=$P(BARTR(1),U,2)  ;Adj Cat
 S BARTR("ADJ TYPE")=$$GET1^DIQ(90052.02,$P(BARTR(1),U,3),.01)  ;Adj Type
 ;PKD 1.8*19 include ADJ TYPE IEN on rpt -> BARTR("ADJ TYPIEN")
 S BARTR("ADJ TYPIEN")=$P(BARTR(1),U,3)
 S:BARTR("ADJ CAT")="" BARTR("ADJ CAT")="NULL"
 ;1.8*19 Use space if ADJ TYP IEN is null to prevent subscript error
 ;S:(BARTR("ADJ TYPE")="") BARTR("ADJ TYPE")="NULL"
 I BARTR("ADJ TYPE")="" S BARTR("ADJ TYPE")="NULL",BARTR("ADJ TYPIEN")=" "
ADJTY I $D(BARY("ADJ TYP")) Q:'$D(BARY("ADJ TYP",BARTR("ADJ TYPIEN")))  ;PKD 1.8*20 Check for Inclusion ADJ TYPE
 S BARTR("DT")=$P(BARTR(0),U)  ;Trans date/time
 S BARTR("TAMT")=$$GET1^DIQ(90050.03,BARTR,3.5)
 S BARTR("INS")=$P(BAR(0),U,3)  ;A/R Acct
 I BARTR("INS")]"" D
 .S D0=BARTR("INS")
 .S BARTR("ITYP")=$$VALI^BARVPM(8)  ;Ins Type CODE
 I BARY("RTYP")=1 D SUMMARY
 I BARY("RTYP")=2 D DETAIL
 Q
SUMMARY ;left of the "=" - LOC^INS TYPE^INSURER
 ;right of the "=" - BILL COUNT^TOTAL BILL AMT^TOTAL PYMTS^ADJ TYPE^TOTAL ADJS
 ;  ***PKD 1.8*19 adding "ADJ TYPIEN" before ADJ TYPE for sort 
 ;  ***& splitting long lines for SAC and clarity in reading
 ; update: bill count; total bill amount ;total pymts
 ; 1.8*19 Lines too long w/out change - Line body must not exceed 245 characters
 I BARTR("TTYP")=40 D
 .S $P(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS")),U,3)=+$P($G(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"))),U,3)+$G(BARTR("TAMT"))
 I BARTR("TTYP")=43!(BARTR("TTYP")=993) D  ;bar*1.8*20
 .I +$P($G(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"))),U,3)=0 S $P(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS")),U,3)=0
 .N NODE
 .S NODE=$G(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"),"ADJS",BARTR("ADJ TYPIEN"),BARTR("ADJ TYPE")))  ;total adjs  bar*1.8*20
 .S $P(NODE,U)=$P(NODE,U)+$G(BARTR("TAMT"))
 .S $P(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"),"ADJS",BARTR("ADJ TYPIEN"),BARTR("ADJ TYPE")),U)=NODE  ;bar*1.8*20
 Q
 I BARTR("TTYP")=40 D
 .S $P(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS")),U,3)=+$P($G(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"))),U,3)+$G(BARTR("TAMT"))
 ;total adjs
 I BARTR("TTYP")=43 D
 .I +$P($G(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"))),U,3)=0 S $P(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS")),U,3)=0
 .S $P(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"),"ADJS",BARTR("ADJ TYPE")),U)=+$P($G(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"),"ADJS",BARTR("ADJ TYPE"))),U)+$G(BARTR("TAMT"))  ;total adjs
 Q
 ;
DETAIL ;left of the "=" - LOC^ALLOW CAT^INS TYPE^INSURER^BILL
 ;right of the "=" - DOS^APPROVAL DT^TOTAL BILL AMT^TOTAL PYMTS^# DAYS (DOS-APPR.DT)
 ; if adj
 ;right of the "=" - ADJ DT^ADJ TYPE^ADJ AMT^#DAYS (APPR.DT-ADJ.DT)
 S $P(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL),U)=$$SDT^BARDUTL(BAR("DOS"))
 S $P(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL),U,2)=$$CDT^BARDUTL(BAR("APPDT"))
 S $P(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL),U,3)=BAR("BAMT")
 ;# of days between appr. date & DOS
 S X1=BAR("APPDT")
 S X2=BAR("DOS")
 D ^%DTC
 S $P(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL),U,5)=X
 ;
 I BARTR("TTYP")=40 D
 .S $P(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL),U,4)=$P(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL),U,4)+BARTR("TAMT")
 I BARTR("TTYP")=43!(BARTR("TTYP")=993) D  ;bar*1.8*20
 .S BAR(BARBILL)=+$G(BAR(BARBILL))+1
 .;# of days between appr. date & adj date
 .S X1=+BARTR("DT")
 .S X2=BAR("APPDT")
 .D ^%DTC
 .N NODE
 .S $P(NODE,U)=$$CDT^BARDUTL(BARTR("DT"))
 .S $P(NODE,U,2)=BARTR("ADJ TYPIEN")  ;adj type
 .S $P(NODE,U,3)=BARTR("ADJ CAT")
 .S $P(NODE,U,4)=BARTR("ADJ TYPE")  ;adj category
 .S $P(NODE,U,5)=BARTR("TAMT")  ;adj amt
 .S $P(NODE,U,6)=X  ;# days
 .S ^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL,"ADJS",+$G(BAR(BARBILL)))=NODE
 Q
PRINT ;
 D HDB
 I '$D(^TMP($J,"BAR-TRANST"))&(BARY("RTYP")=1) D  Q
 .W !!!!!?25,"*** NO DATA TO PRINT ***"
 .D EOP^BARUTL(0)
 ;summary lines
 I $D(^TMP($J,"BAR-TRANST")) W !,"LOCATION^ALLOWANCE CAT^INSURER TYPE^INSURER^BILL COUNT^TOTAL BILL AMOUNT^TOTAL PAYMENTS^ADJ TYPE IEN^ADJUSTMENT TYPE^TOTAL ADJUSTMENTS"
 S BAR("LOC")=0
 F  S BAR("LOC")=$O(^TMP($J,"BAR-TRANST",BAR("LOC"))) Q:'BAR("LOC")  D
 .S BAR("ITYP")=""
 .F  S BAR("ITYP")=$O(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"))) Q:BAR("ITYP")=""  D
 .. I BAR("ITYP")="No Billing Entity" QUIT  ;P.OTTIS HEAT #74599 
 ..S BAR("INS")=""
 ..F  S BAR("INS")=$O(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"))) Q:BAR("INS")'?1N.N  D
 ...S BARO("LOC")=$P($G(^AUTTLOC(BAR("LOC"),0)),U,2)
 ...S BARO("ALLC")=$P($T(@BAR("ITYP")),";;",2)
 ...S BARO("ITYP")=$P($T(@BAR("ITYP")),";;",3)
 ...I BAR("INS")'=0 S BARO("INS")=$$GET1^DIQ(90050.02,BAR("INS")_",",.01) I 1
 ...E  S BARO("INS")="No A/R Account"
 ...S BARREC=BARO("LOC")_U_BARO("ALLC")_U_BARO("ITYP")_U_BARO("INS")_U
 ...W !,BARREC_$G(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS")))
 ...I $D(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"),"ADJS")) D
 ....S (BAR("ADJ"),BAR("ADJIEN"))=""  ;only one AdjType per AdjTypeIEN
 ....S BARACNT=0
 ....F  S BAR("ADJIEN")=$O(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"),"ADJS",BAR("ADJIEN"))) Q:BAR("ADJIEN")=""  D
 .....S BAR("ADJ")=$O(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"),"ADJS",BAR("ADJIEN"),""))  ;bar*1.8*20
 .....S BAR("ADJ TYP")=""
 .....F  S BAR("ADJ TYP")=$O(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"),"ADJS",BAR("ADJIEN"),BAR("ADJ TYP"))) Q:BAR("ADJ TYP")=""  D
 ......I BARACNT'=0 W !,BARREC_U_U
 ......W U_BAR("ADJIEN")_U_BAR("ADJ")_U_$G(^TMP($J,"BAR-TRANST",BAR("LOC"),BAR("ITYP"),BAR("INS"),"ADJS",BAR("ADJIEN"),BAR("ADJ TYP")))  ;bar*1.8*20
 ......S BARACNT=1
 .....;end new NOHEAT
 ;detail lines
 I '$D(^TMP($J,"BAR-TRANS"))&(BARY("RTYP")=2) D  Q
 .W !!!!!?25,"*** NO DATA TO PRINT ***"
 .D EOP^BARUTL(0)
 I $D(^TMP($J,"BAR-TRANS")) D
 .W !,"LOCATION^ALLOWANCE CAT^INSURER TYPE^INSURER^BILL^DOS^APPROVAL DT^TOTAL BILL AMT^TOTAL PAYMENTS^#DAYS (DOS-APPR.DT)^ADJUSTMENT DT^ADJUSTMENT TYPE^ADJUSTMENT CATEGORY IEN^ADJUSTMENT CATEGORY^ADJUSTMENT AMOUNT^#DAYS (APPR.DT-ADJ.DT)"
 S BAR("LOC")=0
 F  S BAR("LOC")=$O(^TMP($J,"BAR-TRANS",BAR("LOC"))) Q:'BAR("LOC")  D
 .S BAR("ITYP")=""
 .F  S BAR("ITYP")=$O(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"))) Q:BAR("ITYP")=""  D
 .. I BAR("ITYP")="No Billing Entity" QUIT  ;P.OTTIS HEAT #74599 
 ..S BAR("INS")=""
 ..F  S BAR("INS")=$O(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"))) Q:BAR("INS")'?1N.N  D
 ...S BARBILL=""
 ...F  S BARBILL=$O(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL)) Q:BARBILL=""  D
 ....S BARO("LOC")=$P($G(^AUTTLOC(BAR("LOC"),0)),U,2)
 ....S BARO("ALLC")=$P($T(@BAR("ITYP")),";;",2)
 ....S BARO("ITYP")=$P($T(@BAR("ITYP")),";;",3)
 ....I BAR("INS")'=0 S BARO("INS")=$$GET1^DIQ(90050.02,BAR("INS")_",",.01) I 1
 ....E  S BARO("INS")="No A/R Account"
 ....S BARREC=BARO("LOC")_U_BARO("ALLC")_U_BARO("ITYP")_U_BARO("INS")_U_BARBILL_U
 ....S BARDTAIL=$G(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL))
 ....W !,BARREC_BARDTAIL
 ....I $D(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL,"ADJS")) D
 .....S BARACNT=0
 .....F  S BARACNT=$O(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL,"ADJS",BARACNT)) Q:'BARACNT  D
 ......I BARACNT>1 D
 .......I BARDET D  W !,BARREC_BARDTAIL
 .......E  W !,BARREC_U_U_U_U
 ......W U_$G(^TMP($J,"BAR-TRANS",BAR("LOC"),BAR("ITYP"),BAR("INS"),BARBILL,"ADJS",BARACNT))
 Q
HDB ; EP
 ; Page & column hdr
 ;EP for writing Rpt Hdr
 W $$EN^BARVDF("IOF"),!
 I $D(BAR("PRIVACY")) W ?($S($D(BAR(132)):34,$D(BAR(180)):68,1:8)),"WARNING: Confidential Patient Information, Privacy Act Applies",!
 K BAR("LINE")
 S $P(BAR("LINE"),"=",$S($D(BAR(133)):132,$D(BAR(180)):181,1:81))=""
 W BAR("LINE"),!
 W BAR("HD",0),?$S($D(BAR(132)):102,$D(BAR(180)):150,1:51)
 D NOW^%DTC
 S Y=%
 X ^DD("DD")
 W $P(Y,":",1,2)
 S BAR("TMPLVL")=0
 F  S BAR("TMPLVL")=$O(BAR("HD",BAR("TMPLVL"))) Q:'BAR("TMPLVL")&(BAR("TMPLVL")'=0)  W:$G(BAR("HD",BAR("TMPLVL")))]"" !,BAR("HD",BAR("TMPLVL"))
 W !,BAR("LINE")
 K BAR("LINE")
 Q
 ;
 ; ********************************************************************
 ;THIS TABLE REPLICATES ^AUTTINTY INSURER TYPE (21 ENTRIES) P.OTT 4/12/2013
 ;AND MAPS INSURER TYPE CODE TO CATEGORY (IE: W --> OTHER)
H ;;PRIVATE INSURANCE;;HMO
M ;;PRIVATE INSURANCE;;MEDICARE SUPPL.
D ;;MEDICAID;;MEDICAID FI
R ;;MEDICARE;;MEDICARE FI
P ;;PRIVATE INSURANCE;;PRIVATE INSURANCE
W ;;OTHER;;WORKMEN'S COMP
C ;;OTHER;;CHAMPUS
N ;;OTHER;;NON-BENEFICIARY (NON-INDIAN)
I ;;OTHER;;INDIAN PATIENT
K ;;MEDICAID;;CHIP (KIDSCARE)
T ;;OTHER;;THIRD PARTY LIABILITY 
G ;;OTHER;;GUARANTOR
MD ;;MEDICARE;;MCR PART D
MH ;;MEDICARE;;MEDICARE HMO
MMC ;;MEDICARE;;MCR MANAGED CARE
TSI ;;OTHER;;TRIBAL SELF INSURED
SEP ;;OTHER;;STATE EXCHANGE PLAN
FPL ;;MEDICAID;;FPL 133 PERCENT
MC ;;MEDICARE;;MCR PART C
F ;;PRIVATE INSURANCE;;FRATERNAL ORGANIZATION
V ;;VETERAN;;VETERANS MEDICAL BENEFITS
  ;;***END OF TABLE**
 ;EOR - IHS/DIT/CPC 1.8*28