DG53862I ; SLC/PKR - Update cross-references for Clinical Reminders Index. ;04/18/2014
 ;;5.3;Registration;**862**;Aug 13, 1993;Build 138
 ;
 Q
 ;===========================================
AWRITE(REF) ;Write all the descendants of the array.
 N DONE,IND,LEN,LN,PROOT,ROOT,START,TEMP,TEXT
 I REF="" Q
 S LN=0
 S PROOT=$P(REF,")",1)
 ;Build the root so we can tell when we are done.
 S TEMP=$NA(@REF)
 S ROOT=$P(TEMP,")",1)
 S REF=$Q(@REF)
 I REF'[ROOT Q
 S DONE=0
 F  Q:(REF="")!(DONE)  D
 . S START=$F(REF,ROOT)
 . S LEN=$L(REF)
 . S IND=$E(REF,START,LEN)
 . S LN=LN+1,TEXT(LN)=PROOT_IND_"="_@REF
 . S REF=$Q(@REF)
 . I REF'[ROOT S DONE=1
 D MES^XPDUTL(.TEXT)
 Q
 ;
 ;===========================================
CPTFXR ;Create all the cross-references.
 D BMES^XPDUTL("Creating Clinical Reminders Index cross-references.")
 D CPTFDXR
 D CPTFPXR
 Q
 ;
 ;===========================================
