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

BAR50P04.m

Go to the documentation of this file.
BAR50P04 ; IHS/SD/LSL - MATCH REASONS AND CLAIMS ; 01/09/2009
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**5,6,10,20,21,22,23,24,26,28**;OCT 26, 2005;Build 92
 ;IHS/SD/POT 1.8*23 HEAT87149 FIXING LINE +210
 ;IHS/SD/POT 1.8*23 HEAT82698 LEADING ZEROES IN BILL #
 ;IHS/SD/POT 1.8*23 FIX INIT VALUE OF CLMDA (+27)
 ;IHS/SD/POT 1.8*24 HEAT147572 ALLOW TRIBAL SITES ERA POSTING OF NEG BAL & CANCELLED BILLS 1/15/2014;  2/5/2014
 ;IHS/SD/POT 1.8*26 HEAT170856 correct non-ihs functionality when parm "ALLOW ERA POSTING NEG BALANCES" set
 ;IHS/SD/SDR 1.8*26 HEAT170856 Made changes so BLMT and REV work same.  One would add reasons that other would take away.  Also corrected check for Allow ERA cancelled clm parm.
 ;IHS/SD/SDR 1.8*26 HEAT233443 - Stopped MAXNUMBER error.  Occurred when 'E' is in CLP01 element.  Changed it to 'A'.  We look for bill number (excluding alpha) so most matches are made so it doesn't matter
 ;  that it is 'A' instead of 'E'.
 ;IHS/SD/SDR 1.8*28 CR8347 HEAT281465 If CLP01=0 make it still go through process so it will change status from BUILT to CLAIM UNMATCHED w/reason NTP of no RPMS bill.
 ;IHS/SD/SDR 1.8*28 CR9572 HEAT258378 Fixed if they don't pick anything when mult. potential matches; also made it so mult. potential matches and none picked is Claim Unmatched w/RNTP of UOR.
EN(TRDA,IMPDA)  ;EP ;SCAN CLMS BUILT "B" STATUS
 N REVERSAL,ERACHECK
 D INIT^BARUTL
 W !,"Matching E-Claims to A/R Bills and Reason Codes",!
 I TRNAME["HIPAA" D  Q
 .S INDEX="B"
 .D INDEX,PRT^BAR50DET
 F INDEX="B","X","C","R" D INDEX,PRT^BAR50DET
 Q
INDEX ;EP
 S QFLG=0
 W !,"Processing Claim Status using claim Index ",INDEX,!
 S BARDBG=1  ;1=build detail matching report  ;IHS/DIT/CPC - BAR*1.8*28
 K ^XTMP("BAR-LIST_DETAIL",$J,DUZ(2))
 K ^XTMP("BAR-LIST",$J,DUZ(2))
 S BARMSG="PERFORMING TRADITIONAL HIPAA CHECKS...("_$$FTYPE()_")" W !,BARMSG
 I $G(BARDBG) D INS^BAR50DET(BARMSG,0)
 K BARFLG
 S CLMDA=0 F  S CLMDA=$O(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA)) Q:'CLMDA  S ^XTMP("BAR-LIST",$J,DUZ(2),$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U),CLMDA)=""
 S CLMCNT=0,BARBL=""
 ;F  S BARBL=$O(^XTMP("BAR-LIST",$J,DUZ(2),BARBL)) Q:BARBL=""  D  Q:QFLG=1  ;bar*1.8*26 IHS/SD/SDR HEAT170856
 F  S BARBL=$O(^XTMP("BAR-LIST",$J,DUZ(2),BARBL)) Q:BARBL=""  D  ;bar*1.8*26 IHS/SD/SDR HEAT170856
 .S CLMDA=0
 .;F  S CLMDA=$O(^XTMP("BAR-LIST",$J,DUZ(2),BARBL,CLMDA)) Q:'CLMDA  K ERRS D CLMFLG(CLMDA,.ERRORS)  Q:$G(QFLG)=1  ;bar*1.8*26 IHS/SD/SDR HEAT170856
 .F  S CLMDA=$O(^XTMP("BAR-LIST",$J,DUZ(2),BARBL,CLMDA)) Q:'CLMDA  K ERRS D CLMFLG(CLMDA,.ERRORS)  ;bar*1.8*26 IHS/SD/SDR HEAT170856
 ;Q:QFLG=1  ;bar*1.8*29 IHS/SD/SDR HEAT170856
 S BARFLG=$$EN^BAR50P0Z(IMPDA)  ;PLB/Pymt Rev/Neg pymt amt chks
 ;old D:$$IHS^BARUFUT(DUZ(2)) NEGBAL^BAR50EB(IMPDA,"ERA") ;CHK FOR NEG BAL IN RPMS BILLS
 D NEGBAL^BAR50EB(IMPDA,"ERA")  ;note:IHS/TRIBAL CHK INSIDE BAR50EB CHK FOR NEG BAL IN RPMS BILLS HEAT147572 MOD: 2/5/2014
 ;NOTE: MATCHED PYMTS & CREDITS W/HAVE THE 'POST THIS CLM AS TYPE' FLD = TO 20=PYMT CREDIT
 ;D:$$IHS^BARUFUT(DUZ(2)) NONPAYCH^BAR50EP1(IMPDA) ;CHK PYMTS NOT MATCHED TO REV TO SEE IF BEING POSTED TO 'NONPYMT' BATCH ;bar*1.8*26 IHS/SD/POT HEAT170856
 D:$$IHSNEGB^BARUFUT(DUZ(2)) NONPAYCH^BAR50EP1(IMPDA)  ;bar*1.8*26 IHS/SD/POT HEAT170856
 ;K ERRORS
 Q
