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

ACHS3PPT.m

Go to the documentation of this file.
ACHS3PPT ; IHS/OIT/FCJ - PRINT THIRD PARTY PAYMENT REPORT ALL PATIENTS BY INS ;  
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**16**;JUN 11, 2001
 ;NEW ROUTINE FOR PATCH 16
 ;
 ;
 S ACHSBM=22
P1 ;
 S ACHSFAC=""  F  S ACHSFAC=$O(^TMP("ACHS3PP",$J,ACHSFAC)) G:ACHSFAC="" TOTL D  Q:$D(DUOUT)
 .S ACHSINS="",ACHSPAGE=0,ACHSFLG1=0 D HEADER
 .F ACHSX="I","U","T"  D  Q:$D(DUOUT)
 ..S ACHSFLG=1,ACHSDOC="",ACHSFLG1=1
 ..S (ACHSINSP,ACHSINSS,ACHSOBLT,ACHS3PPT,ACHSIHST,ACHSINSX,ACHSDOCT)=0
 ..I ACHSX="T" D P2 Q
 ..F  S ACHSDOC=$O(^TMP("ACHS3PP",$J,ACHSFAC,ACHSX,ACHSDOC)) Q:ACHSDOC=""  D  Q:$D(DUOUT)
 ...S ACHSINST=0
 ...S Z=$G(^TMP("ACHS3PP",$J,ACHSFAC,ACHSDOC))
 ...S Z1=$G(^TMP("ACHS3PP",$J,ACHSFAC,ACHSX,ACHSDOC))
 ...S ACHSINS=$S(ACHSX="U":"UNIDENTIFIED INSURANCE",1:"IHS ONLY PAY")
 ...S (ACHSINSP,ACHSINST)=^TMP("ACHS3PP",$J,ACHSFAC,ACHSX,ACHSDOC)
 ...I ACHSX="I",$P(^TMP("ACHS3PP",$J,ACHSFAC,ACHSDOC),U,3)>0 Q
 ...D DETAIL D:ACHSRTYP="P" PRT
 ..Q:$D(DUOUT)
 ..S ACHSFLG1=0 D TOT2
 Q
