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

ABMMUPVH.m

Go to the documentation of this file.
ABMMUPVH ;IHS/SD/SDR - MU Patient Volume Hospital Report ;
 ;;2.6;IHS 3P BILLING SYSTEM;**7,10,11**;NOV 12, 2009;Build 133
 ;
EN ;
 I $P($G(^ABMMUPRM(1,0)),U,2)="" D  Q
 .W !!,"Setup has not been done.  Please do MUP option prior to running any reports",!
 .S DIR(0)="E",DIR("A")="Enter RETURN to Continue" D ^DIR K DIR
 ;
 K ^XTMP("ABM-PVH",$J)
 S ABMY("RTYP")="HOS"
 D FAC^ABMMUPVP Q:'$D(ABMF)&($D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT))
 M ABMFAC=ABMF
 ;
 W !!,"Hospital/ER Participation year for the Meaningful Use EHR incentive program",!!
 W "For Hospitals/ERs, the Participation year is a federal fiscal year, which "
 W !,"begins on October 1, and ends on the following September 30."
 W !!,"Note: The qualification year is the year prior to the participation year."
 W !,"Patient Volume is calculated on encounters that occurred in the qualification"
 W !,"year, which is the year prior to the participation year.  To view volume for "
 W !,"the current year, select next year as the participation year.",!
 ;
 D PARTYR^ABMMUPVP Q:$D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT)  ;participation year
 ;start new code abm*2.6*11 MU4
 I (ABMY("PYR")>2012) D  Q
 .W !!?5,"**NOTE** For CY 2013+, you should use report options within menu "
 .W !?15,"MUS2 PARTICIPATION CY 2013+ PATIENT VOLUME REPORTS"
 .W ! S DIR(0)="E",DIR("A")="Enter RETURN to Continue" D ^DIR K DIR
 ;end new code MU4
 D 90DAY^ABMMUPVP Q:$D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT)  ;select 90-day window
 D RFORMAT^ABMMUPVP Q:$D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT)  ;summary/abbrev. sum/patient list
 D SUMMARY^ABMMUPVP Q:$D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT)  ;summary of selections
 D ^XBFMK
 S DIR(0)="S^P:Print Report;R:Return to Selection Criteria -Erases ALL previous selections"
 S DIR("A")="Do you want to print this report?"
 D ^DIR K DIR Q:$D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT)
 I $P(Y,U)="R" K ABMY,ABMPRVDR,ABMF G EN
 S ABMQ("RX")="POUT^ABMDRUTL"
 S ABMQ("NS")="ABM"
 S ABMQ("RP")="COMPUTE^ABMMUPVH"
 D ^ABMDRDBQ
 Q
COMPUTE ;EP - gather data report
 I ABMY("90")="B" D  Q
 .S X1=ABMY("SDT")
 .S X2=89
 .D C^%DTC
 .S ABMY("EDT")=X
 .D VISITS
 .D BILLS
 .D CALC
 .D PRINT
 ;
 I ABMY("90")="C" D VISITS,BILLS,CALC,PRINT Q
 ;
 S ABMY("SDT")=(ABMY("QYR")-1701)_"1001"
 S X1=ABMY("SDT")
 S X2=89
 D C^%DTC
 S ABMY("EDT")=X
 D VISITS
 D BILLS
 D CALC
 S ABM=0
 F  S ABM=$O(ABMF(ABM)) Q:'ABM  D
 .I +$G(^XTMP("ABM-PVH",$J,"LOC TOP",ABM))>9.99 K ABMF(ABM)
 I '$D(ABMF) D PRINT Q
 S ABMQLFLG=0
 F  D  Q:ABMQLFLG=1
 .S X1=ABMY("SDT")
 .S X2=1
 .D C^%DTC
 .S ABMY("SDT")=X
 .S ABMDFLG=1
 .S X1=ABMY("SDT")
 .S X2=89
 .D C^%DTC
 .S ABMY("EDT")=X
 .I ABMY("EDT")>((ABMY("QYR")-1700)_"0930")!(ABMY("EDT")>DT) S ABMQLFLG=1 Q
 .K ^XTMP("ABM-PVH",$J,"VISITS")
 .D VISITS
 .D BILLS
 .D CALC
 .S ABM=0
 .F  S ABM=$O(ABMF(ABM)) Q:'ABM  D
 ..I +$G(^XTMP("ABM-PVH",$J,"LOC TOP",ABM))>9.99 K ABMF(ABM)
 .I '$D(ABMF) S ABMQLFLG=1 Q
 D PRINT
 Q
