Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: AUMSCBA

AUMSCBA.m

Go to the documentation of this file.
AUMSCBA  ;IHS/OIT/NKD - SCB UPDATE - FULL TABLE UPDATE 12/10/2013 ;
 ;;15.0;TABLE MAINTENANCE;**3**;SEP 9,2014;Build 1
 ; 03/12/14 - SPECIAL COUNTY PRE-MERGE
 ;          - STATION NUMBER FULL UPDATE
 ; 05/29/15 - CLINIC FULL UPDATE
 ;          - QUIET PARAMETER
 ;
 ; GENERAL FRAMEWORK FOR PROCESSING
 ; 1) PRE
 ;  KILL INDEXES
 ;  RE-INDEX
 ;  MERGE DUPLICATES (OPTIONAL)
 ;  ATTEMPT CODE CORRECTION (OPTIONAL)
 ;  CREATE TEMP GLOBAL OF FULL TABLE
 ; 2) 1ST PASS
 ;  ITERATE THROUGH LOCAL, BY CODE_NAME
 ;  MATCH TO TEMP GLOBAL, REMOVE FROM TEMP IF FOUND
 ;  STORE ENTRIES NOT MATCHED
 ; 3) 2ND PASS
 ;  ITERATE THROUGH STORED ENTRIES, BY CODE
 ;  MATCH TO TEMP, REMOVE FROM TEMP IF FOUND
 ;  STORE ENTRIES NOT MATCHED
 ; 4) 3RD PASS
 ;  ITERATE THROUGH STORED ENTRIES, BY NAME
 ;  MATCH TO TEMP, REMOVE FROM TEMP IF FOUND
 ;  STORE ENTRIES NOT MATCH
 ; 5) END
 ;  UPDATE REMAINING FROM TEMP
 ;  INACTIVATE LOCALS NOT MATCHED
 Q
ALL ;EP - PROCESS FULL TABLE UPDATE
 D AREA,SU,LOC
 D ST,CTY,COM
 D STNM^AUMSCBA2  ; IHS/OIT/NKD AUM*14.0*2 ADDED CALL TO STNM UPDATE
 D CLIN^AUMSCBA2  ; IHS/OIT/NKD AUM*15.0*3 ADDED CALL TO CLIN UPDATE
 Q
AREA ; AREA FILE
 ; DUP/COMP/CODE/NAME
 ; T=TAG,GL=GLOBAL,TGL=TEMP GLOBAL,L=LIST,CNT=COUNT,FL=FILE,INFL=INACTIVE FIELD
 N AUMT,AUMGL,AUMTGL,AUML,AUML2,AUML3,AUMCNT,AUMFL,AUMINFL
 S AUMT="AREA",AUMGL="^AUTTAREA(",AUMTGL="^TMP(""AUM"","_$J_",""ALL"",""AREA""",AUMFL=9999999.21,AUMINFL=.05
 Q:'$D(@(AUMTGL_")"))
 D RSLT^AUMSCBD($$REPEAT^XLFSTR("-",20)),RSLT^AUMSCBD("AREA CLEANUP")
 D REINDX(AUMGL,"B^C")  ; RE-INDEX
 D DUP(AUMT,AUMFL,AUMGL,"C")  ; MERGE DUP
 ;
 ; COMPOSITE SEARCH
 ; BUILD TEMP GLOBAL X-REF
 D BUILD^AUMSCBA(AUMTGL,"COMP","1^2")
 ; TEMP GLOBAL COUNT, MATCH TEMP TO LOCAL AND STORE REMAINING
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML=$$MATCH(AUMT,AUMGL,AUMTGL,"C","COMP","1")
 ; CHECK IF MATCHING HAS FINISHED (0 TEMP OR 0 LOCAL RECORDS REMAIN)
 I ($G(@(AUMTGL_",0)"))=0)!(AUML']"") D END(AUMT,AUMGL,AUMTGL,AUML) Q
 ;
 ; CODE SEARCH
 D BUILD^AUMSCBA(AUMTGL,"C","1")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML2=$$MATCH(AUMT,AUMGL,AUMTGL,"C","C",,.AUML)
 I ($G(@(AUMTGL_",0)"))=0)!(AUML2']"") D END(AUMT,AUMGL,AUMTGL,AUML2) Q
 ;
 ; NAME SEARCH
 D BUILD^AUMSCBA(AUMTGL,"B","2")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML3=$$MATCH(AUMT,AUMGL,AUMTGL,"B","B",,.AUML2)
 D END(AUMT,AUMGL,AUMTGL,AUML3)
 ;
 Q
SU ; SERVICE UNIT FILE
 ; INV CODE/DUP/COMP/CODE/NAME
 N AUMT,AUMGL,AUMTGL,AUML,AUML2,AUML3,AUMCNT,AUMFL,AUMINFL,AUMI
 S AUMT="SU",AUMGL="^AUTTSU(",AUMTGL="^TMP(""AUM"","_$J_",""ALL"",""SU""",AUMFL=9999999.22,AUMINFL=.05
 Q:'$D(@(AUMTGL_")"))
 D RSLT^AUMSCBD($$REPEAT^XLFSTR("-",20)),RSLT^AUMSCBD("SERVICE UNIT CLEANUP")
 S AUMI=0 F  S AUMI=$O(^AUTTSU(AUMI)) Q:'AUMI  K:$D(^AUTTSU(AUMI,-9)) ^AUTTSU(AUMI,-9)
 ;
 K ^TMP("AUM",$J,"INV","SU")
 M ^TMP("AUM",$J,"INV","SU","C")=^AUTTSU("C")
 ;
 D REINDX(AUMGL,"B^C")
 ;
 N AUMCNT,AUMCNT2
 S AUMCNT=0 F  S AUMCNT=$O(^TMP("AUM",$J,"INV","SU","C",AUMCNT)) Q:AUMCNT']""  D
 . S AUMCNT2=0 F  S AUMCNT2=$O(^TMP("AUM",$J,"INV","SU","C",AUMCNT,AUMCNT2)) Q:AUMCNT2']""  D
 . . Q:'$D(^AUTTSU(AUMCNT2,0))
 . . I AUMCNT'=$P($G(^AUTTSU(AUMCNT2,0)),U,4) D
 . . . I $L(AUMCNT)=4 D  Q
 . . . . N AUMCNT3,AUMCNT4,FDA
 . . . . S AUMCNT3=$E(AUMCNT,1,2),AUMCNT4=$O(^AUTTAREA("C",AUMCNT3,0))
 . . . . Q:AUMCNT4']""
 . . . . S FDA(AUMFL,AUMCNT2_",",.02)=AUMCNT4
 . . . . D UPDATE^DIE(,"FDA")
 . . . . D RSLT^AUMSCBD(" CORRECTING INVALID ENTRY: "_AUMCNT2_" / TO: "_$$GET1^DIQ(AUMFL,AUMCNT2,.04,"I"))
 ;
 K ^TMP("AUM",$J,"INV","SU")
 ;
 D DUP(AUMT,AUMFL,AUMGL,"C")
 ;
 D BUILD^AUMSCBA(AUMTGL,"COMP","1^2^3")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML=$$MATCH(AUMT,AUMGL,AUMTGL,"C","COMP","1")
 I ($G(@(AUMTGL_",0)"))=0)!(AUML']"") D END(AUMT,AUMGL,AUMTGL,AUML) Q
 ;
 D BUILD^AUMSCBA(AUMTGL,"C","1^2")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML2=$$MATCH(AUMT,AUMGL,AUMTGL,"C","C",,.AUML)
 I ($G(@(AUMTGL_",0)"))=0)!(AUML2']"") D END(AUMT,AUMGL,AUMTGL,AUML2) Q
 ;
 D BUILD^AUMSCBA(AUMTGL,"B","3")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML3=$$MATCH(AUMT,AUMGL,AUMTGL,"B","B",,.AUML2)
 D END(AUMT,AUMGL,AUMTGL,AUML3)
 ;
 Q
LOC ; LOCATION FILE
 ; INV CODE/COMP/CODE
 N AUMT,AUMGL,AUMGL2,AUMTGL,AUML,AUML2,AUML3,AUMCNT,AUMFL,AUMINFL
 S AUMT="LOC",AUMGL="^AUTTLOC(",AUMGL2="^DIC(4,",AUMTGL="^TMP(""AUM"","_$J_",""ALL"",""LOC""",AUMFL=9999999.06,AUMINFL=.27
 Q:'$D(@(AUMTGL_")"))
 D RSLT^AUMSCBD($$REPEAT^XLFSTR("-",20)),RSLT^AUMSCBD("LOCATION CLEANUP")
 ;
 K ^TMP("AUM",$J,"INV","LOC")
 M ^TMP("AUM",$J,"INV","LOC","C")=^AUTTLOC("C")
 ;
 D REINDX("^DIC(4,","B^D"),REINDX("^AUTTLOC(","AC^B^C")
 ;
 N AUMCNT,AUMCNT2
 S AUMCNT=0 F  S AUMCNT=$O(^TMP("AUM",$J,"INV","LOC","C",AUMCNT)) Q:AUMCNT']""  D
 . S AUMCNT2=0 F  S AUMCNT2=$O(^TMP("AUM",$J,"INV","LOC","C",AUMCNT,AUMCNT2)) Q:AUMCNT2']""  D
 . . Q:'$D(^AUTTLOC(AUMCNT2,0))
 . . I AUMCNT'=$P($G(^AUTTLOC(AUMCNT2,0)),U,10) D
 . . . I $L(AUMCNT)=6 D  Q
 . . . . N AUMCNT3,AUMCNT4,FDA
 . . . . S AUMCNT3=$E(AUMCNT,1,4),AUMCNT4=$O(^AUTTSU("C",AUMCNT3,0))
 . . . . Q:AUMCNT4']""
 . . . . S FDA(AUMFL,AUMCNT2_",",.04)=$$GET1^DIQ(9999999.22,AUMCNT4,.02,"I")
 . . . . S FDA(AUMFL,AUMCNT2_",",.05)=AUMCNT4
 . . . . D UPDATE^DIE(,"FDA")
 . . . . D RSLT^AUMSCBD(" CORRECTING INVALID ENTRY: "_AUMCNT2_" / TO: "_$$GET1^DIQ(AUMFL,AUMCNT2,.12,"I"))
 ;
 K ^TMP("AUM",$J,"INV","LOC")
 ;
 D BUILD^AUMSCBA(AUMTGL,"COMP","1^2^3^4")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML=$$MATCH(AUMT,AUMGL,AUMTGL,"C","COMP","1")
 I ($G(@(AUMTGL_",0)"))=0)!(AUML']"") D END(AUMT,AUMGL,AUMTGL,AUML) Q
 ;
 D BUILD^AUMSCBA(AUMTGL,"C","1^2^3")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML2=$$MATCH(AUMT,AUMGL,AUMTGL,"C","C",,.AUML)
 D END(AUMT,AUMGL,AUMTGL,AUML2)
 ;
 Q
ST ; STATE FILE
 ; DUP/COMP/CODE/NAME
 N AUMT,AUMGL,AUMTGL,AUML,AUML2,AUML3,AUMCNT,AUMFL,AUMINFL
 S AUMT="STATE",AUMGL="^DIC(5,",AUMTGL="^TMP(""AUM"","_$J_",""ALL"",""STATE""",AUMFL=5,AUMINFL=9999999.02
 Q:'$D(@(AUMTGL_")"))
 D RSLT^AUMSCBD($$REPEAT^XLFSTR("-",20)),RSLT^AUMSCBD("STATE CLEANUP")
 D REINDX(AUMGL,"B^C")
 D DUP(AUMT,AUMFL,AUMGL,"C")
 ;
 D BUILD^AUMSCBA(AUMTGL,"COMP","3^1")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML=$$MATCH(AUMT,AUMGL,AUMTGL,"C","COMP","1")
 I ($G(@(AUMTGL_",0)"))=0)!(AUML']"") D END(AUMT,AUMGL,AUMTGL,AUML) Q
 ;
 D BUILD^AUMSCBA(AUMTGL,"C","3")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML2=$$MATCH(AUMT,AUMGL,AUMTGL,"C","C",,.AUML)
 I ($G(@(AUMTGL_",0)"))=0)!(AUML2']"") D END(AUMT,AUMGL,AUMTGL,AUML2) Q
 ;
 D BUILD^AUMSCBA(AUMTGL,"B","1")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML3=$$MATCH(AUMT,AUMGL,AUMTGL,"B","B",,.AUML2)
 D END(AUMT,AUMGL,AUMTGL,AUML3)
 ;
 Q
CTY ; COUNTY FILE
 ; INV CODE/DUP/COMP/CODE
 N AUMT,AUMGL,AUMTGL,AUML,AUML2,AUML3,AUMCNT,AUMFL,AUMINFL
 S AUMT="CNTY",AUMGL="^AUTTCTY(",AUMTGL="^TMP(""AUM"","_$J_",""ALL"",""CNTY""",AUMFL=9999999.23,AUMINFL=.08
 Q:'$D(@(AUMTGL_")"))
 D RSLT^AUMSCBD($$REPEAT^XLFSTR("-",20)),RSLT^AUMSCBD("COUNTY CLEANUP")
 ;
 K ^TMP("AUM",$J,"INV","CTY")
 M ^TMP("AUM",$J,"INV","CTY","C")=^AUTTCTY("C")
 ;
 D REINDX(AUMGL,"B^C")
 ;
 N AUMCNT,AUMCNT2
 S AUMCNT=0 F  S AUMCNT=$O(^TMP("AUM",$J,"INV","CTY","C",AUMCNT)) Q:AUMCNT']""  D
 . S AUMCNT2=0 F  S AUMCNT2=$O(^TMP("AUM",$J,"INV","CTY","C",AUMCNT,AUMCNT2)) Q:AUMCNT2']""  D
 . . Q:'$D(^AUTTCTY(AUMCNT2,0))
 . . I AUMCNT'=$P($G(^AUTTCTY(AUMCNT2,0)),U,4) D
 . . . I $L(AUMCNT)=4 D  Q
 . . . . N AUMCNT3,AUMCNT4,FDA
 . . . . S AUMCNT3=$E(AUMCNT,1,2),AUMCNT4=$O(^DIC(5,"C",AUMCNT3,0))
 . . . . Q:AUMCNT4']""
 . . . . S FDA(AUMFL,AUMCNT2_",",.02)=AUMCNT4
 . . . . D UPDATE^DIE(,"FDA")
 . . . . D RSLT^AUMSCBD(" CORRECTING INVALID ENTRY: "_AUMCNT2_" / TO: "_$$GET1^DIQ(AUMFL,AUMCNT2,.04,"I"))
 ;
 K ^TMP("AUM",$J,"INV","CTY")
 ;
 D DUP(AUMT,AUMFL,AUMGL,"C")
 ;
 D BUILD^AUMSCBA(AUMTGL,"COMP","1^2^3")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML=$$MATCH(AUMT,AUMGL,AUMTGL,"C","COMP","1")
 I ($G(@(AUMTGL_",0)"))=0)!(AUML']"") D END(AUMT,AUMGL,AUMTGL,AUML) Q
 ;
 D BUILD^AUMSCBA(AUMTGL,"C","1^2")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML2=$$MATCH(AUMT,AUMGL,AUMTGL,"C","C",,.AUML)
 D END(AUMT,AUMGL,AUMTGL,AUML2)
 ;
 Q
COM ; COMMUNITY FILE
 ; INV CODE/COMP/CODE
 N AUMT,AUMGL,AUMTGL,AUML,AUML2,AUML3,AUMCNT,AUMFL,AUMINFL
 S AUMT="COM",AUMGL="^AUTTCOM(",AUMTGL="^TMP(""AUM"","_$J_",""ALL"",""COM""",AUMFL=9999999.05,AUMINFL=.18
 Q:'$D(@(AUMTGL_")"))
 D RSLT^AUMSCBD($$REPEAT^XLFSTR("-",20)),RSLT^AUMSCBD("COMMUNITY CLEANUP")
 ;
 K ^TMP("AUM",$J,"INV","COM")
 M ^TMP("AUM",$J,"INV","COM","C")=^AUTTCOM("C")
 ;
 D REINDX(AUMGL,"B^C")
 ;
 N AUMCNT,AUMCNT2
 S AUMCNT=0 F  S AUMCNT=$O(^TMP("AUM",$J,"INV","COM","C",AUMCNT)) Q:AUMCNT']""  D
 . S AUMCNT2=0 F  S AUMCNT2=$O(^TMP("AUM",$J,"INV","COM","C",AUMCNT,AUMCNT2)) Q:AUMCNT2']""  D
 . . Q:'$D(^AUTTCOM(AUMCNT2,0))
 . . I AUMCNT'=$P($G(^AUTTCOM(AUMCNT2,0)),U,8) D
 . . . I $L(AUMCNT)=7 D  Q
 . . . . N AUMCNT3,AUMCNT4,FDA
 . . . . S AUMCNT3=$E(AUMCNT,1,4),AUMCNT4=$O(^AUTTCTY("C",AUMCNT3,0))
 . . . . Q:AUMCNT4']""
 . . . . S FDA(AUMFL,AUMCNT2_",",.03)=$$GET1^DIQ(9999999.23,AUMCNT4,.02,"I")
 . . . . S FDA(AUMFL,AUMCNT2_",",.02)=AUMCNT4
 . . . . D UPDATE^DIE(,"FDA")
 . . . . D RSLT^AUMSCBD(" CORRECTING INVALID ENTRY: "_AUMCNT2_" / TO: "_$$GET1^DIQ(AUMFL,AUMCNT2,.08,"I"))
 ;
 K ^TMP("AUM",$J,"INV","COM")
 ;
 D BUILD^AUMSCBA(AUMTGL,"COMP","1^2^3^4")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML=$$MATCH(AUMT,AUMGL,AUMTGL,"C","COMP","1")
 I ($G(@(AUMTGL_",0)"))=0)!(AUML']"") D END(AUMT,AUMGL,AUMTGL,AUML) Q
 ;
 D BUILD^AUMSCBA(AUMTGL,"C","1^2^3")
 S AUMCNT=$G(@(AUMTGL_",0)")),AUML2=$$MATCH(AUMT,AUMGL,AUMTGL,"C","C",,.AUML)
 D END(AUMT,AUMGL,AUMTGL,AUML2)
 ;
 Q
 ;
BUILD(AUMGL,AUMIN,AUMD) ; BUILD X-REFS - TEMP GLOBAL
 ; GL=GLOBAL,IN=INDEX,D=PIECES TO BUILD X-REF
 N CNT,CNT2
 S CNT=0 F  S CNT=$O(@(AUMGL_")")@(CNT)) Q:'CNT  D
 . N AUMDD,AUMDA
 . S AUMDD=""
 . F CNT2=1:1:$L(AUMD,U) S AUMDD=AUMDD_$E($P(@(AUMGL_")")@(CNT),U,$P(AUMD,U,CNT2)),1,30)
 . S AUMDA=AUMGL_","""_AUMIN_""","""_AUMDD_""","_CNT_")"
 . S @(AUMDA)=""
 Q
 ;
MATCH(AUMT,AUMGL,AUMTGL,AUMIN,AUMTIN,AUMC,AUML,AUMQ) ; SEARCH/MATCH/UPDATE - IHS/OIT/NKD AUM*15.0*3 ADDED QUIET
 ; T=TAG,GL=GLOBAL,TGL=TEMP GLOBAL,IN=INDEX,TIN=TEMP INDEX,C=ADDITIONAL PIECE FOR X-REF,AUML=IENS TO PROCESS,AUMQ=QUIET
 S AUMQ=$G(AUMQ,1)  ; IHS/OIT/NKD AUM*15.0*3 QUIET, DEFAULT TO 1
 N CNT,CNT2,TMP,TMP2,AUMR
 S AUMR=U
 ; ITERATE THROUGH LOCAL INDEX
 S CNT=0 F  S CNT=$O(@(AUMGL_""""_AUMIN_""")")@(CNT)) Q:CNT']""  D
 . I AUMGL="^DIC(5,",AUMIN="C",CNT'?2N Q  ; EXCEPTION FOR STATE (C X-REF BUILT FROM 2 FIELDS)
 . ; ITERATE THROUGH IENS
 . S CNT2=0 F  S CNT2=$O(@(AUMGL_""""_AUMIN_""")")@(CNT,CNT2)) Q:CNT2']""  D
 . . I $D(AUML),(AUML'[("^"_CNT2_"^")) Q  ; SKIP OVER CODES NOT IN AUML
 . . N TMP,TMP2
 . . S TMP=CNT_$S($D(AUMC):$E($P($G(@(AUMGL_CNT2_",0)")),U,AUMC),1,30),1:"")  ; BUILD KEY TO COMPARE
 . . S:(AUMGL="^AUTTLOC(")&(AUMTIN="COMP") TMP=CNT_$E($P($G(^DIC(4,CNT2,0)),U,AUMC),1,30)  ; EXCEPTION FOR LOCATION/INSTITUTION NAME
 . . S TMP2=$O(@(AUMTGL_","""_AUMTIN_""")")@(TMP,0))  ; CHECK IF KEY MATCHES IN TEMP GLOBAL
 . . I TMP2']"" S AUMR=AUMR_CNT2_"^"  Q  ; IF NO, ADD TO RESULT AS UNMATCHED
 . . ; UPDATE THE ENTRY - IF ENTRY WAS ALREADY INACTIVE, USE THAT DATE INSTEAD
 . . I $$GET1^DID(AUMFL,AUMINFL,"","LABEL")]"",$$GET1^DIQ(AUMFL,CNT2,AUMINFL)]"",$P($G(@(AUMTGL_","_TMP2_")")),U,7)]"" D
 . . . S $P(@(AUMTGL_","_TMP2_")"),U,7)=17000000+$$GET1^DIQ(AUMFL,CNT2,AUMINFL,"I")
 . . D ENTRY^AUMSCBD(AUMT,"ALL",$G(@(AUMTGL_","_TMP2_")")),CNT2,AUMQ)  ; IHS/OIT/NKD AUM*15.0*3 QUIET
 . . K @(AUMTGL_","_TMP2_")"),@(AUMTGL_","""_AUMTIN_""")")@(TMP,TMP2)  ; REMOVE FROM TEMP GLOBAL AND DECREMENT COUNT
 . . S @(AUMTGL_",0)")=@(AUMTGL_",0)")-1
 S:AUMR=U AUMR=""  ; IF NO RESULTS, SET BACK TO EMPTY STRING
 K @(AUMTGL_","""_AUMTIN_""")")  ; CLEAR OUT REMAINING ENTRIES IN TEMP GLOBAL INDEX
 Q AUMR
 ;
END(AUMT,AUMGL,AUMTGL,AUML) ; END PROCESSING
 ; UPDATE REMAINING IN TEMP GLOBAL
 ; INACTIVATE LOCALS NOT MATCHED
 N CNT
 ; TMP REMAINING
 I ($G(@(AUMTGL_",0)"))'=0) D
 . S CNT=0 F  S CNT=$O(@(AUMTGL_")")@(CNT)) Q:CNT']""  D
 . . ; ONCE TO ADD, THEN TO UPDATE/INACTIVATE
 . . I $P($G(@(AUMTGL_","_CNT_")")),U,7)]"" D ENTRY^AUMSCBD(AUMT,"ALL",$P($G(@(AUMTGL_","_CNT_")")),U,1,6),,2)
 . . D ENTRY^AUMSCBD(AUMT,"ALL",$G(@(AUMTGL_","_CNT_")")),,1)
 ; LOCAL REMAINING
 I (AUML]"") D
 . N CNT,CNT2,FDA,AUMLI
 . S CNT2=0
 . Q:AUMT="LOC"
 . Q:$$GET1^DID(AUMFL,AUMINFL,"","LABEL")']""
 . F CNT=1:1:$L(AUML,U) D
 . . S AUMLI=$P(AUML,U,CNT)
 . . Q:AUMLI']""
 . . Q:$$GET1^DIQ(AUMFL,AUMLI,AUMINFL)]""
 . . S FDA(AUMFL,AUMLI_",",AUMINFL)=AUMDT,CNT2=CNT2+1
 . I $D(FDA) D UPDATE^DIE(,"FDA")
 . D RSLT^AUMSCBD(" INACTIVATING "_CNT2_" UNMATCHED LOCAL ENTRIES")
 ;
 K @(AUMTGL_")")
 Q
 ;
REINDX(AUMGL,AUMIN) ; RE-INDEX FILE
 ; GL=GLOBAL,IN=LIST OF INDEXES
 Q:AUMIN']""
 N CNT,DIK,DA,DIC
 F CNT=1:1:$L(AUMIN,"^") Q:$P(AUMIN,"^",CNT)']""  K @(AUMGL_""""_$P(AUMIN,"^",CNT)_""")")
 S DIK=AUMGL
 D IXALL^DIK
 D ^XBFMK
 Q
 ;
DUP(AUMT,AUMFL,AUMGL,AUMIN) ; SEARCH FOR DUPLICATE ENTRIES AND MERGE
 N AUMCNT,AUMCNT2,AUMTMP,AUMTMP2
 S AUMCNT=0 F  S AUMCNT=$O(@(AUMGL_""""_AUMIN_""")")@(AUMCNT)) Q:AUMCNT']""  D
 . I AUMGL="^DIC(5,",AUMIN="C",AUMCNT'?2N Q  ; EXCEPTION FOR STATE (C X-REF BUILT FROM 2 FIELDS)
 . S AUMCNT2=0,AUMCNT2=$O(@(AUMGL_""""_AUMIN_""")")@(AUMCNT,AUMCNT2))
 . Q:$O(@(AUMGL_""""_AUMIN_""")")@(AUMCNT,AUMCNT2))']""
 . S AUMTMP(AUMCNT,AUMCNT2)=""
 . F  S AUMCNT2=$O(@(AUMGL_""""_AUMIN_""")")@(AUMCNT,AUMCNT2)) Q:AUMCNT2']""  S AUMTMP(AUMCNT,AUMCNT2)=""
 S AUMCNT=0 F  S AUMCNT=$O(AUMTMP(AUMCNT)) Q:AUMCNT']""  D
 . S AUMTMP2=""
 . D RSLT^AUMSCBD(" RESOLVING DUPLICATES FOR CODE: "_AUMCNT)
 . S AUMCNT2=0 F  S AUMCNT2=$O(AUMTMP(AUMCNT,AUMCNT2)) Q:AUMCNT2']""  S AUMTMP2=AUMTMP2_$S($L(AUMTMP2):U,1:"")_AUMCNT2 ;D RSLT^AUMSCBD("  IEN: "_AUMCNT2_$J("",$L(AUMCNT2)-8)_" - 0 NODE: "_$G(@(AUMGL_AUMCNT2_",0)")))
 . F AUMCNT2=1:1:$L(AUMTMP2,U)-1 Q:$P(AUMTMP2,U,AUMCNT2)']""  D
 . . D MERG(AUMFL,AUMGL,$P(AUMTMP2,U,AUMCNT2),$P(AUMTMP2,U,$L(AUMTMP2,U)))
 Q
 ;
MERG(AUMFL,AUMGL,AUMFROM,AUMTO) ; COMPARE/MERGE
 N DILN,DITM,L
 I AUMGL="^AUTTCTY(" D CTYMERG(AUMFROM,AUMTO) S DITM("EXCLUDE",9002073.31)=""  ; IHS/OIT/NKD AUM*14.0*2 - SPECIAL COUNTY PRE-MERGE
 S DILN=21,DITM=0,L=1
 S DITM("DDEF")=2,DITM("DDIF")=1,DITM("DELETE")=""
 S DITM("DFF")=AUMFL,DITM("DIC")=AUMGL,DITM("DIMERGE")=1
 S DITM("DIT(1)")=AUMFROM,DITM("DIT(2)")=AUMTO
 S DITM("NON-INTERACTIVE")="",DITM("NOTALK")="",DITM("REPOINT")=""
 D ^DITM2,END^DITM,^XBFMK
 Q
 ;
 ; IHS/OIT/NKD AUM*14.0*2 - SPECIAL COUNTY PRE-MERGE
CTYMERG(AUMFROM,AUMTO) ; CHS SERVICE DELIVERY AREA MERGE
 N FDA,AUMCNT,AUMCNT2
 S AUMCNT=0 F  S AUMCNT=$O(^ACHSSDA(AUMCNT)) Q:'AUMCNT  D
 . Q:'$D(^ACHSSDA(AUMCNT,30,"B",AUMFROM))
 . S AUMCNT2=0 F  S AUMCNT2=$O(^ACHSSDA(AUMCNT,30,"B",AUMFROM,AUMCNT2)) Q:'AUMCNT2  D
 . . Q:(+$G(^ACHSSDA(AUMCNT,30,AUMCNT2,0))'=AUMFROM)
 . . S FDA(9002073.31,AUMCNT2_","_AUMCNT_",",.01)=AUMTO
 I $D(FDA) D UPDATE^DIE(,"FDA")
 Q