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

LREPIRS1.m

Go to the documentation of this file.
LREPIRS1 ;VA/DALOI/CKA-EMERGING PATHOGENS LOCAL REPORT ;9/9/03
 ;;5.2;LAB SERVICE;**1030**;NOV 01, 1997
 ;;5.2;LAB SERVICE;**281**;Sep 27, 1994
 ; Reference to ^DIC(21 supported by IA #913
 Q
REPORT ;
 S X1=DT,X2=180 D C^%DTC
 S LRSP="                              "
 S ^XTMP("LREPILOCALREP"_LRLRDT,0)=X_"^"_DT_"^EPI Local Report generation^"_$S($D(DUZ):DUZ,1:"UNKNOWN")
 S LRHDGLC=0 D SAVHDG^LREPIRS2
 S MSG=0,LRLC=1,LRSPSHT=""
 F  S MSG=$O(^TMP("HLS",$J,MSG)) Q:'MSG  S LRMSGLIN=^(MSG) D
 .S LRSPSHT=""
 .Q:$P(LRMSGLIN,"|")=""
 .Q:'$D(LRSEG($P(LRMSGLIN,"|")))
 .I $P(LRMSGLIN,"|")="PID" D
 ..S LRSPSHT="********************************************************************************"
 ..S ^XTMP("LREPILOCALREP"_LRLRDT,LRLC)=LRSPSHT S LRLC=LRLC+1
 .I $P(LRMSGLIN,"|")="PID" D
 ..I $D(LRSEG("PID",1)) S LRSPSHT=$P(LRMSGLIN,HLFS,2)_$E(LRSP,1,7-$L($P(LRMSGLIN,HLFS,2)))
 ..I $D(LRSEG("PID",2)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,20)_" "
 ..I $D(LRSEG("PID",3)) S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,4),LRCS,4) D
 ...S LRSPSHT=LRSPSHT_$E(LRSP,1,16-($L($P($P(LRMSGLIN,HLFS,4),LRCS,4))))
 ..I $D(LRSEG("PID",4)) S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,6),LRCS)_","_$P($P(LRMSGLIN,HLFS,6),LRCS,2)_" "_$P($P(LRMSGLIN,HLFS,6),LRCS,3)_"  " D
 ...S LRSPSHT=LRSPSHT_$E(LRSP,1,29-($L($P(LRMSGLIN,HLFS,6))))
 ..I $D(LRSEG("PID",5)) S LRSPSHT=LRSPSHT_$$CDT^LREPIRP($P(LRMSGLIN,HLFS,8)) D
 ...S LRSPSHT=LRSPSHT_$E(LRSP,1,9-($L($P(LRMSGLIN,HLFS,8))))
 ..I $D(LRSEG("PID",6)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,9)_"  "
 ..I $D(LRSEG("PID",7)) D  K LRZ,LRY
 ...S LRZ=0,DFN=$P($P(LRMSGLIN,HLFS,4),LRCS) F LRY=1:1 S LRZ=$O(^DPT(DFN,.02,LRZ)) Q:'LRZ
 ...I LRY>2 S LRSPSHT=LRSPSHT_"MULTIPLE "
 ...E  S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,11),LRCS,2)_" "
 ..I $D(LRSEG("PID",8)) S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,12),LRCS,1)_$E(LRSP,1,9-$L($P($P(LRMSGLIN,HLFS,12),LRCS,1)))
 ..I $D(LRSEG("PID",9)) S LRSPSHT=LRSPSHT_$P($P($P(LRMSGLIN,HLFS,12),LRCS,4),U,2)_"  " D
 ...S LRSPSHT=LRSPSHT_$E(LRSP,1,15-$L($P($P($P(LRMSGLIN,HLFS,12),LRCS,4),U,2)))
 ..I $D(LRSEG("PID",10)) S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,12),LRCS,5)_" "
 ..I $D(LRSEG("PID",11)) S LRSPSHT=LRSPSHT_$P($P($P(LRMSGLIN,HLFS,12),LRCS,9),U,2)_$E(LRSP,1,20-$L($P($P($P(LRMSGLIN,HLFS,12),LRCS,9),U,2)))
 ..I $D(LRSEG("PID",12)) S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,23),LRCS,2)_$E(LRSP,1,20-$L($P($P(LRMSGLIN,HLFS,23),LRCS,2)))
 ..I $D(LRSEG("PID",13)) D  I LRPOS="" S LRSPSHT=LRSPSHT_"  "
 ...S LRPOS=$P(LRMSGLIN,HLFS,28)
 ...Q:LRPOS=""
 ...S LRPOSN=0
 ...F  S LRPOSN=$O(^DIC(21,LRPOSN)) Q:LRPOSN'>0  I $P($G(^DIC(21,LRPOSN,0)),U,3)=LRPOS S LRPOSNAM=$P(^(0),U) Q
 ...S LRSPSHT=LRSPSHT_LRPOSNAM_"  "
 ..I LRSPSHT'="" S ^XTMP("LREPILOCALREP"_LRLRDT,LRLC)=LRSPSHT S LRLC=LRLC+1 S LRSPSHT=""
 .K LRPOS,LRPOSN,LRPOSNAM
 .I $P(LRMSGLIN,"|")="PV1" D
 ..I $D(LRSEG("PV1",1)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,2)_$E(LRSP,1,7-$L($P(LRMSGLIN,HLFS,2)))
 ..I $D(LRSEG("PV1",2)) D
 ...S TYPE=$P(LRMSGLIN,HLFS,3),TYPE=$S(TYPE="U":"Update",TYPE="I":"Inpatient",1:"Outpatient")
 ...S LRSPSHT=LRSPSHT_TYPE_$E(LRSP,1,14-$L(TYPE))
 ...K TYPE
 ..I $D(LRSEG("PV1",3)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,4)_$E(LRSP,1,20-$L($P(LRMSGLIN,HLFS,4)))
 ..I $D(LRSEG("PV1",4)) S LRSPSHT=LRSPSHT_$S($P($P(LRMSGLIN,HLFS,37),LRCS,2)'="":$P($P(LRMSGLIN,HLFS,37),LRCS,2),1:"**No Facility**")_$E(LRSP,1,23-$L($P($P(LRMSGLIN,HLFS,37),LRCS,2)))
 ..I $D(LRSEG("PV1",5)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,40)_$E(LRSP,1,9-$L($P(LRMSGLIN,HLFS,40)))
 ..I $D(LRSEG("PV1",6)) S LRSPSHT=LRSPSHT_$$CDT^LREPIRP($P(LRMSGLIN,HLFS,45))_" "
 ..I $D(LRSEG("PV1",7)) S LRSPSHT=LRSPSHT_$$CDT^LREPIRP($P(LRMSGLIN,HLFS,46))
 ..I LRSPSHT'="" S ^XTMP("LREPILOCALREP"_LRLRDT,LRLC)=LRSPSHT S LRLC=LRLC+1 S LRSPSHT=""
 .I $P(LRMSGLIN,"|")="NTE" D
 ..I $D(LRSEG("NTE",1)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,2)_$E(LRSP,1,8-$L($P(LRMSGLIN,HLFS,2)))
 ..I $D(LRSEG("NTE",2)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,3)_"  "
 ..I LRSPSHT'="" S ^XTMP("LREPILOCALREP"_LRLRDT,LRLC)=LRSPSHT S LRLC=LRLC+1 S LRSPSHT=""
 .I $P(LRMSGLIN,"|")="OBR" D
 ..I $D(LRSEG("OBR",1)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,2)_$E(LRSP,1,7-$L($P(LRMSGLIN,HLFS,2)))
 ..I $D(LRSEG("OBR",2)) S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,5),LRCS,2)_$E(LRSP,1,20-$L($P($P(LRMSGLIN,HLFS,5),LRCS,2)))
 ..I $D(LRSEG("OBR",3)) S LRSPSHT=LRSPSHT_$$CDT^LREPIRP($P(LRMSGLIN,HLFS,8))_$E(LRSP,1,17-$L($$CDT^LREPIRP($P(LRMSGLIN,HLFS,8))))
 ..I $D(LRSEG("OBR",4)) S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,16),LRCS,3)_$E(LRSP,1,20-$L($P($P(LRMSGLIN,HLFS,16),LRCS,3)))
 ..I $D(LRSEG("OBR",5)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,19)
 ..S LRSPSHT=LRSPSHT_"   "_$P($P(LRMSGLIN,HLFS,27),LRCS,2)
 ..I LRSPSHT'="" S ^XTMP("LREPILOCALREP"_LRLRDT,LRLC)=LRSPSHT S LRLC=LRLC+1 S LRSPSHT=""
 .I $P(LRMSGLIN,"|")="OBX" D
 ..I $P(LRMSGLIN,HLFS,3)="ST" D
 ...S TST=$P(LRMSGLIN,HLFS,4),TSTNM=$P($P(TST,LRCS,2),LRCS)
 ...S OV=$P(LRMSGLIN,HLFS,6)
 ..I $P(LRMSGLIN,HLFS,3)="CE" D
 ...S TSTNM=""
 ...S OV=$P($P(LRMSGLIN,HLFS,6),LRCS,2)
 ..S FD=$$CDT^LREPIRP($P(LRMSGLIN,HLFS,15)),RR=$P(LRMSGLIN,HLFS,9)
 ..S UN=$P(LRMSGLIN,HLFS,7)
 ..I $P($P(LRMSGLIN,HLFS,4),LRCS,9)="LOINC" D
 ...S LOINC=$P($P(LRMSGLIN,HLFS,4),LRCS,7),LOINCN=$P($P(LRMSGLIN,HLFS,4),LRCS,8)
 ..I $D(LRSEG("OBX",1)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,2)_$E(LRSP,1,7-$L($P(LRMSGLIN,HLFS,2)))
 ..I $D(LRSEG("OBX",2)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,3)_"  "
 ..I $D(LRSEG("OBX",3)) S LRSPSHT=LRSPSHT_TSTNM_"  "
 ..I $D(LRSEG("OBX",4)) S LRSPSHT=LRSPSHT_$G(LOINC)_"  "
 ..I $D(LRSEG("OBX",5)) S LRSPSHT=LRSPSHT_$G(LOINCN)_"  "
 ..I $D(LRSEG("OBX",6)) S LRSPSHT=LRSPSHT_OV_"  "
 ..I $D(LRSEG("OBX",7)) S LRSPSHT=LRSPSHT_UN_"  "
 ..I $D(LRSEG("OBX",8)) S LRSPSHT=LRSPSHT_RR_"  "
 ..I $D(LRSEG("OBX",9)) S LRSPSHT=LRSPSHT_FD_"  "
 ..S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,5)
 ..I LRSPSHT'="" S ^XTMP("LREPILOCALREP"_LRLRDT,LRLC)=LRSPSHT S LRLC=LRLC+1 S LRSPSHT=""
 ..K TST,TSTNM,LOINC,LOINCN,ENTRY,UN,RR,FD,OV
 .I $P(LRMSGLIN,"|")="DG1" D
 ..I $D(LRSEG("DG1",1)) S LRSPSHT=LRSPSHT_$P(LRMSGLIN,HLFS,2)_$E(LRSP,1,7-$L($P(LRMSGLIN,HLFS,2)))
 ..I $D(LRSEG("DG1",2)) S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,4),LRCS,1)_" " D
 ...S LRSPSHT=LRSPSHT_$E(LRSP,1,14-$L($P($P(LRMSGLIN,HLFS,4),LRCS,1)))
 ..I $D(LRSEG("DG1",3)) S LRSPSHT=LRSPSHT_$P($P(LRMSGLIN,HLFS,4),LRCS,2) D
 ...S LRSPSHT=LRSPSHT_$E(LRSP,1,39-$L($P($P(LRMSGLIN,HLFS,4),LRCS,2)))
 ..I $D(LRSEG("DG1",4)) S LRSPSHT=LRSPSHT_$$CDT^LREPIRP($P(LRMSGLIN,HLFS,5))_" "
 ..I LRSPSHT'="" S ^XTMP("LREPILOCALREP"_LRLRDT,LRLC)=LRSPSHT S LRLC=LRLC+1
 K MSGLIN,LRSEG,ENTRY,FD,HLFS,LOINC,LOINCN,LRCS,LRHDGLC,LRLC,LRMSGLIN
 K LRPOS,LRSP,LRSPSHT,MSG,OV,RR,TST,TSTNM,TYPE,UN,X,X1,X2
 Q