Sync process - example code comparing uuid's
The following code is for the Patient Sync method of synchronization, which is no longer in-use.
Loop through the current records and add them to a Hashmap<uuid,createdDate). This pattern is used for all objects in zeprs - encounters, problems, comments, etc.
Map currentCommentMap = new HashMap(); // create a hashmap that stores the uuid if (currentComments != null) { // loop through the current items and pop them into Map for (Comment item : currentComments) { String uuid = item.getUuid(); currentCommentMap.put(uuid, uuid); } }
Then loop through the records you're importing and see if the uuid exists.
If not, set some import id's and (in some cases) the patient and pregnancy id and save the new record.
for (int i = 0; i < importComments.size(); i++) { Comment item = (Comment) importComments.get(i); item.setImportCommentId(item.getId()); String uuid = item.getUuid(); if (currentCommentMap.get(uuid) == null) { XmlUtils.saveImportedComment(item, conn, comments); } }
Clear the map afterwards:
currentCommentMap.clear();
- Printer-friendly version
- Login to post comments
- PDF version