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

ACHSDNS.m

Go to the documentation of this file.
ACHSDNS ; IHS/ITSC/PMF - DENIAL STATISTICS REPORT (1/2) ;7/27/10  16:15
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**18**;JUN 11, 2001
 ;ACHS*3.1*6 4/24/03 IHS/SET/FCJ MULTIPLE CHANGES ADDED TO RUN 2 OTHER
 ;           REPORTS BY DOS, COMMUNITY
 ;           ADDED DEV LINE LABEL
 ;           REQUEST TO SORT BY PAYOR WILL BE INCLUDED IN PATCH 7 BUT
 ;           HAS BEEN STARTED
 ;ACHS*3.1*7 10/10/03 ITSC/SET/FCJ ADDED ACHSPRT IN LABEL DEV
 ;ACHS*3.1*18 7/19/2010;IHS/OIT/ABK;Change every occurrance of Deferred to Unmet Need
 ;
 ;
SEL D QSEL
 S ACHSRPT=$$DIR^ACHS("N^1:3:0","Select",1,"","^D QSEL^ACHSDNS",3)
 G:ACHSRPT'?1N.3N K
 D A2
 Q
A2 ; --- Input date range
 S ACHSBDT=$$DATE^ACHS("B","DENIAL STATISTICS")
 G K:ACHSBDT<1
 S ACHSEDT=$$DATE^ACHS("E","DENIAL STATISTICS")
 G A2:ACHSEDT<1
 I $$EBB^ACHS(ACHSBDT,ACHSEDT) G A2
 S ACHSHAT=""
