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

RGMTHLDP.m

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