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

ACHSVUR2.m

Go to the documentation of this file.
ACHSVUR2 ; IHS/OIT/FCJ - VENDOR USAGE REPORT FOR One Vendor;     [ 10/31/2003  12:12 PM ]
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**26**;JUN 11, 2001;Build 43
 ;3.1*26  IHS/OIT/FCJ NEW RTN
 ;Allows selection of one vendor and data to be saved to a file.
 ;
 ;
 S ACHSIO=IO
 K ^TMP($J),^TMP("ACHSVUR2",$J)
BDT ; Enter beginning date.
 S ACHSBDT=$$DATE^ACHS("B","Vendor Usage","ISSUE")
 G K:$D(DUOUT)!$D(DTOUT)!(ACHSBDT<1)
EDT ; Enter the ending date.
 S ACHSEDT=$$DATE^ACHS("E","Vendor Usage","ISSUE")
 G BDT:$D(DUOUT),K:$D(DTOUT)!(ACHSEDT<1),EDT:$$EBB^ACHS(ACHSBDT,ACHSEDT)
DOCS ; Select type of docs to print.
 S ACHSRPT=$$DIR^XBDIR("S^1:ALL documents;2:OPEN documents only","Print which documents","1","","","^D HELP^ACHS(""H1"",""ACHSVUR2"")",2)
 G EDT:$D(DUOUT),K:$D(DTOUT)
 G DOCS:$D(DUOUT),K:$D(DTOUT)