P2 ;
 S ACHSI="",ACHSINST=0
 F  S ACHSI=$O(^TMP("ACHS3PP",$J,ACHSFAC,ACHSX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=3) S ACHS0ST=ACHS0ST+1
 Q
PRT ;Prints Data
 W:ACHSFLG1=1 !!,ACHSINS S ACHSFLG1=0
 D
 . W !?1,ACHSDOC,?15,ACHSSERV,?23,ACHSIDT,?40
 . S X=ACHSOBL,X2=2
 . D COMMA^%DTC
 . W $J(X,12),?55
 . S X=ACHSIHSP,X2=2
 . D COMMA^%DTC
 . W $J(X,12),?68
 . S X=$S(ACHSX="I":ACHS3PP,1:ACHSINSP),X2=2
 . D COMMA^%DTC
 . W $J(X,12)
 I IOST["P-",$Y>ACHSBM S ACHSFLG=0,ACHSFLG1=1 D HEADER
 I IOST["C-",'$D(IO("S")),$Y>ACHSBM G END:'$$DIR^XBDIR("E") S ACHSFLG=0,ACHSFLG1=1 D HEADER
 Q
 ;
TOT2 ;
 W:ACHSRTYP="P" !!,$$REPEAT^XLFSTR("-",80)
 W:ACHSRTYP="T" !!,ACHSINS
 W !?1,"TOTAL",?10,$J(ACHSDOCT,4)
 S X=ACHSOBLT,X2="2$"
 D COMMA^%DTC
 W ?40,$J(X,12)
 S X=ACHSIHST,X2="2$"
 D COMMA^%DTC
 W ?55,$J(X,12)
 S X=$S(ACHSX="I":ACHS3PPT,1:ACHSINSX),X2="2$"
 D COMMA^%DTC
 W ?68,$J(X,12)
 K DIR
 I IOST["C-",'$D(IO("S")),$Y>ACHSBM W !! G END:'$$DIR^XBDIR("E") D HEADER
 S ACHSFLG1=0 D:ACHSRTYP="P" HEADER
 Q
TOTL ;
 W !!,$$REPEAT^XLFSTR("-",80),!?1,"TOTAL",?10,$J(ACHSDOCS,4)
 S X=ACHSOBLS,X2="2$"
 D COMMA^%DTC
 W ?40,$J(X,12)
 S X=ACHSIHSS,X2="2$"
 D COMMA^%DTC
 W ?55,$J(X,12)
 S X=ACHS3PPS,X2="2$"
 D COMMA^%DTC
 W ?68,$J(X,12)
 I ACHSOBLS>0&(ACHSIHSS>0) W !! S Z=(ACHSIHSS/ACHSOBLS)*100 W "PERCENTAGE OF PAYMENT TO OBLIGATED",?61,$E(Z,1,5)_"%"
 I ACHSOBLS>0&(ACHS3PPS>0) S X=(ACHS3PPS/ACHSOBLS)*100 W ?74,$E(X,1,5)_"%"
 I ACHSSER=4 W !?5,"*HOSP - ",ACHS43ST,"*",?25,"*DENT - ",ACHS57ST,"*",?45,"*OUTP - ",ACHS64ST,"*",?65,"*UNKN - ",ACHS0ST,"*"
 K DIR
 I IOST["C-",'$D(IO("S")) W !! G END:'$$DIR^XBDIR("E")
END ;Close device, kill variables, quit
 S:$D(ZTQUEUED) ZTREQ="@"
 D ^%ZISC
 K ACHS3PP,ACHS3PPS,ACHS3PPT,ACHSDAT,ACHSDOC,ACHSDOCS,ACHSDOCT
 K ACHSHRN,ACHSIDT,ACHSIHSP,ACHSIHSS,ACHSIHST,ACHSQIO,ACHS0ST
 K ACHSOBL,ACHSOBLS,ACHSOBLT,ACHSPAT,ACHSSERP,ACHSSERV,ACHSTIM,ACHSUSR,C,Z,S,D,P
 K ACHSFLG,ACHSFLG1,ACHSPAGE,DIR,I,X,X2,Y,ACHSOT,ACHS43ST,ACHS43T,ACHS57ST,ACHS57T
 K ACHS64ST,ACHS64T,ACHSSER
 K ACHSI,ACHSINS,ACHSINSS,ACHSINST,ACHSRTYP,ACHSX
 K ^TMP("ACHS3PP",$J)
 Q
 ;
 U IO
 W @IOF
 S ACHSPAGE=ACHSPAGE+1
 S Y=$$HTE^XLFDT($H),ACHSDAT=$P(Y,"@",1),ACHSTIM=$P(Y,"@",2)
 W !,"*",ACHSDAT
 S X=$$LOC^ACHS
 W ?((80/2)-($L(X)/2)),X
 W ?71,ACHSTIM,"*",!,"*User: ",ACHSUSR,?70,"Device:",IO,"*"
 W !!
 S X="3rd Party Payment Report - Page "
 W ?((80/2)-($L(X)/2)),X_ACHSPAGE
 W !
 S X="For FISCAL YEAR: "
 W ?((80/2)-($L(X)/2)),X_ACHSFY
 W !
 I ACHSSER'=4 S ACHSSERP=$S(ACHSSER=1:"HOSPITAL",ACHSSER=2:"DENTAL",ACHSSER=3:"OUTPATIENT",1:"UNKNOWN") W ?33,"SERVICE: "_ACHSSERP W !
 W $$REPEAT^XLFSTR("*",80)
 S ACHSFLG=0
 ;
HEADER1 ;
 W !! W:ACHSRTYP["T" "PAYOR"
 W:ACHSRTYP["P" ?1,"DOCUMENT #",?15,"SERV",?23,"ISSUE DT"
 W ?41,"$ OBLIGD $",?55,"$ IHS PMT $",?70,"$ 3P PMT $"
 W:ACHSFLG1=1 !,ACHSINS S ACHSFLG1=0
 Q
 ;
NODATA ;
 W !!!,"NO DATA FOR SPECIFIED FISCAL YEAR"
 K ^TMP("ACHS3PP",$J)
 I $D(ACHSSERP) W " FOR "_ACHSSERP_" SERVICE(S)" W !!!!
 I IOST["C-",'$D(IO("S")) G:'$$DIR^XBDIR("E") END G ^ACHS3PPQ
 G END
 ;