VISITS ;
 S ABMFILE="AUPNVINP"
 S ABMSDT=ABMY("SDT")
 S ABMEDT=ABMY("EDT")+.999999
 F  S ABMSDT=$O(^AUPNVINP("B",ABMSDT)) Q:'ABMSDT!(ABMSDT>ABMEDT)  D
 .S ABMVIEN=0
 .F  S ABMVIEN=$O(^AUPNVINP("B",ABMSDT,ABMVIEN)) Q:'ABMVIEN  D
 ..S ABMVDFN=$$GET1^DIQ(9000010.02,ABMVIEN,.03,"I")
 ..S ABMSCAT=$$GET1^DIQ(9000010,ABMVDFN,.07,"I")  ;service cat
 ..S ABMCLNC=$$GET1^DIQ(9000010,ABMVDFN,.08,"I")  ;clinic
 ..S ABMPT=$$GET1^DIQ(9000010,ABMVDFN,.05,"I")  ;patient
 ..D VISITCK
 S ABMSDT=ABMY("SDT")
 S ABMEDT=ABMY("EDT")+.999999
 S ABMFILE="AUPNVSIT"
 F  S ABMSDT=$O(^AUPNVSIT("B",ABMSDT)) Q:'ABMSDT!(ABMSDT>ABMEDT)  D
 .S ABMVDFN=0
 .F  S ABMVDFN=$O(^AUPNVSIT("B",ABMSDT,ABMVDFN)) Q:'ABMVDFN  D
 ..S ABMSCAT=$$GET1^DIQ(9000010,ABMVDFN,.07,"I")  ;service cat
 ..S ABMCLNC=$$GET1^DIQ(9000010,ABMVDFN,.08,"I")  ;clinic
 ..S ABMPT=$$GET1^DIQ(9000010,ABMVDFN,.05,"I")  ;patient
 ..D VISITCK
  Q
VISITCK ;EP
 ;service cat MUST be H, or (A w/clinic=30)
 K ABMFLG
 I ABMFILE="AUPNVINP",ABMSCAT="H" S ABMFLG=1
 I (ABMFILE="AUPNVSIT")&((ABMSCAT="A")&(ABMCLNC=30)) S ABMFLG=1
 Q:(+$G(ABMFLG)=0)
 S ABMVLOC=$$GET1^DIQ(9000010,ABMVDFN,.06,"I")
 I ($$GET1^DIQ(9000010,ABMVLOC,.12)'="")&(ABMSDT>$$GET1^DIQ(9000010,ABMVLOC,.12,"I")&($$GET1^DIQ(9000010,ABMVLOC,1111,"I")'="R")) Q
 Q:'$D(ABMF(ABMVLOC))  ;not a selected location
 S ^XTMP("ABM-PVH",$J,"LOC-DENOM",ABMY("SDT"))=+$G(^XTMP("ABM-PVH",$J,"LOC-DENOM",ABMY("SDT")))+1
 S ^XTMP("ABM-PVH",$J,"LOC-DENOM",ABMY("SDT"),ABMVLOC)=+$G(^XTMP("ABM-PVH",$J,"LOC-DENOM",ABMY("SDT"),ABMVLOC))+1
 S ^XTMP("ABM-PVH",$J,"PT VSTS",ABMPT,ABMSDT,ABMVDFN)=""  ;list of visits by patient,DOS
 S ^XTMP("ABM-PVH",$J,"VISITS",ABMVDFN)=""  ;list of visits to check for pymt
 S ^XTMP("ABM-PVH",$J,"VISIT CNT")=+$G(^XTMP("ABM-PVH",$J,"VISIT CNT"))+1  ;count of visits
 S ^XTMP("ABM-PVH",$J,"ALL VISITS",ABMVDFN)=""  ;list of all visits looked at
 S ^XTMP("ABM-PVH",$J,"ALL VISIT CNT")=+$G(^XTMP("ABM-PVH",$J,"ALL VISIT CNT"))+1  ;count of all visits
 I ^XTMP("ABM-PVH",$J,"ALL VISIT CNT")#1000 U IO(0) W "."
 K ABMITYP
 D PTDATA
 Q