VEND ;  Select one vendor.
 S DIC(0)="AEQMZ",DIC="^AUTTVNDR(",DIC("A")="Enter Provider/Vendor:  "
 S:DIC(0)["L" DLAYGO=9999999.11
 D ^DIC
 K DIC,DLAYGO
 G DOCS:Y=-1
 S ACHSVIEN=+Y
 S ACHSVNAM=$P(^AUTTVNDR(ACHSVIEN,0),U)
FILE ;CREATE A FILE
 S %=$$DIR^XBDIR("Y","Create a file","N","","","^D HELP^ACHS(""H2"",""ACHSVUR2"")",2)
 G VEND:$D(DUOUT),K:$D(DTOUT)
 S ACHSFIL=$S(%:"Y",1:"N")
DEV ; Select device for report.
 W !
 S %=$$PB^ACHS
 I %=U!$D(DTOUT)!$D(DUOUT) D K Q
 I %="B" D VIEWR^XBLM("CALC^ACHSVUR2"),EN^XBVK("VALM") G KILL
 K IOP,%ZIS
 S %ZIS="PQ"
 D ^%ZIS,SLV^ACHSFU:$D(IO("S"))
 K %ZIS
 I POP W !,*7,"No device specified." D HOME^%ZIS G K
 I '$D(IO("Q")) D CALC G KILL
 K IO("Q")
 I $E(IOST)'="P" W *7,!,"Please queue to printers only." G DEV
 S ZTIO="",ACHSQIO=ION_";"_IOST_";"_IOM_";"_IOSL,ZTRTN="CALC^ACHSVUR2",ZTDESC="CHS Vendor Report, "_ACHSRPT_", "_$$FMTE^XLFDT(ACHSBDT)_" to "_$$FMTE^XLFDT(ACHSEDT)
 F %="ACHSVIEN","ACHSVNAM","ACHSHRN","ACHSDOB","ACHSQIO","ACHSBDT","ACHSRPT","ACHSEDT" S ZTSAVE(%)=""
 D ^%ZTLOAD
 G:'$D(ZTSK) DEV
KILL ; Kill vars, close device, quit.
 I ACHSFIL="Y" D FILSAV
 X:$D(IO("S")) ACHSPPC
 K DA,DFN,ZTSK,^TMP($J,"ACHSVUR2")
 K ^TMP("ACHSVUR2",$J)
 D ERPT^ACHS,EN^XBVK("ACHS"),^ACHSVAR:'$D(ZTQUEUED)
K ; Kill vars, close device, quit.
 K ACHSAMT,ACHSVIEN,ACHSVNAM,ACHSHRN,ACHSDOB,ACHSBDT,ACHSEDT,ACHSIO,ACHSQIO,ACHSRPT,DTOUT,DUOUT,ZTSK
 D ^%ZISC
 Q
 ;
CALC ;EP - TaskMan.
 D FC^ACHSUF
 I $D(ACHSERR),ACHSERR=1 G K
 S ACHSTRDT=ACHSBDT-1
 K ^TMP($J,"ACHSVUR2")
 ;
TRDT ; Loop thru transaction date x-ref.
 S ACHSTRDT=$O(^ACHSF(DUZ(2),"TB",ACHSTRDT))
 G PRINT:+ACHSTRDT=0!(+ACHSTRDT>ACHSEDT)
 S ACHSTYPE=""
 ;
TRTYPE ; Loop thru transaction type.
 S ACHSTYPE=$O(^ACHSF(DUZ(2),"TB",ACHSTRDT,ACHSTYPE))
 G TRDT:ACHSTYPE="",TRTYPE:ACHSTYPE'="I"
 S DA=0
 ;
TRANS ; Loop thru transactions, compile report data.
 S (ACHSDOCN,ACHSVPTR,ACHSFY,ACHSSTS,DFN,ACHSSCPT,ACHSSC,ACHSCLRK,ACHSDOC,ACHSBLNK)=""
 ;
 S DA=$O(^ACHSF(DUZ(2),"TB",ACHSTRDT,ACHSTYPE,DA))
 G TRDT:+DA=0,TRDT:'$D(^ACHSF(DUZ(2),"D",DA,0))
 S ACHSDOCN=$P(^ACHSF(DUZ(2),"D",DA,0),U),ACHSVPTR=$P(^(0),U,8),ACHSFY=$E($P(^(0),U,27),3,4),ACHSSTS=$P(^(0),U,12),DFN=$P(^(0),U,22),ACHSBLNK=+$P(^(0),U,3)
 ;
 I ACHSVPTR'=ACHSVIEN G TRANS   ;SINGLE PROVIDER
 ;
 ;Amount either adjusted amount or payment amount, or, if that doesn't exist, the
 ;obligated amount
 ;
 D
 . I $D(^ACHSF(DUZ(2),"D",DA,"ZA")) S ACHS("$")=$G(^ACHSF(DUZ(2),"D",DA,"ZA")),ACHS("$")=+ACHS("$")_"*" Q
 . I $D(^ACHSF(DUZ(2),"D",DA,"PA")) S ACHS("$")=$G(^ACHSF(DUZ(2),"D",DA,"PA")),ACHS("$")=+ACHS("$")_"*" Q
 . S ACHS("$")=$P($G(^ACHSF(DUZ(2),"D",DA,0)),U,9)
 ;
 G TRANS:(DFN'=+DFN)&('ACHSBLNK),TRANS:ACHSSTS=4!(ACHSRPT=2&(ACHSSTS>2))!(ACHSVPTR']""),TRANS:'$D(^AUTTVNDR(ACHSVPTR,0)) S ACHSVNDR=$P(^(0),U)
 I 'ACHSBLNK,'$D(^DPT(DFN,0)) G TRANS
 ;
 I $D(DFN),(DFN'="") S ACHSSSN=$P($G(^DPT(DFN,0)),"^",9),ACHSHRN=$P(^AUPNPAT(DFN,41,DUZ(2),0),"^",2)
 ;
 S ACHSSCPT=$P($G(^ACHSF(DUZ(2),"D",DA,0)),U,7)
 S ACHSSC=$P($G(^ACHS(3,DUZ(2),1,+ACHSSCPT,0)),"^",1)
 S ACHSCLRK=$P(^ACHSF(DUZ(2),"D",DA,0),U,18)
 S ACHSCLRK=$P($G(^VA(200,ACHSCLRK,0)),"^",2)
 ;
 ;
 S ACHSDOC=ACHSFY_"-"_ACHSFC_"-"_ACHSDOCN
 S ^TMP("ACHSVUR2",$J,ACHSVNDR,ACHSVPTR,ACHSDOC,DA)=$S(ACHSBLNK=0:$P(^DPT(DFN,0),U),ACHSBLNK=1:"* BLANKET",ACHSBLNK=2:"* SPECIAL TRANS",1:"")_U_ACHS("$")_U_$G(ACHSSSN)_U_$G(ACHSHRN)_U_$G(ACHSSC)_U_$G(ACHSCLRK)
 G TRANS
 ;
PRINT ; Kill calc vars, print.
 K ACHSBLNK,ACHSDOCN,ACHSFY,ACHSSTS,ACHSTRDT,ACHSTYPE
 ;
 S ACHSVNDR="",(ACHSTOT,ACHSTOT("$"),ACHSPD,ACHSPD("$"))=0,ACHST1=$$C^XBFUNC("VENDOR USAGE REPORT - "_$S(ACHSRPT=2:"OPEN DOCUMENTS ONLY",1:"OPEN AND PAID DOCUMENTS"))
 S ACHST2=$$C^XBFUNC("For the period "_$$FMTE^XLFDT(ACHSBDT)_" through "_$$FMTE^XLFDT(ACHSEDT)),X3=0
 S ACHSV=$$C^XBFUNC("Provider: "_ACHSVNAM)
 D BRPT^ACHSFU
 X:$D(IO("S")) ACHSPPO
 D HDR
 K ACHSHDR
A ;
 S ACHSVNDR=$O(^TMP("ACHSVUR2",$J,ACHSVNDR))
 G ENDPRNT:ACHSVNDR=""
 S ACHSVPTR=0
B ;
 S ACHSVPTR=$O(^TMP("ACHSVUR2",$J,ACHSVNDR,ACHSVPTR))
 G A:+ACHSVPTR=0,B:'$D(^AUTTVNDR(ACHSVPTR))
 S ACHSHDR=""
 S ACHSDOC="",(ACHSVDOC,ACHSVDOC("$"))=0
 ;
C ;
 S ACHSDOC=$O(^TMP("ACHSVUR2",$J,ACHSVNDR,ACHSVPTR,ACHSDOC)) G F:ACHSDOC="" S DA=$O(^(ACHSDOC,0)),ACHSNAME=$P(^(DA),U),ACHS("$")=$P(^(DA),U,2),ACHSSSN=$P(^(DA),U,3),ACHSHRN=$P(^(DA),U,4),ACHSSC=$P(^(DA),U,5),ACHSCLRK=$P(^(DA),U,6)
 G C:'$D(^ACHSF(DUZ(2),"D",DA,0)) S ACHSTOS=$P(^(0),U,4),DFN=$P(^(0),U,22)
 I +ACHSTOS>0 S ACHSTOS=$P($P($P($P(^DD(9002080.01,3,0),U,3),";",ACHSTOS),":",2)," ")
 S (Y,ACHSDOS,ACHSAMT)=""
 I $D(^ACHSF(DUZ(2),"D",DA,3)),+$P(^(3),U)>0 S Y=+$P(^(3),U),ACHSDOS=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3)
 ;
D ;
 W !?3,ACHSDOC,?16,$E(ACHSNAME,1,25),?42,ACHSHRN,?53,ACHSTOS,?58,ACHSDOS
 W !,?3,ACHSCLRK,?16,$E(ACHSSSN,6,9),?52,ACHSSC
 ;
 S ACHSBLNK=$P(^ACHSF(DUZ(2),"D",DA,0),U,3)
 ;
 S X=$FN(+ACHS("$"),",",2)
 I $D(ACHSSTAR) S X=X_ACHSSTAR K ACHSSTAR
 W ?78-$L(X),X S ACHSAMT=X
 I ACHS("$")["*" W "*" S ACHSPD=ACHSPD+1,ACHSPD("$")=ACHSPD("$")+ACHS("$"),ACHSAMT=ACHSAMT_"*"
 I $Y>ACHSBM D RTRN^ACHS G KILL:$D(DUOUT)!$D(DTOUT) D HDR W:$D(ACHSVNDR) ACHSVNDR," (continued)"
 ;
E ;
 S ACHSVDOC=ACHSVDOC+1,ACHSVDOC("$")=ACHSVDOC("$")+ACHS("$"),ACHSTOT=ACHSTOT+1,ACHSTOT("$")=ACHSTOT("$")+ACHS("$")
 I ACHSFIL="Y" S ^TMP($J,"ACHSVUR2","REC"_ACHSVDOC)=ACHSDOC_"^"_ACHSNAME_"^"_ACHSHRN_"^"_ACHSTOS_"^"_ACHSDOS_"^"_ACHSCLRK_"^"_$E(ACHSSSN,6,9)_"^"_ACHSSC_"^"_ACHSAMT
 G C
 ;
F ;
 S X2="2$",X3=16,X=ACHSVDOC("$")
 D COMMA^%DTC
 W !?10,$$REPEAT^XLFSTR("-",55),!?10,"TOTALS     DOCUMENTS:",$J(ACHSVDOC,5),?42,"DOLLARS:",X,!,$$REPEAT^XLFSTR("-",79),!
 G B
 ;
ENDPRNT ;
 W !,$$REPEAT^XLFSTR("=",79),!
 S X2="2$",X3=16,X=ACHSPD("$")
 D COMMA^%DTC
 W "TOTAL PAID",?21,"DOCUMENTS:",$J(ACHSPD,5),?42,"DOLLARS:",X,!
 I ACHSFIL="Y" S ^TMP($J,"ACHSVUR2","TOT1")="TOTAL PAID DOCUMENTS: ^"_$J(ACHSPD,5)_"^DOLLARS: ^"_X
 S X=ACHSTOT("$")-ACHSPD("$")
 D COMMA^%DTC
 W "TOTAL OUTSTANDING",?21,"DOCUMENTS:",$J(ACHSTOT-ACHSPD,5),?42,"DOLLARS:",X,!,$$REPEAT^XLFSTR("-",79),!
 I ACHSFIL="Y" S ^TMP($J,"ACHSVUR2","TOT2")="TOTAL OUTSTANDING DOCUMENTS: ^"_$J(ACHSTOT-ACHSPD,5)_"^DOLLARS: ^"_X
 S X=ACHSTOT("$")
 D COMMA^%DTC
 W "GRAND TOTALS",?21,"DOCUMENTS:",$J(ACHSTOT,5),?42,"DOLLARS:",X
 I ACHSFIL="Y" S ^TMP($J,"ACHSVUR2","TOT3")="GRAND TOTALS DOCUMENTS: ^"_$J(ACHSTOT,5)_"^DOLLARS: ^"_X
 D RTRN^ACHS:'$D(IO("S"))
 W @IOF
 Q
 ;
HDR ; Paginate.
 S ACHSPG=ACHSPG+1
 W @IOF,!!?19,"***  CONTRACT HEALTH MANAGEMENT SYSTEM  ***",!,ACHSUSR,?71,"Page",$J(ACHSPG,3),!,ACHSLOC,!,ACHST1,!,ACHSV,!,ACHSTIME,!,ACHST2
 W !!?3,"DOCUMENT #   PATIENT NAME",?43,"HRN",?52,"TYPE    DOS",?70,"DOLLARS"
 W !,?3,"STAFF",?17,"LAST 4SSN",?53,"OC",?69,"(* = PAID)"
 W !,$$REPEAT^XLFSTR("=",79),!
 I ACHSFIL="Y" D
 .S ^TMP($J,"ACHSVUR2",1)="***  CONTRACT HEALTH MANAGEMENT SYSTEM  ***"
 .S ^TMP($J,"ACHSVUR2",2)=ACHSLOC
 .S ^TMP($J,"ACHSVUR2",3)= ACHST1
 .S ^TMP($J,"ACHSVUR2",4)=ACHSV
 .S ^TMP($J,"ACHSVUR2","HDR4")=ACHSTIME
 .S ^TMP($J,"ACHSVUR2","HDR5")=ACHST2
 .S ^TMP($J,"ACHSVUR2","HDR6")= "DOCUMENT #^PATIENT NAME^HRN^TYPE^DOS^STAFF^LAST-4SSN^OC^DOLLARS *=PAID"
 Q
 ;
H1 ;EP - From HELP^ACHS() via ^DIR.
 ;;@;!
 ;;Enter a '1' if you want to list all documents.
 ;;Enter a '2' if you want only OPEN documents to be listed.
 ;;###
 ;
H2 ;EP - From HELP^ACHS() via ^DIR.
 ;;@;!
 ;;Enter 'Y' to create a file to be transferred into excel.
 ;;@;!!
 ;;###
 ;
FILSAV ;SAVE FILE
 ;
 N XBFN,XBE,XBJ,XBUF,XBQ,XBMED,XBFLT,XBS1,XBIO,XBF,XBGL
 S X=$E(DT,4,7)_$E(DT,2,3)
 D NOW^%DTC S X=(%I(3)+1700)_$E(%,4,7)_"_"_$P(%,".",2)
 S:$L(X)'=15 X=X_0
 S X1=$$ASF^ACHS(DUZ(2)),XBE=$J
 S XBFN="CHS-"_$TR(ACHSVNAM," ","")_"-"_X1_"."_X
 S XBMED="F",XBFLT=1
 S XBQ="N"
 S XBUF=$$PARM^ACHS(1,5)
 I XBUF="" S XBUF=$P(^AUTTSITE(1,1),U,2)
 S XBS1="ACHS REPORTS"
 S XBIO=51,XBF=$J,XBGL="^TMP(" D ^ZIBGSVEM
 ;S XBGL="TMP("_$J_",""ACHSVUR2"","D ^XBGSAVE
 Q
 ;