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

DGBTR17.m

Go to the documentation of this file.
DGBTR17 ;ALB/RFE - VOUCHER REPORT; 03/14/12
 ;;1.0;Beneficiary Travel;**20**;November 11, 2011;Build 185
 Q
EN ; Entry point
 N %,%Y,ACCOUNT,ADDRLIN,ALLOW,CCFEE,DED,DEPARTLIN,DESTLIN,DFN,DGBTDIV,DGBTDIVI,DGBTDIVN,DGBTEXCEL,DGBTQ,ECON,ENDDT,ENTRY,ERR,EQUAL,FERRIES,FACLIN
 N FIRSTPAGE,GRAND,I,II,LINEZERO,MASDATE,MASLIN,MASRATE,MEALS,MILES,MILESRATE,MILESTRAV,RAY,PAGE,PATSTATE,PATZERO,POP,PDT,SQ1,SQ2,STARTDT,TMPADD,TRIPS
 N TRIPTYP,WRTLIN,X,X2,X3,Y,ZTQUEUED
 K ^TMP("DGBTVRPT",$J)
 D CLEAN^DILF
 S X2="2$"
DIVISN ; if MED CTR DIV file set up (first record) and record does not exist, write warning and exit
 S X=$G(^DG(40.8,0)) I X="" W !,"WARNING...MEDICAL CENTER DIVISION FILE IS NOT SET UP",!,"USE THE ADT PARAMETER OPTION FILE TO SET UP DIVISION" Q
 ;  check if multi-divisional center (GL node exists and 2nd piece=1). Do lookup, if it exists-set local variables
 I $D(^DG(43,1,"GL")),$P(^("GL"),U,2) D  Q:Y'>0  Q:$D(ERR)  D MAIN,QUIT Q
 .S DGBTDIVN=$$YESNO^DGBTUTL("Do you wish to run this report for all divisions")
 .I DGBTDIVN S DGBTDIVN="ALL",(DGBTDIVI,DGBTDIV)=0 Q
 .I (($D(DIRUT))!($D(DTOUT))!($D(DUOUT))) Q
 .K DIR S DIR(0)="P^40.8:EMZ" D ^DIR K DIR
 .I (($D(DIRUT))!($D(DTOUT))!($D(DUOUT))) Q
 .S DGBTDIVN=+Y,DGBTDIVI=$P(Y,U,2)
 .D INSTIT
 I (($D(DIRUT))!($D(DTOUT))!($D(DUOUT))) D CLEAN^DILF Q
 ;  if not a multi-divisional center, default to institution name
 S DGBTDIVN=$O(^DG(40.8,0)),DGBTDIVI=$P(^DG(40.8,DGBTDIVN,0),U) D INSTIT
 Q:$D(ERR)
 D MAIN
 D QUIT
 Q
MAIN ;
 K DIR
 S DIR("A")="START DATE: ",DIR(0)="DA^2991231:NOW:EX" D ^DIR K DIR
 I ($D(DIRUT))!($D(DIROUT)) Q
 S STARTDT=Y
 S DIR("A")="END DATE: ",DIR(0)="DA^"_STARTDT_":NOW:EX" D ^DIR K DIR
 I ($D(DIRUT))!($D(DIROUT)) Q
 S ENDDT=Y
 S DGBTEXCEL=$$SELEXCEL^DGBTUTL
 I DGBTEXCEL="^" Q
 I 'DGBTEXCEL N COLWID S COLWID=132 D PRINTMSG^DGBTUTL
 D DEVICE^DGBTUTL("Beneficiary Travel Fiscal Report","MAIN1^DGBTR17(DGBTEXCEL,STARTDT,ENDDT,DGBTDIVI,DGBTDIVN,DGBTDIV)",DGBTEXCEL,132)
 I $G(DGBTQ) Q
 ;
 ;I $D(IO("Q")) D:'$D(ZTQUEUED) ^%ZISC Q
 D MAIN1(DGBTEXCEL,STARTDT,ENDDT,DGBTDIVI,DGBTDIVN,DGBTDIV)
 D:'$D(ZTQUEUED) ^%ZISC
 U IO
 Q
