XIPSYNC ;OIFOO/SO- SYNC UP FILE 5'S COUNTY MULTIPLE WITH 5.13;6:56 AM  16 Nov 2005
 ;;8.0;KERNEL;**328,378**;Jul 10, 1995;Build 59
 Q
EP1 ;MAIN ENTRY POINT
 N XIPQ S XIPQ=0 ;ALLOW DIALOG TO DISPLAY OR PRINT
 ;
 N XUMF S XUMF=1 ;ALLOW EDITING ;8*378
 ;
 D S1,S2
 Q
 ;
DEQUE ;DEQUEUING ENTRY POINT
 N XIPQ S XIPQ=1 ;KEEP DIALOG FROM DISPLAYING OR PRINTING
 ;
 N XUMF S XUMF=1 ;ALLOW EDITING ;8*378
 ;
 D S1,S2
 Q
 ;
S1 ;SET INACTIVE DATE FOR ALL COUNTIES TO DT
 N ST
 S ST=0 ;ST=STATE IEN
 I 'XIPQ D MES^XPDUTL("Begin updating COUNTY multiple...")
 F  S ST=$O(^DIC(5,ST)) Q:'ST  D
 . I +$P(^DIC(5,ST,0),U,3)>56,+$P(^(0),U,3)'=72 Q  ;NOT US STATE OR PR
 . N CO S CO=0 ;CO=COUNTY IEN
 . F  S CO=$O(^DIC(5,ST,1,CO)) Q:'CO  D
 .. I $P(^DIC(5,ST,1,CO,0),U,5)]"" Q  ;DON'T CHANGE DATE
 .. N FDA,DIERR,EM
 .. S FDA(5.01,CO_","_ST_",",5)=DT
 .. D FILE^DIE("","FDA","EM")
 .. Q
 Q
 ;
S2 ;EDIT COUNTY MULTIPLE USING FILE 5.13
 N IEN,X,FST,FCO
 ;FST=2 DIGIT STATE FIPS CODE, FCO=3 DIGIT COUNTY FIPS CODE
 S IEN=0 ;5.13'S IEN
 F  S IEN=$O(^XIP(5.13,IEN)) Q:'IEN  S X=^XIP(5.13,IEN,0),FST=$E(X,1,2),FCO=$E(X,3,5) D
 . N ST,CO
 . S ST=0,CO=0
 . S ST=$O(^DIC(5,"C",FST,ST))
 . I 'ST,'XIPQ D MES^XPDUTL("Can not find STATE CODE: "_FST_" in STATE file.") Q
 . S CO=$O(^DIC(5,ST,1,"C",FCO,CO))
 . I 'CO D  Q  ;ADD COUNTY
 .. N DIERR,EM,FDA
 .. I 'XIPQ D MES^XPDUTL("Adding County: "_$P(X,U,2)_"("_FCO_")"_" to State: "_$$GET1^DIQ(5,ST_",",.01))
 .. S FDA(5.01,"?+1,"_ST_",",.01)=$P(X,U,2)
 .. S FDA(5.01,"?+1,"_ST_",",2)=FCO
 .. D UPDATE^DIE("","FDA","","EM")
 .. Q
 . I CO D  Q  ;REACTIVATE COUNTY
 .. N DIERR,EM,FDA
 .. S FDA(5.01,CO_","_ST_",",5)=$S($P(X,U,4)]"":$P(X,U,4),1:"")
 .. D  ;SPELL CHECK 5.13 v STATE FILE'S COUNTY
 ... N DIERR,X1
 ... S X1=$$GET1^DIQ(5.01,CO_",",.01)
 ... I X1'=$P(X,U,2) S FDA(5.01,CO_","_ST_",",.01)=$P(X,U,2)
 .. D FILE^DIE("","FDA","EM")
 .. Q
 . Q
 I 'XIPQ D MES^XPDUTL("Finished updating COUNTY multiple.")
 Q
