RGMTHLDP ;BIR/CML-MPI/PD HL7 ACTIVITY BY PATIENT/ALL PROTOCOLS ;11/05/01
;;1.0;CLINICAL INFO RESOURCE NETWORK;**21**;30 Apr 99
;
;Reference to ^ORD(101 supported by IA #2596
;Reference to ^HL(771.6 supported by IA #2507
;Reference to ^HLMA( supported by IA #3273
;Reference to ^HLCS(870 supported by IA #2525
;Reference to ^DPT(DFN,"MPI" supported by IA #2070
;
S QFLG=1
CHK ;
I '$D(^XTMP("RGMT","HL")) D G QUIT
.W !!,$C(7),"The option ""Compile MPI/PD HL7 Data"" must have"
.W !,"run to completion before this report can be printed!"
I '$D(^XTMP("RGMT","HL","@@@@","STOPPED")) D G QUIT
.W !!,$C(7),"The option ""Compile MPI/PD HL7 Data"" is currently running."
.W !,"This report cannot be generated until the compile has run to completion."
.W !!,"Please try again later.",!
W @IOF
I $D(^XTMP("RGMT","HL","@@@@","RANGE")) D
.W !!,"Data has been compiled for ",^XTMP("RGMT","HL","@@@@","RANGE"),"."
.W !,"Use the ""Compile MPI/PD HL7 Data"" option if this range is not sufficient."
;
BEGIN ;
W !!,"This option allows you to search for ALL activity in the HL7 MESSAGE TEXT"
W !,"(#772) file for a specific patient during a selected period of time. This"
W !,"search is accomplished using data set into a temporary global built by the"
W !,"option ""Compile MPI/PD HL7 Data""."
;
ASK1 ;Ask for PATIENT
W !!!,"Patient lookup can be done by (P)atient Name/SSN or by (I)CN.",!
S DIR(0)="SB^I:ICN;P:PATIENT NAME/SSN",DIR("A")="Select LOOKUP",DIR("B")="P"
D ^DIR K DIR G:$D(DIRUT) QUIT S TYPE=Y
I TYPE="P" D LOOKUP1 G:'$D(ICN) ASK1 G ASK2
I TYPE="I" D LOOKUP2 G:'$D(ICN) ASK1
;check if selected patient had activity in compiled data
I 'ICN,'$D(^XTMP("RGMT","HLDFN",DFN)) D MSG G QUIT
I '$D(^XTMP("RGMT","HLICN",ICN)) D MSG G QUIT
;
ASK2 ;Ask for Date Range
W !!,"Enter date range for data to be included in report."
K DIR,DIRUT,DTOUT,DUOUT
S DIR(0)="DAO^:DT:EPX",DIR("A")="Beginning Date: "
D ^DIR K DIR G:$D(DIRUT) QUIT S RGBDT=Y
S DIR(0)="DAO^"_RGBDT_":DT:EPX",DIR("A")="Ending Date: "
D ^DIR K DIR G:$D(DIRUT) QUIT S RGEDT=Y
;
DEV ;
W !!,"The right margin for this report is 80.",!!
S ZTSAVE("RGBDT")="",ZTSAVE("RGEDT")="",ZTSAVE("DFN")="",ZTSAVE("ICN")=""
D EN^XUTMDEVQ("START^RGMTHLDP","MPI/PD - Print HL7 Message Data for Patient/All Protocols") I 'POP Q
W !,"NO DEVICE SELECTED OR REPORT PRINTED!!"
G QUIT
;
START ;
K ^TMP("RGMTHLDP",$J) S U="^"
;
LOOP ;Loop on ^XTMP("RGMT","HLICN" & ^XTMP("RGMT","HLDFN"
I '$D(^XTMP("RGMT","HLICN"))&'($D(^XTMP("RGMT","HLDFN"))) G QUIT
S STOPDT=RGEDT_".9"
F SUB1="HLICN","HLDFN" S SUB2=$S(SUB1="HLICN":ICN,1:DFN) D
.S RGDT=RGBDT-.1
.F S RGDT=$O(^XTMP("RGMT",SUB1,SUB2,RGDT)) Q:'RGDT Q:RGDT>STOPDT D
..S PROT="" F S PROT=$O(^XTMP("RGMT",SUB1,SUB2,RGDT,PROT)) Q:PROT="" D
...S TYPE="" F S TYPE=$O(^XTMP("RGMT",SUB1,SUB2,RGDT,PROT,TYPE)) Q:TYPE="" D
....S STAT="" F S STAT=$O(^XTMP("RGMT",SUB1,SUB2,RGDT,PROT,TYPE,STAT)) Q:STAT="" D
.....S IEN=0 F S IEN=$O(^XTMP("RGMT",SUB1,SUB2,RGDT,PROT,TYPE,STAT,IEN)) Q:'IEN D
......S ^TMP("RGMTHLDP",$J,PROT,RGDT,TYPE,STAT,IEN)=^XTMP("RGMT",SUB1,SUB2,RGDT,PROT,TYPE,STAT,IEN)
;
PRT ;Print report
S (PG,QFLG)=0,U="^",$P(LN,"-",81)="",SITE=$P($$SITE^VASITE(),U,2)
S PRGBDT=$$FMTE^XLFDT(RGBDT),PRGEDT=$$FMTE^XLFDT(RGEDT)
D NOW^%DTC S HDT=$$FMTE^XLFDT($E(%,1,12))
D HDR
S PROT="" F S PROT=$O(^TMP("RGMTHLDP",$J,PROT)) Q:PROT="" Q:QFLG W !!,PROT,":" D
.S RGDT=0
.F S RGDT=$O(^TMP("RGMTHLDP",$J,PROT,RGDT)) Q:'RGDT Q:QFLG D
..S TYPE=""
..F S TYPE=$O(^TMP("RGMTHLDP",$J,PROT,RGDT,TYPE)) Q:TYPE="" Q:QFLG D
...S STAT=""
...F S STAT=$O(^TMP("RGMTHLDP",$J,PROT,RGDT,TYPE,STAT)) Q:STAT="" Q:QFLG D
....S IEN=0
....F S IEN=$O(^TMP("RGMTHLDP",$J,PROT,RGDT,TYPE,STAT,IEN)) Q:'IEN Q:QFLG D
.....D:$Y+3>IOSL HDR Q:QFLG
.....W !!?4,$$FMTE^XLFDT($E(RGDT,1,12))
.....W ?25,$S(TYPE="O":"OUTGOING",1:"INCOMING"),?41,STAT,?69,IEN
.....I ^TMP("RGMTHLDP",$J,PROT,RGDT,TYPE,STAT,IEN)]"" D Q
......W !?35,^TMP("RGMTHLDP",$J,PROT,RGDT,TYPE,STAT,IEN)
.....S HLMAIEN=0
.....F S HLMAIEN=$O(^HLMA("B",IEN,HLMAIEN)) Q:'HLMAIEN Q:QFLG D
......S HLMASTAT=$P(^HL(771.6,($P(^HLMA(HLMAIEN,"P"),"^")),0),"^")
......S HLMAPROT=$P(^ORD(101,$P(^HLMA(HLMAIEN,0),"^",8),0),"^")
......S HLMALINK=$P(^HLCS(870,$P(^HLMA(HLMAIEN,0),"^",7),0),"^")
......D:$Y+3>IOSL HDR Q:QFLG
......W !?4,"=>^HLMA(",HLMAIEN,?24,$E(HLMAPROT,1,25),?50,$E(HLMASTAT,1,22),?74,HLMALINK
I '$D(^TMP("RGMTHLDP",$J)) W !!,"No data found for this patient."
QUIT ;
I $E(IOST)="C"&('QFLG) S DIR(0)="E" D D ^DIR K DIR
.S SS=22-$Y F JJ=1:1:SS W !
K ^TMP("RGMTHLDP",$J)
K %,DFN,GOT,HDT,ICN,IEN,JJ,LL,LN,PG,PRGBDT,PRGEDT,PROT,QFLG,RGBDT
K HLMAIEN,HLMASTAT,HLMAPROT,HLMALINK
K RGDT,RGEDT,SITE,SS,STAT,STOPDT,SUB1,SUB2,TXT,TYPE,X,Y,ZTSK
W:$E(IOST)'="C" @IOF D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
Q
;
HDR ;HEADER
I $E(IOST)="C" S SS=22-$Y F JJ=1:1:SS W !
I $E(IOST)="C",PG>0 S DIR(0)="E" W ! D ^DIR K DIR I 'Y S QFLG=1 Q
S PG=PG+1 W:$Y!($E(IOST)="C") @IOF
W !,"HL7 TRANSMISSION PATIENT DATA at ",SITE," on ",HDT,?72,"Page: ",PG
W !!,"Patient: ",$P(^DPT(DFN,0),U)
W !,"Date Range: ",PRGBDT," to ",PRGEDT
W !!,"Related Event Protocol"
W !?4,"Date",?26,"Type",?42,"Status",?69,"^HL(772,IEN"
W !?4,"=>^HLMA(IEN",?24,"Protocol",?50,"Status",?74,"Link",!,LN
Q
;
LOOKUP1 ;Lookup by patient name/ssn
W ! K DFN,ICN
S DIC="^DPT(",DIC(0)="QEAM",DIC("A")="Select PATIENT: " D ^DIC K DIC
Q:Y<0
S DFN=+Y
S ICN=+$P($G(^DPT(DFN,"MPI")),U)
Q
;
LOOKUP2 ;Lookup by ICN
W ! K DFN,ICN
S DIR(0)="N:1:999999999999:0",DIR("A")="Select ICN" D ^DIR K DIR Q:$D(DIRUT)
S ICN=Y S DFN=$$GETDFN^MPIF001(ICN)
I +DFN<0 W !!,"No patient DFN match can be found for this ICN!" K DFN,ICN Q
W " ",$P(^DPT(DFN,0),"^")
Q
;
MSG ;
W !!,"This patient has no HL7 messaging activity in the current compiled data set."
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGMTHLDP 5957 printed Oct 16, 2024@17:43:13 Page 2
RGMTHLDP ;BIR/CML-MPI/PD HL7 ACTIVITY BY PATIENT/ALL PROTOCOLS ;11/05/01
+1 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**21**;30 Apr 99
+2 ;
+3 ;Reference to ^ORD(101 supported by IA #2596
+4 ;Reference to ^HL(771.6 supported by IA #2507
+5 ;Reference to ^HLMA( supported by IA #3273
+6 ;Reference to ^HLCS(870 supported by IA #2525
+7 ;Reference to ^DPT(DFN,"MPI" supported by IA #2070
+8 ;
+9 SET QFLG=1
CHK ;
+1 IF '$DATA(^XTMP("RGMT","HL"))
Begin DoDot:1
+2 WRITE !!,$CHAR(7),"The option ""Compile MPI/PD HL7 Data"" must have"
+3 WRITE !,"run to completion before this report can be printed!"
End DoDot:1
GOTO QUIT
+4 IF '$DATA(^XTMP("RGMT","HL","@@@@","STOPPED"))
Begin DoDot:1
+5 WRITE !!,$CHAR(7),"The option ""Compile MPI/PD HL7 Data"" is currently running."
+6 WRITE !,"This report cannot be generated until the compile has run to completion."
+7 WRITE !!,"Please try again later.",!
End DoDot:1
GOTO QUIT
+8 WRITE @IOF
+9 IF $DATA(^XTMP("RGMT","HL","@@@@","RANGE"))
Begin DoDot:1
+10 WRITE !!,"Data has been compiled for ",^XTMP("RGMT","HL","@@@@","RANGE"),"."
+11 WRITE !,"Use the ""Compile MPI/PD HL7 Data"" option if this range is not sufficient."
End DoDot:1
+12 ;
BEGIN ;
+1 WRITE !!,"This option allows you to search for ALL activity in the HL7 MESSAGE TEXT"
+2 WRITE !,"(#772) file for a specific patient during a selected period of time. This"
+3 WRITE !,"search is accomplished using data set into a temporary global built by the"
+4 WRITE !,"option ""Compile MPI/PD HL7 Data""."
+5 ;
ASK1 ;Ask for PATIENT
+1 WRITE !!!,"Patient lookup can be done by (P)atient Name/SSN or by (I)CN.",!
+2 SET DIR(0)="SB^I:ICN;P:PATIENT NAME/SSN"
SET DIR("A")="Select LOOKUP"
SET DIR("B")="P"
+3 DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO QUIT
SET TYPE=Y
+4 IF TYPE="P"
DO LOOKUP1
if '$DATA(ICN)
GOTO ASK1
GOTO ASK2
+5 IF TYPE="I"
DO LOOKUP2
if '$DATA(ICN)
GOTO ASK1
+6 ;check if selected patient had activity in compiled data
+7 IF 'ICN
IF '$DATA(^XTMP("RGMT","HLDFN",DFN))
DO MSG
GOTO QUIT
+8 IF '$DATA(^XTMP("RGMT","HLICN",ICN))
DO MSG
GOTO QUIT
+9 ;
ASK2 ;Ask for Date Range
+1 WRITE !!,"Enter date range for data to be included in report."
+2 KILL DIR,DIRUT,DTOUT,DUOUT
+3 SET DIR(0)="DAO^:DT:EPX"
SET DIR("A")="Beginning Date: "
+4 DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO QUIT
SET RGBDT=Y
+5 SET DIR(0)="DAO^"_RGBDT_":DT:EPX"
SET DIR("A")="Ending Date: "
+6 DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO QUIT
SET RGEDT=Y
+7 ;
DEV ;
+1 WRITE !!,"The right margin for this report is 80.",!!
+2 SET ZTSAVE("RGBDT")=""
SET ZTSAVE("RGEDT")=""
SET ZTSAVE("DFN")=""
SET ZTSAVE("ICN")=""
+3 DO EN^XUTMDEVQ("START^RGMTHLDP","MPI/PD - Print HL7 Message Data for Patient/All Protocols")
IF 'POP
QUIT
+4 WRITE !,"NO DEVICE SELECTED OR REPORT PRINTED!!"
+5 GOTO QUIT
+6 ;
START ;
+1 KILL ^TMP("RGMTHLDP",$JOB)
SET U="^"
+2 ;
LOOP ;Loop on ^XTMP("RGMT","HLICN" & ^XTMP("RGMT","HLDFN"
+1 IF '$DATA(^XTMP("RGMT","HLICN"))&'($DATA(^XTMP("RGMT","HLDFN")))
GOTO QUIT
+2 SET STOPDT=RGEDT_".9"
+3 FOR SUB1="HLICN","HLDFN"
SET SUB2=$SELECT(SUB1="HLICN":ICN,1:DFN)
Begin DoDot:1
+4 SET RGDT=RGBDT-.1
+5 FOR
SET RGDT=$ORDER(^XTMP("RGMT",SUB1,SUB2,RGDT))
if 'RGDT
QUIT
if RGDT>STOPDT
QUIT
Begin DoDot:2
+6 SET PROT=""
FOR
SET PROT=$ORDER(^XTMP("RGMT",SUB1,SUB2,RGDT,PROT))
if PROT=""
QUIT
Begin DoDot:3
+7 SET TYPE=""
FOR
SET TYPE=$ORDER(^XTMP("RGMT",SUB1,SUB2,RGDT,PROT,TYPE))
if TYPE=""
QUIT
Begin DoDot:4
+8 SET STAT=""
FOR
SET STAT=$ORDER(^XTMP("RGMT",SUB1,SUB2,RGDT,PROT,TYPE,STAT))
if STAT=""
QUIT
Begin DoDot:5
+9 SET IEN=0
FOR
SET IEN=$ORDER(^XTMP("RGMT",SUB1,SUB2,RGDT,PROT,TYPE,STAT,IEN))
if 'IEN
QUIT
Begin DoDot:6
+10 SET ^TMP("RGMTHLDP",$JOB,PROT,RGDT,TYPE,STAT,IEN)=^XTMP("RGMT",SUB1,SUB2,RGDT,PROT,TYPE,STAT,IEN)
End DoDot:6
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+11 ;
PRT ;Print report
+1 SET (PG,QFLG)=0
SET U="^"
SET $PIECE(LN,"-",81)=""
SET SITE=$PIECE($$SITE^VASITE(),U,2)
+2 SET PRGBDT=$$FMTE^XLFDT(RGBDT)
SET PRGEDT=$$FMTE^XLFDT(RGEDT)
+3 DO NOW^%DTC
SET HDT=$$FMTE^XLFDT($EXTRACT(%,1,12))
+4 DO HDR
+5 SET PROT=""
FOR
SET PROT=$ORDER(^TMP("RGMTHLDP",$JOB,PROT))
if PROT=""
QUIT
if QFLG
QUIT
WRITE !!,PROT,":"
Begin DoDot:1
+6 SET RGDT=0
+7 FOR
SET RGDT=$ORDER(^TMP("RGMTHLDP",$JOB,PROT,RGDT))
if 'RGDT
QUIT
if QFLG
QUIT
Begin DoDot:2
+8 SET TYPE=""
+9 FOR
SET TYPE=$ORDER(^TMP("RGMTHLDP",$JOB,PROT,RGDT,TYPE))
if TYPE=""
QUIT
if QFLG
QUIT
Begin DoDot:3
+10 SET STAT=""
+11 FOR
SET STAT=$ORDER(^TMP("RGMTHLDP",$JOB,PROT,RGDT,TYPE,STAT))
if STAT=""
QUIT
if QFLG
QUIT
Begin DoDot:4
+12 SET IEN=0
+13 FOR
SET IEN=$ORDER(^TMP("RGMTHLDP",$JOB,PROT,RGDT,TYPE,STAT,IEN))
if 'IEN
QUIT
if QFLG
QUIT
Begin DoDot:5
+14 if $Y+3>IOSL
DO HDR
if QFLG
QUIT
+15 WRITE !!?4,$$FMTE^XLFDT($EXTRACT(RGDT,1,12))
+16 WRITE ?25,$SELECT(TYPE="O":"OUTGOING",1:"INCOMING"),?41,STAT,?69,IEN
+17 IF ^TMP("RGMTHLDP",$JOB,PROT,RGDT,TYPE,STAT,IEN)]""
Begin DoDot:6
+18 WRITE !?35,^TMP("RGMTHLDP",$JOB,PROT,RGDT,TYPE,STAT,IEN)
End DoDot:6
QUIT
+19 SET HLMAIEN=0
+20 FOR
SET HLMAIEN=$ORDER(^HLMA("B",IEN,HLMAIEN))
if 'HLMAIEN
QUIT
if QFLG
QUIT
Begin DoDot:6
+21 SET HLMASTAT=$PIECE(^HL(771.6,($PIECE(^HLMA(HLMAIEN,"P"),"^")),0),"^")
+22 SET HLMAPROT=$PIECE(^ORD(101,$PIECE(^HLMA(HLMAIEN,0),"^",8),0),"^")
+23 SET HLMALINK=$PIECE(^HLCS(870,$PIECE(^HLMA(HLMAIEN,0),"^",7),0),"^")
+24 if $Y+3>IOSL
DO HDR
if QFLG
QUIT
+25 WRITE !?4,"=>^HLMA(",HLMAIEN,?24,$EXTRACT(HLMAPROT,1,25),?50,$EXTRACT(HLMASTAT,1,22),?74,HLMALINK
End DoDot:6
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+26 IF '$DATA(^TMP("RGMTHLDP",$JOB))
WRITE !!,"No data found for this patient."
QUIT ;
+1 IF $EXTRACT(IOST)="C"&('QFLG)
SET DIR(0)="E"
Begin DoDot:1
+2 SET SS=22-$Y
FOR JJ=1:1:SS
WRITE !
End DoDot:1
DO ^DIR
KILL DIR
+3 KILL ^TMP("RGMTHLDP",$JOB)
+4 KILL %,DFN,GOT,HDT,ICN,IEN,JJ,LL,LN,PG,PRGBDT,PRGEDT,PROT,QFLG,RGBDT
+5 KILL HLMAIEN,HLMASTAT,HLMAPROT,HLMALINK
+6 KILL RGDT,RGEDT,SITE,SS,STAT,STOPDT,SUB1,SUB2,TXT,TYPE,X,Y,ZTSK
+7 if $EXTRACT(IOST)'="C"
WRITE @IOF
DO ^%ZISC
if $DATA(ZTQUEUED)
SET ZTREQ="@"
+8 QUIT
+9 ;
HDR ;HEADER
+1 IF $EXTRACT(IOST)="C"
SET SS=22-$Y
FOR JJ=1:1:SS
WRITE !
+2 IF $EXTRACT(IOST)="C"
IF PG>0
SET DIR(0)="E"
WRITE !
DO ^DIR
KILL DIR
IF 'Y
SET QFLG=1
QUIT
+3 SET PG=PG+1
if $Y!($EXTRACT(IOST)="C")
WRITE @IOF
+4 WRITE !,"HL7 TRANSMISSION PATIENT DATA at ",SITE," on ",HDT,?72,"Page: ",PG
+5 WRITE !!,"Patient: ",$PIECE(^DPT(DFN,0),U)
+6 WRITE !,"Date Range: ",PRGBDT," to ",PRGEDT
+7 WRITE !!,"Related Event Protocol"
+8 WRITE !?4,"Date",?26,"Type",?42,"Status",?69,"^HL(772,IEN"
+9 WRITE !?4,"=>^HLMA(IEN",?24,"Protocol",?50,"Status",?74,"Link",!,LN
+10 QUIT
+11 ;
LOOKUP1 ;Lookup by patient name/ssn
+1 WRITE !
KILL DFN,ICN
+2 SET DIC="^DPT("
SET DIC(0)="QEAM"
SET DIC("A")="Select PATIENT: "
DO ^DIC
KILL DIC
+3 if Y<0
QUIT
+4 SET DFN=+Y
+5 SET ICN=+$PIECE($GET(^DPT(DFN,"MPI")),U)
+6 QUIT
+7 ;
LOOKUP2 ;Lookup by ICN
+1 WRITE !
KILL DFN,ICN
+2 SET DIR(0)="N:1:999999999999:0"
SET DIR("A")="Select ICN"
DO ^DIR
KILL DIR
if $DATA(DIRUT)
QUIT
+3 SET ICN=Y
SET DFN=$$GETDFN^MPIF001(ICN)
+4 IF +DFN<0
WRITE !!,"No patient DFN match can be found for this ICN!"
KILL DFN,ICN
QUIT
+5 WRITE " ",$PIECE(^DPT(DFN,0),"^")
+6 QUIT
+7 ;
MSG ;
+1 WRITE !!,"This patient has no HL7 messaging activity in the current compiled data set."
+2 QUIT