DG17204 ;BHM/RGY,ALS-Edit mapping entries ;FEB 20, 1998
 ;;5.3;Registration;**172**;Aug 13, 1993
EDIT(TYPE) ;
 NEW DA,DIE,DR,L,TO,FR,DIC,FLDS,BY
 F X=0:0 S X=$O(^XTMP("DGTMP",390.2,X)) Q:'X  I $P(^(X,0),"^",2)=TYPE,'$P(^(0),"^",3) Q
 I 'X W !!,"*** No mapping necessary! ***",! K X Q
 W !! D MESS($S(TYPE=11:"MARITAL",1:"RELIGION")) W !
 S L=0,DIC="^XTMP(""DGTMP"",390.2,",(TO,FR)="",(BY,FLDS)="[DG172 "_$S(TYPE=11:"MARITAL",1:"RELIGION")_" MAPPING]"
 D EN1^DIP
START ;
 S DIC("A")="Select Non-Standard "_$S(TYPE=11:"Marital Status: ",1:"Religion: "),DIC="^XTMP(""DGTMP"",390.2,",DIC(0)="QEAM",DIC("S")="I '$P(^(0),U,3),$P(^(0),U,2)="_TYPE D ^DIC Q:Y<0  S DA=+Y
 S DIE="^XTMP(""DGTMP"",390.2,",DR=$S(TYPE=11:.07,1:.06)
 D ^DIE
 K Y
 W ! G START