CLMFLG(CLMDA,ERRORS) ;EP
 ;NEXT LINE MOVED TO TOP OF SUBR
 I (($P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,2)),U))'=($P($G(^BAREDI("I",DUZ(2),IMPDA,5,BARCKIEN,0)),U)))  D  Q  ;only look at 1 chk's clms
 N BARTMPM,BARTMPCL ;RETURN FLAG
 S BILMATCH=0
 S BARTMPCL=$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U)
 I $G(BARDBG) D
 .D INS^BAR50DET($$LINE(),0)
 .S BARMSG="PROCESSING ENTRY: "_$J(CLMDA,6)_"  CLAIM "_BARTMPCL W !,BARMSG
 .D INS^BAR50DET(BARMSG,0)
 ;start old bar*1.8*28 IHS/SD/SDR CR8347 HEAT281465
 ;I BARTMPCL=0 D  Q
 ;.S BARMSG=" INVALID CLAIM NUMBER" W BARMSG
 ;.D INS^BAR50DET(BARMSG,1)
 ;end old bar*1.8*28 IHS/SD/SDR CR8347 HEAT281465
 I $P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U,2)="P"  D  Q  ;quit if posted
 .I $G(BARDBG) D INS^BAR50DET(" POSTED - SKIPP",1)
 ;S BARTMPM=$$OVERIDE^BAR50EP1(CLMDA) I BARTMPM D  Q  ;P.OTT  ;bar*1.8*26 IHS/SD/SDR HEAT170856
 .I $G(BARDBG) D INS^BAR50DET(" OVERRIDE: "_$P(BARTMPM,"^",2),1)
 I $P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U,2)="E" D  Q  ;user marked as Exception-skip
 .I $G(BARDBG) D INS^BAR50DET(" EXCEPTION - SKIP",1)
 D DELREAS(IMPDA,CLMDA)  ;CLR ERRORS, SET STAT TO MATCHED, BEGIN BY ASSUMING ALL CLMS ARE MATCHED & ERROR FREE
 ;CHK & SET CLM MATCH STATUS
 I TRNAME["HIPAA" D
 .S CLMCNT=+$G(CLMCNT)+1
 .I $G(BARDBG) W !?2,CLMCNT,?10,BARBL,"  ",$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U)
 .S CLMFLG=$$HIPAACLM(IMPDA,CLMDA,.ERRORS)
 .Q:$G(QFLG)=1
 .S REAFLG=$$HIPAAREA(IMPDA,CLMDA,.ERRORS)
 Q:$G(QFLG)=1
 ;
 I TRNAME'["HIPAA" D
 .S CLMFLG=$$CLM(CLMDA)
 .S REAFLG=$$REA(CLMDA)
 ;
 S STAT=""
 I CLMFLG,REAFLG S STAT="M"  ;MATCHED
 I 'CLMFLG,REAFLG S STAT="C"  ;CLM UNMATCHED
 I CLMFLG,'REAFLG S STAT="M"
 I 'CLMFLG,'REAFLG S STAT="C"
 K DR,DIE,DA
 S DIE=$$DIC^XBDIQ1(90056.0205)
 S DR=".02////^S X=STAT"
 S DA(1)=IMPDA
 S DA=CLMDA
 D ^DIE
 I TRNAME["HIPAA" D
 .I '$G(REAFLG),$G(REATYP)="RT" S STAT="RT"  ;RSN CD NOT DEFINED IN STD TBL  ;ADDED $G ;IHS/DIT/CPC - BAR*1.8*28
 .I '$G(REAFLG),$G(REATYP)="RF" S STAT="RF"  ;RSN CD NOT ON RA  ;ADDED $G ;IHS/DIT/CPC - BAR*1.8*28
 .I '$G(REAFLG),$G(REATYP)="RU" S STAT="RU"  ;STD ADJ CD NOT MAPPED TO RPMS  ;ADDED $G ;IHS/DIT/CPC - BAR*1.8*28
 .I '$G(CLMFLG),$G(CLMTYP)="CF" S STAT="CF"  ;CLM# (CLP01) NOT SENT ON RA ;ADDED $G ;IHS/DIT/CPC - BAR*1.8*28
 .I '$G(CLMFLG),$G(CLMTYP)="CT" S STAT="CT"  ;RA CLM NOT FOUND IN RPMS  ;ADDED $G ;IHS/DIT/CPC - BAR*1.8*28
 .I '$G(CLMFLG),$G(CLMTYP)="CC" S STAT="CC"  ;RA CLM IN RPMS AR BUT CANCELLED IN 3P  ;ADDED $G ;IHS/DIT/CPC - BAR*1.8*28
 .I '$G(CLMFLG),$G(CLMTYP)="CD" S STAT="CD"  ;DOS DOESN'T MATCH RPMS  ;ADDED $G ;IHS/DIT/CPC - BAR*1.8*28
 ;RSNS FOUND FOR 'NOT TO POST' (OLD)
 I $D(ERRORS("CT")) K ERRORS S ERRORS("CT")=""
 I $D(ERRORS("DUPB")) K ERRORS S ERRORS("DUPB")=""
 I $D(ERRORS) D ADDREAS(IMPDA,CLMDA,.ERRORS)
 ;CHKS FOR RSNS 'NOT TO POST'
 K ERRORS,STAT,REA,READA,REASDA,REAFLG,BARMSG,CLMTYP,REATYP  ;IHS/DIT/CPC - BAR*1.8*28
 Q
CLM(CLMDA) ;EP ;MATCH/SET/FLAG E-CLM TO A/R BILL
 S X=$$VAL^XBDIQ1(90056.0205,"IMPDA,CLMDA",.01)
 K DIC,DA,DR
 S DIC=90050.01
 S DIC(0)="M"
 D ^DIC
 I Y'>0 Q 0
 S BARBLDA=+Y
 S DIE=$$DIC^XBDIQ1(90056.0205)
 S DA=CLMDA
 S DA(1)=IMPDA
 S DR="1.01////^S X=BARBLDA"
 D ^DIE
 Q 1
REA(CLMDA) ;EP ;LOOP MATCH/SET/FLAG RSN CODES OF E-CLM
 K ADJ
 S REAFLG=1
 S ADJDA=0
 F  S ADJDA=$O(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,30,ADJDA)) Q:ADJDA'>0  D
 .S ACAT=$$VALI^XBDIQ1(90056.0208,"IMPDA,CLMDA,ADJDA",.04)
 .S AREA=$$VALI^XBDIQ1(90056.0208,"IMPDA,CLMDA,ADJDA",.05)
 .S REA=$$VAL^XBDIQ1(90056.0208,"IMPDA,CLMDA,ADJDA",.03)
 .I '$L(REA) S REAFLG=0 Q
 .;lookup rsn in rsn table
 .K DIC,DA,DR
 .S DIC=$$DIC^XBDIQ1(90056.0107)
 .S DA(1)=TRDA
 .S X=$P(REA," ")
 .S DIC(0)="X"
 .D ^DIC
 .I Y'>0 D  Q
 ..S BARMSG=" NO REASON "_X W !,BARMSG
 ..I $G(BARDBG) D INS^BAR50DET(BARMSG,0)
 ..S REAFLG=0
 .S READA=+Y
 .;line below to ignore inpt w/non-cov'd days
 .I +CLMFLG>0,$P($G(^BARBL(DUZ(2),BARBLDA,1)),U,14)=111,$P(Y,U,2)=96 Q
 .Q:$P(Y,U,2)=93  ;Q if rsn is 93 w/o attempting to match
 .;pull A/R cat & rsn
 .S ACAT=$$VALI^XBDIQ1(90056.0107,"TRDA,READA",2.01)
 .S AREA=$$VALI^XBDIQ1(90056.0107,"TRDA,READA",2.02)
 .I ACAT,AREA D SETREA I 1
 .E  S REAFLG=0
 Q REAFLG