BILLS ;EP
 S ABMCNT=0
 S ABMDUZ2=0
 S ABMFOUND=0
 F  S ABMDUZ2=$O(^ABMDBILL(ABMDUZ2)) Q:'ABMDUZ2  D
 .S ABMVDFN=0
 .F  S ABMVDFN=$O(^XTMP("ABM-PVH",$J,"VISITS",ABMVDFN)) Q:'ABMVDFN  D
 ..I (+$G(^XTMP("ABM-PVH",$J,"VISITS",ABMVDFN)))=1 Q  ;already counted this visit on report
 ..Q:'$D(^ABMDBILL(ABMDUZ2,"AV",ABMVDFN))  ;visit not under this DUZ(2)
 ..S ABMP("BDFN")=0
 ..F  S ABMP("BDFN")=$O(^ABMDBILL(ABMDUZ2,"AV",ABMVDFN,ABMP("BDFN"))) Q:'ABMP("BDFN")  D  Q:(+$G(^XTMP("ABM-PVH",$J,"VISITS",ABMVDFN)))=1
 ...S (ABMBILLN,ABMSAV)=$P($G(^ABMDBILL(ABMDUZ2,ABMP("BDFN"),0)),U)
 ...I $P($G(^ABMDBILL(ABMDUZ2,ABMP("BDFN"),0)),U,4)="X" Q
 ...S ABMVLOC=$P($G(^ABMDBILL(ABMDUZ2,ABMP("BDFN"),0)),U,3)
 ...S ABMINS=$P($G(^ABMDBILL(ABMDUZ2,ABMP("BDFN"),0)),U,8)
 ...S ABMPT=$P($G(^ABMDBILL(ABMDUZ2,ABMP("BDFN"),0)),U,5)
 ...F  S ABMBILLN=$O(^BARBL(ABMPAR,"B",ABMBILLN)) Q:$G(ABMBILLN)=""!(ABMBILLN'[ABMSAV)  D  Q:(+$G(^XTMP("ABM-PVH",$J,"VISITS",ABMVDFN)))=1
 ....S ABMARIEN=0
 ....S ABMHOLD=DUZ(2)
 ....S DUZ(2)=ABMPAR
 ....F  S ABMARIEN=$O(^BARBL(DUZ(2),"B",ABMBILLN,ABMARIEN)) Q:'ABMARIEN  D  Q:(+$G(^XTMP("ABM-PVH",$J,"VISITS",ABMVDFN)))=1
 .....S ABMARACT=$$GET1^DIQ(90050.01,ABMARIEN_",",3,"I")     ;A/R BILL, A/R ACCOUNT
 .....S D0=ABMARACT
 .....S ABMITYP=$$VALI^BARVPM(8)   ;GET 'VIP INSURER TYPE' CODE
 .....S ABMGRP=$S(ABMITYP="D":"MCD",ABMITYP="K":"CHIP",1:"OTHR")
 .....S ABMABILN=$P($G(^BARBL(DUZ(2),ABMARIEN,0)),U)
 .....S ABMTRIEN=0,ABMQFLG=0
 .....F  S ABMTRIEN=$O(^BARTR(DUZ(2),"AC",ABMARIEN,ABMTRIEN)) Q:'ABMTRIEN  D  Q:ABMQFLG=1
 ......S ABMTRTYP=$P($G(^BARTR(DUZ(2),ABMTRIEN,1)),U)
 ......I "^40^113^114^121^132^137^138^139^"'[("^"_ABMTRTYP_"^") Q  ;payment or payment credit
 ......I ($$GET1^DIQ(90050.03,ABMTRIEN,3.5))<(.01) Q  ;don't count 0 pymts or reversals
 ......I ABMITYP="D"!((ABMITYP="K")&$D(^ABMMUPRM(1,1,"B",ABMVLOC))) D
 .......S ABMQFLG=1
 .......I (+$G(^XTMP("ABM-PVH",$J,"VISITS",ABMVDFN)))=1 Q  ;already counted this visit on report
 .......S ^XTMP("ABM-PVH",$J,"LOC-NUM",ABMY("SDT"))=+$G(^XTMP("ABM-PVH",$J,"LOC-NUM",ABMY("SDT")))+1
 .......S ^XTMP("ABM-PVH",$J,"LOC-NUM",ABMY("SDT"),ABMVLOC)=+$G(^XTMP("ABM-PVH",$J,"LOC-NUM",ABMY("SDT"),ABMVLOC))+1
 .......S ^XTMP("ABM-PVH",$J,"LOC-VST",ABMVDFN)=""
 .......S ^XTMP("ABM-PVH",$J,"VISITS",ABMVDFN)=1
 ......S ^XTMP("ABM-PVH",$J,"LOC ENC CNT",ABMY("SDT"),ABMVLOC,ABMGRP)=+$G(^XTMP("ABM-PVH",$J,"LOC ENC CNT",ABMY("SDT"),ABMVLOC,ABMGRP))+1
 ......S ^XTMP("ABM-PVH",$J,"LOC ENC CNT",ABMY("SDT"),ABMGRP)=+$G(^XTMP("ABM-PVH",$J,"LOC ENC CNT",ABMY("SDT"),ABMGRP))+1
 ......;I ABMCNT#1000 U IO(0) W "."  ;abm*2.6*11 HEAT94295
 ......I (ABMCNT#1000&(IOST["C")) U IO(0) W "."  ;abm*2.6*11 HEAT94295
 ......S ABMCNT=+$G(ABMCNT)+1
 ......D PTDATA
 .....S DUZ(2)=ABMHOLD
 ...I +$G(ABMFOUND)=1 D OTHERVST  ;check for other visits on DOS to mark as paid
 Q
OTHERVST ;EP
 S ABMPT=$P($G(^ABMDBILL(DUZ(2),ABMP("BDFN"),0)),U,5)
 S (ABMDOS,ABMDOSSV)=$P($G(^ABMDBILL(DUZ(2),ABMP("BDFN"),7)),U)
 F  S ABMDOS=$O(^XTMP("ABM-PVH",$J,"PT VSTS",ABMPT,ABMDOS)) Q:'ABMDOS!($P(ABMDOS,".")>$P(ABMDOSSV,"."))  D
 .S ABMVCHK=0
 .F  S ABMVCHK=$O(^XTMP("ABM-PVH",$J,"PT VSTS",ABMPT,ABMDOS,ABMVCHK)) Q:'ABMVCHK  D
 ..Q:^XTMP("ABM-PVH",$J,"VISITS",ABMVCHK)=1  ;already counted this visit
 ..S ABMPIEN=0
 ..F  S ABMPIEN=$O(^AUPNVPRV("AD",ABMVCHK,ABMPIEN)) Q:'ABMPIEN  D
 ...S ABMPRV=$$GET1^DIQ(9000010.06,ABMPIEN,.01,"I")
 ...Q:$D(^XTMP("ABM-PVH",$J,"LOC-VST",ABMVCHK))
 ...S ^XTMP("ABM-PVH",$J,"LOC-NUM",ABMY("SDT"))=+$G(^XTMP("ABM-PVH",$J,"LOC-NUM",ABMY("SDT")))+1
 ...S ^XTMP("ABM-PVH",$J,"LOC-NUM",ABMY("SDT"),ABMVLOC)=+$G(^XTMP("ABM-PVH",$J,"LOC-NUM",ABMY("SDT"),ABMVLOC))+1
 ...S ^XTMP("ABM-PVH",$J,"VISITS",ABMVCHK)=1
 Q
PTDATA ;EP
 S ABMPNM=$$GET1^DIQ(2,ABMPT,.01,"E")
 S ABMINSO=$S(+$G(ABMINS):$$GET1^DIQ(9999999.18,ABMINS,.01,"E"),1:"NO BILL")
 S:$G(ABMITYP)="" ABMITYP="X"
 S:$G(ABMTRIEN)="" ABMTRIEN="NOT PAID"
 S ABMREC=ABMVDFN_U_ABMPT_U_$P(ABMTRIEN,".")_U_$S(ABMITYP="D"!((ABMITYP="K")&$D(^ABMMUPRM(1,1,"B",ABMVLOC))):"*",1:"")
 ;S ^XTMP("ABM-PVH",$J,"PT LST",ABMY("SDT"),ABMVLOC,ABMITYP,ABMINSO,$P(ABMPNM,","),$P(ABMPNM,",",2),$P($G(^AUPNVSIT(ABMVDFN,0)),U))=ABMREC  ;abm*2.6*11 HEAT94295
 S ^XTMP("ABM-PVH",$J,"PT LST",ABMY("SDT"),ABMVLOC,ABMITYP,ABMINSO,$P(ABMPNM,","),$P(ABMPNM,",",2),$P($G(^AUPNVSIT(ABMVDFN,0)),U),ABMVDFN)=ABMREC  ;abm*2.6*11 HEAT94295
 I ($G(ABMTRIEN)'="NOT PAID"),$D(^XTMP("ABM-PVH",$J,"PT LST",ABMY("SDT"),ABMVLOC,"X","NO BILL",$P(ABMPNM,","),$P(ABMPNM,",",2),$P($G(^AUPNVSIT(ABMVDFN,0)),U))) D
 .K ^XTMP("ABM-PVH",$J,"PT LST",ABMY("SDT"),ABMVLOC,"X","NO BILL",$P(ABMPNM,","),$P(ABMPNM,",",2),$P($G(^AUPNVSIT(ABMVDFN,0)),U))
 Q
CALC ;EP
 S ABMSDT=0
 F  S ABMSDT=$O(^XTMP("ABM-PVH",$J,"LOC-DENOM",ABMSDT)) Q:'ABMSDT  D
 .S ABMLOC=0
 .F  S ABMLOC=$O(^XTMP("ABM-PVH",$J,"LOC-DENOM",ABMSDT,ABMLOC)) Q:'ABMLOC  D
 ..S ABMPERCT=$J((+$G(^XTMP("ABM-PVH",$J,"LOC-NUM",ABMSDT,ABMLOC))/(+$G(^XTMP("ABM-PVH",$J,"LOC-DENOM",ABMSDT,ABMLOC))))*100,0,1)
 ..S ^XTMP("ABM-PVH",$J,"LOC PERCENT",ABMSDT,ABMLOC)=ABMPERCT
 ..I '$D(^XTMP("ABM-PVH",$J,"LOC TOP",ABMLOC)) S ^XTMP("ABM-PVH",$J,"LOC TOP",ABMLOC)=ABMPERCT_"^"_ABMSDT
 ..I +$P($G(^XTMP("ABM-PVH",$J,"LOC TOP",ABMLOC)),U)<ABMPERCT S ^XTMP("ABM-PVH",$J,"LOC TOP",ABMLOC)=ABMPERCT_"^"_ABMSDT
 Q
PRINT ;EP
 S ABMVLOC=0
 F  S ABMVLOC=$O(ABMFAC(ABMVLOC)) Q:'ABMVLOC  D  D PAZ^ABMDRUTL Q:$D(DTOUT)!$D(DUOUT)!$D(DIROUT)
 .S ABM("PG")=1
 .S ABMSDT=$P($G(^XTMP("ABM-PVH",$J,"LOC TOP",ABMVLOC)),U,2)
 .I +$G(^XTMP("ABM-PVH",$J,"LOC TOP",ABMVLOC))>9.99 S ABMPMET=1
 .D HDR^ABMMUPV3
 .;W !,"Hospital used in this report: ",$$GET1^DIQ(9999999.06,ABMVLOC,.01,"E"),$S($D(^ABMMUPRM(1,1,"B",ABMVLOC)):" (FQHC/RHC)",1:""),!  ;abm*2.6*10 HEAT61752
 .W !,"Hospital used in this report: ",$$GET1^DIQ(9999999.06,ABMVLOC,.01,"E"),$S($D(^ABMMUPRM(1,1,"B",ABMVLOC)):" (FQHC/RHC/Tribal)",1:""),!  ;abm*2.6*10 HEAT61752
 .S ABMPMET=0
 .I ABMY("RFMT")="P" D PATIENT^ABMMUPH1 Q
 .I +$G(^XTMP("ABM-PVH",$J,"LOC TOP",ABMVLOC))>9.99 D MET^ABMMUPH1 Q
 .D NOTMET^ABMMUPH1
 K ^XTMP("ABM-PVH",$J)
 Q