DIEZ3 ;SFISC/MKO-COMPILE INPUT TEMPLATE, BUILD CODE TO CHECK KEYS ;2:54 PM 15 Jul 1999 [ 04/02/2003 8:25 AM ]
;;22.0;VA FileMan;**1001**;APR 1, 2003
;;22.0;VA FileMan;**11**;Mar 30, 1999
;Per VHA Directive 10-93-142, this routine should not be modified.
;
;In:
; DIEZKEY(uniqxref#) = count
; DQ = item # in DR string
;
GETKEY(DIEZFIL,DIEZFLD,DIEZKEY,DQ) ;Build routine to check keys
Q:'$D(DIEZKEY)
N DIEZUI
;
;Build code to check field-level keys
D L("K"_DQ_"() N DIMAXL,DIUIR,DIXR")
S DIEZUI=0
F S DIEZUI=$O(DIEZKEY(DIEZUI)) Q:'DIEZUI D
. D BLD(DIEZFIL,DIEZFLD,DIEZUI,DQ,DIEZKEY(DIEZUI))
Q
;
BLD(DIEZFIL,DIEZFLD,DIEZUI,DQ,DIEZCNT) ;Get code for one index DIEZXR
N DIEZMAXL,DIEZSLIS,DIEZUIR
D XRINFO^DIKCU2(DIEZUI,.DIEZUIR,"",.DIEZMAXL)
;
D L(" S DIXR="_DIEZUI)
D L(" S @DIEZTMP@(""V"","_DIEZFIL_",DIIENS,"_DIEZFLD_",""N"")=X")
D L(" N X D C"_DQ_"X"_DIEZCNT_"(""N"")")
D L(" K @DIEZTMP@(""V"","_DIEZFIL_",DIIENS,"_DIEZFLD_",""N"")")
D L(" S DIUIR=$NA("_DIEZUIR_") Q:'$D(@DIUIR) 1")
;
I $D(DIEZMAXL) D
. N ORD,X
. S X="S ",ORD=0
. F S ORD=$O(DIEZMAXL(ORD)) Q:'ORD D
.. S X=X_"DIMAXL("_ORD_")="_DIEZMAXL(ORD)_","
. I X?.E1"," D L(" "_$E(X,1,$L(X)-1))
;
D L(" Q $$UNIQUE^DIE17(.X,.DA,DIUIR,""C"_DQ_"X"_DIEZCNT_U_DNM_DRN_""""_$S($D(DIEZMAXL):",.DIMAXL",1:"")_")")
Q
;
L(X) ;Add CODE to ^UTILITY
S L=L+1,^UTILITY($J,0,L)=X,T=T+$L(X)+2
Q
DIEZ3 ;SFISC/MKO-COMPILE INPUT TEMPLATE, BUILD CODE TO CHECK KEYS ;2:54 PM 15 Jul 1999 [ 04/02/2003 8:25 AM ]
+1 ;;22.0;VA FileMan;**1001**;APR 1, 2003
+2 ;;22.0;VA FileMan;**11**;Mar 30, 1999
+3 ;Per VHA Directive 10-93-142, this routine should not be modified.
+4 ;
+5 ;In:
+6 ; DIEZKEY(uniqxref#) = count
+7 ; DQ = item # in DR string
+8 ;
GETKEY(DIEZFIL,DIEZFLD,DIEZKEY,DQ) ;Build routine to check keys
+1 IF '$DATA(DIEZKEY)
QUIT
+2 NEW DIEZUI
+3 ;
+4 ;Build code to check field-level keys
+5 DO L("K"_DQ_"() N DIMAXL,DIUIR,DIXR")
+6 SET DIEZUI=0
+7 FOR
SET DIEZUI=$ORDER(DIEZKEY(DIEZUI))
IF 'DIEZUI
QUIT
Begin DoDot:1
+8 DO BLD(DIEZFIL,DIEZFLD,DIEZUI,DQ,DIEZKEY(DIEZUI))
End DoDot:1
+9 QUIT
+10 ;
BLD(DIEZFIL,DIEZFLD,DIEZUI,DQ,DIEZCNT) ;Get code for one index DIEZXR
+1 NEW DIEZMAXL,DIEZSLIS,DIEZUIR
+2 DO XRINFO^DIKCU2(DIEZUI,.DIEZUIR,"",.DIEZMAXL)
+3 ;
+4 DO L(" S DIXR="_DIEZUI)
+5 DO L(" S @DIEZTMP@(""V"","_DIEZFIL_",DIIENS,"_DIEZFLD_",""N"")=X")
+6 DO L(" N X D C"_DQ_"X"_DIEZCNT_"(""N"")")
+7 DO L(" K @DIEZTMP@(""V"","_DIEZFIL_",DIIENS,"_DIEZFLD_",""N"")")
+8 DO L(" S DIUIR=$NA("_DIEZUIR_") Q:'$D(@DIUIR) 1")
+9 ;
+10 IF $DATA(DIEZMAXL)
Begin DoDot:1
+11 NEW ORD,X
+12 SET X="S "
SET ORD=0
+13 FOR
SET ORD=$ORDER(DIEZMAXL(ORD))
IF 'ORD
QUIT
Begin DoDot:2
+14 SET X=X_"DIMAXL("_ORD_")="_DIEZMAXL(ORD)_","
End DoDot:2
+15 IF X?.E1","
DO L(" "_$EXTRACT(X,1,$LENGTH(X)-1))
End DoDot:1
+16 ;
+17 DO L(" Q $$UNIQUE^DIE17(.X,.DA,DIUIR,""C"_DQ_"X"_DIEZCNT_U_DNM_DRN_""""_$SELECT($DATA(DIEZMAXL):",.DIMAXL",1:"")_")")
+18 QUIT
+19 ;
L(X) ;Add CODE to ^UTILITY
+1 SET L=L+1
SET ^UTILITY($JOB,0,L)=X
SET T=T+$LENGTH(X)+2
+2 QUIT