Search in sources :

Example 1 with HL7DataBasedResourceModel

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);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Expression(io.github.linuxforhealth.api.Expression) JsonNode(com.fasterxml.jackson.databind.JsonNode) HL7DataBasedResourceModel(io.github.linuxforhealth.hl7.resource.HL7DataBasedResourceModel)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Expression (io.github.linuxforhealth.api.Expression)1 HL7DataBasedResourceModel (io.github.linuxforhealth.hl7.resource.HL7DataBasedResourceModel)1