DEV S %ZIS="OPQ"
 D ^%ZIS
 I POP D HOME^%ZIS G K
 G:'$D(IO("Q")) START
 K IO("Q")
 I $D(IO("S"))!($E(IOST)'="P") W *7,!,"Please queue to system printers." D ^%ZISC G DEV
 ;
 S ZTRTN="START^ACHSDNS",ZTIO="",ZTDESC="CHS Denial Statistics, "_(ACHSBDT+17000000)_" to "_(ACHSEDT+17000000),ACHSQIO=ION_";"_IOST_";"_IOM_";"_IOSL  ; Y2000
 ;
 ;ITSC/SET/FCJ ACHS*3.1*7  ADDED ACHSRPT
 ;F %="ACHSQIO","ACHSBDT","ACHSEDT" S ZTSAVE(%)=""
 F %="ACHSQIO","ACHSBDT","ACHSEDT","ACHSRPT" S ZTSAVE(%)=""
 D ^%ZTLOAD
 G:'$D(ZTSK) DEV
K ;
 K ACHS,ACHSBDT,ACHSEDT,ACHSHAT,ACHSQIO,DTOUT,DUOUT,ZTIO,ZTSK
 D ^%ZISC
 Q
 ;
START ;EP - TaskMan.
ST ;
 N ACHSMPRI
 S ACHSISDT=ACHSBDT-1
 K ^TMP($J,"ACHSDNS")
A ; --- START OF Loops
 S ACHSSUB=$S((ACHSRPT<3):"SET",ACHSRPT=3:"SET3",ACHSRPT=4:"SET4")
DOI ;SORT BY DATE OF ISSUE
 I ACHSRPT'=2 D
 .F  S ACHSISDT=$O(^ACHSDEN(DUZ(2),"D","AISSUE",ACHSISDT)) Q:+ACHSISDT=0!(+ACHSISDT>ACHSEDT)  D
 ..S DA=0,ACHSINST=0
 ..F  S DA=$O(^ACHSDEN(DUZ(2),"D","AISSUE",ACHSISDT,DA)) Q:+DA=0  D
 ...D B
 ...S:ACHS("A")'="TOTAL" $P(^TMP($J,"ACHSDNS","X","TOTALD"),U)=+$P($G(^TMP($J,"ACHSDNS","X","TOTALD")),U)+1
DOS ;SORT BY DATE OF SERVICE
 I ACHSRPT=2 D
 .F  S ACHSISDT=$O(^ACHSDEN(DUZ(2),"D","ES",ACHSISDT)) Q:+ACHSISDT=0!(+ACHSISDT>ACHSEDT)  D
 ..S DA=0
 ..F  S DA=$O(^ACHSDEN(DUZ(2),"D","ES",ACHSISDT,DA)) Q:+DA=0  D B
 ;G:ACHSRPT<4 GRNDTOT
 G GRNDTOT
B ; --- Loop thru Denial IENs
 Q:'$D(^ACHSDEN(DUZ(2),"D",DA,0))
 Q:'$D(^ACHSDEN(DUZ(2),"D",DA,100))
 S ACHSTYPE=$P($G(^ACHSDEN(DUZ(2),"D",DA,100)),U,10)
 Q:ACHSTYPE']""
 Q:$P($G(^ACHSDEN(DUZ(2),"D",DA,0)),U)["#"
 D DOLLARS
 S ACHSMPRI=$P($G(^ACHSDEN(DUZ(2),"D",DA,400)),U,2)
 I ACHSMPRI S ACHSMPRI=$P($G(^ACHSMPRI(ACHSMPRI,0)),U)
 E  S ACHSMPRI="UNKNOWN"
 S ACHS("A")="TOTAL"
 D @ACHSSUB
 Q:'$G(^ACHSDEN(DUZ(2),"D",DA,250))
 S ACHS("A")=$P($G(^ACHSDEN(DUZ(2),"D",DA,250)),U),ACHSREAS=$P($G(^ACHSDENS(+ACHS("A"),0)),U)
 D @ACHSSUB
 Q
 ;
GRNDTOT ; --- Compute Grand Total For each Group.
 S ACHS=""
G1 ;
 F  S ACHS=$O(^TMP($J,"ACHSDNS",ACHS)) G END:ACHS="" D
 .S ACHS(1)="",(ACHS("C"),ACHS("D"))=0
 .F  S ACHS(1)=$O(^TMP($J,"ACHSDNS",ACHS,ACHS(1))) Q:ACHS(1)=""  D
 ..I ACHSRPT<3 D  Q
 ...S ACHS("C")=ACHS("C")+$G(^TMP($J,"ACHSDNS",ACHS,ACHS(1)))
 ...S ACHS("D")=ACHS("D")+$P($G(^TMP($J,"ACHSDNS",ACHS,ACHS(1))),U,2)
 ..S ACHS(2)=""
 ..F  S ACHS(2)=$O(^TMP($J,"ACHSDNS",ACHS,ACHS(1),ACHS(2))) Q:ACHS(2)=""  D
 ...S ACHS(3)=""
 ...F  S ACHS(3)=$O(^TMP($J,"ACHSDNS",ACHS,ACHS(1),ACHS(2),ACHS(3))) Q:ACHS(3)=""  D
 ....S ACHS("C")=ACHS("C")+$G(^TMP($J,"ACHSDNS",ACHS,ACHS(1),ACHS(2),ACHS(3)))
 ....S ACHS("D")=ACHS("D")+$P($G(^TMP($J,"ACHSDNS",ACHS,ACHS(1),ACHS(2),ACHS(3))),U,2)
 .S ^TMP($J,"ACHSDNS",ACHS,"TOTAL")=ACHS("C")_U_ACHS("D")
 ;
END ;
 K ACHS,ACHSREAS,ACHSINS,ACHSINST
 G ^ACHSDNS1
 ;
SET ;
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSTYPE),U)=+$P($G(^TMP($J,"ACHSDNS",ACHS("A"),ACHSTYPE)),U)+1
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSTYPE),U,2)=+$P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSTYPE),U,2)+ACHS("$")
 ;
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSTYPE,ACHSMPRI),U)=$P($G(^TMP($J,"ACHSDNS",ACHS("A"),ACHSTYPE,ACHSMPRI)),U)+1
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSTYPE,ACHSMPRI),U,2)=$P($G(^TMP($J,"ACHSDNS",ACHS("A"),ACHSTYPE,ACHSMPRI)),U,2)+ACHS("$")
 Q