SETREA ;EP SET CAT & REA INTO E-CLM
 K DIC,DIE,DR,DA
 S DIE=$$DIC^XBDIQ1(90056.0208)
 S DA(2)=IMPDA
 S DA(1)=CLMDA,DA=ADJDA
 S DR=".04////^S X=ACAT;.05////^S X=AREA"
 D ^DIE
 Q
HIPAAREA(IMPDA,CLMDA,ERRORS) ;mult errors
 ;Match HIPAA std codes to RPMS
 K ADJ
 S REAFLG=1
 S ADJDA=0
 F  S ADJDA=$O(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,30,ADJDA)) Q:'+ADJDA  D HIPAAR2
 Q REAFLG
HIPAAR2 ;Match HIPAA std codes to RPMS
 S REA=$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,30,ADJDA,0)),U,3)
 I REA="" D  ;
 .W !,"Standard adjustment reason not sent on RA."
 .S REAFLG=0
 .S REATYP="RF"
 .S ERRORS("RF")="" ;
 S ACAT=$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,30,ADJDA,0)),U,4)
 S AREA=$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,30,ADJDA,0)),U,5)
 K DIC,DR,DA
 S DIC="^BARADJ("
 S X=$P(REA," ")
 S DIC(0)="XZ"
 D ^DIC
 I +Y<1 D  Q
 .W !,"Standard adjustment reason ",X," not in standard table."
 .S REAFLG=0
 .S REATYP="RT"
 .S ERRORS("RT")="" ;
 S READA=+Y
 I $P(Y(0),U,3)=""!($P(Y(0),U,4)="") D  ;
 .W !,"Can't map standard adjustment reason ",X," to RPMS."
 .S REAFLG=0
 .S REATYP="RU"
 .S ERRORS("RU")="" ;BAR*1.8*5 SRS-80 TPF
 K DIC,DA,DR,DIE
 S DIE=$$DIC^XBDIQ1(90056.0208)
 S DA(2)=IMPDA
 S DA(1)=CLMDA
 S DA=ADJDA
 S DR=".04////^S X=$P(Y(0),U,3)"
 S DR=DR_";.05////^S X=$P(Y(0),U,4)"
 D ^DIE
 Q
