DIARR6 ;SFISC/DCM-PROCESS ARCHIVED FILE WITH INDEX ;11/18/92 11:49 AM
;;22.0;VA FileMan;;Mar 30, 1999
;Per VHA Directive 10-93-142, this routine should not be modified.
S DIARFILE=$P(DIARL,U,3),DIARFN=+$P(DIARL,U,2)
S DIARREC=$P(DIARL,U,4,99)
F DIARXX=1:1 S DIARFLD=$P(DIARREC,U,DIARXX) Q:DIARFLD="" S DIARFNO=$P(DIARFLD,":"),DIARFNA=$P(DIARFLD,":",2) D
. I +DIARFNO=.01 S DIAR01=DIARFNA
. S DIARPC(DIARXX)=DIARFNO_U_DIARFNA
. S:+DIARFNO'=.01 DIARID(DIARFNO)=DIARFNA_U_DIARFNO
. S DIARCNT=DIARXX
. Q
S DIARCTR=0,DIARFLGT=0
F X DIARX Q:DIARL["$DAT" S DIARCTR=DIARCTR+1 F DIARXX=1:1:DIARCNT S DIARFLD=$P(DIARL,U,DIARXX) S DIARFNA=$P(DIARPC(DIARXX),U,2),DIARFNO=+DIARPC(DIARXX),^TMP("DIARHLP",$J,DIARCTR,DIARFNO)=DIARFNA_" = "_DIARFLD D FLGTH
Q
;
FLGTH S $P(DIARPC(DIARXX),U,3)=$S($L(DIARFLD)>+$P(DIARPC(DIARXX),U,3):$L(DIARFLD),1:+$P(DIARPC(DIARXX),U,3))
Q
;
PROC S DIARIXCT=0 K DIARRF
PROC1 F X DIARX Q:DIARL["$DAT" G PROC1:DIARL["$INDEX" D PROC2 D MATCH^DIARR2 K:'$G(DIARIXX(DIARIXCT)) DIARIXX(DIARIXCT) G PROC1
Q:'$D(DIARIXX)
S (DIARIXCT,DIARXX)=1 D:$G(DIARIXX(DIARIXCT)) FOUND
F S DIARXX=$O(DIARIXX(DIARXX)) Q:DIARXX'>0 D PROC1A
Q
;
PROC1A F X DIARX Q:DIARL["#$#" I DIARL["$DAT" S DIARIXCT=DIARIXCT+1 I DIARIXCT=DIARXX D FOUND Q
Q
;
PROC2 K DIARA S DIARIXCT=DIARIXCT+1,DIARIXX(DIARIXCT)=""
F DIARXX=1:1:DIARCNT S DIARVAL=$P(DIARL,U,DIARXX) D PROC2A
Q
;
PROC2A I +$P(DIARPC(DIARXX),U)=.01 S DIARA(.01)=DIARVAL Q
S DIARA("ID",+$P(DIARPC(DIARXX),U))=DIARVAL
Q
;
FOUND K ^TMP("DIARFG",$J) S DIARZ=1 D SET
F DIARZ=DIARZ+1:1 X DIARX D SET I DIARL["$END DAT" Q
F DIARZ=1:1 S DIARY=$P(DIARIXX(DIARIXCT),",",DIARZ) Q:DIARY="" S DIARRF(DIARY)=$S($D(DIARRF(DIARY)):DIARRF(DIARY)+1,1:0) D SETFG
Q
;
SET S ^TMP("DIARFG",$J,DIARZ)=DIARL
Q
;
SETFG S %X="^TMP(""DIARFG"",$J,",%Y="^TMP(""DIAR"",$J,DIARY,DIARRF(DIARY)," D %XY^%RCR
Q
DIARR6 ;SFISC/DCM-PROCESS ARCHIVED FILE WITH INDEX ;11/18/92 11:49 AM
+1 ;;22.0;VA FileMan;;Mar 30, 1999
+2 ;Per VHA Directive 10-93-142, this routine should not be modified.
+3 SET DIARFILE=$PIECE(DIARL,U,3)
SET DIARFN=+$PIECE(DIARL,U,2)
+4 SET DIARREC=$PIECE(DIARL,U,4,99)
+5 FOR DIARXX=1:1
SET DIARFLD=$PIECE(DIARREC,U,DIARXX)
IF DIARFLD=""
QUIT
SET DIARFNO=$PIECE(DIARFLD,":")
SET DIARFNA=$PIECE(DIARFLD,":",2)
Begin DoDot:1
+6 IF +DIARFNO=.01
SET DIAR01=DIARFNA
+7 SET DIARPC(DIARXX)=DIARFNO_U_DIARFNA
+8 IF +DIARFNO'=.01
SET DIARID(DIARFNO)=DIARFNA_U_DIARFNO
+9 SET DIARCNT=DIARXX
+10 QUIT
End DoDot:1
+11 SET DIARCTR=0
SET DIARFLGT=0
+12 FOR
XECUTE DIARX
IF DIARL["$DAT"
QUIT
SET DIARCTR=DIARCTR+1
FOR DIARXX=1:1:DIARCNT
SET DIARFLD=$PIECE(DIARL,U,DIARXX)
SET DIARFNA=$PIECE(DIARPC(DIARXX),U,2)
SET DIARFNO=+DIARPC(DIARXX)
SET ^TMP("DIARHLP",$JOB,DIARCTR,DIARFNO)=DIARFNA_" = "_DIARFLD
DO FLGTH
+13 QUIT
+14 ;
FLGTH SET $PIECE(DIARPC(DIARXX),U,3)=$SELECT($LENGTH(DIARFLD)>+$PIECE(DIARPC(DIARXX),U,3):$LENGTH(DIARFLD),1:+$PIECE(DIARPC(DIARXX),U,3))
+1 QUIT
+2 ;
PROC SET DIARIXCT=0
KILL DIARRF
PROC1 FOR
XECUTE DIARX
IF DIARL["$DAT"
QUIT
IF DIARL["$INDEX"
GOTO PROC1
DO PROC2
DO MATCH^DIARR2
IF '$GET(DIARIXX(DIARIXCT))
KILL DIARIXX(DIARIXCT)
GOTO PROC1
+1 IF '$DATA(DIARIXX)
QUIT
+2 SET (DIARIXCT,DIARXX)=1
IF $GET(DIARIXX(DIARIXCT))
DO FOUND
+3 FOR
SET DIARXX=$ORDER(DIARIXX(DIARXX))
IF DIARXX'>0
QUIT
DO PROC1A
+4 QUIT
+5 ;
PROC1A FOR
XECUTE DIARX
IF DIARL["#$#"
QUIT
IF DIARL["$DAT"
SET DIARIXCT=DIARIXCT+1
IF DIARIXCT=DIARXX
DO FOUND
QUIT
+1 QUIT
+2 ;
PROC2 KILL DIARA
SET DIARIXCT=DIARIXCT+1
SET DIARIXX(DIARIXCT)=""
+1 FOR DIARXX=1:1:DIARCNT
SET DIARVAL=$PIECE(DIARL,U,DIARXX)
DO PROC2A
+2 QUIT
+3 ;
PROC2A IF +$PIECE(DIARPC(DIARXX),U)=.01
SET DIARA(.01)=DIARVAL
QUIT
+1 SET DIARA("ID",+$PIECE(DIARPC(DIARXX),U))=DIARVAL
+2 QUIT
+3 ;
FOUND KILL ^TMP("DIARFG",$JOB)
SET DIARZ=1
DO SET
+1 FOR DIARZ=DIARZ+1:1
XECUTE DIARX
DO SET
IF DIARL["$END DAT"
QUIT
+2 FOR DIARZ=1:1
SET DIARY=$PIECE(DIARIXX(DIARIXCT),",",DIARZ)
IF DIARY=""
QUIT
SET DIARRF(DIARY)=$SELECT($DATA(DIARRF(DIARY)):DIARRF(DIARY)+1,1:0)
DO SETFG
+3 QUIT
+4 ;
SET SET ^TMP("DIARFG",$JOB,DIARZ)=DIARL
+1 QUIT
+2 ;
SETFG SET %X="^TMP(""DIARFG"",$J,"
SET %Y="^TMP(""DIAR"",$J,DIARY,DIARRF(DIARY),"
DO %XY^%RCR
+1 QUIT