SET3 ;REPORT TYPE WITH COMMUNITY    
 I $P(^ACHSDEN(DUZ(2),"D",DA,0),U,6)="Y" D
 .Q:'$D(^AUPNPAT($P(^ACHSDEN(DUZ(2),"D",DA,0),U,7),11))
 .S ACHSCOM=$P(^AUPNPAT($P(^ACHSDEN(DUZ(2),"D",DA,0),U,7),11),U,17)
 .Q:ACHSCOM=""
 .S ACHSCOM=$P(^AUPNPAT($P(^ACHSDEN(DUZ(2),"D",DA,0),U,7),11),U,17)
 .S ACHSST=$P(^AUTTCOM(ACHSCOM,0),U,3)
 .S ACHSCOM=$P(^AUTTCOM(ACHSCOM,0),U)
 I $P(^ACHSDEN(DUZ(2),"D",DA,0),U,6)="N" D
 .Q:ACHSCOM=""
 .S ACHSCOM=$P(^ACHSDEN(DUZ(2),"D",DA,10),U,3)
 .S ACHSST=$P(^ACHSDEN(DUZ(2),"D",DA,10),U,4)
 Q:ACHSCOM=""
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSCOM,ACHSST,ACHSTYPE),U)=+$P($G(^TMP($J,"ACHSDNS",ACHS("A"),ACHSCOM,ACHSST,ACHSTYPE)),U)+1
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSCOM,ACHSST,ACHSTYPE),U,2)=+$P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSCOM,ACHSST,ACHSTYPE),U,2)+ACHS("$")
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSCOM,ACHSST,ACHSTYPE,ACHSMPRI),U)=$P($G(^TMP($J,"ACHSDNS",ACHS("A"),ACHSCOM,ACHSST,ACHSTYPE,ACHSMPRI)),U)+1
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSCOM,ACHSST,ACHSTYPE,ACHSMPRI),U,2)=$P($G(^TMP($J,"ACHSDNS",ACHS("A"),ACHSCOM,ACHSST,ACHSTYPE,ACHSMPRI)),U,2)+ACHS("$")
 S:(ACHS("A")'="TOTAL")&('$D(^TMP($J,"ACHSDNS","X",ACHSCOM,ACHSST,ACHS("A"),ACHSTYPE))) ^(ACHSTYPE)=""
 Q
 ;
SET4 ;REPORT BY ALTERNATE RESOURCES
 I ACHS("$")'=0,ACHS("A")="TOTAL" S ACHSINS="SELF PAY",ACHSINST=ACHS("$") D SETINS
 I ACHS("A")'="TOTAL",ACHSINST'=0 S ACHSINS="SELF PAY",ACHS("$")=ACHSINST D SETINS
 I $D(^ACHSDEN(DUZ(2),"D",DA,800)) D
 .S DA(1)=0
 .F  S DA(1)=$O(^ACHSDEN(DUZ(2),"D",DA,800,DA(1))) Q:DA(1)'?1N.N  D
 ..S %=$P(^ACHSDEN(DUZ(2),"D",DA,800,DA(1),0),U),ACHS("$")=$P(^(0),U,2)
 ..S ACHSINS=$S(%'?1.N:%,1:$P($G(^AUTNINS(%,0)),U))
 ..I ACHSINS'="MEDICAID",ACHSINS'="MEDICARE" S ACHSINS="OTHER INSURANCE/COVERAGE"
 ..Q:(ACHSINS="")!(ACHS("$"))
 ..D SETINS
 Q
SETINS ;SET OTHER PAYMENT TYPES
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSINS,ACHSTYPE),U)=+$P($G(^TMP($J,"ACHSDNS",ACHS("A"),ACHSINS,ACHSTYPE)),U)+1
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSINS,ACHSTYPE),U,2)=+$P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSINS,ACHSTYPE),U,2)+ACHS("$")
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSINS,ACHSTYPE,ACHSMPRI),U)=$P($G(^TMP($J,"ACHSDNS",ACHS("A"),ACHSINS,ACHSTYPE,ACHSMPRI)),U)+1
 S $P(^TMP($J,"ACHSDNS",ACHS("A"),ACHSINS,ACHSTYPE,ACHSMPRI),U,2)=$P($G(^TMP($J,"ACHSDNS",ACHS("A"),ACHSINS,ACHSTYPE,ACHSMPRI)),U,2)+ACHS("$")
 S:(ACHS("A")'="TOTAL")&('$D(^TMP($J,"ACHSDNS","X",ACHSINS,ACHS("A"),ACHSTYPE))) ^(ACHSTYPE)=""
 Q
 ;
