use of io.github.linuxforhealth.hl7.resource.HL7DataBasedResourceModel in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7DataBasedResourceDeserializer method deserialize.
@Override
public HL7DataBasedResourceModel deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
ObjectNode node = jsonParser.getCodec().readTree(jsonParser);
JsonNode hl7PrefixNode = node.get(SPEC);
String hl7Prefix = null;
if (hl7PrefixNode != null) {
hl7Prefix = hl7PrefixNode.toString();
}
// generate expressions from the resource YAML
Map<String, Expression> expressions = generateExpressions(node);
JsonNode namenode = node.get(RESOURCE_TYPE_FIELD_NAME);
String name = String.valueOf(ctxt.findInjectableValue("resourceName", null, null));
if (namenode != null) {
name = namenode.textValue();
}
// And is base FHIR resource like Patient and Organization. Not a datatype/? or reference/? etc.
if (!expressions.isEmpty() && name.indexOf('/') == -1) {
LOGGER.debug("Adding common expressions to the list of expressions for {}", name);
expressions.putAll(getCommonExpressions());
}
return new HL7DataBasedResourceModel(name, expressions, hl7Prefix);
}
Aggregations