Commit 9623ee0a authored by R.W.Majeed's avatar R.W.Majeed
Browse files

birthdate, deathdate, sex parsed from new XML format. Test extended for this information.

parent ceb1e1a8
......@@ -21,15 +21,16 @@ import de.sekmi.histream.ObservationFactory;
import de.sekmi.histream.ObservationSupplier;
import de.sekmi.histream.ext.ExternalSourceType;
import de.sekmi.histream.ext.Patient;
import de.sekmi.histream.ext.Patient.Sex;
import de.sekmi.histream.ext.Visit;
import de.sekmi.histream.impl.ObservationFactoryImpl;
import de.sekmi.histream.impl.ObservationImpl;
public class JAXBObservationSupplier extends AbstractObservationParser implements ObservationSupplier {
private static final String DOCUMENT_ROOT = "eav-data";
private static final String PATIENT_ELEMENT = "patient";
private static final String ENCOUNTER_ELEMENT = "encounter";
private static final String FACT_WRAPPER = "facts";
static final String DOCUMENT_ROOT = "eav-data";
static final String PATIENT_ELEMENT = "patient";
static final String ENCOUNTER_ELEMENT = "encounter";
static final String FACT_WRAPPER = "facts";
private ExtensionAccessor<Patient> patientAccessor;
......@@ -139,6 +140,15 @@ public class JAXBObservationSupplier extends AbstractObservationParser implement
// register with extension
currentPatient = patientAccessor.accessStatic(patientId, (ExternalSourceType)this);
// TODO set patient data
if( patientData.containsKey("birthdate") ){
currentPatient.setBirthDate(DateTimeAccuracy.parsePartialIso8601(patientData.get("birthdate")));
}
if( patientData.containsKey("deathdate") ){
currentPatient.setDeathDate(DateTimeAccuracy.parsePartialIso8601(patientData.get("deathdate")));
}
if( patientData.containsKey("gender") ){
currentPatient.setSex(Sex.valueOf(patientData.get("gender")));
}
}
/**
* Reads encounter element with content.
......
......@@ -161,6 +161,9 @@ class XMLObservationParser extends AbstractObservationParser{
overwrite = true;
}
// XXX only for testing
overwrite = true; // TODO rewrite overwrite/sync condition
if( overwrite ){
patient.setBirthDate(birthDate);
patient.setDeathDate(deathDate);
......
......@@ -46,6 +46,7 @@ import de.sekmi.histream.ObservationSupplier;
import de.sekmi.histream.Value;
import de.sekmi.histream.ext.Patient;
import de.sekmi.histream.ext.Visit;
import de.sekmi.histream.ext.Patient.Sex;
import de.sekmi.histream.DateTimeAccuracy;
import de.sekmi.histream.Modifier;
import de.sekmi.histream.impl.ObservationFactoryImpl;
......@@ -81,7 +82,11 @@ public class FileObservationProviderTest {
Patient p = o.getExtension(Patient.class);
Assert.assertNotNull("Patient extension required", p);
Assert.assertEquals("XX12345", p.getId());
Assert.assertEquals(DateTimeAccuracy.parsePartialIso8601("2001-01-01"), p.getBirthDate());
Assert.assertEquals(DateTimeAccuracy.parsePartialIso8601("2020"), p.getDeathDate());
Assert.assertEquals(Sex.Female, p.getSex());
// TODO: test more patient information
Visit v = o.getExtension(Visit.class);
Assert.assertNotNull("Visit extension required", v);
Assert.assertEquals("Zuhause", v.getLocationId());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment