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

LREPIRS.m

Go to the documentation of this file.
  1. LREPIRS ;VA/DALOI/CKA - EPI-LOCAL REPORT/SPREADSHEET ; 5/14/03
  1. ;;5.2;LAB SERVICE;**1030**;NOV 01, 1997
  1. ;;5.2;LAB SERVICE;**281**;Sep 27, 1994
  1. ; Reference to ^ORD(101 supported by IA #872
  1. ;USED TO PRINT REPORT OR SPREADSHEET
  1. D NOW^%DTC
  1. S LRLRDT=% ;Set LRLRDT- local report date time=now
  1. S LRRTYPE=1,LRPROT=0
  1. S LRPROT=$O(^ORD(101,"B","LREPI",LRPROT))
  1. W @IOF,?(IOM/2-15),"Laboratory Generate Local Report/Spreadsheet option"
  1. CRI K LRCYCLE,LREPI S LRMSG="Pathogens" D ALL G:$D(DIRUT) EXIT
  1. K DIR,DIRUT,DTOUT,DUOUT,DIROUT
  1. I +LRALL D PICKALL G DATE
  1. S LRMSG="Local Pathogens" D ALL G:$D(DIRUT) CRI
  1. K DIR,DIRUT,DTOUT,DUOUT,DIROUT
  1. I +LRALL D LOCALL G DATE
  1. I +LRALL'>0 D
  1. .W @IOF
  1. .F Q:$D(DIRUT) D
  1. ..S DIR(0)="PAO^69.5:EMZ",DIR("A")="Select Pathogens: "
  1. ..S DIR("S")="D CHKL^LREPIRM I LROK I $P(^(0),U,7)=LRPROT"
  1. ..D ^DIR
  1. ..Q:$D(DIRUT)
  1. ..S LREPI(+Y)=""
  1. G:$D(DTOUT)!$D(DUOUT)!$D(DIROUT) CRI
  1. I '$D(LREPI) W !,"Sorry No Pathogens Selected" G EXIT
  1. DATE ;Select Search Date
  1. K DIR,DIRUT
  1. S DIR("A")="Select Start Date: "
  1. S DIR(0)="DOA^:"_DT D ^DIR
  1. G:$D(DIRUT) CRI
  1. S LRRPS=Y
  1. K DIR,DIRUT
  1. S DIR("A")="Select End Date: "
  1. S DIR(0)="DOA^:"_DT D ^DIR
  1. G:$D(DIRUT) DATE
  1. S LRRPE=Y
  1. RORS ;REPORT OR SPREADSHEET
  1. K DIR,DIRUT
  1. S DIR(0)="SO^1:REPORT;2:SPREADSHEET"
  1. D ^DIR
  1. G:$D(DIRUT) DATE
  1. S LRREP=Y
  1. W !!
  1. I LRREP=1,$D(^XTMP("LREPILOCALREP"_LRLRDT)) D G EXIT
  1. .W !,"Data already exists for this date and time. Please try again later."
  1. I LRREP=2,$D(^XTMP("LREPILOCALSPSHT"_LRLRDT)) D G EXIT
  1. .W !,"Data already exists for this date and time. Please try again later."
  1. D SEG G:$D(DIRUT) RORS
  1. TITLE K DIR,DIRUT
  1. S DIR(0)="F^3:30",DIR("A")="DOCUMENT TITLE"
  1. D ^DIR
  1. G:$D(DIRUT) RORS
  1. S ^XTMP("LREPI"_$S(LRREP=1:"LOCALREP",1:"LOCALSPSHT")_LRLRDT,"TITLE")=Y
  1. D TASK,HOME^%ZIS
  1. EXIT ;
  1. K D0,J,LRALL,LRAUTO,LRBEG,LRCYCLE,LRDT,LREND,LREPI,LRMSG,LROK,LROVR
  1. K LRDUZ,LRRNDT,LRRPE,LRREP,LRRPS,LRRTYPE,LRY,ZTSAVE
  1. K ZTRTN,ZTIO,ZTDESC,ZTDTH,ZTSK,X,Y,X1,%DT
  1. K LRLC,LRHDG,LRPROT,LRLRDT
  1. K DIR,DIROUT,DIRUT,DTOUT,DUOUT,I,LRSEG
  1. K ^TMP($J)
  1. Q
  1. ;
  1. TASK ;LETS TASK THIS JOB
  1. Q:'$D(LREPI)
  1. W !!
  1. S LRDUZ=DUZ
  1. K ZTSAVE
  1. S ZTSAVE("LRRTYPE")="" S:LRRTYPE=0 ZTDTH=DT
  1. S ZTSAVE("LR*")=""
  1. S ZTIO="",ZTRTN="EN^LREPI",ZTDESC="Laboratory EPI local spreadsheet/report-generate"
  1. D ^%ZTLOAD
  1. I '$D(ZTQUEUED)&($D(ZTSK)) W @IOF,!!,"The Task has been queued",!,"Task # ",$G(ZTSK) H 5
  1. Q
  1. PICKALL ;SELECT ALL ASSOCIATED PARAMETERS
  1. S Y=0 F S Y=$O(^LAB(69.5,Y)) Q:+Y'>0 D CHK S:LROK LREPI(Y)=""
  1. Q
  1. LOCALL ;SELECT ALL LOCAL PATHOGENS
  1. S Y=99 F S Y=$O(^LAB(69.5,Y)) Q:Y'>0 D CHK S:LROK LREPI(Y)=""
  1. Q
  1. CHK ;CHECK TO SEE IF ITS OK
  1. S:'$D(LRCYCLE) LRCYCLE=$P(^LAB(69.5,Y,0),U,5)
  1. S LROK=1
  1. S:($P(^LAB(69.5,Y,0),U,2)="1") LROK=0 Q
  1. S:$P(^LAB(69.5,Y,0),U,7)="" LROK=0 Q
  1. S:'$D(^ORD(101,$P(^LAB(69.5,Y,0),U,7),0)) LROK=0 Q
  1. S:$P(^LAB(69.5,Y,0),U,5)=LRCYCLE LROK=0 Q
  1. Q
  1. ALL K DIR,DIRUT
  1. S DIR(0)="Y",DIR("B")="NO",DIR("A")="Include All "_LRMSG
  1. S DIR("?")="Enter (Y)es or return to individually select pathogens."
  1. D ^DIR
  1. S LRALL=+Y
  1. Q
  1. SEG ;CHOOSE SEGMENTS FOR SPREADSHEET
  1. W !,"Choose the segments to capture for ",$S(LRREP=1:"report.",1:"spreadsheet.")
  1. W !,"1-PID"
  1. W !,"2-PV1"
  1. W !,"3-DG1"
  1. W !,"4-NTE"
  1. W !,"5-OBR"
  1. W !,"6-OBX"
  1. K DIR,DIRUT
  1. S DIR(0)="L^1:6"
  1. D ^DIR
  1. Q:$D(DIRUT)
  1. S LRY=Y
  1. I LRY[1 S LRSEG("PID")=1 D
  1. .W !!
  1. .W !,"Choose the fields from the PID segment to capture for ",$S(LRREP=1:"report.",1:"spreadsheet.")
  1. .W !,"1-Set Id"
  1. .W !,"2-SSN"
  1. .W !,"3-MPI"
  1. .W !,"4-Patient Name"
  1. .W !,"5-Date of Birth"
  1. .W !,"6-Sex"
  1. .W !,"7-Race"
  1. .W !,"8-Homeless"
  1. .W !,"9-State"
  1. .W !,"10-Zip Code"
  1. .W !,"11-County"
  1. .W !,"12-Ethnicity"
  1. .W !,"13-Period of Service"
  1. .K DIR,DIRUT
  1. .S DIR(0)="L^1:13"
  1. .D ^DIR
  1. .Q:$D(DIRUT)
  1. .F I=1:1:13 I Y[I S LRSEG("PID",I)=""
  1. I LRY[2 S LRSEG("PV1")=1 D
  1. .W !,"Choose the fields from the PV1 segment to capture for ",$S(LRREP=1:"report.",1:"spreadsheet.")
  1. .W !,"1-Set Id"
  1. .W !,"2-Patient Class"
  1. .W !,"3-Hospital Location"
  1. .W !,"4-Discharge Disposition"
  1. .W !,"5-Facility"
  1. .W !,"6-Admit Date/Time"
  1. .W !,"7-Discharge Date/Time"
  1. .K DIR,DIRUT
  1. .S DIR(0)="L^1:7"
  1. .D ^DIR
  1. .Q:$D(DIRUT)
  1. .F I=1:1:7 I Y[I S LRSEG("PV1",I)=""
  1. I LRY[3 S LRSEG("DG1")=1 D
  1. .W !,"Choose the fields from the DG1 segment to capture for ",$S(LRREP=1:"report.",1:"spreadsheet.")
  1. .W !,"1-Set Id"
  1. .W !,"2-Diagnosis Code"
  1. .W !,"3-Diagnosis"
  1. .W !,"4-Admission Date"
  1. .K DIR,DIRUT
  1. .S DIR(0)="L^1:4"
  1. .D ^DIR
  1. .Q:$D(DIRUT)
  1. .F I=1:1:4 I Y[I S LRSEG("DG1",I)=""
  1. I LRY[4 S LRSEG("NTE")=1 D
  1. .W !,"Choose the fields from the NTE segment to capture for ",$S(LRREP=1:"report.",1:"spreadsheet.")
  1. .W !,"1-Set Id"
  1. .W !,"2-Comment"
  1. .K DIR,DIRUT
  1. .S DIR(0)="L^1:2"
  1. .D ^DIR
  1. .Q:$D(DIRUT)
  1. .F I=1:1:2 I Y[I S LRSEG("NTE",I)=""
  1. I LRY[5 S LRSEG("OBR")=1 D
  1. .W !,"Choose the fields from the OBR segment to capture for ",$S(LRREP=1:"report.",1:"spreadsheet.")
  1. .W !,"1-Set Id"
  1. .W !,"2-Test Name"
  1. .W !,"3-Accession Date"
  1. .W !,"4-Specimen"
  1. .W !,"5-Accession Number"
  1. .K DIR,DIRUT
  1. .S DIR(0)="L^1:5"
  1. .D ^DIR
  1. .Q:$D(DIRUT)
  1. .F I=1:1:5 I Y[I S LRSEG("OBR",I)=""
  1. I LRY[6 S LRSEG("OBX")=1 D
  1. .W !,"Choose the fields from the OBX segment to capture for ",$S(LRREP=1:"report.",1:"spreadsheet.")
  1. .W !,"1-Set Id"
  1. .W !,"2-Value Type"
  1. .W !,"3-Test Name"
  1. .W !,"4-LOINC Code"
  1. .W !,"5-LOINC Name"
  1. .W !,"6-Test Result"
  1. .W !,"7-Units"
  1. .W !,"8-Abnormal Flags"
  1. .W !,"9-Verified Date/Time"
  1. .K DIR,DIRUT
  1. .S DIR(0)="L^1:9"
  1. .D ^DIR
  1. .Q:$D(DIRUT)
  1. .F I=1:1:10 I Y[I S LRSEG("OBX",I)=""
  1. Q