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

ACHSDSTL.m

Go to the documentation of this file.
ACHSDSTL ;IHS/OIT/FCJ - DOCUMENT STATUS REPORT BY FY; [ 02/09/2001  10:54 AM ]
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**26**;JUN 11, 2001;Build 43
 ;3.1*26  IHS/OIT/FCJ NEW RTN FR A 1.6 VERSION
 ;
 ;
 W !!,$$C^XBFUNC("***   DOCUMENT STATUS REPORT FOR SPECIAL LOCAL PO'S  ***",80)
 W !!,$$C^XBFUNC("for  "_$P(^DIC(4,DUZ(2),0),"^"),80)
 S ACHSIO=IO
 D ^ACHSVAR,LINES^ACHSFU
BDT ; Enter beginning date.
 S ACHSBDT=$$DATE^ACHS("B","for Special Local PO's","ISSUE")
 G ENDQ:$D(DUOUT)!$D(DTOUT)!(ACHSBDT<1)
EDT ; Enter the ending date.
 S ACHSEDT=$$DATE^ACHS("E","for Special Local PO's","ISSUE")
 G BDT:$D(DUOUT)!(ACHSEDT<1),EDT:$$EBB^ACHS(ACHSBDT,ACHSEDT)
TYPE ;
 S TYPE=3     ;COMBINED OPEN,CLOSED, CANCELLED
