HBHCRP7 ;LR VAMC(IRMS)/MJT - HBHC file 631 rpt, user selects: adm or D/C by date range, & sort alphabetic by pt or date of adm or D/C; includes adm/D/C date, pt name, last four, & primary DX @ adm/D/C (code & text) ;12/21/05 3:43pm
;;1.0;HOSPITAL BASED HOME CARE;**5,6,21,22,24,25**;NOV 01, 1993;Build 45
;
; This routine references the following supported ICRs:
; 5747 $$CODEC^ICDEX
; 5747 $$VSTD^ICDEX
;
;******************************************************************************
;******************************************************************************
; --- ROUTINE MODIFICATION LOG ---
;
;PKG/PATCH DATE DEVELOPER MODIFICATION
;----------- ---------- ----------- ----------------------------------------
;HBH*1.0*25 FEB 2012 K GUPTA Support for ICD-10 Coding System
;******************************************************************************
;******************************************************************************
;
S DIR(0)="SB^A:Admissions;D:Discharges;",DIR("A")="Select Admissions or Discharges",DIR("?")="Enter 'A' to include Admissions on the report, 'D' to choose Discharges." D ^DIR
G:$D(DIRUT) EXIT
S HBHCTYPS=Y(0),HBHCTYP=$E(Y(0),1,9),HBHCXREF=$S(Y="A":"AD",1:"AC"),HBHCDXPC=$S(Y="A":19,1:47),HBHCCC=0
; Prompt user for sort preference: alphabetical by patient or date of admission or D/C
K DIR S DIR(0)="SB^A:Alphabetical;D:Date of Admission or D/C",DIR("A")="Sort Alphabetically by Patient or by Date",DIR("?")="Sort report alphabetically by patient (A), or by date of admission or D/C (D)." D ^DIR
G:$D(DIRUT) EXIT
; HBHCFLG exists if alphabetic sort selected
S:Y="A" HBHCFLG=1
D START^HBHCUTL
G:(HBHCBEG1=-1)!(HBHCEND1=-1) EXIT
S %ZIS="Q" K IOP,ZTIO,ZTSAVE D ^%ZIS G:POP EXIT
I $D(IO("Q")) S ZTRTN="DQ^HBHCRP7",ZTDESC="HBPC "_HBHCTYP_"Alphabetic Date Range Report",ZTSAVE("HBHC*")="" D ^%ZTLOAD G EXIT
DQ ; De-queue
U IO
K ^TMP("HBHC",$J)
S $P(HBHCY,"-",133)="",$P(HBHCZ,"=",133)=""
S:'$D(HBHCFLG) HBHCHEAD=HBHCTYPS_" by Date Range, Date Range Sort"
S:$D(HBHCFLG) HBHCHEAD=HBHCTYPS_" by Date Range, Alphabetic Sort"
I $D(HBHCFLG) S HBHCHDR="W ""Patient Name"",?38,HBHCTYP_"" Date"",?60" I 1
E S HBHCHDR="W HBHCTYP_"" Date"",?19,""Patient Name"",?60"
S HBHCHDR=HBHCHDR_",""Last Four"",?82,"""_$$ICDTEXT^HBHCUTL3(HBHCBEG1,HBHCEND1)_" Code"",?100,""Diagnosis Text"""
S HBHCCOLM=(132-(30+$L(HBHCHEAD))\2) S:HBHCCOLM'>0 HBHCCOLM=1
D TODAY^HBHCUTL
LOOP ; Loop thru ^HBHC(631) "AD" (admission date) or "AC" (discharge date) cross-ref to build report
S X1=HBHCBEG1,X2=-1 D C^%DTC S HBHCDATE=X
F S HBHCDATE=$O(^HBHC(631,HBHCXREF,HBHCDATE)) Q:(HBHCDATE="")!(HBHCDATE>HBHCEND1) S HBHCDFN="" F S HBHCDFN=$O(^HBHC(631,HBHCXREF,HBHCDATE,HBHCDFN)) Q:HBHCDFN="" S HBHCNOD0=^HBHC(631,HBHCDFN,0) D:$P(HBHCNOD0,U,15)=1 PROCESS
D:IO'=IO(0)!($D(IO("S"))) HDR132^HBHCUTL
I '$D(IO("S")),(IO=IO(0)) S HBHCCC=HBHCCC+1 D HDR132^HBHCUTL
W:'$D(^TMP("HBHC",$J)) !!,"No "_HBHCTYPS_" found for Date Range selected."
I $D(^TMP("HBHC",$J)) D PRTLOOP W !!,HBHCZ,!,"Total "_HBHCTYPS_": ",HBHCTOT,!,HBHCZ
D END132^HBHCUTL1
EXIT ; Exit module
D ^%ZISC
K DIR,DIRUT,HBHCBEG1,HBHCBEG2,HBHCCOLM,HBHCCC,HBHCDATE,HBHCDFN,HBHCDPT0,HBHCDT,HBHCDXPC,HBHCEND1,HBHCEND2,HBHCFLG,HBHCHDR,HBHCHEAD,HBHCICDP,HBHCNAME,HBHCNOD0,HBHCPAGE,HBHCTDY,HBHCTMP,HBHCTOT,HBHCTYP,HBHCTYPS,HBHCXREF
K HBHCY,HBHCZ,X,X1,X2,Y,^TMP("HBHC",$J)
Q
PROCESS ; Process record & create ^TMP("HBHC",$J global
S HBHCDPT0=^DPT($P(HBHCNOD0,U),0),HBHCICDP=$P(HBHCNOD0,U,HBHCDXPC)
N HBHCDXCODE,HBHCDXDESC
I HBHCICDP]"" D I 1
. S HBHCDXCODE=$$CODEC^ICDEX(80,HBHCICDP)
. S HBHCDXDESC=$$VSTD^ICDEX(HBHCICDP)
S:'$D(HBHCFLG) ^TMP("HBHC",$J,HBHCDATE,$P(HBHCDPT0,U))=$E($P(HBHCDPT0,U,9),6,9)_U_$G(HBHCDXCODE)_U_$G(HBHCDXDESC)
S:$D(HBHCFLG) ^TMP("HBHC",$J,$P(HBHCDPT0,U),HBHCDATE)=$E($P(HBHCDPT0,U,9),6,9)_U_$G(HBHCDXCODE)_U_$G(HBHCDXDESC)
Q
PRTLOOP ; Print loop
S HBHCTOT=0
I '$D(HBHCFLG) S HBHCDT="" F S HBHCDT=$O(^TMP("HBHC",$J,HBHCDT)) Q:HBHCDT="" S HBHCNAME="" F S HBHCNAME=$O(^TMP("HBHC",$J,HBHCDT,HBHCNAME)) Q:HBHCNAME="" D PRT
I $D(HBHCFLG) S HBHCNAME="" F S HBHCNAME=$O(^TMP("HBHC",$J,HBHCNAME)) Q:HBHCNAME="" S HBHCDT="" F S HBHCDT=$O(^TMP("HBHC",$J,HBHCNAME,HBHCDT)) Q:HBHCDT="" D PRT
Q
PRT ; Print report
I ($D(ZTRTN)!(HBHCCC=0))&((IOSL-$Y)<5) W @IOF D HDR132^HBHCUTL
S HBHCTOT=HBHCTOT+1
S:'$D(HBHCFLG) HBHCTMP=^TMP("HBHC",$J,HBHCDT,HBHCNAME)
S:$D(HBHCFLG) HBHCTMP=^TMP("HBHC",$J,HBHCNAME,HBHCDT)
W:'$D(HBHCFLG) !,$E(HBHCDT,4,5)_"-"_$E(HBHCDT,6,7)_"-"_$E(HBHCDT,2,3),?19,HBHCNAME,?60,$P(HBHCTMP,U),?82,$P(HBHCTMP,U,2),?100,$P(HBHCTMP,U,3),!,HBHCY
W:$D(HBHCFLG) !,HBHCNAME,?38,$E(HBHCDT,4,5)_"-"_$E(HBHCDT,6,7)_"-"_$E(HBHCDT,2,3),?60,$P(HBHCTMP,U),?82,$P(HBHCTMP,U,2),?100,$P(HBHCTMP,U,3),!,HBHCY
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHBHCRP7 4878 printed Oct 16, 2024@17:59:28 Page 2
HBHCRP7 ;LR VAMC(IRMS)/MJT - HBHC file 631 rpt, user selects: adm or D/C by date range, & sort alphabetic by pt or date of adm or D/C; includes adm/D/C date, pt name, last four, & primary DX @ adm/D/C (code & text) ;12/21/05 3:43pm
+1 ;;1.0;HOSPITAL BASED HOME CARE;**5,6,21,22,24,25**;NOV 01, 1993;Build 45
+2 ;
+3 ; This routine references the following supported ICRs:
+4 ; 5747 $$CODEC^ICDEX
+5 ; 5747 $$VSTD^ICDEX
+6 ;
+7 ;******************************************************************************
+8 ;******************************************************************************
+9 ; --- ROUTINE MODIFICATION LOG ---
+10 ;
+11 ;PKG/PATCH DATE DEVELOPER MODIFICATION
+12 ;----------- ---------- ----------- ----------------------------------------
+13 ;HBH*1.0*25 FEB 2012 K GUPTA Support for ICD-10 Coding System
+14 ;******************************************************************************
+15 ;******************************************************************************
+16 ;
+17 SET DIR(0)="SB^A:Admissions;D:Discharges;"
SET DIR("A")="Select Admissions or Discharges"
SET DIR("?")="Enter 'A' to include Admissions on the report, 'D' to choose Discharges."
DO ^DIR
+18 if $DATA(DIRUT)
GOTO EXIT
+19 SET HBHCTYPS=Y(0)
SET HBHCTYP=$EXTRACT(Y(0),1,9)
SET HBHCXREF=$SELECT(Y="A":"AD",1:"AC")
SET HBHCDXPC=$SELECT(Y="A":19,1:47)
SET HBHCCC=0
+20 ; Prompt user for sort preference: alphabetical by patient or date of admission or D/C
+21 KILL DIR
SET DIR(0)="SB^A:Alphabetical;D:Date of Admission or D/C"
SET DIR("A")="Sort Alphabetically by Patient or by Date"
SET DIR("?")="Sort report alphabetically by patient (A), or by date of admission or D/C (D)."
DO ^DIR
+22 if $DATA(DIRUT)
GOTO EXIT
+23 ; HBHCFLG exists if alphabetic sort selected
+24 if Y="A"
SET HBHCFLG=1
+25 DO START^HBHCUTL
+26 if (HBHCBEG1=-1)!(HBHCEND1=-1)
GOTO EXIT
+27 SET %ZIS="Q"
KILL IOP,ZTIO,ZTSAVE
DO ^%ZIS
if POP
GOTO EXIT
+28 IF $DATA(IO("Q"))
SET ZTRTN="DQ^HBHCRP7"
SET ZTDESC="HBPC "_HBHCTYP_"Alphabetic Date Range Report"
SET ZTSAVE("HBHC*")=""
DO ^%ZTLOAD
GOTO EXIT
DQ ; De-queue
+1 USE IO
+2 KILL ^TMP("HBHC",$JOB)
+3 SET $PIECE(HBHCY,"-",133)=""
SET $PIECE(HBHCZ,"=",133)=""
+4 if '$DATA(HBHCFLG)
SET HBHCHEAD=HBHCTYPS_" by Date Range, Date Range Sort"
+5 if $DATA(HBHCFLG)
SET HBHCHEAD=HBHCTYPS_" by Date Range, Alphabetic Sort"
+6 IF $DATA(HBHCFLG)
SET HBHCHDR="W ""Patient Name"",?38,HBHCTYP_"" Date"",?60"
IF 1
+7 IF '$TEST
SET HBHCHDR="W HBHCTYP_"" Date"",?19,""Patient Name"",?60"
+8 SET HBHCHDR=HBHCHDR_",""Last Four"",?82,"""_$$ICDTEXT^HBHCUTL3(HBHCBEG1,HBHCEND1)_" Code"",?100,""Diagnosis Text"""
+9 SET HBHCCOLM=(132-(30+$LENGTH(HBHCHEAD))\2)
if HBHCCOLM'>0
SET HBHCCOLM=1
+10 DO TODAY^HBHCUTL
LOOP ; Loop thru ^HBHC(631) "AD" (admission date) or "AC" (discharge date) cross-ref to build report
+1 SET X1=HBHCBEG1
SET X2=-1
DO C^%DTC
SET HBHCDATE=X
+2 FOR
SET HBHCDATE=$ORDER(^HBHC(631,HBHCXREF,HBHCDATE))
if (HBHCDATE="")!(HBHCDATE>HBHCEND1)
QUIT
SET HBHCDFN=""
FOR
SET HBHCDFN=$ORDER(^HBHC(631,HBHCXREF,HBHCDATE,HBHCDFN))
if HBHCDFN=""
QUIT
SET HBHCNOD0=^HBHC(631,HBHCDFN,0)
if $PIECE(HBHCNOD0,U,15)=1
DO PROCESS
+3 if IO'=IO(0)!($DATA(IO("S")))
DO HDR132^HBHCUTL
+4 IF '$DATA(IO("S"))
IF (IO=IO(0))
SET HBHCCC=HBHCCC+1
DO HDR132^HBHCUTL
+5 if '$DATA(^TMP("HBHC",$JOB))
WRITE !!,"No "_HBHCTYPS_" found for Date Range selected."
+6 IF $DATA(^TMP("HBHC",$JOB))
DO PRTLOOP
WRITE !!,HBHCZ,!,"Total "_HBHCTYPS_": ",HBHCTOT,!,HBHCZ
+7 DO END132^HBHCUTL1
EXIT ; Exit module
+1 DO ^%ZISC
+2 KILL DIR,DIRUT,HBHCBEG1,HBHCBEG2,HBHCCOLM,HBHCCC,HBHCDATE,HBHCDFN,HBHCDPT0,HBHCDT,HBHCDXPC,HBHCEND1,HBHCEND2,HBHCFLG,HBHCHDR,HBHCHEAD,HBHCICDP,HBHCNAME,HBHCNOD0,HBHCPAGE,HBHCTDY,HBHCTMP,HBHCTOT,HBHCTYP,HBHCTYPS,HBHCXREF
+3 KILL HBHCY,HBHCZ,X,X1,X2,Y,^TMP("HBHC",$JOB)
+4 QUIT
PROCESS ; Process record & create ^TMP("HBHC",$J global
+1 SET HBHCDPT0=^DPT($PIECE(HBHCNOD0,U),0)
SET HBHCICDP=$PIECE(HBHCNOD0,U,HBHCDXPC)
+2 NEW HBHCDXCODE,HBHCDXDESC
+3 IF HBHCICDP]""
Begin DoDot:1
+4 SET HBHCDXCODE=$$CODEC^ICDEX(80,HBHCICDP)
+5 SET HBHCDXDESC=$$VSTD^ICDEX(HBHCICDP)
End DoDot:1
IF 1
+6 if '$DATA(HBHCFLG)
SET ^TMP("HBHC",$JOB,HBHCDATE,$PIECE(HBHCDPT0,U))=$EXTRACT($PIECE(HBHCDPT0,U,9),6,9)_U_$GET(HBHCDXCODE)_U_$GET(HBHCDXDESC)
+7 if $DATA(HBHCFLG)
SET ^TMP("HBHC",$JOB,$PIECE(HBHCDPT0,U),HBHCDATE)=$EXTRACT($PIECE(HBHCDPT0,U,9),6,9)_U_$GET(HBHCDXCODE)_U_$GET(HBHCDXDESC)
+8 QUIT
PRTLOOP ; Print loop
+1 SET HBHCTOT=0
+2 IF '$DATA(HBHCFLG)
SET HBHCDT=""
FOR
SET HBHCDT=$ORDER(^TMP("HBHC",$JOB,HBHCDT))
if HBHCDT=""
QUIT
SET HBHCNAME=""
FOR
SET HBHCNAME=$ORDER(^TMP("HBHC",$JOB,HBHCDT,HBHCNAME))
if HBHCNAME=""
QUIT
DO PRT
+3 IF $DATA(HBHCFLG)
SET HBHCNAME=""
FOR
SET HBHCNAME=$ORDER(^TMP("HBHC",$JOB,HBHCNAME))
if HBHCNAME=""
QUIT
SET HBHCDT=""
FOR
SET HBHCDT=$ORDER(^TMP("HBHC",$JOB,HBHCNAME,HBHCDT))
if HBHCDT=""
QUIT
DO PRT
+4 QUIT
PRT ; Print report
+1 IF ($DATA(ZTRTN)!(HBHCCC=0))&((IOSL-$Y)<5)
WRITE @IOF
DO HDR132^HBHCUTL
+2 SET HBHCTOT=HBHCTOT+1
+3 if '$DATA(HBHCFLG)
SET HBHCTMP=^TMP("HBHC",$JOB,HBHCDT,HBHCNAME)
+4 if $DATA(HBHCFLG)
SET HBHCTMP=^TMP("HBHC",$JOB,HBHCNAME,HBHCDT)
+5 if '$DATA(HBHCFLG)
WRITE !,$EXTRACT(HBHCDT,4,5)_"-"_$EXTRACT(HBHCDT,6,7)_"-"_$EXTRACT(HBHCDT,2,3),?19,HBHCNAME,?60,$PIECE(HBHCTMP,U),?82,$PIECE(HBHCTMP,U,2),?100,$PIECE(HBHCTMP,U,3),!,HBHCY
+6 if $DATA(HBHCFLG)
WRITE !,HBHCNAME,?38,$EXTRACT(HBHCDT,4,5)_"-"_$EXTRACT(HBHCDT,6,7)_"-"_$EXTRACT(HBHCDT,2,3),?60,$PIECE(HBHCTMP,U),?82,$PIECE(HBHCTMP,U,2),?100,$PIECE(HBHCTMP,U,3),!,HBHCY
+7 QUIT