HDR ;EP
 S ACHSPG=ACHSPG+1
 ;{ABK,7/19/10}W @IOF,!!,$$C^ACHS("***  CHS DENIAL/DEFERRED SERVICES  ***",80),!,ACHSUSR,?71,"Page",$J(ACHSPG,3),!,ACHSLOC
 W @IOF,!!,$$C^ACHS("***  CHS DENIAL  ***",80),!,ACHSUSR,?71,"Page",$J(ACHSPG,3),!,ACHSLOC
 I $D(ZTSK) S X="(task "_ZTSK_")" W ?79-$L(X),X
 W !,$$C^ACHS("DENIAL FACILITY STATISTICS",80),!,ACHSTIME,!!,ACHST1,!!
 W:ACHSRPT=3 !,"COMMUNITY:  ",ACHSCOM,", ",$P(^DIC(5,ACHSST,0),U),!
 W:ACHSRPT=4 !,"PAYOR:  ",ACHSINS,!
 I ACHSPART=1 W "DENIAL REASON",?37,"TYPE",?44,"TOTAL",?53,"%",?63,"DOLLARS",?76,"%"
 I ACHSPART=2 W ?37,"TYPE",?44,"TOTAL",?53,"%",?63,"DOLLARS",?76,"%"
 ;{ABK,7/19/10}I ACHSPART=3 W "TYPE OF DEFERRED SERVICE",?37,"TYPE",?44,"TOTAL",?53,"%",?63,"DOLLARS",?76,"%"
 I ACHSPART=3 W "TYPE OF UNMET NEED",?37,"TYPE",?44,"TOTAL",?53,"%",?63,"DOLLARS",?76,"%"
 W !,$$REPEAT^XLFSTR("=",79),!
 Q
 ;
DOLLARS ;EP - Get Dollar Amount for each Denial.
 S ACHS("$")=$S(+$P($G(^ACHSDEN(DUZ(2),"D",DA,100)),U,9):+$P($G(^ACHSDEN(DUZ(2),"D",DA,100)),U,9),1:+$P($G(^ACHSDEN(DUZ(2),"D",DA,100)),U,8))
 ;
 I $D(^ACHSDEN(DUZ(2),"D",DA,200)) F DA(1)=0:0 S DA(1)=$O(^ACHSDEN(DUZ(2),"D",DA,200,DA(1))) Q:'DA(1)  D
 .I $D(^ACHSDEN(DUZ(2),"D",DA,200,DA(1),0)) D
 ..S ACHS("$")=ACHS("$")+$S(+$P($G(^ACHSDEN(DUZ(2),"D",DA,200,DA(1),0)),U,3):$P($G(^ACHSDEN(DUZ(2),"D",DA,200,DA(1),0)),U,3),1:+$P($G(^ACHSDEN(DUZ(2),"D",DA,200,DA(1),0)),U,2))
 ;
 I $D(^ACHSDEN(DUZ(2),"D",DA,210)) F DA(1)=0:0 S DA(1)=$O(^ACHSDEN(DUZ(2),"D",DA,210,DA(1))) Q:'DA(1)  D
 .I $D(^ACHSDEN(DUZ(2),"D",DA,210,DA(1),0)) D
 ..S ACHS("$")=ACHS("$")+$S(+$P($G(^ACHSDEN(DUZ(2),"D",DA,210,DA(1),0)),U,7):+$P($G(^ACHSDEN(DUZ(2),"D",DA,210,DA(1),0)),U,7),1:+$P($G(^ACHSDEN(DUZ(2),"D",DA,210,DA(1),0)),U,6))
 ;
 I $D(^ACHSDEN(DUZ(2),"D",DA,800)) F DA(1)=0:0 S DA(1)=$O(^ACHSDEN(DUZ(2),"D",DA,800,DA(1))) Q:'DA(1)  D
 .I $D(^ACHSDEN(DUZ(2),"D",DA,800,DA(1),0)) S ACHS("$")=ACHS("$")-(+$P($G(^ACHSDEN(DUZ(2),"D",DA,800,DA(1),0)),U,2))
 Q
 ;
QSEL ;
 W !!?20,"1) Print Report by Date of Issue"
 W !?20,"2) Print Report by Date of Service"
 W !?20,"3) Print Report by Community"
 ;W !?20,"4) Print Report by Primary Payor"
 Q