Search in sources :

Example 41 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class CapabilityStatementComparer method compare.

public CapabilityStatementComparison compare(CapabilityStatement left, CapabilityStatement right) {
    if (left == null)
        throw new DefinitionException("No CapabilityStatement provided (left)");
    if (right == null)
        throw new DefinitionException("No CapabilityStatement provided (right)");
    CapabilityStatementComparison res = new CapabilityStatementComparison(left, right);
    session.identify(res);
    CapabilityStatement cs = new CapabilityStatement();
    res.setUnion(cs);
    session.identify(cs);
    cs.setName("Union" + left.getName() + "And" + right.getName());
    cs.setTitle("Union of " + left.getTitle() + " And " + right.getTitle());
    cs.setStatus(left.getStatus());
    cs.setDate(new Date());
    CapabilityStatement cs1 = new CapabilityStatement();
    res.setIntersection(cs1);
    session.identify(cs1);
    cs1.setName("Intersection" + left.getName() + "And" + right.getName());
    cs1.setTitle("Intersection of " + left.getTitle() + " And " + right.getTitle());
    cs1.setStatus(left.getStatus());
    cs1.setDate(new Date());
    compareMetadata(left, right, res.getMetadata(), res);
    comparePrimitives("kind", left.getKindElement(), right.getKindElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    compareCanonicalList("instantiates", left.getInstantiates(), right.getInstantiates(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getInstantiates(), cs1.getInstantiates());
    compareCanonicalList("imports", left.getImports(), right.getImports(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getImports(), cs1.getImports());
    comparePrimitives("software.name", left.getSoftware().getNameElement(), right.getSoftware().getNameElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("software.version", left.getSoftware().getVersionElement(), right.getSoftware().getVersionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("software.releaseDate", left.getSoftware().getReleaseDateElement(), right.getSoftware().getReleaseDateElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("implementation.description", left.getImplementation().getDescriptionElement(), right.getImplementation().getDescriptionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("implementation.url", left.getImplementation().getUrlElement(), right.getImplementation().getUrlElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("fhirVersion", left.getFhirVersionElement(), right.getFhirVersionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    compareCodeList("format", left.getFormat(), right.getFormat(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getFormat(), cs1.getFormat());
    compareCodeList("patchFormat", left.getPatchFormat(), right.getPatchFormat(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getPatchFormat(), cs1.getPatchFormat());
    compareCanonicalList("implementationGuide", left.getImplementationGuide(), right.getImplementationGuide(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getImplementationGuide(), cs1.getImplementationGuide());
    compareRests(left.getRest(), right.getRest(), res.getCombined(), res.getUnion().getRest(), res.getIntersection().getRest(), res.getUnion(), res.getIntersection(), res, "CapabilityStatement.rest");
    return res;
}
Also used : CapabilityStatement(org.hl7.fhir.r5.model.CapabilityStatement) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) Date(java.util.Date)

Example 42 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class ProfileComparer method compare.

public ProfileComparison compare(StructureDefinition left, StructureDefinition right) throws DefinitionException, FHIRFormatError, IOException {
    check(left, "left");
    check(right, "right");
    ProfileComparison res = new ProfileComparison(left, right);
    session.identify(res);
    StructureDefinition sd = new StructureDefinition();
    res.setUnion(sd);
    session.identify(sd);
    sd.setName("Union" + left.getName() + "And" + right.getName());
    sd.setTitle("Union of " + left.getTitle() + " And " + right.getTitle());
    sd.setStatus(left.getStatus());
    sd.setDate(new Date());
    StructureDefinition sd1 = new StructureDefinition();
    res.setIntersection(sd1);
    session.identify(sd1);
    sd1.setName("Intersection" + left.getName() + "And" + right.getName());
    sd1.setTitle("Intersection of " + left.getTitle() + " And " + right.getTitle());
    sd1.setStatus(left.getStatus());
    sd1.setDate(new Date());
    compareMetadata(left, right, res.getMetadata(), res);
    comparePrimitives("fhirVersion", left.getFhirVersionElement(), right.getFhirVersionElement(), res.getMetadata(), IssueSeverity.WARNING, res);
    comparePrimitives("kind", left.getKindElement(), right.getKindElement(), res.getMetadata(), IssueSeverity.WARNING, res);
    comparePrimitives("abstract", left.getAbstractElement(), right.getAbstractElement(), res.getMetadata(), IssueSeverity.WARNING, res);
    comparePrimitives("type", left.getTypeElement(), right.getTypeElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    comparePrimitives("baseDefinition", left.getBaseDefinitionElement(), right.getBaseDefinitionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
    if (left.getType().equals(right.getType())) {
        DefinitionNavigator ln = new DefinitionNavigator(session.getContextLeft(), left);
        DefinitionNavigator rn = new DefinitionNavigator(session.getContextRight(), right);
        StructuralMatch<ElementDefinitionNode> sm = new StructuralMatch<ElementDefinitionNode>(new ElementDefinitionNode(left, ln.current()), new ElementDefinitionNode(right, rn.current()));
        compareElements(res, sm, ln.path(), null, ln, rn);
        res.combined = sm;
    }
    return res;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) DefinitionNavigator(org.hl7.fhir.r5.utils.DefinitionNavigator) Date(java.util.Date)

Example 43 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class Conformance method copy.

public Conformance copy() {
    Conformance dst = new Conformance();
    copyValues(dst);
    dst.url = url == null ? null : url.copy();
    dst.version = version == null ? null : version.copy();
    dst.name = name == null ? null : name.copy();
    dst.status = status == null ? null : status.copy();
    dst.experimental = experimental == null ? null : experimental.copy();
    dst.date = date == null ? null : date.copy();
    dst.publisher = publisher == null ? null : publisher.copy();
    if (contact != null) {
        dst.contact = new ArrayList<ConformanceContactComponent>();
        for (ConformanceContactComponent i : contact) dst.contact.add(i.copy());
    }
    ;
    dst.description = description == null ? null : description.copy();
    if (useContext != null) {
        dst.useContext = new ArrayList<CodeableConcept>();
        for (CodeableConcept i : useContext) dst.useContext.add(i.copy());
    }
    ;
    dst.requirements = requirements == null ? null : requirements.copy();
    dst.copyright = copyright == null ? null : copyright.copy();
    dst.kind = kind == null ? null : kind.copy();
    dst.software = software == null ? null : software.copy();
    dst.implementation = implementation == null ? null : implementation.copy();
    dst.fhirVersion = fhirVersion == null ? null : fhirVersion.copy();
    dst.acceptUnknown = acceptUnknown == null ? null : acceptUnknown.copy();
    if (format != null) {
        dst.format = new ArrayList<CodeType>();
        for (CodeType i : format) dst.format.add(i.copy());
    }
    ;
    if (profile != null) {
        dst.profile = new ArrayList<Reference>();
        for (Reference i : profile) dst.profile.add(i.copy());
    }
    ;
    if (rest != null) {
        dst.rest = new ArrayList<ConformanceRestComponent>();
        for (ConformanceRestComponent i : rest) dst.rest.add(i.copy());
    }
    ;
    if (messaging != null) {
        dst.messaging = new ArrayList<ConformanceMessagingComponent>();
        for (ConformanceMessagingComponent i : messaging) dst.messaging.add(i.copy());
    }
    ;
    if (document != null) {
        dst.document = new ArrayList<ConformanceDocumentComponent>();
        for (ConformanceDocumentComponent i : document) dst.document.add(i.copy());
    }
    ;
    return dst;
}
Also used : IBaseConformance(org.hl7.fhir.instance.model.api.IBaseConformance)

Example 44 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeImplementationGuide.

protected void composeImplementationGuide(Complex parent, String parentType, String name, ImplementationGuide element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "ImplementationGuide", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "ImplementationGuide", "url", element.getUrlElement(), -1);
    if (element.hasVersionElement())
        composeString(t, "ImplementationGuide", "version", element.getVersionElement(), -1);
    if (element.hasNameElement())
        composeString(t, "ImplementationGuide", "name", element.getNameElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "ImplementationGuide", "status", element.getStatusElement(), -1);
    if (element.hasExperimentalElement())
        composeBoolean(t, "ImplementationGuide", "experimental", element.getExperimentalElement(), -1);
    if (element.hasDateElement())
        composeDateTime(t, "ImplementationGuide", "date", element.getDateElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "ImplementationGuide", "publisher", element.getPublisherElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "ImplementationGuide", "contact", element.getContact().get(i), i);
    if (element.hasDescriptionElement())
        composeMarkdown(t, "ImplementationGuide", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "ImplementationGuide", "useContext", element.getUseContext().get(i), i);
    for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "ImplementationGuide", "jurisdiction", element.getJurisdiction().get(i), i);
    if (element.hasCopyrightElement())
        composeMarkdown(t, "ImplementationGuide", "copyright", element.getCopyrightElement(), -1);
    if (element.hasFhirVersionElement())
        composeId(t, "ImplementationGuide", "fhirVersion", element.getFhirVersionElement(), -1);
    for (int i = 0; i < element.getDependency().size(); i++) composeImplementationGuideImplementationGuideDependencyComponent(t, "ImplementationGuide", "dependency", element.getDependency().get(i), i);
    for (int i = 0; i < element.getPackage().size(); i++) composeImplementationGuideImplementationGuidePackageComponent(t, "ImplementationGuide", "package", element.getPackage().get(i), i);
    for (int i = 0; i < element.getGlobal().size(); i++) composeImplementationGuideImplementationGuideGlobalComponent(t, "ImplementationGuide", "global", element.getGlobal().get(i), i);
    for (int i = 0; i < element.getBinary().size(); i++) composeUri(t, "ImplementationGuide", "binary", element.getBinary().get(i), i);
    if (element.hasPage())
        composeImplementationGuideImplementationGuidePageComponent(t, "ImplementationGuide", "page", element.getPage(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 45 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeStructureDefinition.

protected void composeStructureDefinition(Complex parent, String parentType, String name, StructureDefinition element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "StructureDefinition", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "StructureDefinition", "url", element.getUrlElement(), -1);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "StructureDefinition", "identifier", element.getIdentifier().get(i), i);
    if (element.hasVersionElement())
        composeString(t, "StructureDefinition", "version", element.getVersionElement(), -1);
    if (element.hasNameElement())
        composeString(t, "StructureDefinition", "name", element.getNameElement(), -1);
    if (element.hasTitleElement())
        composeString(t, "StructureDefinition", "title", element.getTitleElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "StructureDefinition", "status", element.getStatusElement(), -1);
    if (element.hasExperimentalElement())
        composeBoolean(t, "StructureDefinition", "experimental", element.getExperimentalElement(), -1);
    if (element.hasDateElement())
        composeDateTime(t, "StructureDefinition", "date", element.getDateElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "StructureDefinition", "publisher", element.getPublisherElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "StructureDefinition", "contact", element.getContact().get(i), i);
    if (element.hasDescriptionElement())
        composeMarkdown(t, "StructureDefinition", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "StructureDefinition", "useContext", element.getUseContext().get(i), i);
    for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "StructureDefinition", "jurisdiction", element.getJurisdiction().get(i), i);
    if (element.hasPurposeElement())
        composeMarkdown(t, "StructureDefinition", "purpose", element.getPurposeElement(), -1);
    if (element.hasCopyrightElement())
        composeMarkdown(t, "StructureDefinition", "copyright", element.getCopyrightElement(), -1);
    for (int i = 0; i < element.getKeyword().size(); i++) composeCoding(t, "StructureDefinition", "keyword", element.getKeyword().get(i), i);
    if (element.hasFhirVersionElement())
        composeId(t, "StructureDefinition", "fhirVersion", element.getFhirVersionElement(), -1);
    for (int i = 0; i < element.getMapping().size(); i++) composeStructureDefinitionStructureDefinitionMappingComponent(t, "StructureDefinition", "mapping", element.getMapping().get(i), i);
    if (element.hasKindElement())
        composeEnum(t, "StructureDefinition", "kind", element.getKindElement(), -1);
    if (element.hasAbstractElement())
        composeBoolean(t, "StructureDefinition", "abstract", element.getAbstractElement(), -1);
    if (element.hasContextTypeElement())
        composeEnum(t, "StructureDefinition", "contextType", element.getContextTypeElement(), -1);
    for (int i = 0; i < element.getContext().size(); i++) composeString(t, "StructureDefinition", "context", element.getContext().get(i), i);
    for (int i = 0; i < element.getContextInvariant().size(); i++) composeString(t, "StructureDefinition", "contextInvariant", element.getContextInvariant().get(i), i);
    if (element.hasTypeElement())
        composeCode(t, "StructureDefinition", "type", element.getTypeElement(), -1);
    if (element.hasBaseDefinitionElement())
        composeUri(t, "StructureDefinition", "baseDefinition", element.getBaseDefinitionElement(), -1);
    if (element.hasDerivationElement())
        composeEnum(t, "StructureDefinition", "derivation", element.getDerivationElement(), -1);
    if (element.hasSnapshot())
        composeStructureDefinitionStructureDefinitionSnapshotComponent(t, "StructureDefinition", "snapshot", element.getSnapshot(), -1);
    if (element.hasDifferential())
        composeStructureDefinitionStructureDefinitionDifferentialComponent(t, "StructureDefinition", "differential", element.getDifferential(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Aggregations

ArrayList (java.util.ArrayList)10 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)9 JsonObject (com.google.gson.JsonObject)8 Date (java.util.Date)8 IOException (java.io.IOException)7 FhirContext (ca.uhn.fhir.context.FhirContext)6 JsonArray (com.google.gson.JsonArray)6 HashMap (java.util.HashMap)5 FhirVersionEnum (ca.uhn.fhir.context.FhirVersionEnum)4 IParser (ca.uhn.fhir.parser.IParser)4 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)4 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)4 JsonPrimitive (com.google.gson.JsonPrimitive)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 Bundle (org.hl7.fhir.r4.model.Bundle)3 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)3 CascadingDeleteInterceptor (ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor)2