HIPAACLM(IMPDA,CLMDA,ERRORS) ;BAR*1.8*5 SRS-80 TPF ERRORS CAN BE MULTIPLE
 N BARTMP,BARAMT,BARDOS,ERAAMT,ERADOS,ERATYPE,BARFND
 ;Match RA clms to RPMS
 ;1st chk bill# "B" x-ref; if no, chk other identifier "G" x-ref (Pharmacy POS)
 S BAREIENS=CLMDA_","_IMPDA_","
 ;S BARTEST=$$GET1^DIQ(90056.0205,BAREIENS,.01)  ;bar*1.8*26 IHS/SD/SDR HEAT233443
 S BARTEST=$TR($P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U),"E","A")  ;bar*1.8*26 IHS/SD/SDR HEAT233443
 S (BARBIEN,BARBILL)=""  ;IHS/DIT/CPC BAR*1.8*28
 S (BARBIEN,BARBILL)=$$GETBBILL(BARTEST) ;P.OTT ENDS WITH FIRST NON ALPHANUMERIC CHAR
 I BARBILL="" D  Q  ;
 .S CLMTYP="CF"
 .W !,"Bill number not sent on ERA"
 .S ERRORS("CF")=""
 S BARCNT=0
 D CLM^BAR50P4A(BAREIENS,BARBILL,.BARX,.BARMMFLG) ;bar*1.8*20 
 I BARFND=0 D
 .S BARMSG=$P($G(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,0)),U)_"  ***CLAIM NOT FOUND IN RPMS***"
 .W !,BARMSG
 .D INS^BAR50DET(BARMSG,0) ;SAME MSG INTO REPORT
 .D NOMATCH^BAR50DET ;NOT MATCH
 I $$GET1^DIQ(90056.0205,BAREIENS,1.01,"I")'="" S BARCNT=1  ;IENS->BAREIENS
 ;FROM p.ott
 I BARCNT=1 S BARBIEN=$O(BARTMP(0))
 I BILMATCH=1 D  ;
 .S NEWSTAT="M"
 .S BARBIEN=$O(BILMATCH("")) S BARCNT=1
 .S BARMSG=$J("",5)_"ERA BILL "_$$GET1^DIQ(90056.0205,BAREIENS,.01) W !,BARMSG
 .I $G(BARDBG) D INS^BAR50DET(BARMSG,0)
 .S BARMSG=" MATCHED TO "_$S(BARX="G":"(POS)",1:"")_" A/R BILL "_$P($G(^BARBL(DUZ(2),BARBIEN,0)),U)
 .W BARMSG
 .I $G(BARDBG) D INS^BAR50DET(BARMSG,1)
 ;TO p.ott
 I BARCNT=0 S CLMTYP="CT",ERRORS("CT")=""
