Hi Markus,
yes, that's an additional complexity. For example BloodPressure needs two values.
So the idea is that we annotate our data fields with "BloodPressure" and the path, eg. ""Observation.component:diastolicBloodPressure.value[x]", which specifies to which value inside a Resource this should be mapped to.
And yes, there will be the problem of different Units, and converting valuesets from our internal representation to the FHIR one, but all of this can be sorted out.
My current problem is, that I don't know how to create Resources with HAPI FHIR Library. I have a StructureDefinition, I have set of values, and I know where they should go in there, but I don't know how to create a Resource from these input.
For the BodyWeight example, I have done this:
public static Resource createResourceForValue(Patient patient, StructureDefinition structureDefinition, Type value, Date creationDate) {
String type = structureDefinition.getType();
if ("Observation".equals(type)) {
Observation obs = new Observation();
obs.setId(generateRandomID());
obs.getMeta().addProfile(structureDefinition.getUrl());
Identifier identifier = obs.addIdentifier();
identifier.setValue(generateRandomIDentifier());
identifier.getAssigner().setReference("Organization/secuTrial");
obs.setStatus(ObservationStatus.FINAL);
obs.getCode().addCoding().setSystem("
http://loinc.org").setCode("29463-7").setDisplay("Body weight");
obs.getCode().addCoding().setSystem("
http://snomed.info/sct").setCode("27113001").setDisplay("Body weight (observable entity)");
obs.getCode().setText("Body weight");
obs.getSubject().setReference(patient.getResourceType() + "/" + patient.getId());
obs.setEffective(new DateTimeType(creationDate));
obs.setValue(value);
return obs;
} else {
throw new RuntimeException("unhandled type: "+type);
}
}
This is a literal translation of the BodyWeight example into Java code. But of course, it would be horrible to write this kind of method for all the 68 StructureDefinitions that exist in Gecco. After all, the information is already available in the StructureDefinitions, so why hardcode it all again? It seems like a lot of manual work, where a lot of mistakes can happen, and the worst thing is, I have only constructed this from the example given, so I have no idea if I covered all edge cases.
So to summarize my problem, I'm looking for something which takes as input:
- a StructureDefinition
- a list of values with their corresponding FHIRPath
- a Patient
- and possible a date
which then produces the correct FHIR Resource.
It seems I don't understand FHIR at all, because I can find exactly nothing on this topic, yet, shouldn't everyone have this problem? People are creating Resources all the time, no? How do they do this? Do we really have to replicate all the StructureDefinitions in code?
Thanks,
Marc