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

BAR50R01.m

Go to the documentation of this file.
BAR50R01 ;IHS/DIT/CPC - 20171031 A/R ERA CORRECTED INFORMATION NOTICE
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**27**;NOV 30, 2017;Build 12
 ;
 ;ASKS FOR A A/R EDI FILE RECORD, SCANS FOR NM1*74 ENTRIES FOR CORRECTED
 ;PERSON INFORMATION AND PRINTS REPORT WITH SUBMITTED AND CORRECTED DATA
 ;
 ;IHS/DIT/CPC New Medicare Card Initiative CR09273 11/3/2017 - BAR*1.8*27
 ;
 ;
 ;
RUNRPT ; EP
 I $G(DUZ(2))="" D  Q
 .W !!,"Check your DUZ setup."
 .D EOP^BARUTL(1)
 N RPTLOOK S RPTLOOK=1  ;Allow rpts to view ERA batches older than 3rd qtr past
 D SELFL^BAREDP00
 I Y'>0 Q
 I TRNAME'[("5010") W !!,"The file selected is not a 5010 ERA, please select another" G RUNRPT
 D BLD
 I COUNT>0 D
 .D DEVICE
 .Q:$G(BARTERM)
 .U IO(0)
 .W:'$D(IO("S")) !!,"Printing..."
 .U IO
 .S BAR("PG")=0
 .D HDR
 .D REPORT
 .I $D(DTOUT)!$D(DUOUT)!$D(DIROUT) Q
 .;F I=$Y:1:(IOSL-5) W !
 .W !
 .D CENTER^BAR50R02("END OF REPORT",80,"*","*",.ENDBNR)
 .S I=0 F  S I=$O(ENDBNR(I)) Q:I=""  W !,$G(ENDBNR(I))
 .K ENDBNR
 .D FOOTER
 D ^%ZISC
 D HOME^%ZIS
 D CLNUP
 Q
 ;
BLD ;
 K ^TMP($J,"BAR50R01") ; CLEAR TMP NODE
 S NODE=0,COUNT=0
 F  S NODE=$O(^BAREDI("I",DUZ(2),IMPDA,15,NODE)) Q:+NODE=0  D
 .I $E(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),1,6)="N1*PR*" D   ;PAYER
 ..S (PAYERNAME,PAYERADD,PAYERCSZ,PAYERTEL,PAYEROTH)=""
 ..S PAYERNAME=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),"*",3)
 ..S:PAYERNAME']"" PAYERNAME="NOTLISTED"
 ..S:$E(^BAREDI("I",DUZ(2),IMPDA,15,NODE+1,0),1,3)="N3*" PAYERADD=^BAREDI("I",DUZ(2),IMPDA,15,NODE+1,0)
 ..S:$E(^BAREDI("I",DUZ(2),IMPDA,15,NODE+2,0),1,3)="N4*" PAYERCSZ=^BAREDI("I",DUZ(2),IMPDA,15,NODE+2,0)
 ..S:$E(^BAREDI("I",DUZ(2),IMPDA,15,NODE+3,0),1,11)="PER*CX**TE*" PAYERTEL=^BAREDI("I",DUZ(2),IMPDA,15,NODE+3,0)
 ..S:$E(^BAREDI("I",DUZ(2),IMPDA,15,NODE+4,0),1,7)="PER*BL*" PAYEROTH=^BAREDI("I",DUZ(2),IMPDA,15,NODE+4,0)
 ..;END PAYER NODES
 .;
 .;GET CLAIM PAYMENT NODES
 .I $E(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),1,4)="CLP*" S CLMPMNT=^BAREDI("I",DUZ(2),IMPDA,15,NODE,0)
 .I $E(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),1,4)="CAS*" S CLMADJ(NODE)=^BAREDI("I",DUZ(2),IMPDA,15,NODE,0)
 .;
 .;GET CORRECTED INSURED, SET TMP GLOBAL FOR REPORTING
 .I $E(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),1,9)="NM1*74*1*" D    ;CORRECTED
 ..S COUNT=COUNT+1
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",1)=PAYERNAME                ;PAYER
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",2)=$P(PAYERADD,"*",2)       ;PAYER ADDRESS 1
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",3)=$P(PAYERADD,"*",3)       ;PAYER ADDRESS 2
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",4)=$P(PAYERCSZ,"*",2)       ;PAYER CITY
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",5)=$P(PAYERCSZ,"*",3)       ;PAYER STATE
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",6)=$P(PAYERCSZ,"*",4)       ;PAYER ZIP
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",7)=$P(PAYERTEL,"*",5)       ;PAYER TELEPHONE
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",8)=$P(PAYEROTH,"*",3)       ;PAYER OTHER NAME
 ..S:$P(PAYEROTH,"*",4)="EM" $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",9)=$P(PAYEROTH,"*",5)       ;PAYER EM
 ..S:$P(PAYEROTH,"*",6)="TE" $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER"),"^",3)=$P(PAYEROTH,"*",7)       ;PAYER OTHER TELEPHONE
 ..;END PAYER NODES
 ..;START CLAIM NODES
 ..I $P(CLMPMNT,"*",2)]"" D          ;CLAIM NUMBER
 ...S ^TMP($J,"BAR50R01",PAYERNAME,COUNT,"CLAIM")=$P(CLMPMNT,"*",2)      ;CLAIM NUMBER
 ...S NODE30=0,NODE30=$O(^BAREDI("I",DUZ(2),IMPDA,30,"B",$P(CLMPMNT,"*",2),NODE30))
 ...S BARSTATC=$P($G(^BAREDI("I",DUZ(2),IMPDA,30,NODE30,0)),U,2)
 ...I BARSTATC'="P",BARSTATC'="M" S ^TMP($J,"BAR50R01",PAYERNAME,COUNT,"CLAIM")=^TMP($J,"BAR50R01",PAYERNAME,COUNT,"CLAIM")_"-BILL NOT FOUND IN RPMS"
 ..E  S ^TMP($J,"BAR50R01",PAYERNAME,COUNT,"CLAIM")="NO CLAIM NUMBER-BILL NOT FOUND IN RPMS"		
 ..;END CLAIM NODES
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"XCORRECT"),"^",1)="C"       ;CORRECTED NODE
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"XCORRECT"),"^",2)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),"*",4) ;LASTNAME
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"XCORRECT"),"^",3)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),"*",5) ;FIRSTNAME
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"XCORRECT"),"^",4)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),"*",6) ;MID NAME
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"XCORRECT"),"^",5)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),"*",8) ;SUFFIX NAME
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"XCORRECT"),"^",6)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),"*",9) ;ID TYPE
 ..S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"XCORRECT"),"^",7)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE,0),"*",10) ;ID CODE
 ..I $E(^BAREDI("I",DUZ(2),IMPDA,15,NODE-1,0),1,9)="NM1*QC*1*" D
 ...S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT"),"^",1)="P"    ;PATIENT NODE
 ...D PNODE
 ...;
 ..I $E(^BAREDI("I",DUZ(2),IMPDA,15,NODE-1,0),1,9)="NM1*IL*1*" D
 ...S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT"),"^",1)="I"    ;INSURED NODE
 ...D PNODE
 I COUNT=0 W !,"No correction information in this ERA",! Q
 S SORT="",STEST=""
 F SORT=$O(^TMP($J,"BAR50R01","SORT",PAYERNAME,SORT)) Q:SORT=""  D
 .I STEST'=SORT D
 ..S STEST=SORT
 .E
 Q
 ;