CLM2 ;
 S NEWSTAT=$G(NEWSTAT) ;init value 12/12/13
 I BARCNT>1,($$GET1^DIQ(90056.0205,BAREIENS,1.01)="") D
 .S NEWSTAT="",BARANS=""
 .F  D  Q:($G(BARSEL)'="B"&($G(BARSEL)'="H"))
 ..D HDR
 ..D RABILL
 ..D ARBILL
 ..D CHOOSE
 ..I ($G(BARSEL)="Q") S QFLG=1 Q  ;
 ..I (+$G(BARANS)'=0)&(($G(BARSEL)'="B")&($G(BARSEL)'="H")) D
 ...K DIR
 ...S DIR(0)="Y"
 ...S DIR("A")="Are you sure?"
 ...S DIR("B")="N"
 ...D ^DIR
 ...I +Y<1 S BARANS=0 S BARSEL="B"
 .I $G(BARSEL)="" D
 ..W !!,"BILL WILL NOT BE MATCHED AND WILL BE SET TO 'NOT MATCHED'.  CONTINUING.."
 ..S BARSEL="N"
 .;I BARSEL="N" S NEWSTAT="M",ERRORS("DUPB")=""  ;bar*1.8*28 IHS/SD/SDR CR9572 HEAT258378
 .I BARSEL="N" S NEWSTAT="C",ERRORS("UOR")=""  ;bar*1.8*28 IHS/SD/SDR CR9572 HEAT258378
 .I BARSEL="M" S NEWSTAT="M"   ;BAR*1.8*28 IHS/DIT/CPC CR9572
 .I '+BARANS,BARSEL="N" Q  ;
 .I '+BARANS S CLMTYP="CT",ERRORS("CT")="" Q
 .S BARBIEN=BARTMP2(BARANS)
 ;Match DOS
 ;See if 3P cancelled
 S BAR3PIEN=$$FIND3PB^BARUTL(DUZ(2),BARBIEN)
 I BAR3PIEN]"" D   ;
 .S BARBSTAT=$P($G(^ABMDBILL($P(BAR3PIEN,","),$P(BAR3PIEN,",",2),0)),U,4)
 .;S:BARBSTAT="X" CLMTYP="CC"  ;Cancelled in 3P  ;bar*1.8*28 IHS/DIT}
 .S:BARBSTAT="X" CLMTYP="CC",ERRORS("CC")=""  ;bar*1.8*28 IHS/DIT}
 I $$GET1^DIQ(90056.0205,BAREIENS,.02,"I")="M" Q 1  ;IHS/DIT/CPC - BAR*1.8*28
 Q:$D(ERRORS("CT"))!($D(ERRORS("CF")))!($D(ERRORS("UOR"))) 0   ;IHS/DIT/CPC - BAR*1.8*28
 ;Bill matches RPMS-log AR Bill IEN in Image
 S DIE=$$DIC^XBDIQ1(90056.0205)
 S DA=CLMDA
 S DA(1)=IMPDA
 S DR="1.01////^S X=BARBIEN"
 S MATCH="M"
 S DR=DR_";.02////^S X=MATCH"
 D ^DIE
 ;Q:$D(ERRORS) 0   ;IHS/DIT/CPC - BAR*1.8*28
 Q 1
