ABMMUFC5 ;IHS/SD/SDR - EHR Incentive Report (MU) ;
;;2.6;IHS 3P BILLING SYSTEM;**6,7,12,15**;NOV 12, 2009;Build 251
;IHS/SDR/SDR - 2.6*12 - VMBP RQMT_104 - Added VA data to report
;IHS/SD/SDR - 2.6*12 - Added swingbed
;IHS/SD/SDR - 2.6*15 - HEAT183309 - Created separate GETBILLS for 'F' option since they are so different now
GETBILLS ;EP
S ABMPSDT=ABMP("SDT")-10000
F S ABMPSDT=$O(^ABMDBILL(DUZ(2),"AD",ABMPSDT)) Q:'ABMPSDT D ;loop thru service date from x-ref
.S ABMPFLG=0 ;abm*2.6*15 HEAT183309 Req#B
.S ABMP("BDFN")=0
.F S ABMP("BDFN")=$O(^ABMDBILL(DUZ(2),"AD",ABMPSDT,ABMP("BDFN"))) Q:'ABMP("BDFN") D
..S ABMVDFN=0
..F S ABMVDFN=$O(^ABMDBILL(DUZ(2),ABMP("BDFN"),11,ABMVDFN)) Q:'ABMVDFN D Q:ABMPFLG=1
...I $P($G(^AUPNVSIT(ABMVDFN,0)),U,11)=1 Q ;deleted visit
...S ABMSC=$P($G(^AUPNVSIT(ABMVDFN,0)),U,7) ;service category
...I "HIASRO"'[ABMSC Q ;ignore all other service categories
...;H=Hosp
...;I=In Hosp
...;A=Amb
...;S=Day Surg
...;R=Nurs Home
...;O=Observ
...;parent visit link; default to visit if there isn't one
...S ABMP("PVDFN")=$S($P($G(^AUPNVSIT(ABMVDFN,0)),U,12):$P(^AUPNVSIT(ABMVDFN,0),U,12),1:ABMVDFN)
...;if not Hospitalization, use Visit/Admit Date&Time
...I ABMSC'="H",($P($G(^AUPNVSIT(ABMP("PVDFN"),0)),U)<ABMP("SDT")) Q ;seen before start date
...I ABMSC'="H",($P($G(^AUPNVSIT(ABMP("PVDFN"),0)),U)>ABMP("EDT")) Q ;seen after end date
...;if Hospitalization, get Date of Discharge from V Hospitalization file
...S ABMQFLG=1
...I ABMSC="H" D Q:ABMQFLG=0
....;S ABMP("VHIEN")=$O(^AUPNVINP("AD",ABMP("PVDFN"),0)) ;abm*2.6*7
....S ABMP("VHIEN")=+$O(^AUPNVINP("AD",ABMP("PVDFN"),0)) ;abm*2.6*7
....I ABMP("VHIEN")=0 S ABMQFLG=0 Q
....S ABMP("DISCHDT")=$P($G(^AUPNVINP(ABMP("VHIEN"),0)),U)
....I ABMP("DISCHDT")<ABMP("SDT") S ABMQFLG=0 Q ;seen before start date
....I ABMP("DISCHDT")>ABMP("EDT") S ABMQFLG=0 Q ;seen after end date
....;start new abm*2.6*12 swingbed
....S ABMP("SWINGBED")=0
....I $$GET1^DIQ(45.7,$$GET1^DIQ(9000010.02,ABMP("VHIEN"),".04","I"),"9999999.01","E")=21 S ABMP("SWINGBED")=1
....I $$GET1^DIQ(45.7,$$GET1^DIQ(9000010.02,ABMP("VHIEN"),".05","I"),"9999999.01","E")=21 S ABMP("SWINGBED")=1
....;end new swingbed
...S ABMPBDFN=0
...S ABMPFLG=0 ;pymt flg
...K ABMB
...F ABMC=1:1 S ABMPBDFN=$O(^ABMDBILL(DUZ(2),"AV",ABMP("PVDFN"),ABMPBDFN)) Q:'ABMPBDFN D Q:ABMPFLG=1
....S ABMP("BTYP")=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,2) ;bill type
....S ABMP("VTYP")=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,7) ;visit type
....I $P($G(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,4)="X" Q ;skip cancelled bills
....S ABMB(ABMP("VTYP"),ABMP("BTYP"),ABMC)=ABMPBDFN
...I '$D(ABMB) Q ;no active bills found ;abm*2.6*15 HEAT183309
...S ABMP("VTYP")=0
...F S ABMP("VTYP")=$O(ABMB(ABMP("VTYP"))) Q:'ABMP("VTYP") D Q:ABMPFLG=1
....S ABMP("BTYP")=0
....F S ABMP("BTYP")=$O(ABMB(ABMP("VTYP"),ABMP("BTYP"))) Q:'ABMP("BTYP") D Q:ABMPFLG=1
.....S ABMC=0
.....F S ABMC=$O(ABMB(ABMP("VTYP"),ABMP("BTYP"),ABMC)) Q:'ABMC D Q:ABMPFLG=1
......S ABMPBDFN=$G(ABMB(ABMP("VTYP"),ABMP("BTYP"),ABMC))
......S ABM=ABMPBDFN
......S ABMP("PDFN")=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,5)
......S ABMP("INS")=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,8)
......S ABMP("LDFN")=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,3)
......S ABMP("VDT")=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,7)),U)
......S ABMP("NEWBORN")=0 ;abm*2.6*7
......I $$GET1^DIQ(9002274.03,$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,5)),U),.03,"E")="NEWBORN" S ABMP("NEWBORN")=1 ;abm*2.6*7
......S ABMP("PD")=0 ;abm*2.6*15 HEAT183309 Req#B
......D PREV^ABMMUFC3
......I +$G(ABMP("PD"))=0&('ABMPYD) Q ;skip if no payment made on bill
......S ABMPFLG=1
...I ABMPFLG=0 D ;if ABMPFLG=0 there wasn't a pymt on any bill; use the first one billed
....S ABMP("VTYP")=$O(ABMB(0))
....S ABMP("BTYP")=$O(ABMB(ABMP("VTYP"),0))
....S ABMC=$O(ABMB(ABMP("VTYP"),ABMP("BTYP"),0))
....S ABMPBDFN=$G(ABMB(ABMP("VTYP"),ABMP("BTYP"),ABMC))
...;start old abm*2.6*15 HEAT183309 Req#B
...;;if it gets here and ABMPFLG is 0, no pymt was found for any bill for this visit
...;Q:+$G(ABMPFLG)=0
...;end old HEAT183309 Req#B
...;if it gets here, ABMP("BDFN") is the first bill with a payment
...S ABMIT=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,2)),U,2)
...D INSTYP
...S ABMP("INS")=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,8)
...S ABMP("FSDT")=0,ABMFFLG=0
...F S ABMP("FSDT")=$O(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),11,ABMP("FSDT"))) Q:'ABMP("FSDT") D Q:ABMFFLG=1
....I $P($G(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),11,ABMP("FSDT"),0)),U)>ABMP("EDT") Q
....I $P($G(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),11,ABMP("FSDT"),0)),U,2)>ABMP("SDT") Q
....S ABMFFLG=1
...D SETCAT^ABMMUFAC
...;Q:$D(^TMP($J,"ABM-MUVLST",ABMP("PVDFN"))) ;quit if this visit has already counted
...;S ^TMP($J,"ABM-MUVLST",ABMP("PVDFN"))="" ;add visit to list
...;start new abm*2.6*15 HEAT183309 Req#B
...S ABMDOSB=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,7)),U)
...S ABMDOSE=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,7)),U,2)
...S ABMBILLD=+$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,2)),U)
...S ABMVLOC=$$GET1^DIQ(9002274.4,ABMPBDFN,".03","E")
...S ABMNDAYS=+$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,6)),U,6)
...S ABMCDAYS=+$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,7)),U,3)
...S:'ABMCDAYS ABMCDAYS=$P($G(^ABMDBILL(DUZ(2),ABMPBDFN,6)),U,9)
...S:'ABMCDAYS ABMCDAYS=1
...S ABMRT=$S(+$G(ABMP("PD"))'=0&(ABMPYD):"PD",1:"BLD")
...I "^S^B^"[("^"_ABMSUMDT_"^") D SUMMREC
...I "^D^B^"[("^"_ABMSUMDT_"^") D DETREC
Q
SUMMREC ;EP
;cnt # IP/OP discharges
I $D(^TMP($J,"ABM-MUVLST",ABMP("PVDFN")))&(ABMITYP'="PRI/MCD") Q ;quit if this visit has already counted
S ^TMP($J,"ABM-MUVLST",ABMP("PVDFN"))="" ;add visit to list
;
S ^TMP($J,"ABM-MUFAC",ABMITYP,ABMP("RPT-CAT"))=+$G(^TMP($J,"ABM-MUFAC",ABMITYP,ABMP("RPT-CAT")))+1
;tot cov'd days
S:(ABMP("RPT-CAT")="IP SB DISCHGS") ^TMP($J,"ABM-MUFAC",ABMITYP,"IP SB DAYS")=+$G(^TMP($J,"ABM-MUFAC",ABMITYP,"IP SB DAYS"))+ABMCDAYS
S:(ABMP("RPT-CAT")="IP DISCHGS") ^TMP($J,"ABM-MUFAC",ABMITYP,"IP DAYS")=+$G(^TMP($J,"ABM-MUFAC",ABMITYP,"IP DAYS"))+ABMCDAYS
S:(ABMP("RPT-CAT")="IP NB DISCHGS") ^TMP($J,"ABM-MUFAC",ABMITYP,"IP NB DAYS")=+$G(^TMP($J,"ABM-MUFAC",ABMITYP,"IP NB DAYS"))+ABMCDAYS
S:(ABMP("RPT-CAT")="IP CHGS") ^TMP($J,"ABM-MUFAC",ABMITYP,"IP CHGS DAYS")=+$G(^TMP($J,"ABM-MUFAC",ABMITYP,"IP CHGS DAYS"))+ABMCDAYS
Q
DETREC ;EP
I ABMITYP="PRI/MCD" K ^TMP($J,"ABM-MUVLST",ABMP("PVDFN"))
I $D(^TMP($J,"ABM-MUVLST",ABMP("PVDFN"))) Q ;quit if this visit has already counted
S ^TMP($J,"ABM-MUVLST",ABMP("PVDFN"))="" ;add visit to list
;
S ABMP("INSN")=$P($G(^AUTNINS(ABMP("INS"),0)),U)
S ABMREC=ABMDOSB_U_ABMDOSE_U_ABMBILLD_U_+$G(ABMP("PD"))_U_ABMCDAYS_U_ABMNDAYS_U_ABMVLOC_U_DUZ(2)_U_ABMPBDFN
S ^TMP($J,"ABM-MUFAC","DETAIL",ABMITYP,ABMP("RPT-CAT"),ABMP("INSN")_"|"_ABMP("INS"),$S(+$G(ABMP("PVDFN")):ABMP("PVDFN"),1:ABMVDFN))=ABMREC
Q
INSTYP ;EP
I "^R^MH^MD^"[("^"_ABMIT_"^") S ABMITYP="MEDICARE"
I "^P^H^D^F^"[("^"_ABMIT_"^") S ABMITYP="PRIVATE"
I ABMIT="D" S ABMITYP="MEDICAID"
I ABMIT="K" S ABMITYP="KIDSCARE/CHIP"
I ABMIT="V" S ABMITYP="VMBP"
I "^W^C^N^I^T^G^FPL^MMC^MC^SEP^TSI^"[("^"_ABMIT_"^") S ABMITYP="OTHER"
Q
ABMMUFC5 ;IHS/SD/SDR - EHR Incentive Report (MU) ;
+1 ;;2.6;IHS 3P BILLING SYSTEM;**6,7,12,15**;NOV 12, 2009;Build 251
+2 ;IHS/SDR/SDR - 2.6*12 - VMBP RQMT_104 - Added VA data to report
+3 ;IHS/SD/SDR - 2.6*12 - Added swingbed
+4 ;IHS/SD/SDR - 2.6*15 - HEAT183309 - Created separate GETBILLS for 'F' option since they are so different now
GETBILLS ;EP
+1 SET ABMPSDT=ABMP("SDT")-10000
+2 ;loop thru service date from x-ref
FOR
SET ABMPSDT=$ORDER(^ABMDBILL(DUZ(2),"AD",ABMPSDT))
IF 'ABMPSDT
QUIT
Begin DoDot:1
+3 ;abm*2.6*15 HEAT183309 Req#B
SET ABMPFLG=0
+4 SET ABMP("BDFN")=0
+5 FOR
SET ABMP("BDFN")=$ORDER(^ABMDBILL(DUZ(2),"AD",ABMPSDT,ABMP("BDFN")))
IF 'ABMP("BDFN")
QUIT
Begin DoDot:2
+6 SET ABMVDFN=0
+7 FOR
SET ABMVDFN=$ORDER(^ABMDBILL(DUZ(2),ABMP("BDFN"),11,ABMVDFN))
IF 'ABMVDFN
QUIT
Begin DoDot:3
+8 ;deleted visit
IF $PIECE($GET(^AUPNVSIT(ABMVDFN,0)),U,11)=1
QUIT
+9 ;service category
SET ABMSC=$PIECE($GET(^AUPNVSIT(ABMVDFN,0)),U,7)
+10 ;ignore all other service categories
IF "HIASRO"'[ABMSC
QUIT
+11 ;H=Hosp
+12 ;I=In Hosp
+13 ;A=Amb
+14 ;S=Day Surg
+15 ;R=Nurs Home
+16 ;O=Observ
+17 ;parent visit link; default to visit if there isn't one
+18 SET ABMP("PVDFN")=$SELECT($PIECE($GET(^AUPNVSIT(ABMVDFN,0)),U,12):$PIECE(^AUPNVSIT(ABMVDFN,0),U,12),1:ABMVDFN)
+19 ;if not Hospitalization, use Visit/Admit Date&Time
+20 ;seen before start date
IF ABMSC'="H"
IF ($PIECE($GET(^AUPNVSIT(ABMP("PVDFN"),0)),U)<ABMP("SDT"))
QUIT
+21 ;seen after end date
IF ABMSC'="H"
IF ($PIECE($GET(^AUPNVSIT(ABMP("PVDFN"),0)),U)>ABMP("EDT"))
QUIT
+22 ;if Hospitalization, get Date of Discharge from V Hospitalization file
+23 SET ABMQFLG=1
+24 IF ABMSC="H"
Begin DoDot:4
+25 ;S ABMP("VHIEN")=$O(^AUPNVINP("AD",ABMP("PVDFN"),0)) ;abm*2.6*7
+26 ;abm*2.6*7
SET ABMP("VHIEN")=+$ORDER(^AUPNVINP("AD",ABMP("PVDFN"),0))
+27 IF ABMP("VHIEN")=0
SET ABMQFLG=0
QUIT
+28 SET ABMP("DISCHDT")=$PIECE($GET(^AUPNVINP(ABMP("VHIEN"),0)),U)
+29 ;seen before start date
IF ABMP("DISCHDT")<ABMP("SDT")
SET ABMQFLG=0
QUIT
+30 ;seen after end date
IF ABMP("DISCHDT")>ABMP("EDT")
SET ABMQFLG=0
QUIT
+31 ;start new abm*2.6*12 swingbed
+32 SET ABMP("SWINGBED")=0
+33 IF $$GET1^DIQ(45.7,$$GET1^DIQ(9000010.02,ABMP("VHIEN"),".04","I"),"9999999.01","E")=21
SET ABMP("SWINGBED")=1
+34 IF $$GET1^DIQ(45.7,$$GET1^DIQ(9000010.02,ABMP("VHIEN"),".05","I"),"9999999.01","E")=21
SET ABMP("SWINGBED")=1
+35 ;end new swingbed
End DoDot:4
IF ABMQFLG=0
QUIT
+36 SET ABMPBDFN=0
+37 ;pymt flg
SET ABMPFLG=0
+38 KILL ABMB
+39 FOR ABMC=1:1
SET ABMPBDFN=$ORDER(^ABMDBILL(DUZ(2),"AV",ABMP("PVDFN"),ABMPBDFN))
IF 'ABMPBDFN
QUIT
Begin DoDot:4
+40 ;bill type
SET ABMP("BTYP")=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,2)
+41 ;visit type
SET ABMP("VTYP")=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,7)
+42 ;skip cancelled bills
IF $PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,4)="X"
QUIT
+43 SET ABMB(ABMP("VTYP"),ABMP("BTYP"),ABMC)=ABMPBDFN
End DoDot:4
IF ABMPFLG=1
QUIT
+44 ;no active bills found ;abm*2.6*15 HEAT183309
IF '$DATA(ABMB)
QUIT
+45 SET ABMP("VTYP")=0
+46 FOR
SET ABMP("VTYP")=$ORDER(ABMB(ABMP("VTYP")))
IF 'ABMP("VTYP")
QUIT
Begin DoDot:4
+47 SET ABMP("BTYP")=0
+48 FOR
SET ABMP("BTYP")=$ORDER(ABMB(ABMP("VTYP"),ABMP("BTYP")))
IF 'ABMP("BTYP")
QUIT
Begin DoDot:5
+49 SET ABMC=0
+50 FOR
SET ABMC=$ORDER(ABMB(ABMP("VTYP"),ABMP("BTYP"),ABMC))
IF 'ABMC
QUIT
Begin DoDot:6
+51 SET ABMPBDFN=$GET(ABMB(ABMP("VTYP"),ABMP("BTYP"),ABMC))
+52 SET ABM=ABMPBDFN
+53 SET ABMP("PDFN")=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,5)
+54 SET ABMP("INS")=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,8)
+55 SET ABMP("LDFN")=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,3)
+56 SET ABMP("VDT")=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,7)),U)
+57 ;abm*2.6*7
SET ABMP("NEWBORN")=0
+58 ;abm*2.6*7
IF $$GET1^DIQ(9002274.03,$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,5)),U),.03,"E")="NEWBORN"
SET ABMP("NEWBORN")=1
+59 ;abm*2.6*15 HEAT183309 Req#B
SET ABMP("PD")=0
+60 DO PREV^ABMMUFC3
+61 ;skip if no payment made on bill
IF +$GET(ABMP("PD"))=0&('ABMPYD)
QUIT
+62 SET ABMPFLG=1
End DoDot:6
IF ABMPFLG=1
QUIT
End DoDot:5
IF ABMPFLG=1
QUIT
End DoDot:4
IF ABMPFLG=1
QUIT
+63 ;if ABMPFLG=0 there wasn't a pymt on any bill; use the first one billed
IF ABMPFLG=0
Begin DoDot:4
+64 SET ABMP("VTYP")=$ORDER(ABMB(0))
+65 SET ABMP("BTYP")=$ORDER(ABMB(ABMP("VTYP"),0))
+66 SET ABMC=$ORDER(ABMB(ABMP("VTYP"),ABMP("BTYP"),0))
+67 SET ABMPBDFN=$GET(ABMB(ABMP("VTYP"),ABMP("BTYP"),ABMC))
End DoDot:4
+68 ;start old abm*2.6*15 HEAT183309 Req#B
+69 ;;if it gets here and ABMPFLG is 0, no pymt was found for any bill for this visit
+70 ;Q:+$G(ABMPFLG)=0
+71 ;end old HEAT183309 Req#B
+72 ;if it gets here, ABMP("BDFN") is the first bill with a payment
+73 SET ABMIT=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,2)),U,2)
+74 DO INSTYP
+75 SET ABMP("INS")=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,0)),U,8)
+76 SET ABMP("FSDT")=0
SET ABMFFLG=0
+77 FOR
SET ABMP("FSDT")=$ORDER(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),11,ABMP("FSDT")))
IF 'ABMP("FSDT")
QUIT
Begin DoDot:4
+78 IF $PIECE($GET(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),11,ABMP("FSDT"),0)),U)>ABMP("EDT")
QUIT
+79 IF $PIECE($GET(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),11,ABMP("FSDT"),0)),U,2)>ABMP("SDT")
QUIT
+80 SET ABMFFLG=1
End DoDot:4
IF ABMFFLG=1
QUIT
+81 DO SETCAT^ABMMUFAC
+82 ;Q:$D(^TMP($J,"ABM-MUVLST",ABMP("PVDFN"))) ;quit if this visit has already counted
+83 ;S ^TMP($J,"ABM-MUVLST",ABMP("PVDFN"))="" ;add visit to list
+84 ;start new abm*2.6*15 HEAT183309 Req#B
+85 SET ABMDOSB=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,7)),U)
+86 SET ABMDOSE=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,7)),U,2)
+87 SET ABMBILLD=+$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,2)),U)
+88 SET ABMVLOC=$$GET1^DIQ(9002274.4,ABMPBDFN,".03","E")
+89 SET ABMNDAYS=+$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,6)),U,6)
+90 SET ABMCDAYS=+$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,7)),U,3)
+91 IF 'ABMCDAYS
SET ABMCDAYS=$PIECE($GET(^ABMDBILL(DUZ(2),ABMPBDFN,6)),U,9)
+92 IF 'ABMCDAYS
SET ABMCDAYS=1
+93 SET ABMRT=$SELECT(+$GET(ABMP("PD"))'=0&(ABMPYD):"PD",1:"BLD")
+94 IF "^S^B^"[("^"_ABMSUMDT_"^")
DO SUMMREC
+95 IF "^D^B^"[("^"_ABMSUMDT_"^")
DO DETREC
End DoDot:3
IF ABMPFLG=1
QUIT
End DoDot:2
End DoDot:1
+96 QUIT
SUMMREC ;EP
+1 ;cnt # IP/OP discharges
+2 ;quit if this visit has already counted
IF $DATA(^TMP($JOB,"ABM-MUVLST",ABMP("PVDFN")))&(ABMITYP'="PRI/MCD")
QUIT
+3 ;add visit to list
SET ^TMP($JOB,"ABM-MUVLST",ABMP("PVDFN"))=""
+4 ;
+5 SET ^TMP($JOB,"ABM-MUFAC",ABMITYP,ABMP("RPT-CAT"))=+$GET(^TMP($JOB,"ABM-MUFAC",ABMITYP,ABMP("RPT-CAT")))+1
+6 ;tot cov'd days
+7 IF (ABMP("RPT-CAT")="IP SB DISCHGS")
SET ^TMP($JOB,"ABM-MUFAC",ABMITYP,"IP SB DAYS")=+$GET(^TMP($JOB,"ABM-MUFAC",ABMITYP,"IP SB DAYS"))+ABMCDAYS
+8 IF (ABMP("RPT-CAT")="IP DISCHGS")
SET ^TMP($JOB,"ABM-MUFAC",ABMITYP,"IP DAYS")=+$GET(^TMP($JOB,"ABM-MUFAC",ABMITYP,"IP DAYS"))+ABMCDAYS
+9 IF (ABMP("RPT-CAT")="IP NB DISCHGS")
SET ^TMP($JOB,"ABM-MUFAC",ABMITYP,"IP NB DAYS")=+$GET(^TMP($JOB,"ABM-MUFAC",ABMITYP,"IP NB DAYS"))+ABMCDAYS
+10 IF (ABMP("RPT-CAT")="IP CHGS")
SET ^TMP($JOB,"ABM-MUFAC",ABMITYP,"IP CHGS DAYS")=+$GET(^TMP($JOB,"ABM-MUFAC",ABMITYP,"IP CHGS DAYS"))+ABMCDAYS
+11 QUIT
DETREC ;EP
+1 IF ABMITYP="PRI/MCD"
KILL ^TMP($JOB,"ABM-MUVLST",ABMP("PVDFN"))
+2 ;quit if this visit has already counted
IF $DATA(^TMP($JOB,"ABM-MUVLST",ABMP("PVDFN")))
QUIT
+3 ;add visit to list
SET ^TMP($JOB,"ABM-MUVLST",ABMP("PVDFN"))=""
+4 ;
+5 SET ABMP("INSN")=$PIECE($GET(^AUTNINS(ABMP("INS"),0)),U)
+6 SET ABMREC=ABMDOSB_U_ABMDOSE_U_ABMBILLD_U_+$GET(ABMP("PD"))_U_ABMCDAYS_U_ABMNDAYS_U_ABMVLOC_U_DUZ(2)_U_ABMPBDFN
+7 SET ^TMP($JOB,"ABM-MUFAC","DETAIL",ABMITYP,ABMP("RPT-CAT"),ABMP("INSN")_"|"_ABMP("INS"),$SELECT(+$GET(ABMP("PVDFN")):ABMP("PVDFN"),1:ABMVDFN))=ABMREC
+8 QUIT
INSTYP ;EP
+1 IF "^R^MH^MD^"[("^"_ABMIT_"^")
SET ABMITYP="MEDICARE"
+2 IF "^P^H^D^F^"[("^"_ABMIT_"^")
SET ABMITYP="PRIVATE"
+3 IF ABMIT="D"
SET ABMITYP="MEDICAID"
+4 IF ABMIT="K"
SET ABMITYP="KIDSCARE/CHIP"
+5 IF ABMIT="V"
SET ABMITYP="VMBP"
+6 IF "^W^C^N^I^T^G^FPL^MMC^MC^SEP^TSI^"[("^"_ABMIT_"^")
SET ABMITYP="OTHER"
+7 QUIT