Esempio n. 1
0
  private void genExtension(StructureDefinition extension) throws FHIRException {
    // for now, only simple extensions
    if (extension.getSnapshot().getElement().size() == 5
        && !hasSection("Extension: " + tail(extension.getUrl()))) {
      ElementDefinition base = extension.getSnapshot().getElement().get(0);
      ElementDefinition valueX = extension.getSnapshot().getElement().get(4);
      Section section = section("Extension: " + tail(extension.getUrl()));
      Subject subject = section.subject("ex:birthplace");
      subject.predicate("a", "fhir:ExtensionDefinition");
      subject.label(extension.getTitle());
      subject.comment(extension.getDescription());
      if (extension.hasVersion())
        subject.predicate("fhir:version", literal(extension.getVersion()));
      if (extension.hasCopyright())
        subject.predicate("dc:rights", literal(extension.getCopyright()));
      subject.predicate(
          "fhir:status",
          complex()
              .predicate(
                  "a", "fhir:conformance-resource-status\\#" + extension.getStatus().toCode()));
      subject.predicate(
          "fhir:canonicalStatus",
          complex()
              .predicate(
                  "a", getCanonicalStatus("ValueSet.status", extension.getStatus().toCode())));
      for (UsageContext cc : extension.getUseContext())
        codedTriple(subject, "fhir:useContext", cc.getValueCodeableConcept());
      if (extension.hasDate())
        subject.predicate("dc:date", literal(extension.getDateElement().asStringValue()));

      subject.predicate("rdfs:range", processType(valueX.getType().get(0).getCode()));
      if (base.getIsModifier()) subject.predicate("fhir:flag", "fhir:isModifier");
    }
  }