HDR ;hdr
 W !!,$$EN^BARVDF("ULN"),?4,"BILL #",?23,"DOS",?31,"PATIENT NAME"
 W ?57,"BILLED AMT",?71,"BALANCE",$$EN^BARVDF("ULF")
 Q
RABILL ;Write RA data
 S X=$$GET1^DIQ(90056.0205,BAREIENS,.08)
 D ^%DT
 S BARRADT=Y  ;DOS begin
 W !,$$EN^BARVDF("RVN")
 W "ERA"  ;
 W ?4,$E($$GET1^DIQ(90056.0205,BAREIENS,.01),1,15)  ;BILL/RX
 W ?20,$$SDT^BARDUTL(BARRADT)  ;DOS begin
 W ?31,$E($$GET1^DIQ(90056.0205,BAREIENS,.06),1,25)  ;Pt name
 W ?57,$J($FN($$GET1^DIQ(90056.0205,BAREIENS,.05),",",2),10)  ;Billed
 W $$EN^BARVDF("RVF")
 Q
ARBILL ;Loop & write AR data
 S (BARBIEN,BARCNT2)=0
 F  S BARBIEN=$O(BARTMP(BARBIEN)) Q:'+BARBIEN  D
 .S BARCNT2=BARCNT2+1
 .S BARBDT=$$GET1^DIQ(90050.01,BARBIEN,102,"I")
 .W !,$J(BARCNT2,2),")"
 .W ?4,$E($$GET1^DIQ(90050.01,BARBIEN,.01),1,20)  ;expanded ck# to 20 chars  bar*1.8*22 SDR
 .W ?20,$$SDT^BARDUTL(BARBDT)
 .W ?31,$E($$GET1^DIQ(90050.01,BARBIEN,101),1,25)
 .W ?52,$J($FN($$GET1^DIQ(90050.01,BARBIEN,13),",",2),10)
 .W ?68,$J($FN($$GET1^DIQ(90050.01,BARBIEN,15),",",2),10)
 .S BARTMP2(BARCNT2)=BARBIEN
 Q
CHOOSE ;Choose bill from AR
 K DIR
 S DIR(0)="SABO^B:Bill Inquire;H:History;M:Match to Item;N:Not Matched;Q:Quit"
 S DIR("A")="Enter (B)ill Inquire,(H)istory,(M)atch to Item,(N)ot Matched,(Q)uit: "
 D ^DIR
 S BARSEL=Y  ;bar*1.8*28 IHS/SD/SDR CR9572 HEAT258378
 I $D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT) S BARANS=0 Q
 I BARSEL="N"!(BARSEL="Q") S BARANS=0 Q  ;not matched
 K DIR
 S DIR(0)="NAO^1:"_BARCNT2
 S DIR("A")="Which Entry: "
 S DIR("?")="Enter a number between 1 and "_BARCNT2
 D ^DIR
 I $D(DIROUT)!$D(DUOUT)!$D(DIRUT)!$D(DTOUT) S BARANS=0 Q
 S BARANS1=$G(BARTMP2(Y)),BARANS=Y
 I BARSEL="H" D
 .D EN^BARPST5(BARANS1)
 I BARSEL="B" D
 .D DIQ^XBLM(90050.01,BARANS1)
 Q
 ;BAR*1.8*5 SRS-80 TPF
