- DIKKUTL ;SFISC/MKO-UTILITY OPTION TO DEFINE A KEY ;8:13 AM 7 Jun 2001 [ 04/02/2003 8:25 AM ]
- ;;22.0;VA FileMan;**1001**;APR 1, 2003
- ;;22.0;VA FileMan;**68**;Mar 30, 1999
- ;Per VHA Directive 10-93-142, this routine should not be modified.
- MOD ;Create/Modify/Edit a Key
- ;In:
- ; DI = selected top level file#
- ; DIU = global root of file DI
- N DIKKCNT,DIKKFILE,DIKKEY,DIKKQUIT,DIKKROOT,DIKKTOP
- N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- ;
- ;Get subfile
- S DIKKROOT=DIU,DIKKTOP=DI,DIKKFILE=$$SUB^DIKCU(DI)
- S:'$G(DIKKFILE) DIKKFILE=DIKKTOP
- ;
- REMOD ;Get and list keys on file DIKKFILE
- I $G(DIKKQUIT) W ! Q
- D GET^DIKKUTL2(DIKKFILE,.DIKKCNT)
- W ! D LIST^DIKKUTL2(.DIKKCNT)
- ;
- ;Prompt for action
- I 'DIKKCNT S Y="C"
- E S Y=$$RD Q:Y=""
- ;
- ;Delete
- I Y="D" D G REMOD
- . S DIKKEY=$$CHOOSE^DIKKUTL2(.DIKKCNT,"delete") Q:'DIKKEY
- . D DELETE(DIKKEY,DIKKTOP,DIKKFILE)
- ;
- ;Edit
- I Y="E" D G REMOD
- . S DIKKEY=$$CHOOSE^DIKKUTL2(.DIKKCNT,"edit") Q:'DIKKEY
- . D EDIT(DIKKEY,DIKKTOP,DIKKFILE)
- ;
- ;Create
- I Y="C" D G REMOD
- . S DIR(0)="Y",DIR("B")="No"
- . S DIR("A")="Want to create a new Key for this file"
- . D ^DIR K DIR I $D(DIRUT)!'Y S:'DIKKCNT DIKKQUIT=1 Q
- . D CREATE^DIKKUTL1(DIKKTOP,DIKKFILE)
- ;
- ;Verify
- I Y="V" D G REMOD
- . S DIKKEY=$$CHOOSE^DIKKUTL2(.DIKKCNT,"verify") Q:'DIKKEY
- . D VERIFY^DIKKUTL3(DIKKEY,DIKKTOP,DIKKFILE)
- Q
- ;
- DELETE(DIKKEY,DIKKTOP,DIKKFILE) ;Delete a Key
- N DIKKID,DIKKUI,DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- ;
- ;Confirm deletion
- S DIR(0)="Y"
- S DIR("A")="Are you sure you want to delete the Key"
- S DIR("B")="No"
- D ^DIR K DIR Q:$D(DIRUT)!'Y
- ;
- ;Delete
- S DIKKUI=$P($G(^DD("KEY",DIKKEY,0)),U,4)
- S DIKKID=$$KEYID(DIKKEY,DIKKTOP,DIKKFILE)
- D DELKEY(DIKKEY,DIKKID)
- ;
- ;Ask/Delete Uniqueness Index
- I DIKKUI,'$D(^DD("KEY","AU",DIKKUI)) D
- . D DELUI(DIKKUI,DIKKTOP,DIKKFILE,DIKKID)
- Q
- ;
- EDIT(DIKKEY,DIKKTOP,DIKKFILE) ;Edit a Key
- N DIKKCH,DIKKFLD,DIKKID,DIKKNO,DIKKOLD,DIKKUI0,DIKKUI1,DIKKUFLD
- N DA,DDSFILE,DR
- ;
- REEDIT ;Come back here, if user chooses to re-edit the key
- S DIKKID=$$KEYID(DIKKEY,DIKKTOP,DIKKFILE)
- ;
- ;Save original UI, and set and kill logic of original UI
- ;Invoke form to edit key
- ;Set new UI
- S DIKKUI0=$P($G(^DD("KEY",DIKKEY,0)),U,4)
- K DIKKOLD
- D:DIKKUI0 LOADXREF^DIKC1(DIKKFILE,"","K",DIKKUI0,"","DIKKOLD")
- S DDSFILE=.31,DA=DIKKEY,DR="[DIKK EDIT]"
- D ^DDS K DDSFILE,DA,DR
- S DIKKUI1=$P($G(^DD("KEY",DIKKEY,0)),U,4)
- ;
- ;If UI was edited, rebuild it
- I DIKKUI0,DIKKUI0=DIKKUI1 D
- . N DIKKNEW,DIKKFLIS
- . Q:$G(DIKKOLD(DIKKFILE,DIKKUI0,"K"))=$G(^DD("IX",DIKKUI1,2))
- . W !,$C(7)_"The definition of the Uniqueness Index was modified."
- . D LOADXREF^DIKC1(DIKKFILE,"","S",DIKKUI0,"","DIKKNEW")
- . D GETFLIST^DIKCUTL(DIKKUI0,.DIKKFLIS)
- . D KSC^DIKCUTL3(DIKKTOP,.DIKKOLD,.DIKKNEW,.DIKKFLIS)
- K DIKKOLD
- ;
- ;If there was an old UI, and it's '= to new UI, ask/delete old UI
- I DIKKUI0,DIKKUI0'=DIKKUI1 D
- . D DELUI(DIKKUI0,DIKKTOP,DIKKFILE,DIKKID,DIKKEY)
- ;
- ;Quit if key was deleted.
- Q:$D(^DD("KEY",DIKKEY,0))[0
- ;
- ;Get fields in key and new UI
- D GETFLD^DIKKUTL2(DIKKEY,DIKKUI1,.DIKKFLD,.DIKKUFLD)
- ;
- ;If key has no fields and no UI, ask reedit/delete key
- I 'DIKKFLD,'DIKKUI1 D G:DIKKCH<2 REEDIT Q
- . S DIKKCH=$$EORD^DIKKUTL4(DIKKID) Q:DIKKCH'=2
- . D DELKEY(DIKKEY,DIKKID)
- ;
- ;If key has fields but no UI, create one.
- I DIKKFLD,'DIKKUI1 D G:DIKKCH=1 REEDIT Q:DIKKCH=2 G EDITEND
- . F D Q:DIKKCH'=3
- .. S DIKKCH=0
- .. D UICREATE^DIKKUTL1(DIKKEY,DIKKTOP,DIKKFILE,.DIKKNO)
- .. Q:'$G(DIKKNO)
- .. ;
- .. ;User aborted Uniqueness Index creation;
- .. ;Ask edit key/delete key/create UI
- .. W ! S DIKKCH=$$EDORC^DIKKUTL4 Q:DIKKCH'=2
- .. D DELKEY(DIKKEY,DIKKID)
- ;
- ;If neither key nor UI has fields, ask reedit/delete key
- I 'DIKKFLD,'DIKKUFLD D G:DIKKCH<2 REEDIT Q
- . S DIKKCH=$$EORD^DIKKUTL4(DIKKID,1) Q:DIKKCH'=2
- . D DELKEY(DIKKEY,DIKKID)
- ;
- ;Compare fields in Key with fields in Uniqueness Index; quit if same
- G:$$GCMP^DIKCU2("DIKKFLD","DIKKUFLD") EDITEND
- ;
- ;Key has a UI but no fields; or fields and UI don't match.
- ;Prompt re-edit/make key fields match UI/or make UI match key fields
- S DIKKCH=$$RORM^DIKKUTL4(DIKKUFLD,DIKKFLD)
- ;
- ;Re-edit
- I DIKKCH=1 G REEDIT
- ;
- ;Make key fields match UI
- E I DIKKCH=2 D
- . ;Delete all fields in Key
- . W !!," Modifying fields in Key ..."
- . N DA,DIK
- . S DIK="^DD(""KEY"","_DIKKEY_",2,",DA(1)=DIKKEY
- . S DA=0 F S DA=$O(^DD("KEY",DIKKEY,2,DA)) Q:'DA D ^DIK
- . K DA,DIK
- . ;
- . ;Add fields to Key
- . N DIKKFDA,DIKKIENS,DIKKSEQ
- . S DIKKSEQ=0 F S DIKKSEQ=$O(DIKKUFLD(DIKKSEQ)) Q:'DIKKSEQ D
- .. S DIKKIENS="+"_DIKKSEQ_","_DIKKEY_","
- .. S DIKKFDA(.312,DIKKIENS,.01)=$P(DIKKUFLD(DIKKSEQ),U,2)
- .. S DIKKFDA(.312,DIKKIENS,.02)=$P(DIKKUFLD(DIKKSEQ),U)
- .. S DIKKFDA(.312,DIKKIENS,1)=DIKKSEQ
- . D UPDATE^DIE("","DIKKFDA")
- . I '$D(DIERR) W " DONE!"
- . E D MSG^DIALOG(),EOP
- ;
- ;Make UI match key fields
- E I DIKKCH=3 D UIMOD^DIKKUTL1(DIKKUI1,DIKKEY,DIKKTOP,DIKKFILE)
- ;
- EDITEND ;
- S DIKKCH=$$CHECK Q:'DIKKCH
- ;
- W !!,"Checking key integrity ..."
- I $$INTEG^DIKK(DIKKTOP,"","",DIKKEY) W " NO PROBLEMS" D EOP Q
- ;
- S DIKKCH=$$EDORI^DIKKUTL4
- I DIKKCH=2 G REEDIT
- I DIKKCH=1 D DELETE(DIKKEY,DIKKTOP,DIKKFILE)
- Q
- ;
- DELUI(DIKKUI,DIKKTOP,DIKKFILE,DIKKID,DIKKEY) ;Delete the Uniqueness Index
- N I,MSG
- N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- ;
- ;If DIKKEY is passed in, quit if any key other than DIKKEY uses
- ;this index as a Uniqueness Index. (Index can't be deleted.)
- I $G(DIKKEY) D Q:I
- . S I=0 F S I=$O(^DD("KEY","AU",DIKKUI,I)) Q:'I Q:I'=DIKKEY
- ;
- S MSG(0)="Do you want to delete the "_$$UIID(DIKKUI,DIKKTOP,DIKKFILE)_" previously used by "_$S($G(DIKKID)]"":DIKKID,1:"the Key")
- D WRAP^DIKCU2(.MSG)
- S DIR(0)="Y"
- F I=0:1 Q:'$D(MSG(I+1)) S DIR("A",I+1)=MSG(I)
- S DIR("A")=MSG(I)
- W ! D ^DIR K DIR S:$D(DTOUT) Y=1 Q:$D(DUOUT)!'Y
- D DELETE^DIKCUTL(DIKKUI,DIKKTOP,DIKKFILE)
- Q
- ;
- DELKEY(DA,DIKKID) ;Call DIK to delete the key
- N DIK
- S DIK="^DD(""KEY""," D ^DIK
- W !!?2,$G(DIKKID)_" deleted."
- Q
- ;
- UIID(UI,TOP,FILE) ;Return text that identifies uniqueness index
- Q:$D(^DD("IX",UI,0))[0 ""
- Q "'"_$P(^DD("IX",UI,0),U,2)_"' Uniqueness Index (#"_UI_") on "_$S(TOP'=FILE:"Subf",1:"F")_"ile #"_$P(^(0),U)
- ;
- KEYID(KEY,TOP,FILE) ;Return string of text that identifies the key
- Q "Key '"_$P(^DD("KEY",KEY,0),U,2)_"' of "_$S(TOP'=FILE:"Subf",1:"F")_"ile #"_$P(^(0),U)
- ;
- RD() ;Prompt for action
- N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- S DIR(0)="SAO^V:VERIFY;E:EDIT;D:DELETE;C:CREATE"
- S DIR("A")="Choose V (Verify)/E (Edit)/D (Delete)/C (Create): "
- S DIR("?",1)="Enter 'V' to verify the integrity of a Key."
- S DIR("?",2)=" 'E' to edit an existing Key"
- S DIR("?",3)=" 'D' to delete an existing Key"
- S DIR("?",4)=" 'C' to create a new Key."
- W ! D ^DIR S:$D(DIRUT) Y=""
- Q Y
- ;
- EOP ;Issue Press Return to continue prompt
- N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- S DIR(0)="E",DIR("A")="Press RETURN to continue"
- S DIR("?")="Press the RETURN or ENTER key."
- W ! D ^DIR
- Q
- ;
- CHECK() ;Prompt whether to check key integrity
- N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- S DIR("A")="Do want to check the integrity of this key now"
- S DIR("?")="Enter 'Y' to run the key integrity checker."
- S DIR(0)="Y"
- W ! D ^DIR
- Q $S($D(DIRUT):0,1:Y)
- DIKKUTL ;SFISC/MKO-UTILITY OPTION TO DEFINE A KEY ;8:13 AM 7 Jun 2001 [ 04/02/2003 8:25 AM ]
- +1 ;;22.0;VA FileMan;**1001**;APR 1, 2003
- +2 ;;22.0;VA FileMan;**68**;Mar 30, 1999
- +3 ;Per VHA Directive 10-93-142, this routine should not be modified.
- MOD ;Create/Modify/Edit a Key
- +1 ;In:
- +2 ; DI = selected top level file#
- +3 ; DIU = global root of file DI
- +4 NEW DIKKCNT,DIKKFILE,DIKKEY,DIKKQUIT,DIKKROOT,DIKKTOP
- +5 NEW DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- +6 ;
- +7 ;Get subfile
- +8 SET DIKKROOT=DIU
- SET DIKKTOP=DI
- SET DIKKFILE=$$SUB^DIKCU(DI)
- +9 IF '$GET(DIKKFILE)
- SET DIKKFILE=DIKKTOP
- +10 ;
- REMOD ;Get and list keys on file DIKKFILE
- +1 IF $GET(DIKKQUIT)
- WRITE !
- QUIT
- +2 DO GET^DIKKUTL2(DIKKFILE,.DIKKCNT)
- +3 WRITE !
- DO LIST^DIKKUTL2(.DIKKCNT)
- +4 ;
- +5 ;Prompt for action
- +6 IF 'DIKKCNT
- SET Y="C"
- +7 IF '$TEST
- SET Y=$$RD
- IF Y=""
- QUIT
- +8 ;
- +9 ;Delete
- +10 IF Y="D"
- Begin DoDot:1
- +11 SET DIKKEY=$$CHOOSE^DIKKUTL2(.DIKKCNT,"delete")
- IF 'DIKKEY
- QUIT
- +12 DO DELETE(DIKKEY,DIKKTOP,DIKKFILE)
- End DoDot:1
- GOTO REMOD
- +13 ;
- +14 ;Edit
- +15 IF Y="E"
- Begin DoDot:1
- +16 SET DIKKEY=$$CHOOSE^DIKKUTL2(.DIKKCNT,"edit")
- IF 'DIKKEY
- QUIT
- +17 DO EDIT(DIKKEY,DIKKTOP,DIKKFILE)
- End DoDot:1
- GOTO REMOD
- +18 ;
- +19 ;Create
- +20 IF Y="C"
- Begin DoDot:1
- +21 SET DIR(0)="Y"
- SET DIR("B")="No"
- +22 SET DIR("A")="Want to create a new Key for this file"
- +23 DO ^DIR
- KILL DIR
- IF $DATA(DIRUT)!'Y
- IF 'DIKKCNT
- SET DIKKQUIT=1
- QUIT
- +24 DO CREATE^DIKKUTL1(DIKKTOP,DIKKFILE)
- End DoDot:1
- GOTO REMOD
- +25 ;
- +26 ;Verify
- +27 IF Y="V"
- Begin DoDot:1
- +28 SET DIKKEY=$$CHOOSE^DIKKUTL2(.DIKKCNT,"verify")
- IF 'DIKKEY
- QUIT
- +29 DO VERIFY^DIKKUTL3(DIKKEY,DIKKTOP,DIKKFILE)
- End DoDot:1
- GOTO REMOD
- +30 QUIT
- +31 ;
- DELETE(DIKKEY,DIKKTOP,DIKKFILE) ;Delete a Key
- +1 NEW DIKKID,DIKKUI,DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- +2 ;
- +3 ;Confirm deletion
- +4 SET DIR(0)="Y"
- +5 SET DIR("A")="Are you sure you want to delete the Key"
- +6 SET DIR("B")="No"
- +7 DO ^DIR
- KILL DIR
- IF $DATA(DIRUT)!'Y
- QUIT
- +8 ;
- +9 ;Delete
- +10 SET DIKKUI=$PIECE($GET(^DD("KEY",DIKKEY,0)),U,4)
- +11 SET DIKKID=$$KEYID(DIKKEY,DIKKTOP,DIKKFILE)
- +12 DO DELKEY(DIKKEY,DIKKID)
- +13 ;
- +14 ;Ask/Delete Uniqueness Index
- +15 IF DIKKUI
- IF '$DATA(^DD("KEY","AU",DIKKUI))
- Begin DoDot:1
- +16 DO DELUI(DIKKUI,DIKKTOP,DIKKFILE,DIKKID)
- End DoDot:1
- +17 QUIT
- +18 ;
- EDIT(DIKKEY,DIKKTOP,DIKKFILE) ;Edit a Key
- +1 NEW DIKKCH,DIKKFLD,DIKKID,DIKKNO,DIKKOLD,DIKKUI0,DIKKUI1,DIKKUFLD
- +2 NEW DA,DDSFILE,DR
- +3 ;
- REEDIT ;Come back here, if user chooses to re-edit the key
- +1 SET DIKKID=$$KEYID(DIKKEY,DIKKTOP,DIKKFILE)
- +2 ;
- +3 ;Save original UI, and set and kill logic of original UI
- +4 ;Invoke form to edit key
- +5 ;Set new UI
- +6 SET DIKKUI0=$PIECE($GET(^DD("KEY",DIKKEY,0)),U,4)
- +7 KILL DIKKOLD
- +8 IF DIKKUI0
- DO LOADXREF^DIKC1(DIKKFILE,"","K",DIKKUI0,"","DIKKOLD")
- +9 SET DDSFILE=.31
- SET DA=DIKKEY
- SET DR="[DIKK EDIT]"
- +10 DO ^DDS
- KILL DDSFILE,DA,DR
- +11 SET DIKKUI1=$PIECE($GET(^DD("KEY",DIKKEY,0)),U,4)
- +12 ;
- +13 ;If UI was edited, rebuild it
- +14 IF DIKKUI0
- IF DIKKUI0=DIKKUI1
- Begin DoDot:1
- +15 NEW DIKKNEW,DIKKFLIS
- +16 IF $GET(DIKKOLD(DIKKFILE,DIKKUI0,"K"))=$GET(^DD("IX",DIKKUI1,2))
- QUIT
- +17 WRITE !,$CHAR(7)_"The definition of the Uniqueness Index was modified."
- +18 DO LOADXREF^DIKC1(DIKKFILE,"","S",DIKKUI0,"","DIKKNEW")
- +19 DO GETFLIST^DIKCUTL(DIKKUI0,.DIKKFLIS)
- +20 DO KSC^DIKCUTL3(DIKKTOP,.DIKKOLD,.DIKKNEW,.DIKKFLIS)
- End DoDot:1
- +21 KILL DIKKOLD
- +22 ;
- +23 ;If there was an old UI, and it's '= to new UI, ask/delete old UI
- +24 IF DIKKUI0
- IF DIKKUI0'=DIKKUI1
- Begin DoDot:1
- +25 DO DELUI(DIKKUI0,DIKKTOP,DIKKFILE,DIKKID,DIKKEY)
- End DoDot:1
- +26 ;
- +27 ;Quit if key was deleted.
- +28 IF $DATA(^DD("KEY",DIKKEY,0))[0
- QUIT
- +29 ;
- +30 ;Get fields in key and new UI
- +31 DO GETFLD^DIKKUTL2(DIKKEY,DIKKUI1,.DIKKFLD,.DIKKUFLD)
- +32 ;
- +33 ;If key has no fields and no UI, ask reedit/delete key
- +34 IF 'DIKKFLD
- IF 'DIKKUI1
- Begin DoDot:1
- +35 SET DIKKCH=$$EORD^DIKKUTL4(DIKKID)
- IF DIKKCH'=2
- QUIT
- +36 DO DELKEY(DIKKEY,DIKKID)
- End DoDot:1
- IF DIKKCH<2
- GOTO REEDIT
- QUIT
- +37 ;
- +38 ;If key has fields but no UI, create one.
- +39 IF DIKKFLD
- IF 'DIKKUI1
- Begin DoDot:1
- +40 FOR
- Begin DoDot:2
- +41 SET DIKKCH=0
- +42 DO UICREATE^DIKKUTL1(DIKKEY,DIKKTOP,DIKKFILE,.DIKKNO)
- +43 IF '$GET(DIKKNO)
- QUIT
- +44 ;
- +45 ;User aborted Uniqueness Index creation;
- +46 ;Ask edit key/delete key/create UI
- +47 WRITE !
- SET DIKKCH=$$EDORC^DIKKUTL4
- IF DIKKCH'=2
- QUIT
- +48 DO DELKEY(DIKKEY,DIKKID)
- End DoDot:2
- IF DIKKCH'=3
- QUIT
- End DoDot:1
- IF DIKKCH=1
- GOTO REEDIT
- IF DIKKCH=2
- QUIT
- GOTO EDITEND
- +49 ;
- +50 ;If neither key nor UI has fields, ask reedit/delete key
- +51 IF 'DIKKFLD
- IF 'DIKKUFLD
- Begin DoDot:1
- +52 SET DIKKCH=$$EORD^DIKKUTL4(DIKKID,1)
- IF DIKKCH'=2
- QUIT
- +53 DO DELKEY(DIKKEY,DIKKID)
- End DoDot:1
- IF DIKKCH<2
- GOTO REEDIT
- QUIT
- +54 ;
- +55 ;Compare fields in Key with fields in Uniqueness Index; quit if same
- +56 IF $$GCMP^DIKCU2("DIKKFLD","DIKKUFLD")
- GOTO EDITEND
- +57 ;
- +58 ;Key has a UI but no fields; or fields and UI don't match.
- +59 ;Prompt re-edit/make key fields match UI/or make UI match key fields
- +60 SET DIKKCH=$$RORM^DIKKUTL4(DIKKUFLD,DIKKFLD)
- +61 ;
- +62 ;Re-edit
- +63 IF DIKKCH=1
- GOTO REEDIT
- +64 ;
- +65 ;Make key fields match UI
- +66 IF '$TEST
- IF DIKKCH=2
- Begin DoDot:1
- +67 ;Delete all fields in Key
- +68 WRITE !!," Modifying fields in Key ..."
- +69 NEW DA,DIK
- +70 SET DIK="^DD(""KEY"","_DIKKEY_",2,"
- SET DA(1)=DIKKEY
- +71 SET DA=0
- FOR
- SET DA=$ORDER(^DD("KEY",DIKKEY,2,DA))
- IF 'DA
- QUIT
- DO ^DIK
- +72 KILL DA,DIK
- +73 ;
- +74 ;Add fields to Key
- +75 NEW DIKKFDA,DIKKIENS,DIKKSEQ
- +76 SET DIKKSEQ=0
- FOR
- SET DIKKSEQ=$ORDER(DIKKUFLD(DIKKSEQ))
- IF 'DIKKSEQ
- QUIT
- Begin DoDot:2
- +77 SET DIKKIENS="+"_DIKKSEQ_","_DIKKEY_","
- +78 SET DIKKFDA(.312,DIKKIENS,.01)=$PIECE(DIKKUFLD(DIKKSEQ),U,2)
- +79 SET DIKKFDA(.312,DIKKIENS,.02)=$PIECE(DIKKUFLD(DIKKSEQ),U)
- +80 SET DIKKFDA(.312,DIKKIENS,1)=DIKKSEQ
- End DoDot:2
- +81 DO UPDATE^DIE("","DIKKFDA")
- +82 IF '$DATA(DIERR)
- WRITE " DONE!"
- +83 IF '$TEST
- DO MSG^DIALOG()
- DO EOP
- End DoDot:1
- +84 ;
- +85 ;Make UI match key fields
- +86 IF '$TEST
- IF DIKKCH=3
- DO UIMOD^DIKKUTL1(DIKKUI1,DIKKEY,DIKKTOP,DIKKFILE)
- +87 ;
- EDITEND ;
- +1 SET DIKKCH=$$CHECK
- IF 'DIKKCH
- QUIT
- +2 ;
- +3 WRITE !!,"Checking key integrity ..."
- +4 IF $$INTEG^DIKK(DIKKTOP,"","",DIKKEY)
- WRITE " NO PROBLEMS"
- DO EOP
- QUIT
- +5 ;
- +6 SET DIKKCH=$$EDORI^DIKKUTL4
- +7 IF DIKKCH=2
- GOTO REEDIT
- +8 IF DIKKCH=1
- DO DELETE(DIKKEY,DIKKTOP,DIKKFILE)
- +9 QUIT
- +10 ;
- DELUI(DIKKUI,DIKKTOP,DIKKFILE,DIKKID,DIKKEY) ;Delete the Uniqueness Index
- +1 NEW I,MSG
- +2 NEW DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- +3 ;
- +4 ;If DIKKEY is passed in, quit if any key other than DIKKEY uses
- +5 ;this index as a Uniqueness Index. (Index can't be deleted.)
- +6 IF $GET(DIKKEY)
- Begin DoDot:1
- +7 SET I=0
- FOR
- SET I=$ORDER(^DD("KEY","AU",DIKKUI,I))
- IF 'I
- QUIT
- IF I'=DIKKEY
- QUIT
- End DoDot:1
- IF I
- QUIT
- +8 ;
- +9 SET MSG(0)="Do you want to delete the "_$$UIID(DIKKUI,DIKKTOP,DIKKFILE)_" previously used by "_$SELECT($GET(DIKKID)]"":DIKKID,1:"the Key")
- +10 DO WRAP^DIKCU2(.MSG)
- +11 SET DIR(0)="Y"
- +12 FOR I=0:1
- IF '$DATA(MSG(I+1))
- QUIT
- SET DIR("A",I+1)=MSG(I)
- +13 SET DIR("A")=MSG(I)
- +14 WRITE !
- DO ^DIR
- KILL DIR
- IF $DATA(DTOUT)
- SET Y=1
- IF $DATA(DUOUT)!'Y
- QUIT
- +15 DO DELETE^DIKCUTL(DIKKUI,DIKKTOP,DIKKFILE)
- +16 QUIT
- +17 ;
- DELKEY(DA,DIKKID) ;Call DIK to delete the key
- +1 NEW DIK
- +2 SET DIK="^DD(""KEY"","
- DO ^DIK
- +3 WRITE !!?2,$GET(DIKKID)_" deleted."
- +4 QUIT
- +5 ;
- UIID(UI,TOP,FILE) ;Return text that identifies uniqueness index
- +1 IF $DATA(^DD("IX",UI,0))[0
- QUIT ""
- +2 QUIT "'"_$PIECE(^DD("IX",UI,0),U,2)_"' Uniqueness Index (#"_UI_") on "_$SELECT(TOP'=FILE:"Subf",1:"F")_"ile #"_$PIECE(^(0),U)
- +3 ;
- KEYID(KEY,TOP,FILE) ;Return string of text that identifies the key
- +1 QUIT "Key '"_$PIECE(^DD("KEY",KEY,0),U,2)_"' of "_$SELECT(TOP'=FILE:"Subf",1:"F")_"ile #"_$PIECE(^(0),U)
- +2 ;
- RD() ;Prompt for action
- +1 NEW DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- +2 SET DIR(0)="SAO^V:VERIFY;E:EDIT;D:DELETE;C:CREATE"
- +3 SET DIR("A")="Choose V (Verify)/E (Edit)/D (Delete)/C (Create): "
- +4 SET DIR("?",1)="Enter 'V' to verify the integrity of a Key."
- +5 SET DIR("?",2)=" 'E' to edit an existing Key"
- +6 SET DIR("?",3)=" 'D' to delete an existing Key"
- +7 SET DIR("?",4)=" 'C' to create a new Key."
- +8 WRITE !
- DO ^DIR
- IF $DATA(DIRUT)
- SET Y=""
- +9 QUIT Y
- +10 ;
- EOP ;Issue Press Return to continue prompt
- +1 NEW DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- +2 SET DIR(0)="E"
- SET DIR("A")="Press RETURN to continue"
- +3 SET DIR("?")="Press the RETURN or ENTER key."
- +4 WRITE !
- DO ^DIR
- +5 QUIT
- +6 ;
- CHECK() ;Prompt whether to check key integrity
- +1 NEW DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
- +2 SET DIR("A")="Do want to check the integrity of this key now"
- +3 SET DIR("?")="Enter 'Y' to run the key integrity checker."
- +4 SET DIR(0)="Y"
- +5 WRITE !
- DO ^DIR
- +6 QUIT $SELECT($DATA(DIRUT):0,1:Y)