Esempio n. 2
0
  private void genBaseMetadata() {
    Section section = section("Basic Framework");

    // terminology base:
    section.triple("fhir:Concept", "a", "rdf:Class");
    section.label("fhir:Concept", "A concept in a code system defined by FHIR");
    section.comment(
        "fhir:Concept",
        "Concepts are defined as classes, and individual properties have a value which is an anonymous class with a type of the appropriate concept");

    section.triple("fhir:CodeSystem", "rdfs:subClassOf", "rdf:Class");
    section.label("fhir:CodeSystem", "Base class for code systems");
    section.comment(
        "fhir:CodeSystem",
        "A code system identifies the definition framework. Code systems contain concepts");

    section.triple("fhir:ValueSet", "rdfs:subClassOf", "rdf:Class");
    section.label(
        "fhir:ValueSet", "A value set - a set of codes for concepts from one or more code systems");
    section.comment("fhir:Concept", "ValueSets...");

    // wiring the terminology base together
    section.triple("fhir:contains", "a", "rdf:Property");
    section.label("fhir:contains", "A concept in a code system");
    section.triple("fhir:contains", "rdfs:domain", "fhir:CodeSystem");
    section.triple(
        "fhir:contains", "rdfs:range", "fhir:Concept"); // todo: is this valid? a meta-range?

    section.triple("fhir:include", "a", "rdf:Property");
    section.label("fhir:include", "A concept included in a value set");
    section.comment("fhir:include", "Include a code system or value set in a value set");
    section.triple("fhir:include", "rdfs:domain", "fhir:ValueSet");
    section.triple(
        "fhir:include", "rdfs:range", "fhir:Concept"); // todo: is this valid? a meta-range?

    // standard properties
    section.triple("fhir:binding", "a", "rdf:Property");
    section.label("fhir:binding", "ValueSet bound to this property");
    section.comment("fhir:binding", "Refer to FHIR documentation for the use of this property");
    section.triple("fhir:binding", "rdfs:range", "xs:anyUri");

    section.triple("fhir:bindingStrength", "a", "rdf:Property");
    section.label("fhir:bindingStrength", "Strength of ValueSet binding");
    section.comment(
        "fhir:bindingStrength", "Refer to FHIR documentation for the use of this property");
    section.triple("fhir:bindingStrength", "rdfs:range", "xs:anyUri");

    section.triple("fhir:canonicalStatus", "a", "rdf:Property");
    section.label("fhir:canonicalStatus", "Canonical Status Mapping");
    section.comment(
        "fhir:canonicalStatus",
        "Each resource has it's own list of status codes. This contains a mapping through to the basic status");
    section.triple("fhir:canonicalStatus", "rdfs:range", "fhir:canonical-status");

    section.triple("fhir:hasFlag", "a", "rdf:Property");
    section.label("fhir:hasFlag", "Flags for FHIR properties");
    section.comment(
        "fhir:hasFlag",
        "A set of flags that provide additional knowledge about the meaning of a property");
    section.triple("fhir:hasFlag", "rdfs:range", "fhir:flag-item");

    section.triple("fhir:w5", "a", "rdf:Property");
    section.label("fhir:w5", "W5 Categorization (preliminary)");
    section.comment(
        "fhir:w5",
        "FHIR W5 categorization is a preliminary classification of the type of fhir property");
    section.triple("fhir:w5", "rdfs:range", "fhir:w5.system");

    section.triple("fhir:status", "a", "rdf:Property");
    section.label("fhir:status", "The status of the item");
    section.comment("fhir:status", "The status of the item");
    section.triple("fhir:status", "rdfs:range", "fhir:conformance-resource-status");

    section.triple("fhir:version", "a", "rdf:Property");
    section.label("fhir:version", "Assigned Version Number");
    section.comment("fhir:version", "The version number assigned to the item");
    section.triple("fhir:version", "rdfs:range", "xs:string");

    section.triple("fhir:loinc", "a", "rdf:Property");
    section.label("fhir:loinc", "LOINC equivalent concept");
    section.comment(
        "fhir:loinc",
        "LOINC equivalent concept - may be a LOINC code, a LOINC part code, or a LOINC property");
    section.triple("fhir:loinc", "rdfs:range", "xs:anyURI");

    // nil instance
    nilInstance = section.subject("fhir:nil");
    nilInstance.comment(
        "To indicate positively that a property has no value. Intended to be used where elements have a meaning when missing, to indicate that they realyl are missing in the instance");

    // ---------------------------------------------------
    section = section("Property Flags");
    section.triple("fhir:flag-item.system", "a", "fhir:CodeSystem");
    section.comment(
        "fhir:flag-item.system", "An internal code system defined for the FHIR definitions");
    section.triple("fhir:flag-item.system", "fhir:contains", "fhir:flag-item");

    section.triple("fhir:flag-item", "a", "fhir:Concept");

    section.triple("fhir:flag-item\\#isModifier", "rdfs:subClassOf", "fhir:flag-item");
    section.triple("fhir:flag-item\\#isModifier", "owl:oneOf", "(fhir:flag-item\\#isModifier)");
    section.comment(
        "fhir:flag-item\\#isModifier",
        "An element is labeled isModifier if the value it contains may change the interpretation of the element that contains it (including if the element is the resource as a whole). Typical examples of elements that are labeled isModifier are elements such as 'status', 'active', 'refuted', or 'certainty'");

    section.triple("fhir:flag-item\\#isSummaryItem", "rdfs:subClassOf", "fhir:flag-item");
    section.triple(
        "fhir:flag-item\\#isSummaryItem", "owl:oneOf", "(fhir:flag-item\\#isSummaryItem)");
    section.comment(
        "fhir:flag-item\\#isSummaryItem",
        "Whether the element should be included if a client requests a search with the parameter _summary=true.");

    section.triple("fhir:flag-item\\#isXmlAtribute", "rdfs:subClassOf", "fhir:flag-item");
    section.triple(
        "fhir:flag-item\\#isXmlAtribute", "owl:oneOf", "(fhir:flag-item\\#isXmlAtribute)");
    section.comment(
        "fhir:flag-item\\#isXmlAtribute",
        "In the XML format, this property is represented as an attribute not an element");
    section.triple("fhir:isXmlAtribute", "a", "fhir:flag-item\\#isXmlAtribute");

    // ---------------------------------------------------
    section = section("Canonical Status Codes");
    section.triple("fhir:canonical-status.system", "a", "fhir:CodeSystem");
    section.comment(
        "fhir:canonical-status.system", "An internal ontology defined for the FHIR definitions");
    section.triple("fhir:canonical-status.system", "fhir:contains", "fhir:canonical-status");

    section.triple("fhir:canonical-status", "a", "fhir:Concept");

    for (int i = 0; i < definitions.getStatusCodes().get("@code").size(); i++) {
      if (!Utilities.noString(definitions.getStatusCodes().get("@code").get(i))) {
        String pcc = pctEncode(definitions.getStatusCodes().get("@code").get(i));
        section.triple(
            "fhir:canonical-status\\#" + pcc, "rdfs:subClassOf", "fhir:canonical-status");
        section.comment(
            "fhir:canonical-status\\#" + pcc,
            definitions.getStatusCodes().get("@definition").get(i));
      }
    }

    // ---------------------------------------------------
    section = section("W5 Classifications");
    section.triple("fhir:w5.system", "a", "fhir:CodeSystem");
    section.comment("fhir:w5.system", "An internal ontology defined for the FHIR definitions");
    section.triple("fhir:w5.system", "fhir:contains", "fhir:w5");

    section.triple("fhir:w5", "a", "fhir:Concept");

    for (W5Entry e : definitions.getW5s().values()) {
      String pcc = pctEncode(e.getCode());
      section.triple("fhir:w5\\#" + pcc, "rdfs:subClassOf", "fhir:w5");
      section.comment("fhir:w5\\#" + pcc, e.getDescription());
    }
  }