Processing the SyncEvent Zip File

The ImportFeeds scheduled process (see quartz-jobs.xml), which periodcally processes pending files, is lauched by sites that subscribe to an instance's data feed. The following example describes how a remote site subscribes to another remote site's feed; however, a similar process could be used by a server at a data center, with a few modifications.

Locating, Downloading, and Extracting the Files

The SyncUtils.importData method first reads the import/mostRecentSyncEvent file and compares the mostRecentSyncEvent.syncDate with the current date. It loops through the days between the current date and the last sync date. It fetches a list of zip files, sorted by modified date, using the webDAV PROPFIND method for each date. It first checks what files it has already downloaded and processed locally and creates a list of files it has not already downloaded and processed. The SyncUtils.processSyncEventFiles method downloads and extracts each zip file to that day's import directory (a directory within the import dir corresponding to the current date - i.e. 2010/Jan/3/).

Importing Records

As it loops through each pending file, it unzips the archive and deserializes the syncEvent record. It processes the following elements in the syncEvent object by checking if each object's UUID is already in the system:

  • patients
  • events
  • encounters
  • admin records
  • edits - processes only if the edit.getLastModified().getTime() > the edit's encounter.getLastModified().getTime()
  • deletions

Any errors captured by the system are logged and uploaded during the next sync process. Error file location: siteAbbrev/log/pending/errorSyncLog_syncEvent.getUuid().Constants.SYNC_FORMAT.

Results of the import process are saved in that day's import directory, using the zip file's name with -Results appended.This same file is copied to the import directory as mostRecentSyncEvent.

Location of Records on the Local File System

If the syncEvent is an admin field,  the record is deserialized to the admin directory; otherwise, it is deserialized to the "people" directory. Records in the people directory are saved in a directory named using the parentUuid. See SyncUtils.processLocalSyncEvents for details on the sync process.

See the Archive file system page for more information on its directories and file names.