MAIN1(DGBTEXCEL,STARTDT,ENDDT,DGBTDIVI,DGBTDIVN,DGBTDIV) ;
 K ^TMP("DGBTVRPT",$J)
 D GETRECS
 I ($D(DIRUT))!($D(DIROUT))!($D(ERR)) Q
 I '$D(^TMP("DGBTVRPT",$J)) W !,"NO VOUCHERS FOUND" Q
 D PRINT
 Q
PRINT ;
 U IO
 I DGBTEXCEL D
 .W "NAME^ADD1^ADD2^CITY^STATE^ZIP^ID^FAC^DEP^DEST^MILES^M & L^TOTAL - 11^TOTAL - 13^CL DT^CERT^VOUCH DT^ACCOUNT^DED^CC FEE^PAYABLE"
 .Q
 N PROMPT
 S PROMPT="",PAGE=0,$P(EQUAL,"=",133)=""
 D NOW^%DTC S Y=% D DD^%DT S PDT=Y
 S FIRSTPAGE=0
 I 'DGBTEXCEL D HDR
 S SQ1=""
 F  Q:PROMPT="^"  S SQ1=$O(^TMP("DGBTVRPT",$J,SQ1)) Q:SQ1=""  S SQ2=""  D 
 .F  S SQ2=$O(^TMP("DGBTVRPT",$J,SQ1,SQ2)) Q:SQ2=""  D PRT Q:PROMPT="^"
 K ^TMP("DGBTVRPT",$J)
 I ('DGBTEXCEL),(PROMPT="^") Q
 I 'DGBTEXCEL D GTOT
 I IOST["C-" S Y=$$PAUSE^DGBTUTL(DGBTEXCEL)
 I IOST'["C-" W !,"REPORT HAS FINISHED"
 Q
GETRECS ;
 F I="CLAIMS","MILES","ALLOW","M&L","F&B","ALLOW TOT","ECON","ECON TOT","PAYABLE","1W","RT","DED","CC FEE" S GRAND(I)=0
 I DGBTDIVN'="ALL" D
 .S RAY("FACILITY NAME")=$$GET1^DIQ(4,DGBTDIV,.01)
 .S FACLIN=$G(^DIC(4,DGBTDIV,1))
 .S RAY("FACILITY ADDR 1")=$P(FACLIN,"^")
 .S RAY("FACILITY ADDR 2")=$P(FACLIN,"^",2)
 .S RAY("FACILITY CITY")=$P(FACLIN,"^",3)
 S PATSTATE=$$GET1^DIQ(4,DGBTDIV,.02,"I")
 S RAY("FACILITY STATE")=$$GET1^DIQ(5,PATSTATE,1)
 S RAY("FACILITY ZIP")=$$GET1^DIQ(4,DGBTDIV,1.04)
 S ENTRY=$O(^DGBT(392,"D",STARTDT),-1)
 F  S ENTRY=$O(^DGBT(392,"D",ENTRY)) Q:ENTRY=""  Q:ENTRY>ENDDT  D
 .S I=""
 .F  S I=$O(^DGBT(392,"D",ENTRY,I)) Q:I=""  I $$FAC(I),($$GET1^DIQ(392,I,56,"I")="M"),'($$GET1^DIQ(392,I,45.2,"I")) D REC
 Q
QUIT ;
 K ^TMP("DGBTVRPT",$J)
 D CLEAN^DILF
 Q
REC ;
 I DGBTDIVN="ALL" D
 .S DGBTDIVI=$$GET1^DIQ(40.8,$$GET1^DIQ(392,I,11,"I"),.01),DGBTDIV=$$GET1^DIQ(40.8,$$GET1^DIQ(392,I,11,"I"),.07,"I")
 .S RAY("FACILITY NAME")=$$GET1^DIQ(4,DGBTDIV,.01)
 .S FACLIN=$G(^DIC(4,DGBTDIV,1))
 .S RAY("FACILITY ADDR 1")=$P(FACLIN,"^")
 .S RAY("FACILITY ADDR 2")=$P(FACLIN,"^",2)
 .S RAY("FACILITY CITY")=$P(FACLIN,"^",3)
 S LINEZERO=^DGBT(392,I,0)
 S DFN=$P(LINEZERO,"^",2)
 S PATZERO=$G(^DPT(DFN,0))
 S SQ1=RAY("FACILITY NAME")_"^"_$P(I,".")_"^"_$P(PATZERO,",")
 S SQ2=$O(^TMP("DGBTVRPT",$J,SQ1,""),-1)+1
 S GRAND("CLAIMS")=GRAND("CLAIMS")+1
 S CCFEE=$$GET1^DIQ(392,I,55)
 S RAY("NAME")=$P(PATZERO,"^")
 S WRTLIN=$P(PATZERO,"^")
 S TMPADD=$$GET1^DIQ(2,DFN,.12105)
 S ADDRLIN=$G(^DPT(DFN,$S(TMPADD="YES":.121,1:.11)))
 S MASLIN=$$MASLIN
 F II=1:1:4 S WRTLIN=WRTLIN_"^"_$P(ADDRLIN,"^",II)
 F II=1:1:3 S RAY("PAT ADDR "_II)=$P(ADDRLIN,"^",II)
 S RAY("PAT CITY")=$P(ADDRLIN,"^",4)
 S PATSTATE=$$GET1^DIQ(2,DFN,$S(TMPADD="YES":.1215,1:.115),"I")
 S RAY("PAT STATE")=$$GET1^DIQ(5,PATSTATE,1)
 S RAY("PAT ZIP")=$$GET1^DIQ(2,DFN,$S(TMPADD="YES":.1216,1:.116))
 S RAY("SOCIAL SECURITY")=$P(PATZERO,"^",9)
 S RAY("FISCAL SYMBOL")=$P(MASLIN,"^",4)
 S DEPARTLIN=$G(^DGBT(392,I,"D"))
 F II=1:1:3 S RAY("DEPARTURE "_II)=$P(DEPARTLIN,"^",II)
 S RAY("DEPARTURE CITY")=$P(DEPARTLIN,"^",4)
 S PATSTATE=$$GET1^DIQ(392,I,24.1,"I")
 S RAY("DEPARTURE STATE")=$$GET1^DIQ(5,PATSTATE,1)
 S RAY("DEPARTURE ZIP")=$$GET1^DIQ(392,I,24.2)
 S DESTLIN=$G(^DGBT(392,I,"T"))
 F II=1:1:3 S RAY("DESTINATION "_II)=$P(DESTLIN,"^",II)
 S RAY("DESTINATION CITY")=$P(DESTLIN,"^",4)
 S PATSTATE=$$GET1^DIQ(392,I,28.1,"I")
 S RAY("DESTINATION STATE")=$$GET1^DIQ(5,PATSTATE,1)
 S RAY("DESTINATION ZIP")=$$GET1^DIQ(392,I,28.2)
 S MILES=$G(^DGBT(392,I,"M"))
 S (MILESTRAV,RAY("MILES TRAVELED"))=$P(MILES,"^")*$P(MILES,"^",2)
 S GRAND("MILES")=GRAND("MILES")+MILESTRAV
 S (MILESRATE,RAY("MILES RATE"))=$P(MASLIN,"^",3)
 S ALLOW=(MILESTRAV*MILESRATE)
 S RAY("MILEAGE ALLOWANCE")=$$DLRAMT(ALLOW)
 S GRAND("ALLOW")=GRAND("ALLOW")+ALLOW
 S MEALS=$P(MILES,"^",4)
 S RAY("MEALS LODGING")=$$DLRAMT(MEALS)
 S GRAND("M&L")=GRAND("M&L")+MEALS
 S FERRIES=$P(MILES,"^",5)
 S RAY("FERRIES")=$$DLRAMT(FERRIES)
 S GRAND("F&B")=GRAND("F&B")+FERRIES
 S RAY("MILEAGE TOTAL")=$$DLRAMT(ALLOW+MEALS+FERRIES)
 S GRAND("ALLOW TOT")=GRAND("ALLOW TOT")+ALLOW+MEALS+FERRIES
 S ECON=$P(LINEZERO,"^",8)
 S RAY("ECONOMICAL")=$$DLRAMT(ECON)
 S GRAND("ECON")=GRAND("ECON")+ECON
 S RAY("TRANS TOTAL")=$$DLRAMT(MEALS+ECON)
 S GRAND("ECON TOT")=GRAND("ECON TOT")+MEALS+ECON
 S RAY("PAYABLE")=$$DLRAMT($P(LINEZERO,U,10))
 S GRAND("PAYABLE")=GRAND("PAYABLE")+$P(LINEZERO,U,10) S RAY("CLAIM DATE")=$$FMTE^XLFDT(I)
 I DGBTEXCEL S RAY("CLAIM DATE")=$P(RAY("CLAIM DATE"),"@")
 S RAY("PAYEE SIGNATURE")="" ; Future use
 S RAY("VOUCHER DATE")=$$GET1^DIQ(392,I,13)
 S RAY("CERT OFFICIAL")=$$GET1^DIQ(392,I,12)
 S RAY("REMARKS")=$TR($G(^DGBT(392,I,"R")),"^","")
 S ACCOUNT=$$GET1^DIQ(392,I,6,"I")
 S RAY("ACCOUNT")=$$GET1^DIQ(392.3,ACCOUNT,2)
 S RAY("COMMON CARRIER FEE")=$$DLRAMT(CCFEE)
 S GRAND("CC FEE")=GRAND("CC FEE")+CCFEE
 S RAY("ACC DED")=$$DLRAMT($P(LINEZERO,U,9))
 D TOTMONTH Q:$D(ERR)
 S RAY("ONE WAY")=TRIPS(1)
 S RAY("ROUND TRIP")=TRIPS(2)
 S RAY("DEDUCTIBLE")=$$DLRAMT(DED)
 S GRAND("1W")=GRAND("1W")+TRIPS(1)
 S GRAND("RT")=GRAND("RT")+TRIPS(2)
 S GRAND("DED")=GRAND("DED")+DED
 S WRTLIN=RAY("NAME")_"^"_RAY("PAT ADDR 1")_"^"_RAY("PAT ADDR 2")_"^"_RAY("PAT ADDR 3")_"^"_RAY("PAT CITY")_"^"_RAY("PAT STATE")_"^"_RAY("PAT ZIP")
 S WRTLIN=WRTLIN_"^"_RAY("SOCIAL SECURITY")_"^"_RAY("FACILITY NAME")_"^"_RAY("FACILITY ADDR 1")_"^"_RAY("FACILITY ADDR 2")_"^"_RAY("FACILITY CITY")
 S WRTLIN=WRTLIN_"^"_RAY("FACILITY STATE")_"^"_RAY("FACILITY ZIP")_"^"_RAY("FISCAL SYMBOL")_"^"_RAY("DEPARTURE 1")_"^"_RAY("DEPARTURE 2")
 S WRTLIN=WRTLIN_"^"_RAY("DEPARTURE 3")_"^"_RAY("DEPARTURE CITY")_"^"_RAY("DEPARTURE STATE")_"^"_RAY("DEPARTURE ZIP")_"^"_RAY("DESTINATION 1")
 S WRTLIN=WRTLIN_"^"_RAY("DESTINATION 2")_"^"_RAY("DESTINATION 3")_"^"_RAY("DESTINATION CITY")_"^"_RAY("DESTINATION STATE")_"^"_RAY("DESTINATION ZIP")
 S WRTLIN=WRTLIN_"^"_RAY("MILES TRAVELED")_"^"_RAY("MILES RATE")_"^"_RAY("MILEAGE ALLOWANCE")_"^"_RAY("MEALS LODGING")_"^"_RAY("FERRIES")
 S WRTLIN=WRTLIN_"^"_RAY("MILEAGE TOTAL")_"^"_RAY("ECONOMICAL")_"^"_RAY("TRANS TOTAL")_"^"_RAY("PAYABLE")_"^"_RAY("CLAIM DATE")_"^"_RAY("CERT OFFICIAL")
 S WRTLIN=WRTLIN_"^^"_RAY("VOUCHER DATE")_"^"_RAY("REMARKS")_"^"_RAY("ACCOUNT")_"^"_RAY("COMMON CARRIER FEE")_"^"_RAY("ONE WAY")_"^"_RAY("ROUND TRIP")
 S WRTLIN=WRTLIN_"^"_RAY("DEDUCTIBLE")_U_RAY("ACC DED")
 S ^TMP("DGBTVRPT",$J,SQ1,SQ2)=WRTLIN
 Q
FAC(J) ;
 I DGBTDIVN="ALL" Q 1
 Q $$GET1^DIQ(392,J,11,"I")=DGBTDIVN
MASLIN() ;
 S MASRATE=""
 I $D(^DG(43.1,"B",$P(I,"."))) S MASRATE=$O(^DG(43.1,$P(I,".","")))
 E  S MASDATE=$O(^DG(43.1,"B",$P(I,".")),-1) I MASDATE'="" S MASRATE=$O(^DG(43.1,"B",MASDATE,""))
 I MASRATE="" Q ""
 Q $G(^DG(43.1,MASRATE,"BT"))
TOTMONTH ;
 N DTRAY
 F II=0,1,2 S TRIPS(II)=0
 S DED=0
 S II=$O(^DGBT(392,"C",DFN,$E(I,1,5)_"00"),-1)
 F  S II=$O(^DGBT(392,"C",DFN,II)) Q:II=""  Q:$P(II,".")'<$P(I,".")  D
 .I '$$FAC(II) Q
 .Q:$D(^DGBT(392,II,"C"))
 .I $D(DTRAY($P(II,"."))) Q
 .I $$GET1^DIQ(392,II,45.2,"I") Q  ;'=0 Q
 .I $$GET1^DIQ(392.3,$$GET1^DIQ(392,II,6,"I"),2)'=829 Q
 .S DTRAY($P(II,"."))=""
 .S DED=DED+$$GET1^DIQ(392,II,9)
 .S TRIPTYP=+$$GET1^DIQ(392,II,31,"I")
 .S TRIPS(TRIPTYP)=TRIPS(TRIPTYP)+1
 Q 
INSTIT ;  check for pointer to institution file and for address information on institution
 S DGBTDIV=$$GET1^DIQ(40.8,DGBTDIVN,.07,"I")
 Q
 ;
PRT ;
 S WRTLIN=^TMP("DGBTVRPT",$J,SQ1,SQ2)
 I DGBTEXCEL D  Q
 .W !,$P(WRTLIN,U),U,$P(WRTLIN,U,2),U,$P(WRTLIN,U,3),U,$P(WRTLIN,U,5),U,$P(WRTLIN,U,6),U,$P(WRTLIN,U,7),U,$P(WRTLIN,U,8),U,$P(WRTLIN,U,9),U
 .W $P(WRTLIN,U,21),U,$P(WRTLIN,U,27),U,$P(WRTLIN,U,28),U,$P(WRTLIN,U,31),U,$P(WRTLIN,U,33),U,$P(WRTLIN,U,35),U,$P(WRTLIN,U,37),U
 .W $P(WRTLIN,U,38),U,$P(WRTLIN,U,40),U,$P(WRTLIN,U,42),U,$P(WRTLIN,U,47),U,$P(WRTLIN,U,43),U,$P(WRTLIN,U,36)
 I (($Y+11)>IOSL)&(FIRSTPAGE)&('DGBTEXCEL) D  Q:PROMPT[U
 .I ($E(IOST,1)="C"),(IOSL'[99) D  Q:PROMPT[U
 ..K DIR
 ..S DIR("A")="PRESS RETURN TO CONTINUE OR '^' TO STOP....",DIR(0)="FAO" D ^DIR S PROMPT=Y K DIR
 .D HDR
 S FIRSTPAGE=1
 W !,$P(WRTLIN,U),?32,$P(WRTLIN,U,8),?45,$P(WRTLIN,U,37),?67,$P(WRTLIN,U,40),?81,$P(WRTLIN,U,38),?118,$P(WRTLIN,U,42)
 W !,?5,$P(WRTLIN,U,2)," ",$P(WRTLIN,U,3)," ",$P(WRTLIN,U,4)
 W !,?5,$P(WRTLIN,U,5),?22,$P(WRTLIN,U,6),?26,$P(WRTLIN,U,7),?38,$P(WRTLIN,U,9)," ",$P(WRTLIN,U,10)
 I $P(WRTLIN,U,11)'="" W !,?5,$P(WRTLIN,U,11)," ",$P(WRTLIN,U,12)," ",$P(WRTLIN,U,13)," ",$P(WRTLIN,U,14)," ",$P(WRTLIN,U,15)
 I $P(WRTLIN,U,11)="" W !,?5,$P(WRTLIN,U,12)," ",$P(WRTLIN,U,13)," ",$P(WRTLIN,U,14)," ",$P(WRTLIN,U,15)
 W !,?5,$P(WRTLIN,U,16)," ",$P(WRTLIN,U,17)," ",$P(WRTLIN,U,18)
 W !,?5,$P(WRTLIN,U,19)," ",$P(WRTLIN,U,20)," ",$P(WRTLIN,U,21)
 W !,?5,$P(WRTLIN,U,22)," ",$P(WRTLIN,U,23)," ",$P(WRTLIN,U,24)
 W !,?5,$P(WRTLIN,U,25)," ",$P(WRTLIN,U,26)," ",$P(WRTLIN,U,27)
 W !,?5,$P(WRTLIN,U,28),?11,$P(WRTLIN,U,29),?18,$P(WRTLIN,U,30),?30,$P(WRTLIN,U,31),?42,$P(WRTLIN,U,32),?54,$P(WRTLIN,U,33),?67,$P(WRTLIN,U,34)
 W ?79,$P(WRTLIN,U,35),?90,$P(WRTLIN,U,36),?102,$P(WRTLIN,U,44),?106,$P(WRTLIN,U,45),?110,$P(WRTLIN,U,46),?121,$P(WRTLIN,U,43)
 W !,?5,$P(WRTLIN,U,41),?87,$P(WRTLIN,U,15)
 Q
HDR ;
 S PAGE=PAGE+1
 W @IOF
 W "BT ELECTRONIC VOUCHER REPORT      PRINT DATE: ",PDT,?(126-$L(PAGE)),"PAGE ",PAGE
 W !,$$FMTE^XLFDT(STARTDT)," TO ",$$FMTE^XLFDT(ENDDT)
 W !,"DIVISION: ",$S(DGBTDIVN="ALL":"ALL",1:DGBTDIVI)
 W !,$E(EQUAL,1,127)
 W !,"NAME",?32,"SSN",?45,"CLAIM DATE",?67,"ENTRY DATE",?81,"CLERK",?118,"ACCT"
 W !,?5,"ADDRESS"
 W !?5,"CITY",?22,"ST",?26,"ZIP",?38,"FACILITY"
 W !,?5,"FACILITY ADDRESS"
 W !,?5,"DEPARTURE"
 W !,?5,"DEPARTURE"
 W !,?5,"DESTINATION"
 W !,?5,"DESTINATION"
 W !,?5,"MILES",?11,"RATE",?18,"ALLOW",?30,"M&L",?42,"F&B",?54,"TOTAL",?67,"ECON",?79,"TOTAL",?90,"PAYABLE",?102,"1W",?106,"RT",?110,"DED",?121,"CC FEE"
 W !,?5,"REMARKS",?87,"FISCAL SYMBOLS"
 W !,$E(EQUAL,1,127)
 Q
GTOT ;
 W !,$E(EQUAL,1,127)
 W !,"GRAND TOTALS"
 W !,"MILES",?7,"CLMS",?14,"ALLOW",?26,"M&L",?38,"F&B",?50,"TOTAL",?63,"ECON",?75,"TOTAL",?86,"PAYABLE",?98,"1W",?102,"RT",?106,"DED",?117,"CC FEE"
 W !,GRAND("MILES"),?7,GRAND("CLAIMS"),?14,$$DLRAMT(GRAND("ALLOW")),?26,$$DLRAMT(GRAND("M&L")),?38,$$DLRAMT(GRAND("F&B")),?50,$$DLRAMT(GRAND("ALLOW TOT"))
 W ?63,$$DLRAMT(GRAND("ECON")),?75,$$DLRAMT(GRAND("ECON TOT")),?86,$$DLRAMT(GRAND("PAYABLE")),?98,GRAND("1W"),?102,GRAND("RT")
 W ?106,$$DLRAMT(GRAND("DED")),?117,$$DLRAMT(GRAND("CC FEE"))
 W !,$E(EQUAL,1,127)
 Q
DLRAMT(X) ;
 D COMMA^%DTC I 'DGBTEXCEL Q $TR(X," ","")
 Q $TR(X," ,$","")