CPTFDXR ;Update cross-references for PTF ICD diagnosis data.
 ;Fields: 45,79; 45,80; 45,79.16 45,79.17; 45,79.18;
 ;45,79.19; 45,79.201; 45,79.21; 45,79.22; 45,79.22; 45.79.23;
 ;45,79.24; 45,79.241; 45,79.242; 45,79.243; 45,79.244
 ;By name these nodes are: DXLS, PRINCIPAL DIAGNOSIS, SECONDARY
 ;DIAGNOSIS 1, through SECONDARY DIAGNOSIS 12.
 N FIELD,IND,MSG,NAME,NODE,ONAME,RESULT,XREF
 D BMES^XPDUTL("Creating PTF ICD diagnosis cross-references.")
 ;Set the XREF nodes that are the same for all cross-references.
 S XREF("FILE")=45
 S XREF("ROOT FILE")=45
 S XREF("TYPE")="MU"
 S XREF("SHORT DESCR")="Clinical Reminders Index for ICD diagnosis code lookup."
 S XREF("DESCR",1)="This cross-reference builds two indexes, one for finding"
 S XREF("DESCR",2)="all patients with a particular ICD diagnosis code and one for finding all"
 S XREF("DESCR",3)="the ICD diagnosis codes a patient has."
 S XREF("DESCR",4)="The indexes are stored in the Clinical Reminders Index global as:"
 S XREF("DESCR",5)=" ^PXRMINDX(45,CODESYS,""INP"",CODE,NAME,DFN,DATE,DAS) and"
 S XREF("DESCR",6)=" ^PXRMINDX(45,CODESYS,""PNI"",DFN,NAME,CODE,DATE,DAS)"
 S XREF("DESCR",7)="respectively."
 S XREF("DESCR",8)="CODESYS is the standard three-character abbreviation for the coding system."
 S XREF("DESCR",9)="DATE is the discharge date. If it does not"
 S XREF("DESCR",10)="exist then the admission date is used."
 S XREF("EXECUTION")="R"
 S XREF("ACTIVITY")="IR"
 S XREF("VAL",1)=.01
 S XREF("VAL",1,"SUBSCRIPT")=1
 S XREF("VAL",2)=2
 S XREF("VAL",2,"SUBSCRIPT")=2
 S XREF("VAL",3)=11
 S XREF("VAL",3,"SUBSCRIPT")=3
 S XREF("VAL",5)=70
 ;
 ;These XREF nodes change for each cross-reference.
 S XREF("DESCR",11)="NAME is the name of the field where the code is stored. An example is DXLS."
 S XREF("DESCR",12)="If the TYPE OF RECORD is CENSUS then the entry is not indexed."
 S XREF("DESCR",13)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 S XREF("NAME")="ACRDDXLS"
 S XREF("VAL",4)=79
 S XREF("VAL",4,"SUBSCRIPT")=4
 S XREF("SET")="D SPTFDD^DGPTDDCR(.X,.DA,""DXLS"")"
 S XREF("KILL")="D KPTFDD^DGPTDDCR(.X,.DA,""DXLS"")"
 ;Remove any existing cross-references before creating the new one.
 D DELIXN^DDMOD(45,"ACR9DXLS","","MSG")
 D DELIXN^DDMOD(45,XREF("NAME"),"","MSG")
 K MSG
 D CREIXN^DDMOD(.XREF,"",.RESULT,"","MSG")
 I RESULT="" D DCERRMSG^DG53862I(.MSG,.XREF)
 ;
 S XREF("DESCR",11)="NAME is the name of the field where the code is stored. An example is PDX."
 S XREF("DESCR",12)="If the TYPE OF RECORD is CENSUS then the entry is not indexed."
 S XREF("DESCR",13)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 S XREF("NAME")="ACRDPDX"
 S XREF("VAL",4)=80
 S XREF("VAL",4,"SUBSCRIPT")=4
 S XREF("SET")="D SPTFDD^DGPTDDCR(.X,.DA,""PDX"")"
 S XREF("KILL")="D KPTFDD^DGPTDDCR(.X,.DA,""PDX"")"
 ;Remove any existing cross-references before creating the new one.
 D DELIXN^DDMOD(45,"ACR9PDX","","MSG")
 D DELIXN^DDMOD(45,XREF("NAME"),"","MSG")
 K MSG
 D CREIXN^DDMOD(.XREF,"",.RESULT,"","MSG")
 I RESULT="" D DCERRMSG^DG53862I(.MSG,.XREF)
 ;
 S IND=0
 F FIELD=79.16,79.17,79.18,79.19,79.201,79.21,79.22,79.23,79.24,79.241,79.242,79.243,79.244 D
 . S IND=IND+1
 . S XREF("DESCR",11)="NAME is the name of the field where the code is stored. An example is D SD"_IND_", where D SD signifies it is a discharge secondary diagnosis."
 . S XREF("DESCR",12)="If the TYPE OF RECORD is CENSUS then the entry is not indexed."
 . S XREF("DESCR",13)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 . S NAME="SD"_IND
 . S NODE="D "_NAME
 . S ONAME="ACR9D"_NAME
 . S XREF("NAME")="ACRD"_NAME
 . S XREF("VAL",4)=FIELD
 . S XREF("VAL",4,"SUBSCRIPT")=4
 . S XREF("SET")="D SPTFDD^DGPTDDCR(.X,.DA,"""_NODE_""")"
 . S XREF("KILL")="D KPTFDD^DGPTDDCR(.X,.DA,"""_NODE_""")"
 .;Remove any existing cross-references before creating the new one.
 . D DELIXN^DDMOD(45,ONAME,"","","MSG")
 . D DELIXN^DDMOD(45,XREF("NAME"),"","","MSG")
 . K MSG
 . D CREIXN^DDMOD(.XREF,"W",.RESULT,"","MSG")
 . I RESULT="" D DCERRMSG^DG53862I(.MSG,.XREF)
 ;
 ;Add the movement nodes.
 K XREF("VAL")
 S XREF("ROOT FILE")=45.02
 S XREF("VAL",1)=10
 S XREF("DESCR",7)="respectively."
 S XREF("DESCR",8)="CODESYS is the standard three-character abbreviation for the coding system."
 S XREF("DESCR",9)="DATE is the movement date."
 S XREF("DESCR",11)="If the TYPE OF RECORD is CENSUS then the entry is not indexed."
 S XREF("DESCR",12)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 K XREF("DESCR",13)
 S IND=0
 F FIELD=5,6,7,8,9,11,12,13,14,15 D
 . S IND=IND+1
 . S XREF("DESCR",10)="NAME is the name of the field where the code is stored. An example is M ICD"_IND_", where M signifies it is a movement diagnosis."
 . S NAME="ICD"_IND
 . S NODE="M "_NAME
 . S ONAME="ACR9M"_NAME
 . S XREF("NAME")="ACRDM"_IND
 . S XREF("VAL",2)=FIELD
 . S XREF("VAL",2,"SUBSCRIPT")=1
 . S XREF("SET")="D SPTFMD^DGPTDDCR(.X,.DA,"""_NODE_""")"
 . S XREF("KILL")="D KPTFMD^DGPTDDCR(.X,.DA,"""_NODE_""")"
 .;Remove any existing cross-references before creating the new one.
 . D DELIXN^DDMOD(45,ONAME,"","","MSG")
 . D DELIXN^DDMOD(45,XREF("NAME"),"","","MSG")
 . K MSG
 . D CREIXN^DDMOD(.XREF,"",.RESULT,"","MSG")
 . I RESULT="" D DCERRMSG^DG53862I(.MSG,.XREF)
 Q
 ;
 ;===========================================
CPTFPXR ;Update cross-references for PTF ICD procedure data.
 ;For node 401 surgery node:
 ;Fields: 45.01,8; 45.01,9; 45.01,10; 45.01,11; 45.01,12
 ;For node 601, procedure node:
 ;Fields: 45.05,4; 45.05,5; 45.05,6; 45.05,7; 45.05,8
 N IND,MSG,NAME,NODE,ONAME,NODENUM,RESULT,XREF
 D BMES^XPDUTL("Creating PTF ICD procedure cross-references.")
 ;Set the XREF nodes that are the same for all cross-references.
 S XREF("FILE")=45
 S XREF("TYPE")="MU"
 S XREF("SHORT DESCR")="Clinical Reminders Index for ICD procedure code lookup."
 S XREF("DESCR",1)="This cross-reference builds two indexes, one for finding"
 S XREF("DESCR",2)="all patients with a particular ICD procedure code and one for finding all"
 S XREF("DESCR",3)="the ICD procedure codes a patient has."
 S XREF("DESCR",4)="The indexes are stored in the Clinical Reminders Index global as:"
 S XREF("DESCR",5)=" ^PXRMINDX(45,CODESYS,""INP"",CODE,NODE,DFN,DATE,DAS) and"
 S XREF("DESCR",6)=" ^PXRMINDX(45,CODESYS,""PNI"",DFN,NODE,CODE,DATE,DAS)"
 S XREF("DESCR",7)="respectively."
 S XREF("DESCR",8)="CODESYS is the standard three-character abbreviation for the coding system."
 S XREF("DESCR",9)="DATE is the surgery/procedure date."
 S XREF("USE")="ACTION"
 S XREF("EXECUTION")="R"
 S XREF("ACTIVITY")="IR"
 ;
 ;These XREF nodes change for each cross-reference.
 S XREF("ROOT FILE")=45.01
 S XREF("VAL",1)=.01
 S XREF("VAL",1,"SUBSCRIPT")=1
 S XREF("VAL",2,"SUBSCRIPT")=2
 S IND=0,NODE="S"
 S XREF("DESCR",10)="NODE is S (for surgery) followed by operation code number. For example,"
 S XREF("DESCR",12)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 F NODENUM=8,9,10,11,12 D
 . S IND=IND+1
 . S XREF("DESCR",11)=NODE_IND_" means it was found on the S node and it was Operation Code "_IND_"."
 . S ONAME="ACR0S"_IND
 . S XREF("NAME")="ACRPS"_IND
 . S XREF("VAL",2)=NODENUM
 . S XREF("SET")="D SPTFP^DGPTDDCR(.X,.DA,"""_NODE_""","_IND_")"
 . S XREF("KILL")="D KPTFP^DGPTDDCR(.X,.DA,"""_NODE_""","_IND_")"
 .;Remove any existing cross-references before creating the new one.
 . D DELIXN^DDMOD(45,ONAME,"","","MSG")
 . D DELIXN^DDMOD(45,XREF("NAME"),"","","MSG")
 . K MSG
 . D CREIXN^DDMOD(.XREF,"W",.RESULT,"","MSG")
 . I RESULT="" D DCERRMSG^DG53862I(.MSG,.XREF)
 ;
 S XREF("ROOT FILE")=45.05
 S XREF("VAL",1)=.01
 S XREF("VAL",1,"SUBSCRIPT")=1
 S XREF("VAL",2,"SUBSCRIPT")=2
 S IND=0,NODE="P"
 S XREF("DESCR",10)="NODE is P (for procedure) followed by procedure code number. For example,"
 S XREF("DESCR",12)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 F NODENUM=4,5,6,7,8 D
 . S IND=IND+1
 . S XREF("DESCR",11)=NODE_IND_" means it was found on the P node and it was Procedure Code "_IND_"."
 . S ONAME="ACR0P"_IND
 . S XREF("NAME")="ACRPP"_IND
 . S XREF("VAL",2)=NODENUM
 . S XREF("SET")="D SPTFP^DGPTDDCR(.X,.DA,"""_NODE_""","_IND_")"
 . S XREF("KILL")="D KPTFP^DGPTDDCR(.X,.DA,"""_NODE_""","_IND_")"
 .;Remove any existing cross-references before creating the new one.
 . D DELIXN^DDMOD(45,ONAME,"","","MSG")
 . D DELIXN^DDMOD(45,XREF("NAME"),"","","MSG")
 . K MSG
 . D CREIXN^DDMOD(.XREF,"W",.RESULT,"","MSG")
 . I RESULT="" D DCERRMSG^DG53862I(.MSG,.XREF)
 Q
 ;
 ;===========================================
DCERRMSG(MSG,XREF) ;Display cross-reference creation errors.
 D BMES^XPDUTL("A cross-reference could not be created. The error message is:")
 D AWRITE^DG53862I("MSG")
 D BMES^XPDUTL("Cross-reference information:")
 D AWRITE^DG53862I("XREF")
 Q
 ;
 ;===========================================
POST ;Post-init
 ;Update the cross-references.
 D CPTFXR^DG53862I
 ;Rebuild the Index in the new format.
 D REINDEX^DG53862I
 Q
 ;
 ;===========================================
REINDEX ;Rebuild the PTF portion of the Clinical Reminders Index.
 N TEXT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSK
 ;If the Index has already been restructured don't do it again.
 I $D(^PXRMINDX(45,"ICD")),$D(^PXRMINDX(45,"DATE BUILT")) D
 . S TEXT(1)="The PTF Index has already been rebuilt, skipping another rebuild."
 I $D(^PXRMINDX(45,"ICD")),'$D(^PXRMINDX(45,"DATE BUILT")) D
 . S TEXT(1)="The PTF Index has been partially rebuilt; not starting another rebuild in case a rebuild is in progress."
 . S TEXT(2)="Please make sure the Index is completely rebuilt."
 I $D(TEXT(1)) D BMES^XPDUTL(.TEXT) Q
 S ZTRTN="INDEX^DGPTDDCR"
 S ZTDESC="PTF Clinical Reminders Index rebuild"
 S ZTDTH=$H
 S ZTIO=""
 D ^%ZTLOAD
 S TEXT(1)="PTF Clinical Reminders Index rebuild queued."
 S TEXT(2)="The task number is "_ZTSK_"."
 D MES^XPDUTL(.TEXT)
 Q
 ;
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDG53862I   11141     printed  Sep 23, 2025@20:15                                                                                                                                                                                                      Page 2
DG53862I  ; SLC/PKR - Update cross-references for Clinical Reminders Index. ;04/18/2014
 +1       ;;5.3;Registration;**862**;Aug 13, 1993;Build 138
 +2       ;
 +3        QUIT 
 +4       ;===========================================
AWRITE(REF) ;Write all the descendants of the array.
 +1        NEW DONE,IND,LEN,LN,PROOT,ROOT,START,TEMP,TEXT
 +2        IF REF=""
               QUIT 
 +3        SET LN=0
 +4        SET PROOT=$PIECE(REF,")",1)
 +5       ;Build the root so we can tell when we are done.
 +6        SET TEMP=$NAME(@REF)
 +7        SET ROOT=$PIECE(TEMP,")",1)
 +8        SET REF=$QUERY(@REF)
 +9        IF REF'[ROOT
               QUIT 
 +10       SET DONE=0
 +11       FOR 
               if (REF="")!(DONE)
                   QUIT 
               Begin DoDot:1
 +12               SET START=$FIND(REF,ROOT)
 +13               SET LEN=$LENGTH(REF)
 +14               SET IND=$EXTRACT(REF,START,LEN)
 +15               SET LN=LN+1
                   SET TEXT(LN)=PROOT_IND_"="_@REF
 +16               SET REF=$QUERY(@REF)
 +17               IF REF'[ROOT
                       SET DONE=1
               End DoDot:1
 +18       DO MES^XPDUTL(.TEXT)
 +19       QUIT 
 +20      ;
 +21      ;===========================================
CPTFXR    ;Create all the cross-references.
 +1        DO BMES^XPDUTL("Creating Clinical Reminders Index cross-references.")
 +2        DO CPTFDXR
 +3        DO CPTFPXR
 +4        QUIT 
 +5       ;
 +6       ;===========================================
CPTFDXR   ;Update cross-references for PTF ICD diagnosis data.
 +1       ;Fields: 45,79; 45,80; 45,79.16 45,79.17; 45,79.18;
 +2       ;45,79.19; 45,79.201; 45,79.21; 45,79.22; 45,79.22; 45.79.23;
 +3       ;45,79.24; 45,79.241; 45,79.242; 45,79.243; 45,79.244
 +4       ;By name these nodes are: DXLS, PRINCIPAL DIAGNOSIS, SECONDARY
 +5       ;DIAGNOSIS 1, through SECONDARY DIAGNOSIS 12.
 +6        NEW FIELD,IND,MSG,NAME,NODE,ONAME,RESULT,XREF
 +7        DO BMES^XPDUTL("Creating PTF ICD diagnosis cross-references.")
 +8       ;Set the XREF nodes that are the same for all cross-references.
 +9        SET XREF("FILE")=45
 +10       SET XREF("ROOT FILE")=45
 +11       SET XREF("TYPE")="MU"
 +12       SET XREF("SHORT DESCR")="Clinical Reminders Index for ICD diagnosis code lookup."
 +13       SET XREF("DESCR",1)="This cross-reference builds two indexes, one for finding"
 +14       SET XREF("DESCR",2)="all patients with a particular ICD diagnosis code and one for finding all"
 +15       SET XREF("DESCR",3)="the ICD diagnosis codes a patient has."
 +16       SET XREF("DESCR",4)="The indexes are stored in the Clinical Reminders Index global as:"
 +17       SET XREF("DESCR",5)=" ^PXRMINDX(45,CODESYS,""INP"",CODE,NAME,DFN,DATE,DAS) and"
 +18       SET XREF("DESCR",6)=" ^PXRMINDX(45,CODESYS,""PNI"",DFN,NAME,CODE,DATE,DAS)"
 +19       SET XREF("DESCR",7)="respectively."
 +20       SET XREF("DESCR",8)="CODESYS is the standard three-character abbreviation for the coding system."
 +21       SET XREF("DESCR",9)="DATE is the discharge date. If it does not"
 +22       SET XREF("DESCR",10)="exist then the admission date is used."
 +23       SET XREF("EXECUTION")="R"
 +24       SET XREF("ACTIVITY")="IR"
 +25       SET XREF("VAL",1)=.01
 +26       SET XREF("VAL",1,"SUBSCRIPT")=1
 +27       SET XREF("VAL",2)=2
 +28       SET XREF("VAL",2,"SUBSCRIPT")=2
 +29       SET XREF("VAL",3)=11
 +30       SET XREF("VAL",3,"SUBSCRIPT")=3
 +31       SET XREF("VAL",5)=70
 +32      ;
 +33      ;These XREF nodes change for each cross-reference.
 +34       SET XREF("DESCR",11)="NAME is the name of the field where the code is stored. An example is DXLS."
 +35       SET XREF("DESCR",12)="If the TYPE OF RECORD is CENSUS then the entry is not indexed."
 +36       SET XREF("DESCR",13)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 +37       SET XREF("NAME")="ACRDDXLS"
 +38       SET XREF("VAL",4)=79
 +39       SET XREF("VAL",4,"SUBSCRIPT")=4
 +40       SET XREF("SET")="D SPTFDD^DGPTDDCR(.X,.DA,""DXLS"")"
 +41       SET XREF("KILL")="D KPTFDD^DGPTDDCR(.X,.DA,""DXLS"")"
 +42      ;Remove any existing cross-references before creating the new one.
 +43       DO DELIXN^DDMOD(45,"ACR9DXLS","","MSG")
 +44       DO DELIXN^DDMOD(45,XREF("NAME"),"","MSG")
 +45       KILL MSG
 +46       DO CREIXN^DDMOD(.XREF,"",.RESULT,"","MSG")
 +47       IF RESULT=""
               DO DCERRMSG^DG53862I(.MSG,.XREF)
 +48      ;
 +49       SET XREF("DESCR",11)="NAME is the name of the field where the code is stored. An example is PDX."
 +50       SET XREF("DESCR",12)="If the TYPE OF RECORD is CENSUS then the entry is not indexed."
 +51       SET XREF("DESCR",13)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 +52       SET XREF("NAME")="ACRDPDX"
 +53       SET XREF("VAL",4)=80
 +54       SET XREF("VAL",4,"SUBSCRIPT")=4
 +55       SET XREF("SET")="D SPTFDD^DGPTDDCR(.X,.DA,""PDX"")"
 +56       SET XREF("KILL")="D KPTFDD^DGPTDDCR(.X,.DA,""PDX"")"
 +57      ;Remove any existing cross-references before creating the new one.
 +58       DO DELIXN^DDMOD(45,"ACR9PDX","","MSG")
 +59       DO DELIXN^DDMOD(45,XREF("NAME"),"","MSG")
 +60       KILL MSG
 +61       DO CREIXN^DDMOD(.XREF,"",.RESULT,"","MSG")
 +62       IF RESULT=""
               DO DCERRMSG^DG53862I(.MSG,.XREF)
 +63      ;
 +64       SET IND=0
 +65       FOR FIELD=79.16,79.17,79.18,79.19,79.201,79.21,79.22,79.23,79.24,79.241,79.242,79.243,79.244
               Begin DoDot:1
 +66               SET IND=IND+1
 +67               SET XREF("DESCR",11)="NAME is the name of the field where the code is stored. An example is D SD"_IND_", where D SD signifies it is a discharge secondary diagnosis."
 +68               SET XREF("DESCR",12)="If the TYPE OF RECORD is CENSUS then the entry is not indexed."
 +69               SET XREF("DESCR",13)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 +70               SET NAME="SD"_IND
 +71               SET NODE="D "_NAME
 +72               SET ONAME="ACR9D"_NAME
 +73               SET XREF("NAME")="ACRD"_NAME
 +74               SET XREF("VAL",4)=FIELD
 +75               SET XREF("VAL",4,"SUBSCRIPT")=4
 +76               SET XREF("SET")="D SPTFDD^DGPTDDCR(.X,.DA,"""_NODE_""")"
 +77               SET XREF("KILL")="D KPTFDD^DGPTDDCR(.X,.DA,"""_NODE_""")"
 +78      ;Remove any existing cross-references before creating the new one.
 +79               DO DELIXN^DDMOD(45,ONAME,"","","MSG")
 +80               DO DELIXN^DDMOD(45,XREF("NAME"),"","","MSG")
 +81               KILL MSG
 +82               DO CREIXN^DDMOD(.XREF,"W",.RESULT,"","MSG")
 +83               IF RESULT=""
                       DO DCERRMSG^DG53862I(.MSG,.XREF)
               End DoDot:1
 +84      ;
 +85      ;Add the movement nodes.
 +86       KILL XREF("VAL")
 +87       SET XREF("ROOT FILE")=45.02
 +88       SET XREF("VAL",1)=10
 +89       SET XREF("DESCR",7)="respectively."
 +90       SET XREF("DESCR",8)="CODESYS is the standard three-character abbreviation for the coding system."
 +91       SET XREF("DESCR",9)="DATE is the movement date."
 +92       SET XREF("DESCR",11)="If the TYPE OF RECORD is CENSUS then the entry is not indexed."
 +93       SET XREF("DESCR",12)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 +94       KILL XREF("DESCR",13)
 +95       SET IND=0
 +96       FOR FIELD=5,6,7,8,9,11,12,13,14,15
               Begin DoDot:1
 +97               SET IND=IND+1
 +98               SET XREF("DESCR",10)="NAME is the name of the field where the code is stored. An example is M ICD"_IND_", where M signifies it is a movement diagnosis."
 +99               SET NAME="ICD"_IND
 +100              SET NODE="M "_NAME
 +101              SET ONAME="ACR9M"_NAME
 +102              SET XREF("NAME")="ACRDM"_IND
 +103              SET XREF("VAL",2)=FIELD
 +104              SET XREF("VAL",2,"SUBSCRIPT")=1
 +105              SET XREF("SET")="D SPTFMD^DGPTDDCR(.X,.DA,"""_NODE_""")"
 +106              SET XREF("KILL")="D KPTFMD^DGPTDDCR(.X,.DA,"""_NODE_""")"
 +107     ;Remove any existing cross-references before creating the new one.
 +108              DO DELIXN^DDMOD(45,ONAME,"","","MSG")
 +109              DO DELIXN^DDMOD(45,XREF("NAME"),"","","MSG")
 +110              KILL MSG
 +111              DO CREIXN^DDMOD(.XREF,"",.RESULT,"","MSG")
 +112              IF RESULT=""
                       DO DCERRMSG^DG53862I(.MSG,.XREF)
               End DoDot:1
 +113      QUIT 
 +114     ;
 +115     ;===========================================
CPTFPXR   ;Update cross-references for PTF ICD procedure data.
 +1       ;For node 401 surgery node:
 +2       ;Fields: 45.01,8; 45.01,9; 45.01,10; 45.01,11; 45.01,12
 +3       ;For node 601, procedure node:
 +4       ;Fields: 45.05,4; 45.05,5; 45.05,6; 45.05,7; 45.05,8
 +5        NEW IND,MSG,NAME,NODE,ONAME,NODENUM,RESULT,XREF
 +6        DO BMES^XPDUTL("Creating PTF ICD procedure cross-references.")
 +7       ;Set the XREF nodes that are the same for all cross-references.
 +8        SET XREF("FILE")=45
 +9        SET XREF("TYPE")="MU"
 +10       SET XREF("SHORT DESCR")="Clinical Reminders Index for ICD procedure code lookup."
 +11       SET XREF("DESCR",1)="This cross-reference builds two indexes, one for finding"
 +12       SET XREF("DESCR",2)="all patients with a particular ICD procedure code and one for finding all"
 +13       SET XREF("DESCR",3)="the ICD procedure codes a patient has."
 +14       SET XREF("DESCR",4)="The indexes are stored in the Clinical Reminders Index global as:"
 +15       SET XREF("DESCR",5)=" ^PXRMINDX(45,CODESYS,""INP"",CODE,NODE,DFN,DATE,DAS) and"
 +16       SET XREF("DESCR",6)=" ^PXRMINDX(45,CODESYS,""PNI"",DFN,NODE,CODE,DATE,DAS)"
 +17       SET XREF("DESCR",7)="respectively."
 +18       SET XREF("DESCR",8)="CODESYS is the standard three-character abbreviation for the coding system."
 +19       SET XREF("DESCR",9)="DATE is the surgery/procedure date."
 +20       SET XREF("USE")="ACTION"
 +21       SET XREF("EXECUTION")="R"
 +22       SET XREF("ACTIVITY")="IR"
 +23      ;
 +24      ;These XREF nodes change for each cross-reference.
 +25       SET XREF("ROOT FILE")=45.01
 +26       SET XREF("VAL",1)=.01
 +27       SET XREF("VAL",1,"SUBSCRIPT")=1
 +28       SET XREF("VAL",2,"SUBSCRIPT")=2
 +29       SET IND=0
           SET NODE="S"
 +30       SET XREF("DESCR",10)="NODE is S (for surgery) followed by operation code number. For example,"
 +31       SET XREF("DESCR",12)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 +32       FOR NODENUM=8,9,10,11,12
               Begin DoDot:1
 +33               SET IND=IND+1
 +34               SET XREF("DESCR",11)=NODE_IND_" means it was found on the S node and it was Operation Code "_IND_"."
 +35               SET ONAME="ACR0S"_IND
 +36               SET XREF("NAME")="ACRPS"_IND
 +37               SET XREF("VAL",2)=NODENUM
 +38               SET XREF("SET")="D SPTFP^DGPTDDCR(.X,.DA,"""_NODE_""","_IND_")"
 +39               SET XREF("KILL")="D KPTFP^DGPTDDCR(.X,.DA,"""_NODE_""","_IND_")"
 +40      ;Remove any existing cross-references before creating the new one.
 +41               DO DELIXN^DDMOD(45,ONAME,"","","MSG")
 +42               DO DELIXN^DDMOD(45,XREF("NAME"),"","","MSG")
 +43               KILL MSG
 +44               DO CREIXN^DDMOD(.XREF,"W",.RESULT,"","MSG")
 +45               IF RESULT=""
                       DO DCERRMSG^DG53862I(.MSG,.XREF)
               End DoDot:1
 +46      ;
 +47       SET XREF("ROOT FILE")=45.05
 +48       SET XREF("VAL",1)=.01
 +49       SET XREF("VAL",1,"SUBSCRIPT")=1
 +50       SET XREF("VAL",2,"SUBSCRIPT")=2
 +51       SET IND=0
           SET NODE="P"
 +52       SET XREF("DESCR",10)="NODE is P (for procedure) followed by procedure code number. For example,"
 +53       SET XREF("DESCR",12)="For complete details, see the Clinical Reminders Index Technical Guide/Programmer's Manual."
 +54       FOR NODENUM=4,5,6,7,8
               Begin DoDot:1
 +55               SET IND=IND+1
 +56               SET XREF("DESCR",11)=NODE_IND_" means it was found on the P node and it was Procedure Code "_IND_"."
 +57               SET ONAME="ACR0P"_IND
 +58               SET XREF("NAME")="ACRPP"_IND
 +59               SET XREF("VAL",2)=NODENUM
 +60               SET XREF("SET")="D SPTFP^DGPTDDCR(.X,.DA,"""_NODE_""","_IND_")"
 +61               SET XREF("KILL")="D KPTFP^DGPTDDCR(.X,.DA,"""_NODE_""","_IND_")"
 +62      ;Remove any existing cross-references before creating the new one.
 +63               DO DELIXN^DDMOD(45,ONAME,"","","MSG")
 +64               DO DELIXN^DDMOD(45,XREF("NAME"),"","","MSG")
 +65               KILL MSG
 +66               DO CREIXN^DDMOD(.XREF,"W",.RESULT,"","MSG")
 +67               IF RESULT=""
                       DO DCERRMSG^DG53862I(.MSG,.XREF)
               End DoDot:1
 +68       QUIT 
 +69      ;
 +70      ;===========================================
DCERRMSG(MSG,XREF) ;Display cross-reference creation errors.
 +1        DO BMES^XPDUTL("A cross-reference could not be created. The error message is:")
 +2        DO AWRITE^DG53862I("MSG")
 +3        DO BMES^XPDUTL("Cross-reference information:")
 +4        DO AWRITE^DG53862I("XREF")
 +5        QUIT 
 +6       ;
 +7       ;===========================================
POST      ;Post-init
 +1       ;Update the cross-references.
 +2        DO CPTFXR^DG53862I
 +3       ;Rebuild the Index in the new format.
 +4        DO REINDEX^DG53862I
 +5        QUIT 
 +6       ;
 +7       ;===========================================
REINDEX   ;Rebuild the PTF portion of the Clinical Reminders Index.
 +1        NEW TEXT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSK
 +2       ;If the Index has already been restructured don't do it again.
 +3        IF $DATA(^PXRMINDX(45,"ICD"))
               IF $DATA(^PXRMINDX(45,"DATE BUILT"))
                   Begin DoDot:1
 +4                    SET TEXT(1)="The PTF Index has already been rebuilt, skipping another rebuild."
                   End DoDot:1
 +5        IF $DATA(^PXRMINDX(45,"ICD"))
               IF '$DATA(^PXRMINDX(45,"DATE BUILT"))
                   Begin DoDot:1
 +6                    SET TEXT(1)="The PTF Index has been partially rebuilt; not starting another rebuild in case a rebuild is in progress."
 +7                    SET TEXT(2)="Please make sure the Index is completely rebuilt."
                   End DoDot:1
 +8        IF $DATA(TEXT(1))
               DO BMES^XPDUTL(.TEXT)
               QUIT 
 +9        SET ZTRTN="INDEX^DGPTDDCR"
 +10       SET ZTDESC="PTF Clinical Reminders Index rebuild"
 +11       SET ZTDTH=$HOROLOG
 +12       SET ZTIO=""
 +13       DO ^%ZTLOAD
 +14       SET TEXT(1)="PTF Clinical Reminders Index rebuild queued."
 +15       SET TEXT(2)="The task number is "_ZTSK_"."
 +16       DO MES^XPDUTL(.TEXT)
 +17       QUIT 
 +18      ;