BROAD ;
 NEW D0,DG172,TASK,XMY,XMDUZ,XMTEXT,XMSUB,N0,COUNT,TYPE
 S XMDUZ="Religion/Marital Status Conversion",XMSUB="Conversion Finished"
 S XMY(DUZ)="",XMTEXT="DG172(1,"
 F TASK=0:0 S TASK=$O(^XTMP("DGTMP",390.1,TASK)) Q:'TASK  D
   .I $P(^XTMP("DGTMP",390.1,TASK,0),"^",9)="" S XMSUB="Conversion *NOT* Finished"
   .Q
 I XMSUB["NOT" D  Q
   .S DG172(1,1)="The conversion process appears to have been stopped."
   .S DG172(1,2)="To finish the conversion process, restart by using"
   .S DG172(1,3)="the 'Begin Religion/Marital Status Conversion' option"
   .S DG172(1,4)="on the CIRN Pre-Implementation Menu."
   .D ^XMD
   .Q
 S COUNT=1
 F TYPE=11,13 D
   .S DG172(1,COUNT)=$S(TYPE=11:"Marital Status",1:"Religion")_" File Non-Standard Entries:",COUNT=COUNT+1
   .S DG172(1,COUNT)="=========================================",COUNT=COUNT+1
   .F D0=0:0 S D0=$O(^XTMP("DGTMP",390.2,D0)) Q:'D0  D
     ..S N0=$G(^XTMP("DGTMP",390.2,D0,0))
     ..I $P(N0,"^",2)'=TYPE Q
     ..I '$P(N0,"^",3) S DG172(1,COUNT)=$$DESC(N0)_" (# Converted: "_(+$P(N0,"^",9))_")"
     ..S COUNT=COUNT+1
     ..Q
   .S DG172(1,COUNT)=" ",COUNT=COUNT+1
   .Q
 S DG172(1,COUNT)=" ",COUNT=COUNT+1
 S DG172(1,COUNT)="All non-standard entries listed above have been removed",COUNT=COUNT+1
 S DG172(1,COUNT)="from their respective files.",COUNT=COUNT+1
 D ^XMD
 Q
DESC(N0) ;
 NEW TYPE
 S TYPE=$P(N0,"^",2)
 I TYPE=13 Q "Entry: "_$P($G(^DIC(13,+$P(N0,"^",4),0)),"^")_" repointed to: "_$P($G(^DIC(13,+$P(N0,"^",6),0)),"^")
 I TYPE=11 Q "Entry: "_$P($G(^DIC(11,+$P(N0,"^",5),0)),"^")_" repointed to: "_$P($G(^DIC(11,+$P(N0,"^",7),0)),"^")
 Q ""
MESS(M) ;Show message
 NEW C
 F C=1:1 Q:$P($T(@M+C),";;",2)=""  W !,$P($T(@M+C),";;",2)
 Q
MARITAL ;
 ;;This option will identify non-standard MARITAL STATUS file (#11) entries
 ;;and then allows the user to designate, for each non-standard entry,
 ;;a standard entry which this utility will re-point with associated patients.
 ;;For example, you will be able to map all patients with a marital status
 ;;of SINGLE to NEVER MARRIED.
 ;; 
 ;;This mapping will be used during the re-pointing and file clean-up  
 ;;process, the Begin Religion/Marital Status Conversion [DG172 PRE-IMP
 ;;START CONVERSION] option.
 ;; 
 ;;The option (1) provides a list of non-standard MARITAL STATUS
 ;;file entries to the screen or a printer, (2) prompts the user for
 ;;a non-standard entry, and (3) then prompts for the standard
 ;;entry which the utility will re-point with associated patients.
 ;;
RELIGION ;
 ;;This option will identify non-standard RELIGION file (#13) entries and
 ;;then allows the user to designate, for each non-standard entry, a
 ;;standard entry which this utility will re-point associated patients.
 ;;For example, you will be able to map all patients with a religion of
 ;;XXXXXX to UNKNOWN/NO PREFERENCE.
 ;; 
 ;;This linking will be used during the mapping and file clean-up  
 ;;process, Begin Religion/Marital Status Conversion [DG172 PRE-IMP
 ;;START CONVERSION] option.
 ;; 
 ;;The option (1) provides a list of non-standard RELIGION file
 ;;entries to the screen or a printer, (2) prompts the user for
 ;;a non-standard entry, and (3) then prompts for the standard
 ;;entry which the utility will re-point with associated patients.
 ;;
CONV ;
 ;;After the linking of non-standard entries is complete, this conversion
 ;;process is run in order to actually re-point patient records from
 ;;non-standard entries to the specified standard entries.
 ;;
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDG17204   4318     printed  Sep 23, 2025@20:11:07                                                                                                                                                                                                     Page 2
DG17204   ;BHM/RGY,ALS-Edit mapping entries ;FEB 20, 1998
 +1       ;;5.3;Registration;**172**;Aug 13, 1993
EDIT(TYPE) ;
 +1        NEW DA,DIE,DR,L,TO,FR,DIC,FLDS,BY
 +2        FOR X=0:0
               SET X=$ORDER(^XTMP("DGTMP",390.2,X))
               if 'X
                   QUIT 
               IF $PIECE(^(X,0),"^",2)=TYPE
                   IF '$PIECE(^(0),"^",3)
                       QUIT 
 +3        IF 'X
               WRITE !!,"*** No mapping necessary! ***",!
               KILL X
               QUIT 
 +4        WRITE !!
           DO MESS($SELECT(TYPE=11:"MARITAL",1:"RELIGION"))
           WRITE !
 +5        SET L=0
           SET DIC="^XTMP(""DGTMP"",390.2,"
           SET (TO,FR)=""
           SET (BY,FLDS)="[DG172 "_$SELECT(TYPE=11:"MARITAL",1:"RELIGION")_" MAPPING]"
 +6        DO EN1^DIP
START     ;
 +1        SET DIC("A")="Select Non-Standard "_$SELECT(TYPE=11:"Marital Status: ",1:"Religion: ")
           SET DIC="^XTMP(""DGTMP"",390.2,"
           SET DIC(0)="QEAM"
           SET DIC("S")="I '$P(^(0),U,3),$P(^(0),U,2)="_TYPE
           DO ^DIC
           if Y<0
               QUIT 
           SET DA=+Y
 +2        SET DIE="^XTMP(""DGTMP"",390.2,"
           SET DR=$SELECT(TYPE=11:.07,1:.06)
 +3        DO ^DIE
 +4        KILL Y
 +5        WRITE !
           GOTO START
BROAD     ;
 +1        NEW D0,DG172,TASK,XMY,XMDUZ,XMTEXT,XMSUB,N0,COUNT,TYPE
 +2        SET XMDUZ="Religion/Marital Status Conversion"
           SET XMSUB="Conversion Finished"
 +3        SET XMY(DUZ)=""
           SET XMTEXT="DG172(1,"
 +4        FOR TASK=0:0
               SET TASK=$ORDER(^XTMP("DGTMP",390.1,TASK))
               if 'TASK
                   QUIT 
               Begin DoDot:1
 +5                IF $PIECE(^XTMP("DGTMP",390.1,TASK,0),"^",9)=""
                       SET XMSUB="Conversion *NOT* Finished"
 +6                QUIT 
               End DoDot:1
 +7        IF XMSUB["NOT"
               Begin DoDot:1
 +8                SET DG172(1,1)="The conversion process appears to have been stopped."
 +9                SET DG172(1,2)="To finish the conversion process, restart by using"
 +10               SET DG172(1,3)="the 'Begin Religion/Marital Status Conversion' option"
 +11               SET DG172(1,4)="on the CIRN Pre-Implementation Menu."
 +12               DO ^XMD
 +13               QUIT 
               End DoDot:1
               QUIT 
 +14       SET COUNT=1
 +15       FOR TYPE=11,13
               Begin DoDot:1
 +16               SET DG172(1,COUNT)=$SELECT(TYPE=11:"Marital Status",1:"Religion")_" File Non-Standard Entries:"
                   SET COUNT=COUNT+1
 +17               SET DG172(1,COUNT)="========================================="
                   SET COUNT=COUNT+1
 +18               FOR D0=0:0
                       SET D0=$ORDER(^XTMP("DGTMP",390.2,D0))
                       if 'D0
                           QUIT 
                       Begin DoDot:2
 +19                       SET N0=$GET(^XTMP("DGTMP",390.2,D0,0))
 +20                       IF $PIECE(N0,"^",2)'=TYPE
                               QUIT 
 +21                       IF '$PIECE(N0,"^",3)
                               SET DG172(1,COUNT)=$$DESC(N0)_" (# Converted: "_(+$PIECE(N0,"^",9))_")"
 +22                       SET COUNT=COUNT+1
 +23                       QUIT 
                       End DoDot:2
 +24               SET DG172(1,COUNT)=" "
                   SET COUNT=COUNT+1
 +25               QUIT 
               End DoDot:1
 +26       SET DG172(1,COUNT)=" "
           SET COUNT=COUNT+1
 +27       SET DG172(1,COUNT)="All non-standard entries listed above have been removed"
           SET COUNT=COUNT+1
 +28       SET DG172(1,COUNT)="from their respective files."
           SET COUNT=COUNT+1
 +29       DO ^XMD
 +30       QUIT 
DESC(N0)  ;
 +1        NEW TYPE
 +2        SET TYPE=$PIECE(N0,"^",2)
 +3        IF TYPE=13
               QUIT "Entry: "_$PIECE($GET(^DIC(13,+$PIECE(N0,"^",4),0)),"^")_" repointed to: "_$PIECE($GET(^DIC(13,+$PIECE(N0,"^",6),0)),"^")
 +4        IF TYPE=11
               QUIT "Entry: "_$PIECE($GET(^DIC(11,+$PIECE(N0,"^",5),0)),"^")_" repointed to: "_$PIECE($GET(^DIC(11,+$PIECE(N0,"^",7),0)),"^")
 +5        QUIT ""
MESS(M)   ;Show message
 +1        NEW C
 +2        FOR C=1:1
               if $PIECE($TEXT(@M+C),";;",2)=""
                   QUIT 
               WRITE !,$PIECE($TEXT(@M+C),";;",2)
 +3        QUIT 
MARITAL   ;
 +1       ;;This option will identify non-standard MARITAL STATUS file (#11) entries
 +2       ;;and then allows the user to designate, for each non-standard entry,
 +3       ;;a standard entry which this utility will re-point with associated patients.
 +4       ;;For example, you will be able to map all patients with a marital status
 +5       ;;of SINGLE to NEVER MARRIED.
 +6       ;; 
 +7       ;;This mapping will be used during the re-pointing and file clean-up  
 +8       ;;process, the Begin Religion/Marital Status Conversion [DG172 PRE-IMP
 +9       ;;START CONVERSION] option.
 +10      ;; 
 +11      ;;The option (1) provides a list of non-standard MARITAL STATUS
 +12      ;;file entries to the screen or a printer, (2) prompts the user for
 +13      ;;a non-standard entry, and (3) then prompts for the standard
 +14      ;;entry which the utility will re-point with associated patients.
 +15      ;;
RELIGION  ;
 +1       ;;This option will identify non-standard RELIGION file (#13) entries and
 +2       ;;then allows the user to designate, for each non-standard entry, a
 +3       ;;standard entry which this utility will re-point associated patients.
 +4       ;;For example, you will be able to map all patients with a religion of
 +5       ;;XXXXXX to UNKNOWN/NO PREFERENCE.
 +6       ;; 
 +7       ;;This linking will be used during the mapping and file clean-up  
 +8       ;;process, Begin Religion/Marital Status Conversion [DG172 PRE-IMP
 +9       ;;START CONVERSION] option.
 +10      ;; 
 +11      ;;The option (1) provides a list of non-standard RELIGION file
 +12      ;;entries to the screen or a printer, (2) prompts the user for
 +13      ;;a non-standard entry, and (3) then prompts for the standard
 +14      ;;entry which the utility will re-point with associated patients.
 +15      ;;
CONV      ;
 +1       ;;After the linking of non-standard entries is complete, this conversion
 +2       ;;process is run in order to actually re-point patient records from
 +3       ;;non-standard entries to the specified standard entries.
 +4       ;;