DIUCANON ;GFT/GFT-UTILITIES RELATED TO CANONIC TEMPLATES ;2015-01-03  8:57 PM
 ;;22.2;VA FileMan;;Jan 05, 2016;Build 42
 ;;Per VA Directive 6402, this routine should not be modified.
 ;;Submitted to OSEHRA 5 January 2015 by the VISTA Expertise Network.
 ;;Based on Medsphere Systems Corporation's MSC FileMan 1051.
 ;;Licensed under the terms of the Apache License, Version 2.0.
 ;
 ;
FIND(DI,FILE) ;Looks at e.g., ^DIE("CANONIC",9.6,1)="" or ^DIPT("CANONIC",9.6,1)=""
 N T
 S DI=$S(DI=.4:"PT",DI=.401:"BT",DI=.402:"E",1:U) I DI=U Q ""
 S DI="^DI"_DI,T=$O(@DI@("CANONIC",FILE,"")) I T,$P($G(@DI@(T,0)),U,4)=FILE Q T_U_$P(^(0),U) ;GET THE FAVORED INPUT, SORT OR PRINT TEMPLATE
 Q ""
 ;
HELP ;
 W !,"Answer YES only if you want to make this Template name appear in user dialogs",!?9,"as the default for this File."
 I $G(DA),$G(DIE)?1"^DI".E1"(" D
 .N D,F S D=$P(DIE,"("),F=$P($G(@D@(DA,0)),U,4) I F M D=@D@("CANONIC",F) K D(DA) F I=0:0 S I=$O(D(I)) Q:'I  D
 ..I $D(@D@(I,0)) W !,"Note that the Template named '",$P(^(0),U),"' is already canonic for this File!"
 W !
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDIUCANON   1089     printed  Sep 23, 2025@20:30:47                                                                                                                                                                                                    Page 2
DIUCANON  ;GFT/GFT-UTILITIES RELATED TO CANONIC TEMPLATES ;2015-01-03  8:57 PM
 +1       ;;22.2;VA FileMan;;Jan 05, 2016;Build 42
 +2       ;;Per VA Directive 6402, this routine should not be modified.
 +3       ;;Submitted to OSEHRA 5 January 2015 by the VISTA Expertise Network.
 +4       ;;Based on Medsphere Systems Corporation's MSC FileMan 1051.
 +5       ;;Licensed under the terms of the Apache License, Version 2.0.
 +6       ;
 +7       ;
FIND(DI,FILE) ;Looks at e.g., ^DIE("CANONIC",9.6,1)="" or ^DIPT("CANONIC",9.6,1)=""
 +1        NEW T
 +2        SET DI=$SELECT(DI=.4:"PT",DI=.401:"BT",DI=.402:"E",1:U)
           IF DI=U
               QUIT ""
 +3       ;GET THE FAVORED INPUT, SORT OR PRINT TEMPLATE
           SET DI="^DI"_DI
           SET T=$ORDER(@DI@("CANONIC",FILE,""))
           IF T
               IF $PIECE($GET(@DI@(T,0)),U,4)=FILE
                   QUIT T_U_$PIECE(^(0),U)
 +4        QUIT ""
 +5       ;
HELP      ;
 +1        WRITE !,"Answer YES only if you want to make this Template name appear in user dialogs",!?9,"as the default for this File."
 +2        IF $GET(DA)
               IF $GET(DIE)?1"^DI".E1"("
                   Begin DoDot:1
 +3                    NEW D,F
                       SET D=$PIECE(DIE,"(")
                       SET F=$PIECE($GET(@D@(DA,0)),U,4)
                       IF F
                           MERGE D=@D@("CANONIC",F)
                           KILL D(DA)
                           FOR I=0:0
                               SET I=$ORDER(D(I))
                               if 'I
                                   QUIT 
                               Begin DoDot:2
 +4                                IF $DATA(@D@(I,0))
                                       WRITE !,"Note that the Template named '",$PIECE(^(0),U),"' is already canonic for this File!"
                               End DoDot:2
                   End DoDot:1
 +5        WRITE !
 +6        QUIT