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

ABMDRST.m

Go to the documentation of this file.
ABMDRST ; IHS/ASDST/DMJ - Statistical Report ;
 ;;2.6;IHS 3P BILLING SYSTEM;;NOV 12, 2009
 ;Original;TMD;
 ; P-1=VISIT CNT, P-2=UNDUP CNT, P-3=$BILLED, P-4=$PAID
 K ABM,ABMY
 S ABM("RTYP")=0,ABM("PAY")=""
 D ^ABMDRSEL G XIT:$D(DTOUT)!$D(DUOUT)!$D(DIROUT)
 S ABM("HD",0)="STATISTICAL REPORT" D ^ABMDRHD
 S ABMQ("RC")="COMPUTE^ABMDRST",ABMQ("RX")="POUT^ABMDRUTL",ABMQ("NS")="ABM",ABMQ("RP")="PRINT^ABMDRST1"
 D ^ABMDRDBQ
 Q
 ;
COMPUTE ;EP - Entry Point for Setting up Data
 S ABMP("RTN")="ABMDRST"
 S ABMDUZ2=DUZ(2)
 S DUZ(2)=0
 F  S DUZ(2)=$O(^ABMDBILL(DUZ(2))) Q:'DUZ(2)  D
 .K ^TMP($J,"ABM-ST")
 .K ^TMP($J,"ABM-B")
 .S (ABM("NLN"),ABM("NLC"),ABM("NLB"),ABM("NLP"))=0
 .D LOOP^ABMDRUTL
 S DUZ(2)=ABMDUZ2
 Q
 ;
DATA ;
 NEW ABMREC,ABMSTAT,ABMTYP
 S ABMREC=$G(^ABMDBILL(DUZ(2),ABM,0))  ;MOVE BILL FILE TO ABMREC
 S ABMSTAT=$P(ABMREC,U,4)  ;SET BILL STATUS FRM BILL FILE TO ABMSTAT
 S ABMTYP=$P(ABMREC,U,7)  ;SET VISIT TYPE FROM BILL FILE TO ABMTYP
 Q:ABMSTAT="X"  ;QUIT IF BILL STATUS IS EQUAL TO X
 S ABMP("HIT")=0 D ^ABMDRCHK Q:'ABMP("HIT")
 I ABMY("SORT")="C" S ABM("V")=ABM("C")
 S ABM("PT")=$P(^ABMDBILL(DUZ(2),ABM,0),U,5)
 S:'$D(ABM("LC",ABM("L"))) ABM("LC",ABM("L"))=0
 I '$D(ABM(ABM("L"),ABM("V"))) D
 .S ABM(ABM("L"),ABM("V"))="0^0^0^0"
 ;Next line counts # undup pats
 I '$D(^TMP($J,"ABM-ST",ABM("L"),ABM("V"),ABM("PT"))) D
 .S ^TMP($J,"ABM-ST",ABM("L"),ABM("V"),ABM("PT"))=""
 .S $P(ABM(ABM("L"),ABM("V")),U,2)=$P(ABM(ABM("L"),ABM("V")),U,2)+1
 ; NEXT 5 LINES ADDING PAID AMOUNTS
 S ABM("P")=0
 F  S ABM("P")=$O(^ABMDBILL(DUZ(2),ABM,3,ABM("P"))) Q:'ABM("P")  D
 .S ABM("PDD")=+^ABMDBILL(DUZ(2),ABM,3,ABM("P"),0)
 .I $G(ABMY("DT"))="P",ABM("PDD")<ABMY("DT",1)!(ABM("PDD")>ABMY("DT",2)) Q
 .S $P(ABM(ABM("L"),ABM("V")),U,4)=$P(ABM(ABM("L"),ABM("V")),U,4)+$P(^ABMDBILL(DUZ(2),ABM,3,ABM("P"),0),U,2)
 ; NEXT 3 LINES COUNT TOTAL NUMBER OF UNDUP PATIENTS
 I '$D(^TMP($J,"ABM-ST",ABM("L"),ABM("PT"))) DO
 .S ^TMP($J,"ABM-ST",ABM("L"),ABM("PT"))=""
 .S ABM("LC",ABM("L"))=ABM("LC",ABM("L"))+1
 I '$D(^TMP($J,"ABM-ST",ABM("PT"))) DO
 .S ^TMP($J,"ABM-ST",ABM("PT"))=""
 .S ABM("NLC")=ABM("NLC")+1
 ; NEXT 3 LINES CHECKS FOR FIRST VALID BILL 
 SET ABMBILL=+ABMREC ;SET BILL WITHOUT NUMBER
 Q:$D(^TMP($J,"ABM-B",ABMBILL))  ;CK IF IS FOUND
 SET ^TMP($J,"ABM-B",ABMBILL)="" ;CK IF TMP IS UNIQUE USING ABM-B
 ; NEXT LINE COUNTS # OF VISITS
 S $P(ABM(ABM("L"),ABM("V")),U)=$P(ABM(ABM("L"),ABM("V")),U)+1
 ;Next line is adding billed amount
 S $P(ABM(ABM("L"),ABM("V")),U,3)=$P(ABM(ABM("L"),ABM("V")),U,3)+$P(^ABMDBILL(DUZ(2),ABM,2),U,3)
 I ABMTYP=111 D  ;CK IF NOT EQUAL TO OUTPATIENT-NEED ONLY INPATIENTS
 .S ABM(ABM("L"),"COVD")=$G(ABM(ABM("L"),"COVD"))+$P(^ABMDBILL(DUZ(2),ABM,7),U,3)
 Q
 ;
XIT K ABM,ABMY,ABMP
 Q