BARMPAS ; IHS/SD/LSL - Patient Account Statement ;
;;1.8;IHS ACCOUNTS RECEIVABLE;**2,4,5,19,20,23,24**;OCT 26, 2005;Build 69
;
; IHS/SD/LSL - 04/22/03 - V1.7 Patch 2
; IHS/SD/LSL - 12/04/04 - V17 Patch 4 - IM11692
; Modify code to allow tasked option to catch all facilities.
; IHS/SD/LSL - 02/11/04 - V1.7 Patch 5 - IM12222
; Modify MARKACC to allow marking of patient's registered
; at the parents satellite.
; IHS/SD/POTT HEAT80718 ADDED SORTING OPTION BY PATNAME ;BAR1.8*23
; IHS/SD/POTT HEAT95153 BAR1.8*23
; IHS/SD/POTT HEAT63286 added call to populate array BARPSAT ;BAR1.8*23
; IHS/SD/POTT HEAT91646 added OPTION 'PUR' & 'REB' ;BAR1.8*23
; IHS/SD/POTT HEAT106730 BAR1.8*23
; IHS/SD/POTT HEAT152220 2/11/2014 FIX PRO PRINT AND CLEANUP ;BAR1.8*24
; IHS/SD/POTT HEAT100207 FIXED AGE 2/18/2014 ;BAR1.8*24
; ********************************************************************
Q
TASK ; EP
; Called from SCHEDULED OPTION BAR MAN ACCOUNT STATEMENT
; Start with last run date and go to Today.
; Find BAR ACCOUNT STATEMENT in Option Scheduling File
N BARXXX
D INIT^BARUTL
S BARXXX=$$GETX() ;
I BARXXX<0 QUIT
S BARSRTBY=$$GETSRTBY() ;GET SORT-BY
D INITXTMP(BARXXX,BARDTB,BARDTE,BARSRTBY,BARRUNDT) ;;BAR1.8*23
D BARPSAT^BARUTL0 ;;BAR1.8*23 HEAT #63286 added call to populate array BARPSAT
S BARHOLD=DUZ(2)
S DUZ(2)=0 F S DUZ(2)=$O(^BARAC(DUZ(2))) Q:'+DUZ(2) D
. S BARACDA=0 F S BARACDA=$O(^BARAC(DUZ(2),"PAS","Y",BARACDA)) Q:'BARACDA D ACCOUNT(BARACDA)
S DUZ(2)=BARHOLD
D MAIL^XBMAIL("BARZ MANAGER","MAIL^BARMPAS")
Q
; ********************************************************************
;
GETX() ;
K DIC,DR,DIE,DA
S DIC=19.2 ; Option Scheduling File
S X="BAR ACCOUNT STATEMENT"
S DIC(0)="ZM"
D ^DIC
I Y<1 Q -1 ;NO SETUP
S BARSCHED=+Y ; Option IEN
S BARFREQ=$$GET1^DIQ(19.2,BARSCHED,6) ; Option schedule freq
S X1=DT
S X2=-90
D C^%DTC
F S X=$$SCH^XLFDT(BARFREQ,X) Q:X>DT S BARDTB=X ;Last run date
S BARDTE=DT ; Today
D NOW^%DTC
S BARRUNDT=%
S X1=DT
S X2=+15
D C^%DTC
Q X
ACCOUNT(BARACDA) ;
; Find Bills where the AR Account is marked for
; Patient Account Statement
;D INIT^BARUTL ; this keeps it from printing to a slave printer
S (BARBL,BARTOT,BARVISL,BARDOSV)=0
D BARPSAT^BARUTL0 ;;BAR1.8*23 HEAT63286 16-MAR-2012 added call to populate array BARPSAT
S BARPATNM=$$PATNAME(BARACDA) ;BAR1.8*23
I BARSRTBY=0 S BARPATNM="X" ;NOT SORTED BY NAMES - CREATE DUMMY NAME BAR1.8*23
F S BARBL=$O(^BARBL(DUZ(2),"ABAL",BARACDA,BARBL)) Q:'+BARBL D
. S BARBAL=$$GET1^DIQ(90050.01,BARBL,15) ;CURRENT BILL AMOUNT
. Q:BARBAL'>0
. S BARVISL=$$GET1^DIQ(90050.01,BARBL,108) ; VisitLoc
. I BARVISL="" S BARVISL=BARPSAT(DUZ(2),.01) ; if not listed, default to DUZ(2)
. S BARDOSV=$P(^BARBL(DUZ(2),BARBL,1),U,2) ; DOS - VA format
. I BARVISL="" S BARVISL="??"
. I BARDOSV="" S BARDOSV="??"
. S BARTOT=BARTOT+BARBAL
. S ^XTMP("BARPAS"_BARRUNDT,DUZ(2),1,BARPATNM,BARACDA,"OB",BARBL)="" ;NODE 1 FOR 'OB'
. S ^XTMP("BARPAS"_BARRUNDT,DUZ(2),1,BARPATNM,BARACDA,BARVISL,BARDOSV,"OB",BARBL)="" ;NODE 1 FOR 'OB'
. S ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA,BARVISL,BARDOSV,BARBL,"A")=""
;
S ^XTMP("BARPAS"_BARRUNDT,DUZ(2),1,BARPATNM,BARACDA,"OB")=BARTOT
;
; It currently kills all previous entries if the Balance = 0
I BARTOT=0 K ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA)
; -------------------------------------------------------------------------
; Find bills by patient balance
; -------------------------------------------------------------------------
S BARPAT=$$GET1^DIQ(90050.02,BARACDA,1.001)
S BARBL=0 F S BARBL=$O(^BARBL(DUZ(2),"APBAL",BARPAT,BARBL)) Q:'+BARBL D
. ; Add sorts: VisitLocation and DOS
. S BARVISL=$$GET1^DIQ(90050.01,BARBL,108) ; VisitLoc
. I BARVISL="" S BARVISL=BARPSAT(DUZ(2),.01) ; if not listed, default to DUZ(2)
. S BARDOSV=$P(^BARBL(DUZ(2),BARBL,1),U,2) ; DOS
. S ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA,BARVISL,BARDOSV,BARBL,"P")=""
. Q
; -------------------------------------------------------------------------
; Find bills by patient
; -------------------------------------------------------------------------
S BARBL=0 F S BARBL=$O(^BARBL(DUZ(2),"C",BARPAT,BARBL)) Q:'+BARBL D
. S BARBAL=$$GET1^DIQ(90050.01,BARBL,15)
. Q:BARBAL'>0
. ; IHS/SD/PKD 1.8*19 9/10/10
. ; Add sorts: VisitLocation and DOS
. S BARVISL=$$GET1^DIQ(90050.01,BARBL,108) ; VisitLoc
. I BARVISL="" S BARVISL=BARPSAT(DUZ(2),.01) ; if not listed, default to DUZ(2)
. S BARDOSV=$P(^BARBL(DUZ(2),BARBL,1),U,2) ; DOS
. ;STANDARD SORTING (NO PATNAME)
. I BARVISL="" S BARVISL="??"
. I BARDOSV="" S BARDOSV="??"
. S ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA,BARVISL,BARDOSV,BARBL,"P")=""
. D ABAL(BARBL)
;
; -------------------------------------------------------------------------
; Find bills by transaction
; -------------------------------------------------------------------------
S BARTR=BARDTB
F S BARTR=$O(^BARTR(DUZ(2),"AE",BARACDA,BARTR)) Q:BARTR\1>BARDTE Q:'+BARTR D
. S BARBL=$$GET1^DIQ(90050.03,BARTR,4,"I")
. Q:'+BARBL ; No bill on transaction
. ; IHS/SD/PKD 1.8*19 9/10/10
. ; Add sorts: VisitLocation and DOS
. S BARVISL=$$GET1^DIQ(90050.01,BARBL,108) ; VisitLoc
. I BARVISL="" S BARVISL=BARPSAT(DUZ(2),.01) ; if not listed, default to DUZ(2)
. S BARDOSV=$P(^BARBL(DUZ(2),BARBL,1),U,2) ; DOS
. ;STANDARD SORTING (NO PATNAME)
. I BARVISL="" S BARVISL="??"
. I BARDOSV="" S BARDOSV="??"
. S ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA,BARVISL,BARDOSV,BARBL,"T")=""
. D ABAL(BARBL)
Q
; ********************************************************************
;
MAIL ; EP - MAIL MESSAGE TEXT
;;A/R ACCOUNTS (PATIENTS) MONTHLY STATEMENTS
;;This is to notify you that an automatic generation
;;of statements for A/R Patient Accounts has completed.
;;..
;;Please use the Print Patient Account Statement option
;;to print the statements to a printer.
Q
; ********************************************************************
;
MANUAL ; EP
; Called from Print Adhoc Patient Account Statement AR Menu Option
; Ask user to select AR Account marked for Patient Account Statement
D ASKACCT ; Ask AR Account
Q:Y'>0
Q:'$D(BARACDA) ; No acct selected
D DATE(1) ; Ask date range AND init ^XTMP
I +BARDTB<1 Q ; Dates answered wrong
D GETHDR^BARMPAS3 ; MOVED INTO LOOP
Q:'$D(BARHDRDA)
S BARQ("RC")="LOOP^BARMPAS" ; Build tmp global with data
S BARQ("RP")="PRINT^BARMPAS3,CLEANUP^BARMPAS" ;HEAT#152220 BAR1.8*24
S BARQ("NS")="BAR" ; Namespace for variables
S BARQ("RX")="POUT^BARRUTL" ; HEAT#152220 BAR1.8*24
D GETMSG
D ^BARDBQUE ; Double queuing
;D CLEANUP^BARMPAS ; Clean-up routine 11/05/2013 LINE COMMENTED OUT: HEAT#152220 BAR1.8*24
D PAZ^BARRUTL ; Press return to continue
Q
CLEANUP K ^XTMP("BARPAS"_BARRUNDT) ; cleanup scratch global for option PRO 10/10/2013
Q
; ********************************************************************
;^XTMP("BARPAS3130904.070754",0,"DT")="2991227^3130904"
; "SCOPE")="PRO"
; "SORTBY")=1
;
;IHS/SD/AR PATCH 19 06/01/2010
GETMSG ;
; ASK USER TO INCLUDE A MESSAGE WITH REPORTS
K BARPTMSG
S BARPTMSG=""
W !!
K DIR
S DIR("A")="Add a patient statement message"
S DIR("?")="Enter up to 80 characters as a message appended to statement."
S DIR(0)="FO^0:80^"
D ^DIR
Q:Y=""
S BARPTMSG=X
Q
ASKACCT ;
; Ask user to select AR Account marked for Patient Account Statement
W !!
K DIC
S DIC("A")="Select Patient-Account: "
S DIC=90050.02
S DIC(0)="AEQM"
S DIC("S")="I $D(^BARAC(DUZ(2),""PAS"",""Y"",+Y))"
D ^DIC
Q:Y'>0
S BARACDA=+Y
Q
; ********************************************************************
;
DATE(BARMODE) ;
; Select date range
DT1 ;
S BARDTB=$$DATE^BARDUTL(1)
I BARDTB<1 Q
S BARDTE=$$DATE^BARDUTL(2)
I BARDTE<1 W ! G DT1
I BARDTE<BARDTB D G DT1
. W *7
. W !!,"The END date must not be before the START date.",!
I BARMODE>1 QUIT ;CALL W/O INIT
;--------------------MANUAL (PRO) STATEMET --------------
D NOW^%DTC
S BARRUNDT=%
S X1=DT
S X2=+15
D C^%DTC
K ^XTMP("BARPAS"_BARRUNDT)
S ^XTMP("BARPAS"_BARRUNDT,0)=X_"^"_DT_"^"_"BAR ACCOUNT STATEMENT"
S ^XTMP("BARPAS"_BARRUNDT,0,"DT")=BARDTB_"^"_BARDTE
S BARSRTBY=$$GETSRTBY() ;GET SORT-BY
S ^XTMP("BARPAS"_BARRUNDT,0,"SORTBY")=BARSRTBY ;P.OTT
S ^XTMP("BARPAS"_BARRUNDT,0,"SCOPE")="PRO"
Q
; ********************************************************************
;
LOOP ; EP
; Part of manual process
; IHS/SD/PKD 1.8*20 2/24/11 Set XTMP date headers
; If Device definition calls for Start Time, this will capture
; Run Dates rather than having them blank
I $G(BARDTB)=""!($G(BARDTE)="") Q ;Need dates
D ACCOUNT(BARACDA)
Q
; ********************************************************************
;
MARKACC ; EP
; Called from Patient Accounts for Statements AR Menu option
W !
F D Q:BARAC'>0
. W !
. K DIC,DIE,DA,DR,X,Y
. S DIC=90050.02
. S DIC(0)="AEQZM"
. S DIC("S")="I $$GET1^DIQ(90050.02,+Y,1)=9000001"
. S DIC("W")="W ?50,$$GET1^DIQ(90050.02,+Y,101)"
. D ^DIC
. S BARAC=+Y
. Q:Y'>0
. S DIE=DIC
. S DA=+Y
. S DR="101"
. D ^DIE
Q
REBUILD ;EP P.OTT
S BARSRTBY=$$GETSRTBY() ;GET SORT-BY
W !!!,"NOTE: This procedure will *collect* statements for printing."
W !,"Statements will be sorted by ",$P("Billing location, Account Number;Billing location, Patient name",";",BARSRTBY+1)
W !,"When done use the PAS>PRA menu option to print the collected statements."
W !
RBLD D NOW^%DTC
S BARRUNDT=%
D DATE(2) ; Ask date range AND *do not* init ^XTMP
I +BARDTB<1 Q ; Dates answered wrong
I BARDTE>(BARRUNDT\1) D G RBLD
. W !!,"END date cannot be a future day",!
W !
S DIR("A")="OK to start the re-build process"
S DIR("B")="NO"
S DIR(0)="Y"
D ^DIR
K DIR
I Y'=1 Q
;---------------------
S BARTMPD1=BARDTB
S BARTMPD2=BARDTE
S BARXXX=$$GETX() I BARXXX<0 D QUIT
. W !,"**WARNING: The Option Scheduling File for BAR ACCOUNT STATEMENT has not been set up."
. W !,"Cannot proceed."
. W !! H 2
S BARSRTBY=$$GETSRTBY() ;GET SORT-BY
S BARDTB=BARTMPD1
S BARDTE=BARTMPD2
D INITXTMP(BARXXX,BARDTB,BARDTE,BARSRTBY,BARRUNDT) ;P.OTT
D GETHDR^BARMPAS3
Q:'$D(BARHDRDA)
S BARHOLD=DUZ(2)
S DUZ(2)=0 F S DUZ(2)=$O(^BARAC(DUZ(2))) Q:'+DUZ(2) D
. S BARACDA=0 F S BARACDA=$O(^BARAC(DUZ(2),"PAS","Y",BARACDA)) Q:'BARACDA D ACCOUNT(BARACDA)
S DUZ(2)=BARHOLD
W !,"--- Statements collected."
S DIR("A")="Do you want to send e-mail notification"
S DIR("B")="NO"
S DIR(0)="Y"
D ^DIR
K DIR
I Y=1 D MAIL^XBMAIL("BARZ MANAGER","MAIL^BARMPAS")
D PAZ^BARRUTL ; Press return to continue
Q
ASKMODE() ;
K DIRUT,DIR,Y
S Y=$$DIR^XBDIR("S^1:Print Statement for Individual Patient;2:Collect Statements for ALL Flagged Patients","Select Statement Type ","","","","",1)
K DA
Q Y
PURGE ;
NEW BARTMP,BARTMP0,BARARR
S BARCNT=0,(BARTMP,BARTMP0)="BARPAS" F S BARTMP=$O(^XTMP(BARTMP)) Q:BARTMP="" Q:BARTMP'[BARTMP0 S BARCNT=BARCNT+1,BARARR(BARCNT)=BARTMP
I 'BARCNT W !!,"NO ENTRIES TO PURGE",!! QUIT
D LISTRUNS
I BARCNT=1 W !!,"CANNOT PURGE THE ONLY PAS RUN ON FILE.",!! QUIT
I BARCNT>2 W !,"Entries 1-",BARCNT-1," can be purged."
I BARCNT=2 W !,"Entry 1 can be purged."
S DIR("A")="OK to purge?"
S DIR("B")="NO"
S DIR(0)="Y"
D ^DIR
K DIR
I Y'=1 Q
F I=1:1:BARCNT-1 D
. W !,"PURGING ",BARARR(I)
. K ^XTMP(BARARR(I))
. Q
W !,"LAST ENTRY ",BARARR(BARCNT)," NOT PURGED."
D PAZ^BARRUTL ; Press return to continue
Q
PATNAME(BARACDA) ;P.OTT
NEW BARDFN,BARRET,BARNAM
S BARDFN=$$GET1^DIQ(90050.02,BARACDA,1.001) ; IEN to Patient file
S BARNAM=$$GET1^DIQ(9000001,BARDFN,.01)
I BARNAM="" S BARNAM="UNKN"
Q BARNAM_"^"_BARDFN ;TO SEPARATE BILLS FOR 2 PATIENTS WITH THE SAME NAME
;
;LIST EXISTING STATEENTS IN XTMP
LIST S X="BARPAS" F S X=$O(^XTMP(X)) Q:X="" Q:X'["BARPAS" W !,X
Q
GETSRTBY() ;P.OTT
NEW BARSRT,X
;BARSRTBY=0 - NO ALPHA SORTING
;BARSRTBY=1 - ALPHA SORTING (PATNAME^PATEIN)
;INTERNAL VALUES
; 1 BILLING LOC, ACCOUNT NUMBER
; 2 BILLING LOC, PATIENT NAME
S BARSRT=$P($G(^BAR(90052.06,DUZ(2),DUZ(2),20)),U,4)
I +BARSRT=0 Q 0 ;IF NOT SET: 0
I BARSRT S BARSRT=BARSRT-1 ;1,2->0,1
Q BARSRT
;
INITXTMP(X,BARDTB,BARDTE,BARSRTBY,BARRUNDT) ;P.OTT
K ^XTMP("BARPAS"_BARRUNDT)
S ^XTMP("BARPAS"_BARRUNDT,0,"DT")=BARDTB_U_BARDTE
S ^XTMP("BARPAS"_BARRUNDT,0)=X_"^"_BARDTE_"^"_"BAR ACCOUNT STATEMENT"
S ^XTMP("BARPAS"_BARRUNDT,0,"SORTBY")=BARSRTBY ;P.OTT
S ^XTMP("BARPAS"_BARRUNDT,0,"SCOPE")="PRA"
Q
LISTRUNS ;
S BARCNT=0
S BAR1="BARPAS"
F S BAR1=$O(^XTMP(BAR1)) Q:BAR1'["BARPAS" D
. S BARCNT=BARCNT+1 ; Line counter
. S BARDT=$P(BAR1,"BARPAS",2,99) ; Date of Run
. S BARRUN(BARCNT)=BARDT ; Array of runs
. S Y=BARDT
. D DD^%DT
. W !,$J(BARCNT,2),?5,Y ; Line count,date run
. I $G(^XTMP(BAR1,0,"SCOPE"))]"" W " (",$G(^XTMP(BAR1,0,"SCOPE")),") "
. S BARSRTBY=$G(^XTMP("BARPAS"_BARDT,0,"SORTBY"))+1
. I BARSRTBY W " sorted by ",$P("Billing location, Account Number;Billing location, Patient name",";",BARSRTBY)
Q
HELP ;
W !,"This parameter will allow you to choose how patient statements"
W !,"are sorted for printing. Statements will first be sorted by "
W !,"(1) billing location and then by account number, or by"
W !,"(2) billing location and then alphabetically by the patient's last name"
W !,"based on which option is selected."
W !,"If nothing is selected, the print order will default to option 1."
Q
ABAL(BARBL) ;P.OTT COLLECT BILLS WITH NONZERO BALANCE
N BARBAL
S BARBAL=$$GET1^DIQ(90050.01,BARBL,15) ;CURRENT BILL AMOUNT
Q:BARBAL'>0
I '$D(^BARBL(DUZ(2),"ABAL",BARACDA,BARBL)) Q ;HEAT#100207
S ^XTMP("BARPAS"_BARRUNDT,DUZ(2),1,BARACDA,"OB",BARBL)=""
Q
LISTALL S BARCNT=0,(BARTMP,BARTMP0)="BARPAS" F S BARTMP=$O(^XTMP(BARTMP)) Q:BARTMP="" Q:BARTMP'[BARTMP0 D
. S BARCNT=BARCNT+1
. W !,BARCNT,".",?10,BARTMP," ",$G(^XTMP(BARTMP,0))
. F X="DT","SCOPE","SORTBY","REINDEXED" W !?10,X,": ",$G(^XTMP(BARTMP,0,X))
. Q
Q
CLNUP ;
Q ;--EOR-
BARMPAS ; IHS/SD/LSL - Patient Account Statement ;
+1 ;;1.8;IHS ACCOUNTS RECEIVABLE;**2,4,5,19,20,23,24**;OCT 26, 2005;Build 69
+2 ;
+3 ; IHS/SD/LSL - 04/22/03 - V1.7 Patch 2
+4 ; IHS/SD/LSL - 12/04/04 - V17 Patch 4 - IM11692
+5 ; Modify code to allow tasked option to catch all facilities.
+6 ; IHS/SD/LSL - 02/11/04 - V1.7 Patch 5 - IM12222
+7 ; Modify MARKACC to allow marking of patient's registered
+8 ; at the parents satellite.
+9 ; IHS/SD/POTT HEAT80718 ADDED SORTING OPTION BY PATNAME ;BAR1.8*23
+10 ; IHS/SD/POTT HEAT95153 BAR1.8*23
+11 ; IHS/SD/POTT HEAT63286 added call to populate array BARPSAT ;BAR1.8*23
+12 ; IHS/SD/POTT HEAT91646 added OPTION 'PUR' & 'REB' ;BAR1.8*23
+13 ; IHS/SD/POTT HEAT106730 BAR1.8*23
+14 ; IHS/SD/POTT HEAT152220 2/11/2014 FIX PRO PRINT AND CLEANUP ;BAR1.8*24
+15 ; IHS/SD/POTT HEAT100207 FIXED AGE 2/18/2014 ;BAR1.8*24
+16 ; ********************************************************************
+17 QUIT
TASK ; EP
+1 ; Called from SCHEDULED OPTION BAR MAN ACCOUNT STATEMENT
+2 ; Start with last run date and go to Today.
+3 ; Find BAR ACCOUNT STATEMENT in Option Scheduling File
+4 NEW BARXXX
+5 DO INIT^BARUTL
+6 ;
SET BARXXX=$$GETX()
+7 IF BARXXX<0
QUIT
+8 ;GET SORT-BY
SET BARSRTBY=$$GETSRTBY()
+9 ;;BAR1.8*23
DO INITXTMP(BARXXX,BARDTB,BARDTE,BARSRTBY,BARRUNDT)
+10 ;;BAR1.8*23 HEAT #63286 added call to populate array BARPSAT
DO BARPSAT^BARUTL0
+11 SET BARHOLD=DUZ(2)
+12 SET DUZ(2)=0
FOR
SET DUZ(2)=$ORDER(^BARAC(DUZ(2)))
IF '+DUZ(2)
QUIT
Begin DoDot:1
+13 SET BARACDA=0
FOR
SET BARACDA=$ORDER(^BARAC(DUZ(2),"PAS","Y",BARACDA))
IF 'BARACDA
QUIT
DO ACCOUNT(BARACDA)
End DoDot:1
+14 SET DUZ(2)=BARHOLD
+15 DO MAIL^XBMAIL("BARZ MANAGER","MAIL^BARMPAS")
+16 QUIT
+17 ; ********************************************************************
+18 ;
GETX() ;
+1 KILL DIC,DR,DIE,DA
+2 ; Option Scheduling File
SET DIC=19.2
+3 SET X="BAR ACCOUNT STATEMENT"
+4 SET DIC(0)="ZM"
+5 DO ^DIC
+6 ;NO SETUP
IF Y<1
QUIT -1
+7 ; Option IEN
SET BARSCHED=+Y
+8 ; Option schedule freq
SET BARFREQ=$$GET1^DIQ(19.2,BARSCHED,6)
+9 SET X1=DT
+10 SET X2=-90
+11 DO C^%DTC
+12 ;Last run date
FOR
SET X=$$SCH^XLFDT(BARFREQ,X)
IF X>DT
QUIT
SET BARDTB=X
+13 ; Today
SET BARDTE=DT
+14 DO NOW^%DTC
+15 SET BARRUNDT=%
+16 SET X1=DT
+17 SET X2=+15
+18 DO C^%DTC
+19 QUIT X
ACCOUNT(BARACDA) ;
+1 ; Find Bills where the AR Account is marked for
+2 ; Patient Account Statement
+3 ;D INIT^BARUTL ; this keeps it from printing to a slave printer
+4 SET (BARBL,BARTOT,BARVISL,BARDOSV)=0
+5 ;;BAR1.8*23 HEAT63286 16-MAR-2012 added call to populate array BARPSAT
DO BARPSAT^BARUTL0
+6 ;BAR1.8*23
SET BARPATNM=$$PATNAME(BARACDA)
+7 ;NOT SORTED BY NAMES - CREATE DUMMY NAME BAR1.8*23
IF BARSRTBY=0
SET BARPATNM="X"
+8 FOR
SET BARBL=$ORDER(^BARBL(DUZ(2),"ABAL",BARACDA,BARBL))
IF '+BARBL
QUIT
Begin DoDot:1
+9 ;CURRENT BILL AMOUNT
SET BARBAL=$$GET1^DIQ(90050.01,BARBL,15)
+10 IF BARBAL'>0
QUIT
+11 ; VisitLoc
SET BARVISL=$$GET1^DIQ(90050.01,BARBL,108)
+12 ; if not listed, default to DUZ(2)
IF BARVISL=""
SET BARVISL=BARPSAT(DUZ(2),.01)
+13 ; DOS - VA format
SET BARDOSV=$PIECE(^BARBL(DUZ(2),BARBL,1),U,2)
+14 IF BARVISL=""
SET BARVISL="??"
+15 IF BARDOSV=""
SET BARDOSV="??"
+16 SET BARTOT=BARTOT+BARBAL
+17 ;NODE 1 FOR 'OB'
SET ^XTMP("BARPAS"_BARRUNDT,DUZ(2),1,BARPATNM,BARACDA,"OB",BARBL)=""
+18 ;NODE 1 FOR 'OB'
SET ^XTMP("BARPAS"_BARRUNDT,DUZ(2),1,BARPATNM,BARACDA,BARVISL,BARDOSV,"OB",BARBL)=""
+19 SET ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA,BARVISL,BARDOSV,BARBL,"A")=""
End DoDot:1
+20 ;
+21 SET ^XTMP("BARPAS"_BARRUNDT,DUZ(2),1,BARPATNM,BARACDA,"OB")=BARTOT
+22 ;
+23 ; It currently kills all previous entries if the Balance = 0
+24 IF BARTOT=0
KILL ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA)
+25 ; -------------------------------------------------------------------------
+26 ; Find bills by patient balance
+27 ; -------------------------------------------------------------------------
+28 SET BARPAT=$$GET1^DIQ(90050.02,BARACDA,1.001)
+29 SET BARBL=0
FOR
SET BARBL=$ORDER(^BARBL(DUZ(2),"APBAL",BARPAT,BARBL))
IF '+BARBL
QUIT
Begin DoDot:1
+30 ; Add sorts: VisitLocation and DOS
+31 ; VisitLoc
SET BARVISL=$$GET1^DIQ(90050.01,BARBL,108)
+32 ; if not listed, default to DUZ(2)
IF BARVISL=""
SET BARVISL=BARPSAT(DUZ(2),.01)
+33 ; DOS
SET BARDOSV=$PIECE(^BARBL(DUZ(2),BARBL,1),U,2)
+34 SET ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA,BARVISL,BARDOSV,BARBL,"P")=""
+35 QUIT
End DoDot:1
+36 ; -------------------------------------------------------------------------
+37 ; Find bills by patient
+38 ; -------------------------------------------------------------------------
+39 SET BARBL=0
FOR
SET BARBL=$ORDER(^BARBL(DUZ(2),"C",BARPAT,BARBL))
IF '+BARBL
QUIT
Begin DoDot:1
+40 SET BARBAL=$$GET1^DIQ(90050.01,BARBL,15)
+41 IF BARBAL'>0
QUIT
+42 ; IHS/SD/PKD 1.8*19 9/10/10
+43 ; Add sorts: VisitLocation and DOS
+44 ; VisitLoc
SET BARVISL=$$GET1^DIQ(90050.01,BARBL,108)
+45 ; if not listed, default to DUZ(2)
IF BARVISL=""
SET BARVISL=BARPSAT(DUZ(2),.01)
+46 ; DOS
SET BARDOSV=$PIECE(^BARBL(DUZ(2),BARBL,1),U,2)
+47 ;STANDARD SORTING (NO PATNAME)
+48 IF BARVISL=""
SET BARVISL="??"
+49 IF BARDOSV=""
SET BARDOSV="??"
+50 SET ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA,BARVISL,BARDOSV,BARBL,"P")=""
+51 DO ABAL(BARBL)
End DoDot:1
+52 ;
+53 ; -------------------------------------------------------------------------
+54 ; Find bills by transaction
+55 ; -------------------------------------------------------------------------
+56 SET BARTR=BARDTB
+57 FOR
SET BARTR=$ORDER(^BARTR(DUZ(2),"AE",BARACDA,BARTR))
IF BARTR\1>BARDTE
QUIT
IF '+BARTR
QUIT
Begin DoDot:1
+58 SET BARBL=$$GET1^DIQ(90050.03,BARTR,4,"I")
+59 ; No bill on transaction
IF '+BARBL
QUIT
+60 ; IHS/SD/PKD 1.8*19 9/10/10
+61 ; Add sorts: VisitLocation and DOS
+62 ; VisitLoc
SET BARVISL=$$GET1^DIQ(90050.01,BARBL,108)
+63 ; if not listed, default to DUZ(2)
IF BARVISL=""
SET BARVISL=BARPSAT(DUZ(2),.01)
+64 ; DOS
SET BARDOSV=$PIECE(^BARBL(DUZ(2),BARBL,1),U,2)
+65 ;STANDARD SORTING (NO PATNAME)
+66 IF BARVISL=""
SET BARVISL="??"
+67 IF BARDOSV=""
SET BARDOSV="??"
+68 SET ^XTMP("BARPAS"_BARRUNDT,DUZ(2),0,BARPATNM,BARACDA,BARVISL,BARDOSV,BARBL,"T")=""
+69 DO ABAL(BARBL)
End DoDot:1
+70 QUIT
+71 ; ********************************************************************
+72 ;
MAIL ; EP - MAIL MESSAGE TEXT
+1 ;;A/R ACCOUNTS (PATIENTS) MONTHLY STATEMENTS
+2 ;;This is to notify you that an automatic generation
+3 ;;of statements for A/R Patient Accounts has completed.
+4 ;;..
+5 ;;Please use the Print Patient Account Statement option
+6 ;;to print the statements to a printer.
+7 QUIT
+8 ; ********************************************************************
+9 ;
MANUAL ; EP
+1 ; Called from Print Adhoc Patient Account Statement AR Menu Option
+2 ; Ask user to select AR Account marked for Patient Account Statement
+3 ; Ask AR Account
DO ASKACCT
+4 IF Y'>0
QUIT
+5 ; No acct selected
IF '$DATA(BARACDA)
QUIT
+6 ; Ask date range AND init ^XTMP
DO DATE(1)
+7 ; Dates answered wrong
IF +BARDTB<1
QUIT
+8 ; MOVED INTO LOOP
DO GETHDR^BARMPAS3
+9 IF '$DATA(BARHDRDA)
QUIT
+10 ; Build tmp global with data
SET BARQ("RC")="LOOP^BARMPAS"
+11 ;HEAT#152220 BAR1.8*24
SET BARQ("RP")="PRINT^BARMPAS3,CLEANUP^BARMPAS"
+12 ; Namespace for variables
SET BARQ("NS")="BAR"
+13 ; HEAT#152220 BAR1.8*24
SET BARQ("RX")="POUT^BARRUTL"
+14 DO GETMSG
+15 ; Double queuing
DO ^BARDBQUE
+16 ;D CLEANUP^BARMPAS ; Clean-up routine 11/05/2013 LINE COMMENTED OUT: HEAT#152220 BAR1.8*24
+17 ; Press return to continue
DO PAZ^BARRUTL
+18 QUIT
CLEANUP ; cleanup scratch global for option PRO 10/10/2013
KILL ^XTMP("BARPAS"_BARRUNDT)
+1 QUIT
+2 ; ********************************************************************
+3 ;^XTMP("BARPAS3130904.070754",0,"DT")="2991227^3130904"
+4 ; "SCOPE")="PRO"
+5 ; "SORTBY")=1
+6 ;
+7 ;IHS/SD/AR PATCH 19 06/01/2010
GETMSG ;
+1 ; ASK USER TO INCLUDE A MESSAGE WITH REPORTS
+2 KILL BARPTMSG
+3 SET BARPTMSG=""
+4 WRITE !!
+5 KILL DIR
+6 SET DIR("A")="Add a patient statement message"
+7 SET DIR("?")="Enter up to 80 characters as a message appended to statement."
+8 SET DIR(0)="FO^0:80^"
+9 DO ^DIR
+10 IF Y=""
QUIT
+11 SET BARPTMSG=X
+12 QUIT
ASKACCT ;
+1 ; Ask user to select AR Account marked for Patient Account Statement
+2 WRITE !!
+3 KILL DIC
+4 SET DIC("A")="Select Patient-Account: "
+5 SET DIC=90050.02
+6 SET DIC(0)="AEQM"
+7 SET DIC("S")="I $D(^BARAC(DUZ(2),""PAS"",""Y"",+Y))"
+8 DO ^DIC
+9 IF Y'>0
QUIT
+10 SET BARACDA=+Y
+11 QUIT
+12 ; ********************************************************************
+13 ;
DATE(BARMODE) ;
+1 ; Select date range
DT1 ;
+1 SET BARDTB=$$DATE^BARDUTL(1)
+2 IF BARDTB<1
QUIT
+3 SET BARDTE=$$DATE^BARDUTL(2)
+4 IF BARDTE<1
WRITE !
GOTO DT1
+5 IF BARDTE<BARDTB
Begin DoDot:1
+6 WRITE *7
+7 WRITE !!,"The END date must not be before the START date.",!
End DoDot:1
GOTO DT1
+8 ;CALL W/O INIT
IF BARMODE>1
QUIT
+9 ;--------------------MANUAL (PRO) STATEMET --------------
+10 DO NOW^%DTC
+11 SET BARRUNDT=%
+12 SET X1=DT
+13 SET X2=+15
+14 DO C^%DTC
+15 KILL ^XTMP("BARPAS"_BARRUNDT)
+16 SET ^XTMP("BARPAS"_BARRUNDT,0)=X_"^"_DT_"^"_"BAR ACCOUNT STATEMENT"
+17 SET ^XTMP("BARPAS"_BARRUNDT,0,"DT")=BARDTB_"^"_BARDTE
+18 ;GET SORT-BY
SET BARSRTBY=$$GETSRTBY()
+19 ;P.OTT
SET ^XTMP("BARPAS"_BARRUNDT,0,"SORTBY")=BARSRTBY
+20 SET ^XTMP("BARPAS"_BARRUNDT,0,"SCOPE")="PRO"
+21 QUIT
+22 ; ********************************************************************
+23 ;
LOOP ; EP
+1 ; Part of manual process
+2 ; IHS/SD/PKD 1.8*20 2/24/11 Set XTMP date headers
+3 ; If Device definition calls for Start Time, this will capture
+4 ; Run Dates rather than having them blank
+5 ;Need dates
IF $GET(BARDTB)=""!($GET(BARDTE)="")
QUIT
+6 DO ACCOUNT(BARACDA)
+7 QUIT
+8 ; ********************************************************************
+9 ;
MARKACC ; EP
+1 ; Called from Patient Accounts for Statements AR Menu option
+2 WRITE !
+3 FOR
Begin DoDot:1
+4 WRITE !
+5 KILL DIC,DIE,DA,DR,X,Y
+6 SET DIC=90050.02
+7 SET DIC(0)="AEQZM"
+8 SET DIC("S")="I $$GET1^DIQ(90050.02,+Y,1)=9000001"
+9 SET DIC("W")="W ?50,$$GET1^DIQ(90050.02,+Y,101)"
+10 DO ^DIC
+11 SET BARAC=+Y
+12 IF Y'>0
QUIT
+13 SET DIE=DIC
+14 SET DA=+Y
+15 SET DR="101"
+16 DO ^DIE
End DoDot:1
IF BARAC'>0
QUIT
+17 QUIT
REBUILD ;EP P.OTT
+1 ;GET SORT-BY
SET BARSRTBY=$$GETSRTBY()
+2 WRITE !!!,"NOTE: This procedure will *collect* statements for printing."
+3 WRITE !,"Statements will be sorted by ",$PIECE("Billing location, Account Number;Billing location, Patient name",";",BARSRTBY+1)
+4 WRITE !,"When done use the PAS>PRA menu option to print the collected statements."
+5 WRITE !
RBLD DO NOW^%DTC
+1 SET BARRUNDT=%
+2 ; Ask date range AND *do not* init ^XTMP
DO DATE(2)
+3 ; Dates answered wrong
IF +BARDTB<1
QUIT
+4 IF BARDTE>(BARRUNDT\1)
Begin DoDot:1
+5 WRITE !!,"END date cannot be a future day",!
End DoDot:1
GOTO RBLD
+6 WRITE !
+7 SET DIR("A")="OK to start the re-build process"
+8 SET DIR("B")="NO"
+9 SET DIR(0)="Y"
+10 DO ^DIR
+11 KILL DIR
+12 IF Y'=1
QUIT
+13 ;---------------------
+14 SET BARTMPD1=BARDTB
+15 SET BARTMPD2=BARDTE
+16 SET BARXXX=$$GETX()
IF BARXXX<0
Begin DoDot:1
+17 WRITE !,"**WARNING: The Option Scheduling File for BAR ACCOUNT STATEMENT has not been set up."
+18 WRITE !,"Cannot proceed."
+19 WRITE !!
HANG 2
End DoDot:1
QUIT
+20 ;GET SORT-BY
SET BARSRTBY=$$GETSRTBY()
+21 SET BARDTB=BARTMPD1
+22 SET BARDTE=BARTMPD2
+23 ;P.OTT
DO INITXTMP(BARXXX,BARDTB,BARDTE,BARSRTBY,BARRUNDT)
+24 DO GETHDR^BARMPAS3
+25 IF '$DATA(BARHDRDA)
QUIT
+26 SET BARHOLD=DUZ(2)
+27 SET DUZ(2)=0
FOR
SET DUZ(2)=$ORDER(^BARAC(DUZ(2)))
IF '+DUZ(2)
QUIT
Begin DoDot:1
+28 SET BARACDA=0
FOR
SET BARACDA=$ORDER(^BARAC(DUZ(2),"PAS","Y",BARACDA))
IF 'BARACDA
QUIT
DO ACCOUNT(BARACDA)
End DoDot:1
+29 SET DUZ(2)=BARHOLD
+30 WRITE !,"--- Statements collected."
+31 SET DIR("A")="Do you want to send e-mail notification"
+32 SET DIR("B")="NO"
+33 SET DIR(0)="Y"
+34 DO ^DIR
+35 KILL DIR
+36 IF Y=1
DO MAIL^XBMAIL("BARZ MANAGER","MAIL^BARMPAS")
+37 ; Press return to continue
DO PAZ^BARRUTL
+38 QUIT
ASKMODE() ;
+1 KILL DIRUT,DIR,Y
+2 SET Y=$$DIR^XBDIR("S^1:Print Statement for Individual Patient;2:Collect Statements for ALL Flagged Patients","Select Statement Type ","","","","",1)
+3 KILL DA
+4 QUIT Y
PURGE ;
+1 NEW BARTMP,BARTMP0,BARARR
+2 SET BARCNT=0
SET (BARTMP,BARTMP0)="BARPAS"
FOR
SET BARTMP=$ORDER(^XTMP(BARTMP))
IF BARTMP=""
QUIT
IF BARTMP'[BARTMP0
QUIT
SET BARCNT=BARCNT+1
SET BARARR(BARCNT)=BARTMP
+3 IF 'BARCNT
WRITE !!,"NO ENTRIES TO PURGE",!!
QUIT
+4 DO LISTRUNS
+5 IF BARCNT=1
WRITE !!,"CANNOT PURGE THE ONLY PAS RUN ON FILE.",!!
QUIT
+6 IF BARCNT>2
WRITE !,"Entries 1-",BARCNT-1," can be purged."
+7 IF BARCNT=2
WRITE !,"Entry 1 can be purged."
+8 SET DIR("A")="OK to purge?"
+9 SET DIR("B")="NO"
+10 SET DIR(0)="Y"
+11 DO ^DIR
+12 KILL DIR
+13 IF Y'=1
QUIT
+14 FOR I=1:1:BARCNT-1
Begin DoDot:1
+15 WRITE !,"PURGING ",BARARR(I)
+16 KILL ^XTMP(BARARR(I))
+17 QUIT
End DoDot:1
+18 WRITE !,"LAST ENTRY ",BARARR(BARCNT)," NOT PURGED."
+19 ; Press return to continue
DO PAZ^BARRUTL
+20 QUIT
PATNAME(BARACDA) ;P.OTT
+1 NEW BARDFN,BARRET,BARNAM
+2 ; IEN to Patient file
SET BARDFN=$$GET1^DIQ(90050.02,BARACDA,1.001)
+3 SET BARNAM=$$GET1^DIQ(9000001,BARDFN,.01)
+4 IF BARNAM=""
SET BARNAM="UNKN"
+5 ;TO SEPARATE BILLS FOR 2 PATIENTS WITH THE SAME NAME
QUIT BARNAM_"^"_BARDFN
+6 ;
+7 ;LIST EXISTING STATEENTS IN XTMP
LIST SET X="BARPAS"
FOR
SET X=$ORDER(^XTMP(X))
IF X=""
QUIT
IF X'["BARPAS"
QUIT
WRITE !,X
+1 QUIT
GETSRTBY() ;P.OTT
+1 NEW BARSRT,X
+2 ;BARSRTBY=0 - NO ALPHA SORTING
+3 ;BARSRTBY=1 - ALPHA SORTING (PATNAME^PATEIN)
+4 ;INTERNAL VALUES
+5 ; 1 BILLING LOC, ACCOUNT NUMBER
+6 ; 2 BILLING LOC, PATIENT NAME
+7 SET BARSRT=$PIECE($GET(^BAR(90052.06,DUZ(2),DUZ(2),20)),U,4)
+8 ;IF NOT SET: 0
IF +BARSRT=0
QUIT 0
+9 ;1,2->0,1
IF BARSRT
SET BARSRT=BARSRT-1
+10 QUIT BARSRT
+11 ;
INITXTMP(X,BARDTB,BARDTE,BARSRTBY,BARRUNDT) ;P.OTT
+1 KILL ^XTMP("BARPAS"_BARRUNDT)
+2 SET ^XTMP("BARPAS"_BARRUNDT,0,"DT")=BARDTB_U_BARDTE
+3 SET ^XTMP("BARPAS"_BARRUNDT,0)=X_"^"_BARDTE_"^"_"BAR ACCOUNT STATEMENT"
+4 ;P.OTT
SET ^XTMP("BARPAS"_BARRUNDT,0,"SORTBY")=BARSRTBY
+5 SET ^XTMP("BARPAS"_BARRUNDT,0,"SCOPE")="PRA"
+6 QUIT
LISTRUNS ;
+1 SET BARCNT=0
+2 SET BAR1="BARPAS"
+3 FOR
SET BAR1=$ORDER(^XTMP(BAR1))
IF BAR1'["BARPAS"
QUIT
Begin DoDot:1
+4 ; Line counter
SET BARCNT=BARCNT+1
+5 ; Date of Run
SET BARDT=$PIECE(BAR1,"BARPAS",2,99)
+6 ; Array of runs
SET BARRUN(BARCNT)=BARDT
+7 SET Y=BARDT
+8 DO DD^%DT
+9 ; Line count,date run
WRITE !,$JUSTIFY(BARCNT,2),?5,Y
+10 IF $GET(^XTMP(BAR1,0,"SCOPE"))]""
WRITE " (",$GET(^XTMP(BAR1,0,"SCOPE")),") "
+11 SET BARSRTBY=$GET(^XTMP("BARPAS"_BARDT,0,"SORTBY"))+1
+12 IF BARSRTBY
WRITE " sorted by ",$PIECE("Billing location, Account Number;Billing location, Patient name",";",BARSRTBY)
End DoDot:1
+13 QUIT
HELP ;
+1 WRITE !,"This parameter will allow you to choose how patient statements"
+2 WRITE !,"are sorted for printing. Statements will first be sorted by "
+3 WRITE !,"(1) billing location and then by account number, or by"
+4 WRITE !,"(2) billing location and then alphabetically by the patient's last name"
+5 WRITE !,"based on which option is selected."
+6 WRITE !,"If nothing is selected, the print order will default to option 1."
+7 QUIT
ABAL(BARBL) ;P.OTT COLLECT BILLS WITH NONZERO BALANCE
+1 NEW BARBAL
+2 ;CURRENT BILL AMOUNT
SET BARBAL=$$GET1^DIQ(90050.01,BARBL,15)
+3 IF BARBAL'>0
QUIT
+4 ;HEAT#100207
IF '$DATA(^BARBL(DUZ(2),"ABAL",BARACDA,BARBL))
QUIT
+5 SET ^XTMP("BARPAS"_BARRUNDT,DUZ(2),1,BARACDA,"OB",BARBL)=""
+6 QUIT
LISTALL SET BARCNT=0
SET (BARTMP,BARTMP0)="BARPAS"
FOR
SET BARTMP=$ORDER(^XTMP(BARTMP))
IF BARTMP=""
QUIT
IF BARTMP'[BARTMP0
QUIT
Begin DoDot:1
+1 SET BARCNT=BARCNT+1
+2 WRITE !,BARCNT,".",?10,BARTMP," ",$GET(^XTMP(BARTMP,0))
+3 FOR X="DT","SCOPE","SORTBY","REINDEXED"
WRITE !?10,X,": ",$GET(^XTMP(BARTMP,0,X))
+4 QUIT
End DoDot:1
+5 QUIT
CLNUP ;
+1 ;--EOR-
QUIT