VistA-WorldVistAEHR/r/HEALTH_LEVEL_SEVEN-HL/HLCSORA1.m

51 lines
1.9 KiB
Mathematica

HLCSORA1 ;ALB/MFK - REPORT FOR FILE #870 - 11/9/94
;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
;Gather and sort for a custom report from the #870 file.
;We want to be able to sort on various kinds of errors or statuses
START ;
N HLERR,HLSTAT,LINE,HLFILE,HLLINE,HLTMP,HLDIR,HLLINEN,HLNXT
N TMPLINE,START,END
S LINE="",$P(LINE,"-",IOM)=""
S HLERR=$P(HLSORT,"^",1)
S HLSTAT=$P(HLSORT,"^",2)
S HLLINEN=0
K ^TMP("HLCSORAT",$J)
I (HLQUEUE["1") S HLDIR=1 D LOOP
I (HLQUEUE["2") S HLDIR=2 D LOOP
; KILL VARIABLES USED
K HLSORT,HLQUEUE,HLLL
Q
LOOP S HLFILE=0
;START AFTER THE 0 NODE.
F S HLFILE=$O(^HLCS(870,HLLL,HLDIR,HLFILE)) Q:(HLFILE="B")!(HLFILE="") D
.S HLLINE=$G(^HLCS(870,HLLL,HLDIR,HLFILE,0))
.Q:((HLSTAT'="")&($P(HLLINE,"^",2)=""))
.Q:((HLERR'="")&($P(HLLINE,"^",3)=""))
.I ((HLERR[$P(HLLINE,"^",3))!(HLERR=""))&((HLSTAT[$P(HLLINE,"^",2))!(HLSTAT="")) D OUTPUT
Q
OUTPUT ;
S HLLINEN=HLLINEN+1
S ^TMP("HLCSORAT",$J,HLLINEN,1)=LINE
S ^TMP("HLCSORAT",$J,HLLINEN,2)=" Node: "_($P($G(^HLCS(870,HLLL,0)),"^",1))
S $P(X," ",41)=""
S ^TMP("HLCSORAT",$J,HLLINEN,2)=^TMP("HLCSORAT",$J,HLLINEN,2)_$E(X,1,40-$L(^TMP("HLCSORAT",$J,HLLINEN,2)))_"Queue: "_($S(HLDIR=1:"In",HLDIR=2:"Out"))
S ^TMP("HLCSORAT",$J,HLLINEN,3)=" Message number: "_HLFILE
S ^TMP("HLCSORAT",$J,HLLINEN,4)=" Message status: "_$$STATUS($P(HLLINE,"^",2))
S ^TMP("HLCSORAT",$J,HLLINEN,5)=" Message error: "_$$ERROR($P(HLLINE,"^",3))
S ^TMP("HLCSORAT",$J,HLLINEN,6)=" Message text:"
S HLNXT=0
S HLTMP=7
F S HLNXT=$O(^HLCS(870,HLLL,HLDIR,HLFILE,1,HLNXT)) Q:(HLNXT="") D
.S START=1,END=(IOM-3)
.F S TMPLINE=$E(^HLCS(870,HLLL,HLDIR,HLFILE,1,HLNXT,0),START,END) Q:($L(TMPLINE)=0) D
..S ^TMP("HLCSORAT",$J,HLLINEN,HLTMP)=TMPLINE
..S START=START+(IOM-3),END=END+(IOM-3)
..S HLTMP=HLTMP+1
Q
ERROR(ERR) ;
S ERR=$$EXPAND^HLUTIL1(870.019,2,ERR)
Q ERR
STATUS(STAT) ;
S STAT=$$EXPAND^HLUTIL1(870.01,1,STAT)
Q STAT