ADDREAS(IMPDA,CLMDA,ERRORS,SHOWMSG) ;EP - ADD RSN NOT SENT TO 'RSN NOT TO POST MULTIPLE'
 S SHOWMSG=$G(SHOWMSG)
 N REASON,STAT,ERRDA,CURSTAT
 S REASON=""
 F  S REASON=$O(ERRORS(REASON)) Q:REASON=""  D
 .I REASON="CT" D STAT(IMPDA,CLMDA)
 .I SHOWMSG D
 ..S ERRDA=$O(^BARERR("B",REASON,""))
 ..W !,$$GET1^DIQ(90056.21,ERRDA_",",.02,"E")
 .K DIC,DIE,DR,DA,DIR
 .S DIC("P")=$P(^DD(90056.0205,401,0),U,2)
 .S DA(2)=IMPDA
 .S DA(1)=CLMDA
 .S DIC(0)="L"
 .S DIC="^BAREDI(""I"",DUZ(2),"_DA(2)_",30,"_DA(1)_",4,"
 .S X=REASON
 .D ^DIC
 Q
STAT(IMPDA,CLMDA) ;EP
 K DR,DIE,DA
 S DIE=$$DIC^XBDIQ1(90056.0205)
 S STAT="C"
 S DR=".02///^S X=STAT"
 S DA(1)=IMPDA
 S DA=CLMDA
 D ^DIE
 Q
DELREAS(IMPDA,CLMDA) ;EP -CLR 'RSN NOT TO POST' MULTIPLES IN ERA FILE
 N REASDA
 K DA,DIR,DIC,DIE,DR
 S REASDA=0
 F  S REASDA=$O(^BAREDI("I",DUZ(2),IMPDA,30,CLMDA,4,REASDA)) Q:'REASDA  D
 .S DA(2)=IMPDA
 .S DA(1)=CLMDA
 .S DIE="^BAREDI(""I"","_DUZ(2)_","_DA(2)_",30,"_DA(1)_",4,"
 .S DA=REASDA
 .S DR=".01///@"
 .D ^DIE
 K DA,DR,DIE,DIC,DIR
 S DIE=$$DIC^XBDIQ1(90056.0205)
 S DR=""  ;REQ4
 S IENS=CLMDA_","_IMPDA_","  ;REQ4
 ;I $$GET1^DIQ(90056.0205,IENS,71)="" S DR=".02///C"  ;'STATUS' FLD CLM UNMATCHED ;REQ4
 I $$GET1^DIQ(90056.0205,IENS,.02)=""!($$GET1^DIQ(90056.0205,IENS,.02,"I")="B") S DR=".02///C"  ;'STATUS' FLD CLM UNMATCHED IHS/DIT/CPC - BAR*1.8*28
 S DR=DR_";501///@"  ;'POST CLM AS TYPE'
 S DR=DR_";601///@"  ;'PYMT CRDT APPLIED TO'
 S DR=DR_";602///@"  ;'PYMT CRDT APPLIED FROM'
 S DA(1)=IMPDA
 S DA=CLMDA
 D ^DIE
 K DA,DR,DIE,DIC,DIR
 Q
 ;
GETBBILL(BARTMP) ;
 N BARBLNUM,I,CH
 S BARBLNUM="" F I=1:1:$L(BARTMP) S CH=$E(BARTMP,I) Q:CH'?1N  S BARBLNUM=BARBLNUM_CH
 I CH?1A S BARBLNUM=BARBLNUM_CH ;TAKE THE FIRST ALPHA AFTER NNNN
 I BARBLNUM="" Q ""
 Q BARBLNUM
LINE() ;
 N I,STR
 S STR="" F I=1:1:78 S STR=STR_"-"
 Q STR
FTYPE() ;
 Q "5010"
 ;EOR - IHS/DIT/CPC 1.8*28