TOT ;
 S TOTONLY=0
 W !!,"TYPE OF DATA ON REPORT: ",!!,"  1. TOTALS ONLY",!,"  2. DETAILED DOCUMENTS & TOTALS",!!,"  ENTER 1 or 2:  1//" D READ^ACHSFU I $D(DLOUT)!(Y="") S Y=1
 G ENDQ:$D(DTOUT)!$D(DFOUT),EDT:$D(DUOUT) I "12"[Y&(Y>0)&(Y<3) S TOTONLY=Y
 I (TOTONLY'=1)&(TOTONLY'=2) W *7,"  ??" G TOT
FY ;
 W !!,"Enter Fiscal Year (e.g. 2016): " D READ^ACHSFU
 G ENDQ:$D(DTOUT)!$D(DFOUT),TOT:$D(DUOUT)!$D(DLOUT)
 I Y'?4N W *7,"  ??" H 2 G FY
 I '$D(^ACHS(9,DUZ(2),"FY",Y)) W !!,*7,"NO DATA ON FILE FOR FY!!" H 2 G FY
 S TOTFYN=$E(Y,4) S TOTFY=$E(Y,3,4)
DEVICE ;
 W ! K IOP,%ZIS("B") S %ZIS="PQ" D ^%ZIS K %ZIS I IO="" W !,*7,"No device specified." S IOP=$I D ^%ZIS Q
 I $D(IO("Q"))#2,$E(IOST)'="P" W *7,!,"Please queue to printers only." K IO("Q") G DEVICE
 I $D(IO("Q")) K IO("Q") S ZTRTN="ST^ACHSDSTL1",ZTDESC="CHS Document Status - Special Local PO's, "_$E(ACHSBDT,2,7)_" to "_$E(ACHSEDT,2,7) F G="DUZ(2)","ACHSBDT","ACHSEDT","TYPE","TOTFY","TOTFYN","TOTONLY" S ZTSAVE(G)=""
 I  D ^%ZTLOAD G ENDQ
 I IO=$I G ST
 S IOP=IO D ^%ZIS I 'POP G ST
 W !,*7,"Device ",IO," busy." G DEVICE
ST ;
 D ^ACHSVAR,LINES^ACHSFU
 S ACHSPG=0,(TOTP,CNX,OPEN,TOTP("$"),CNX("$"),OPEN("$"))=0,ACHSLOC=$P(^DIC(4,DUZ(2),0),U),Y=ACHSBDT X ^DD("DD") S BDT=Y,Y=ACHSEDT X ^DD("DD") S EDT=Y
 S X="SPECIAL LOCAL DOCUMENT REPORT",X=$$C^XBFUNC(X_" IN FY "_TOTFY,80)
 S ACHST1=X,X=$$C^XBFUNC("For the period "_BDT_" through "_EDT,80) S ACHST2=X K BDT,EDT
 U IO D NOW^ACHS D HEAD S ACHSBDT=ACHSBDT-1 D BM^ACHS
A ; Main loop.
 S ACHSBDT=$O(^ACHSF(DUZ(2),"TB",ACHSBDT))
 G TOTAL:+ACHSBDT=0!(+ACHSBDT>ACHSEDT)
 S ACHSTYPE=""
B ;
 S ACHSTYPE=$O(^ACHSF(DUZ(2),"TB",ACHSBDT,ACHSTYPE))
 G A:ACHSTYPE=""
 G B:ACHSTYPE'="I"
 S ACHSDIEN=0
C ;
 S ACHSDIEN=$O(^ACHSF(DUZ(2),"TB",ACHSBDT,ACHSTYPE,ACHSDIEN))
 G B:+ACHSDIEN=0,C:'$D(^ACHSF(DUZ(2),"D",ACHSDIEN,0))
 G:$P(^ACHSF(DUZ(2),"D",ACHSDIEN,0),"^",3)'=2 C   ;TEST FOR SPECIAL LOCAL PO
 G C:$P(^ACHSF(DUZ(2),"D",ACHSDIEN,0),U,14)'=TOTFYN  ;TEST FOR FY
STAT ;
 S ACHSDOC1=^ACHSF(DUZ(2),"D",ACHSDIEN,0)
 S ACHSSTS=$S($P(ACHSDOC1,U,12)=3:"P",$P(ACHSDOC1,U,12)=4:"C",1:"OPEN")
 S A("DOC1")=$P(ACHSDOC1,U),A("VPTR")=$P(ACHSDOC1,U,8),A("DOC2")=$P(ACHSDOC1,U,14),A("$")=$P(ACHSDOC1,U,9),TOS=$P(ACHSDOC1,U,4),BLANKET=+$P(ACHSDOC1,U,3)
 ;
 I TOTONLY=1 G TOTONLY
 G A:A("VPTR")']"",A:'$D(^AUTTVNDR(A("VPTR"),0)) S A("VENDOR")=$P(^(0),U) S EIN="" S:$D(^(11)) EIN=$P(^(11),U)
 S A("FC")=$P(^AUTTLOC(DUZ(2),0),U,17),A=$P(^(0),U,4),A("PFX")=$P(^AUTTAREA(A,0),U,3),A("FC")=$E(A("FC"),2,3),A("DOC")=A("DOC2")_"-"_A("PFX")_A("FC")_"-"_A("DOC1")
 S A=$O(^ACHSF(DUZ(2),"TB",ACHSBDT,ACHSTYPE,ACHSDIEN,0))
 I +A>0,$D(^ACHSF(DUZ(2),"D",ACHSDIEN,"T",A,0))
 S ACHSNAME=$S($P(ACHSDOC1,U,3)=1:"* BLANKET",$P(ACHSDOC1,U,3)=2:"* SPECIAL TRANS",1:"")
D ;
 G C:'$D(ACHSNAME) S:$D(^ACHSF(DUZ(2),"D",ACHSDIEN,"PA")) A("$")=+^("PA") S:$D(^ACHSF(DUZ(2),"D",ACHSDIEN,"ZA")) A("$")=+^("ZA")
E ;
 G PRINT:ACHSSTS'="C" S A("$")=0,A(1)=0
E1 ;
 S A(1)=$O(^ACHSF(DUZ(2),"D",ACHSDIEN,"T",A(1))) G PRINT:+A(1)=0 S A("$")=+$P(^(A(1),0),U,4) G E1
PRINT ;
 S ACHSSTA=$S(ACHSSTS="P":"PAID",ACHSSTS="P":"CANCEL",1:"OPEN")
 I '$D(ZTSK),$Y>ACHSBM D RTRN^ACHS G:ACHSQUIT END  D HEAD
 W !,$E(ACHSNAME,1,24),?25,$E(A("VENDOR"),1,26),?52,$$FMTE^XLFDT(ACHSBDT,"2D"),?63,ACHSSTA
 G P1:"PC"'[ACHSSTS W $S(ACHSSTS="P":"PAID",1:"CANCEL")
 S X=A("$") D MONEY W ?79-$L(X),X G P2
P1 ;
 I +A("$")'=0 S X=A("$") D MONEY W ?79-$L(X),X
P2 ;
 W !,A("DOC"),?25,EIN I +TOS W ?52,$S(+TOS=1:"HOSPITAL",+TOS=2:"DENTAL",+TOS=3:"OUTPATIENT",1:"")
TOTONLY ;ENTRY POINT TO ONLY CALCULATE TOTALS FOR TOTAL ONLY PRINT
 I ACHSSTS="P" S TOTP=TOTP+1,TOTP("$")=TOTP("$")+A("$")
 I ACHSSTS="C" S CNX=CNX+1,CNX("$")=CNX("$")+A("$")
 I ACHSSTS="OPEN" S OPEN=OPEN+1,OPEN("$")=OPEN("$")+A("$")
 S ISSUE("YM")=$E(ACHSBDT,1,5)
 I '$D(TOPEN(ISSUE("YM"),"$")) S TOPEN(ISSUE("YM"),"$")=0,TOPEN(ISSUE("YM"),"DOC")=0
 S TOPEN(ISSUE("YM"),"$")=TOPEN(ISSUE("YM"),"$")+A("$")
 S TOPEN(ISSUE("YM"),"DOC")=TOPEN(ISSUE("YM"),"DOC")+1
 G C
TOTAL ;
 ;PRINT OUT EACH MONTH END TOTAL
 S YRMO=0
 W !!,?10,"Month Issued",?30,"# of Documents",?65,"Total Amount",!,ACHS("-")
 F  S YRMO=$O(TOPEN(YRMO)) Q:+YRMO=0  D ENDMOPT
 W !!,ACHS("-"),!
TOTTYP ;PRINT DOCUMENT TOTALS BY TYPE
 I TOTP>0,TYPE>2 D
 .W "TOTAL PAID DOCUMENTS: ",?32-$L(TOTP),TOTP,?40,"TOTAL DOLLARS PAID: " S X=TOTP("$") D MONEY W ?79-$L(X),X,!
 I CNX>0,TYPE=3 D
 .W "TOTAL CANCELLED DOCUMENTS: ",?32-$L(CNX),CNX,?40,"TOTAL DOLLARS CANCELLED: " S X=CNX("$") D MONEY W ?79-$L(X),X,!
 I OPEN>0,TYPE=3 D
 .W "TOTAL OPEN DOCUMENTS: ",?32-$L(OPEN),OPEN,?40,"TOTAL DOLLARS: " S X=OPEN("$") D MONEY W ?79-$L(X),X,!
TOTDOC ;
 W !,ACHS("-"),!
 S TOTDOC=0,TOT("$")=0
 S TOTDOC=TOTP+CNX+OPEN,TOT("$")=TOTP("$")+CNX("$")+OPEN("$")
 W "TOTAL DOCUMENTS: ",?32-$L(TOTDOC),TOTDOC,?40,"TOTAL DOLLARS: " S X=TOT("$") D MONEY W ?79-$L(X),X
 W !
 D RTRN^ACHS W @IOF
END ;
 D ERPT^ACHS
 K ZTSK,A,AG,AGT,ACHS,ACHSBDT,CNX,ACHSEDT,EIN,ACHSLOC,OPEN,ACHSNAME,ACHSTYPE,ACHSSSN,ACHSQUIT
 K TOS,TOTP,TYPE,X,X2,Y,Z,BLANKET,TOPEN,K,YRMO,TOT,TOTDOC,TOTFY,TOTFYN,TOTONLY,ACHSSTA
 Q
ENDQ ;
 K ACHSIO,ACHSBDT,DTOUT,DQOUT,DLOUT,DUOUT,DFOUT,ACHSEDT,X,Y
 Q
 S ACHSPG=ACHSPG+1,ACHS("LINE")="=" W @IOF,!!?20,"***  CONTRACT HEALTH CARE SYSTEM  ***",!!,ACHSTIME,?80-$L(ACHSLOC)\2,ACHSLOC,?73,"page ",ACHSPG,!?29,"DOCUMENT STATUS REPORT"
 I $D(ZTSK) W ?77-$L(ZTSK),"(",ZTSK,")"
 W !!,ACHST1,!,ACHST2
 I TOTONLY=2 D
 .W !!,"Patient Name",?25,"Provider of Service",?52,"Trans Dt",?64,"Status",?73,"Amount",!,"Document #",?25,"EIN Number",?52,"Type"
 W !,ACHS("-"),!
 Q
ENDMOPT ;PRINT OUT EACH MONTH TOTALS
 S Y=YRMO_"00" X ^DD("DD") W !?13,Y
 W ?35,TOPEN(YRMO,"DOC")
 S X=TOPEN(YRMO,"$") D MONEY W ?79-$L(X),X
 Q
MONEY ;
 S X2=2 D COMMA^%DTC F Z=1:1 Q:$E(X)'=" "  S X=$E(X,2,99)
 F Z=1:1 Q:$E(X,$L(X))'=" "  S X=$E(X,1,$L(X)-1)
 Q
 ;