PNODE ;
 S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT"),"^",2)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE-1,0),"*",4)   ;LASTNAME
 S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT"),"^",3)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE-1,0),"*",5)   ;FIRSTNAME
 S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT"),"^",4)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE-1,0),"*",6)   ;MID NAME
 S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT"),"^",5)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE-1,0),"*",8)   ;SUFFIX NAME
 S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT"),"^",6)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE-1,0),"*",9)   ;ID TYPE
 S $P(^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT"),"^",7)=$P(^BAREDI("I",DUZ(2),IMPDA,15,NODE-1,0),"*",10)  ;ID CODE
 ;
 S SORT=^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT")
 S CLAIM=^TMP($J,"BAR50R01",PAYERNAME,COUNT,"CLAIM")
 ;
 S ^TMP($J,"BAR50R01","SORT",PAYERNAME,SORT,"PAYER")=^TMP($J,"BAR50R01",PAYERNAME,COUNT,"PAYER")
 S ^TMP($J,"BAR50R01","SORT",PAYERNAME,SORT,"SUBMIT")=^TMP($J,"BAR50R01",PAYERNAME,COUNT,"SUBMIT")
 S ^TMP($J,"BAR50R01","SORT",PAYERNAME,SORT,"XCORRECT")=^TMP($J,"BAR50R01",PAYERNAME,COUNT,"XCORRECT")
 S ^TMP($J,"BAR50R01","SORT",PAYERNAME,SORT,"CLAIM",CLAIM)=^TMP($J,"BAR50R01",PAYERNAME,COUNT,"CLAIM")
 Q
 ;
HDR ;
 S BAR("PRIVACY")=1,BAR("BARTEXT")=0,BAR("HD",0)=""
 S BAR("PG")=BAR("PG")+1
 S $P(BARDASH,"=",80)=""
 S $P(BARLINE,"-",80)=""
 D NOW^%DTC
 S Y=%
 X ^DD("DD")
 S BARDTM=$P(Y,":",1,2)
 W !,BARDASH,!
 W "List Corrections Sent in ERA",?51,BARDTM,"    Page ",BAR("PG"),!
 W "Location: ",$P($G(^DIC(4,DUZ(2),0)),U,1),!
 W "For File Name: ",HSTFILE,!
 W "For RPMS File: ",$P(^BAREDI("I",DUZ(2),IMPDA,0),U,1),!
 W BARDASH,!
 Q
SUBHDR ;
 W ?1,"DATA",?10,"LAST NAME",?33,"FIRST NAME",?51,"MI",?57,"SUFFIX",?65,"POLICY NUMBER",!
 W ?1,"SOURCE",?14,"BILL(s)",!
 W BARLINE,!
 Q
 I BARTYP="S" D
 . X BAR("COL")
 . W !,BARDASH,!
 Q
 ;
REPORT  ;
 S PAYER="",PLEAFTST="",PLEAF="",ILEAFTST="",ILEAFCLM=""
 F  S PAYER=$O(^TMP($J,"BAR50R01","SORT",PAYER)) Q:PAYER=""  D
 .I $D(DTOUT)!$D(DUOUT)!$D(DIROUT) Q
 .S SORT=""
 .F  S SORT=$O(^TMP($J,"BAR50R01","SORT",PAYER,SORT)) Q:SORT=""  D
 ..I $D(DTOUT)!$D(DUOUT)!$D(DIROUT) Q
 ..S PLEAF=^TMP($J,"BAR50R01","SORT",PAYER,SORT,"PAYER")
 ..I PLEAF'=PLEAFTST D
 ...I PLEAFTST]"" D
 ....D CENTER^BAR50R02("END OF "_$P(PLEAFTST,U),80,"*","*",.ENDBNR)
 ....S I=0 F  S I=$O(ENDBNR(I)) Q:I=""  W !,$G(ENDBNR(I))
 ....K ENDBNR
 ....W !!,BARDASH,!
 ...S PNAME1=$P(PLEAF,U,1),PNAME2="",I=0
 ...I $L(PNAME1)>35 D
 ....F I=$L(PNAME1):-1:0 D
 .....I $E(PNAME1,I)=" ",(I<=40) D
 ......S PNAME1=$E(PNAME1,1,I),PNAME2=$E(PNAME1,I+1,$L(PNAME1)-I)
 ...W PNAME1,?45,$P(PLEAF,U,2),!
 ...W PNAME2,?45,$P(PLEAF,U,4),", ",$P(PLEAF,U,5),"  ",$P(PLEAF,U,6),!!
 ...D SUBHDR
 ...S PLEAFTST=PLEAF
 ..S ILEAF=^TMP($J,"BAR50R01","SORT",PAYER,SORT,"SUBMIT")
 ..I ILEAF'=ILEAFTST D
 ...W ?1,"RPMS"
 ...W ?10,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"SUBMIT"),U,2)
 ...W ?33,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"SUBMIT"),U,3)
 ...W ?51,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"SUBMIT"),U,4)
 ...W ?57,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"SUBMIT"),U,5)
 ...W ?65,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"SUBMIT"),U,7)
 ...W !
 ...W ?1,"ERA"
 ...W ?10,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"XCORRECT"),U,2)
 ...W ?33,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"XCORRECT"),U,3)
 ...W ?51,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"XCORRECT"),U,4)
 ...W ?57,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"XCORRECT"),U,5)
 ...W ?65,$P(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"XCORRECT"),U,7)
 ...S I=0 F  S I=$O(^TMP($J,"BAR50R01","SORT",PAYER,SORT,"CLAIM",I)) Q:I=""  W !,?14,^TMP($J,"BAR50R01","SORT",PAYER,SORT,"CLAIM",I)
 ...W !!
 ...I $Y>(IOSL-6) D
 ....W !
 ....D FOOTER
 ....I $D(DTOUT)!$D(DUOUT)!$D(DIROUT) Q
 ....D HDR
 ...S ILEAFTST=ILEAF
 ...I $Y>(IOSL-6) D FOOTER
 ...I $D(DTOUT)!$D(DUOUT)!$D(DIROUT) Q
 Q
 ;
 K DIR S DIR(0)="E" D:'$D(ZTQUEUED)&(IO=IO(0)&'$D(IO("S"))) ^DIR
 W @IOF
 Q
 ;
DEVICE ;SET UP DEVICE
 S %ZIS("A")="Output Device: "
 S %ZIS="MQ"
 D ^%ZIS
 S:POP BARTERM=1
 Q
 ;
CLNUP ;
 K BAR("PG"),BARDASH,BARLINE,BARTERM,CLAIM,CLMADJ,CLMPMNT,CLMTST1,CLMTST2,COUNT
 K DIROUT,DTOUT,DUOUT,ENDBNR,HSTFILE,HSTIME
 K I,ILEAF,ILEAFCLM,ILEAFTST,IMP,IMPDA,IND,J,L
 K NOBTCH,NODE,NODE30,PAYER,PAYERADD,PAYERADD1,PAYERCSZ
 K PAYERNAME,PAYEROTH,PAYERTEL,PLEAF,PLEAFTST,PNAME1,PNAME2,POP
 K RPTLOOK,STEST,TRDA,TRNAME,X
 K ^TMP($J,"BAR50R01")
 Q