If the <patient_id> value already exists in the mapping table then compare the UPDATE_DATE to the existing record's update date. If the new record has a more recent date, then update the current patient record with this data.
Example:
<patient update_date ="2008-05-0418:13:51.00">
<patient_map_id source="HIVE">100</patient_map_id>
<patient_map_id source="BWH">777</patient_map_id>
</patient>
The rows in the PATIENT_MAPPING table before the update:
PATIENT_IDE |
PATIENT_IDE_SOURCE |
PATIENT_NUM |
PATIENT_IDE_STATUS |
UPDATE_DATE |
100 |
HIVE |
100 |
A |
2006-12-03 00:00:00 |
The rows in the PATIENT_MAPPING table after the update:
PATIENT_IDE |
PATIENT_IDE_SOURCE |
PATIENT_NUM |
PATIENT_IDE_STATUS |
UPDATE_DATE |
100 |
HIVE |
100 |
A |
2008-05-04 18:13:51 |