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

BARDMRQN.m

Go to the documentation of this file.
BARDMRQN ;IHS/OIT/FCJ - DEBT MANAGEMENT-QUE LETTER REPORT
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**22,23**;OCT 26, 2005;Build 38
 ;New routine 5-12-2011 for Debt Letter Management
 ;
 ;This report shows recently printed letters by cycle, Insurer and detail
 ;
 ;CODE CLONED FROM BARDMRQ, CALLS  CALC^BARDMRQC ;P.OTT
 ;MAY 2013 NOHEAT P.OTTIS ADDED LOOP TO DISPLAY LIST AFTER RETURN FROM SELD
 ;AUG 2013 NOHEAT P.OTTIS ADDED SUMMARIES (# OF PRINTED BILLS - BARTOT1, TOT $$$ - BARTOT2)
 ;
ST ;
 ;
 ;
 S BMCQ=0,BARRPT="Q",BARSEQ=0
 D SELC G:$D(DIRUT) XIT
 D SELI G:$D(DIRUT) XIT
 D:'$D(BARDCI) SELA G:$D(DIRUT) XIT
 D CALC^BARDMRQC
 G:$G(BARQ) XIT
TRT ;<--------------
 S BARSEQ=0
 D PRINT
 I (BMCQ=1)&(BARCY'="A") G XIT
 D SELD
 I Y<1 G XIT
 G TRT ;-----> ;P.OTT MAY 2013 
XIT ;
 K DIR
 K BARL
 Q
 ;
SELC ;SELECT CYCLE
 S DIR(0)="S^1:CYCLE 1;2:CYCLE 2;3:CYCLE 3;4:CYCLE 4;A:ALL"
 S DIR("A")="Select Cycle to View"
 S DIR("B")="All",DIR("L")=""
 S DIR("?")="Enter 1, 2, 3, 4 or A to view or all cycles"
 S DIR("?",1)="   1 - CYCLE 1"
 S DIR("?",2)="   2 - CYCLE 2"
 S DIR("?",3)="   3 - CYCLE 3"
 S DIR("?",4)="   4 - CYCLE 4"
 D ^DIR
 Q:$D(DIRUT)
 S BARCY=Y,BARCYN=Y(0)
 K DIR Q
 ;
SELI ;SELECT INSURANCE TYPE
 S DIC="^BAR(90052.06,"_DUZ(2)_","_DUZ(2)_",19,"
 S DIC(0)="AEQZ",DIC("A")="View by Insurer Type: "
 D ^DIC
 Q:$D(DUOUT)
 S:$G(Y(0)) BARDCI=$$GET1^DIQ(90053.03,Y(0),".01","E")
 I $G(BARDCI)["NON-BEN" S BARDCI="PATIENT"  ;non-bens are listed under PATIENT in ^TMP("BARDMQN",$J) global
 K DIC,DA
 Q
 ;
SELA ;SELECT ACCOUNT
 S DIC="^BARAC("_DUZ(2)_","
 S DIC(0)="AEQZ",DIC("A")="View by Account: "
 S DIC("S")="I $P(^(0),U,7)=""Y"""
 D ^DIC
 Q:$D(DUOUT)
 I $G(Y(0)) S BARDAC=$P(Y,U),BARDCA=$$VAL^XBDIQ1(90050.02,BARDAC,.01)
 K DIC,DA
 Q
SELD ;SELECT DETAIL
 S BARSEQ=$G(^TMP("BARDM",$J,"QN"),0)
 I 'BARSEQ W !!,"** NO DATA TO LIST **" Q
 S DIR(0)="Y"
 S DIR("A")="Show Detail"
 S DIR("B")="N"
 W ! D ^DIR
 Q:Y=0
 I Y="^" S Y=-1 Q  ;P.OTT
 K DIR
 S DIR(0)="NO^1:"_BARSEQ
 S DIR("A")="What sequence number"
 D ^DIR
 I Y>0 S BARSEQ=Y D
 . D RRDT^BARDMU
 . S BARDL=$P(^TMP("BARDM",$J,"QN",BARSEQ),U),BARDIT=$P(^(BARSEQ),U,2),BARDI=$P(^(BARSEQ),U,3)
 . D HDR2,DET
 K DIR
 Q
PRINT ;
 D HDR
 S BARGTOT1=0,BARGTOT2=0 ;GRAND TOTALS # OF LETTERS;AMOUNT ;P.OTT
 I BARCY="A" D
 . F BARDL="CYCLE 1","CYCLE 2","CYCLE 3","CYCLE 4" Q:$G(BARDLQ)  D TOT
 . D GTOT ;-----------P.OTT AUG 2013
 E  S BARDL=BARCYN D TOT
 Q
HDR ;
 W @IOF
 I $G(BARMODE)="B" D
 . N BARTMP
 . I $G(BARBAT) D
 . . S BARTMP=$G(^BARDMLG(DUZ(2),BARBAT,0))
 . . W !,"Printed letters in batch ",$$DATE($G(BARTMP))
  I $G(BARMODE)="D",$G(BARFROM),$G(BARTO) D
 . W !,"Printed letters in time period ",$$DATE($G(BARFROM))," - ",$$DATE($G(BARTO))
 . ;>S Y=2690720.163 D DD^%DT W Y ;JUL 20, 1969@1630
 W !,"SEQ",?6,"CYCLE",?13,"INS TYPE/INS-ACCOUNT",?55,"# OF BILLS",?69,"AMOUNT",!
 F I=1:1:80 W "-"
 Q
HDR2 ;
 S BARPG=BARPG+1
 W @IOF,!,BARRDT,?23,"Debt Letter Print Report",?70,"PAGE: ",BARPG
 W !!,"A/R PARENT LOCATION: ",BARPSAT(DUZ(2),.01)
 W ?65,BARDL
 W !,"A/R ACCOUNT: ",BARDI,?62,"PERIOD: ",BARPCD($P(BARDL," ",2))," Days"
 W ! F I=1:1:80 W "="
 W !,?40,"SERVICE",?49,"BILLED",?60,"BILLED"
 W !,?2,"HRN",?8,"BILL #",?16,"PATIENT",?40,"DATE",?49,"DATE",?60,"AMOUNT",?72,"BALANCE"
 W ! F I=1:1:80 W "-"
 Q
TOT ;PRINT TOTALS
 I $P($G(^TMP("BARDM",$J,"QN",BARDL)),U)=0 W !!,BARDL," Does not contain any queued Letters" S BMCQ=1 Q
 S BARTOT1=0,BARTOT2=0 ;# OF LETTERS;AMOUNT ;P.OTT
 S BARDIT=0  F  S BARDIT=$O(^TMP("BARDM",$J,"QN",BARDL,BARDIT)) Q:BARDIT=""  D  Q:$G(BARDLQ)
 .S BARDI=0 F  S BARDI=$O(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI)) Q:BARDI=""  D  Q:$G(BARDLQ)
 ..I $D(BARDCA) Q:BARDI'=BARDCA
 ..I $D(BARDCI) Q:BARDIT'=BARDCI
 ..S BARSEQ=BARSEQ+1,BARDITI=BARDIT_"/"_BARDI
 .. S ^TMP("BARDM",$J,"QN")=BARSEQ ;P.OTT 4/11
 ..W !,BARSEQ,?5,BARDL,?13,$E(BARDITI,1,42),?55,$J($P(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI),U),7)
 .. S BARTOT1=BARTOT1+$P(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI),U)
 ..S X=$P(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI),U,3)
 .. S BARTOT2=BARTOT2+X
 .. D COMMA^%DTC W ?66,$J(X,12)
 ..S ^TMP("BARDM",$J,"QN",BARSEQ)=BARDL_U_BARDIT_U_BARDI_U_$E(L,7)
 ..I $Y>(IOSL-6) W ! D RTRN^BARDMU Q:$G(BARDLQ)  D HDR
 ;-----------P.OTT AUG 2013
 I $Y>(IOSL-6) W ! D RTRN^BARDMU Q:$G(BARDLQ)  D HDR
 W !,?55,"   ====",?66,"==========="
 W !,"-- TOTAL:"
 W ?55,$J(BARTOT1,7),?65,$J(BARTOT2,12,2)
 S BARGTOT1=BARGTOT1+BARTOT1
 S BARGTOT2=BARGTOT2+BARTOT2
 W !
 Q
GTOT W !,?55,"   ====",?66,"==========="
 W !,"-- GRAND TOTAL:"
 W ?55,$J(BARGTOT1,7),?65,$J(BARGTOT2,12,2)
 W !
 Q
DET ;DETAIL
 S BARDLQ=""
 S BARBIL=0  F  S BARBIL=$O(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI,BARBIL)) Q:BARBIL=""  D  Q:$G(BARDLQ)
 . S DFN=$P(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI,BARBIL),U),BARHRN=$P(^AUPNPAT(DFN,41,DUZ(2),0),U,2),BARPAT=$P(^DPT(DFN,0),U)
 . S BARDT=$P(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI,BARBIL),U,2)
 . S BARSDT=$E(BARDT,4,5)_"/"_$E(BARDT,6,7)_"/"_$E(BARDT,2,3)
 . S BARDT=$P(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI,BARBIL),U,3)
 . S BARBDT=$E(BARDT,4,5)_"/"_$E(BARDT,6,7)_"/"_$E(BARDT,2,3)
 . W !,BARHRN,?7,BARBIL,?16,$E(BARPAT,1,24),?40,BARSDT,?49,BARBDT
 . S X=$P(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI,BARBIL),U,4) W ?58,$J(X,10,2) ;D COMMA^%DTC W 
 . S X=$P(^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI,BARBIL),U,5) W ?70,$J(X,10,2) ;D COMMA^%DTC W ?60,X
 . I $Y>(IOSL-6) W ! D RTRN^BARDMU Q:$G(BARDLQ)  D HDR2
 Q:$G(BARDLQ)
 W !,?58,"----------",?70,"----------"
 S TMP=^TMP("BARDM",$J,"QN",BARDL,BARDIT,BARDI)
 W !,"TOTAL",?38,$P(TMP,U),"  Bill(s)"
 S X=$P(TMP,U,2) W ?58,$J(X,10,2)
 S X=$P(TMP,U,3) W ?70,$J(X,10,2)
 W ! D RTRN^BARDMU Q:$G(BARDLQ)
 Q
DATE(Y) ;
 S Y=Y\1 D DD^%DT ;JUL 20, 1969@1630 
 Q $P(Y,"@") ;
 ;---EOR--