Search in sources :

Example 81 with Period

use of org.hl7.fhir.r4.model.Period in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeDocumentReferenceDocumentReferenceContextComponent.

protected void composeDocumentReferenceDocumentReferenceContextComponent(Complex parent, String parentType, String name, DocumentReference.DocumentReferenceContextComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "context", name, element, index);
    if (element.hasEncounter())
        composeReference(t, "DocumentReference", "encounter", element.getEncounter(), -1);
    for (int i = 0; i < element.getEvent().size(); i++) composeCodeableConcept(t, "DocumentReference", "event", element.getEvent().get(i), i);
    if (element.hasPeriod())
        composePeriod(t, "DocumentReference", "period", element.getPeriod(), -1);
    if (element.hasFacilityType())
        composeCodeableConcept(t, "DocumentReference", "facilityType", element.getFacilityType(), -1);
    if (element.hasPracticeSetting())
        composeCodeableConcept(t, "DocumentReference", "practiceSetting", element.getPracticeSetting(), -1);
    if (element.hasSourcePatientInfo())
        composeReference(t, "DocumentReference", "sourcePatientInfo", element.getSourcePatientInfo(), -1);
    for (int i = 0; i < element.getRelated().size(); i++) composeDocumentReferenceDocumentReferenceContextRelatedComponent(t, "DocumentReference", "related", element.getRelated().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 82 with Period

use of org.hl7.fhir.r4.model.Period in project org.hl7.fhir.core by hapifhir.

the class Convert method makeTimingFromBoundedPIVL.

private Timing makeTimingFromBoundedPIVL(Element ivl, Element pivl) throws Exception {
    Timing t = new Timing();
    t.setRepeat(new TimingRepeatComponent());
    Element p = cda.getChild(pivl, "period");
    t.getRepeat().setBounds(makePeriodFromIVL(ivl));
    t.getRepeat().setPeriod(new BigDecimal(p.getAttribute("value")));
    t.getRepeat().setPeriodUnit(convertTimeUnit(p.getAttribute("unit")));
    return t;
}
Also used : Element(org.w3c.dom.Element) TimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent) EventTiming(org.hl7.fhir.dstu3.model.Timing.EventTiming) BigDecimal(java.math.BigDecimal)

Example 83 with Period

use of org.hl7.fhir.r4.model.Period in project org.hl7.fhir.core by hapifhir.

the class JsonParser method composeType.

protected void composeType(String prefix, Type type) throws IOException {
    if (type == null)
        ;
    else if (type instanceof Age)
        composeAge(prefix + "Age", (Age) type);
    else if (type instanceof Count)
        composeCount(prefix + "Count", (Count) type);
    else if (type instanceof Money)
        composeMoney(prefix + "Money", (Money) type);
    else if (type instanceof Distance)
        composeDistance(prefix + "Distance", (Distance) type);
    else if (type instanceof Duration)
        composeDuration(prefix + "Duration", (Duration) type);
    else if (type instanceof SimpleQuantity)
        composeSimpleQuantity(prefix + "SimpleQuantity", (SimpleQuantity) type);
    else if (type instanceof Period)
        composePeriod(prefix + "Period", (Period) type);
    else if (type instanceof Coding)
        composeCoding(prefix + "Coding", (Coding) type);
    else if (type instanceof Range)
        composeRange(prefix + "Range", (Range) type);
    else if (type instanceof Quantity)
        composeQuantity(prefix + "Quantity", (Quantity) type);
    else if (type instanceof Attachment)
        composeAttachment(prefix + "Attachment", (Attachment) type);
    else if (type instanceof Ratio)
        composeRatio(prefix + "Ratio", (Ratio) type);
    else if (type instanceof Annotation)
        composeAnnotation(prefix + "Annotation", (Annotation) type);
    else if (type instanceof SampledData)
        composeSampledData(prefix + "SampledData", (SampledData) type);
    else if (type instanceof Reference)
        composeReference(prefix + "Reference", (Reference) type);
    else if (type instanceof CodeableConcept)
        composeCodeableConcept(prefix + "CodeableConcept", (CodeableConcept) type);
    else if (type instanceof Identifier)
        composeIdentifier(prefix + "Identifier", (Identifier) type);
    else if (type instanceof Signature)
        composeSignature(prefix + "Signature", (Signature) type);
    else if (type instanceof TriggerDefinition)
        composeTriggerDefinition(prefix + "TriggerDefinition", (TriggerDefinition) type);
    else if (type instanceof ElementDefinition)
        composeElementDefinition(prefix + "ElementDefinition", (ElementDefinition) type);
    else if (type instanceof Timing)
        composeTiming(prefix + "Timing", (Timing) type);
    else if (type instanceof ModuleMetadata)
        composeModuleMetadata(prefix + "ModuleMetadata", (ModuleMetadata) type);
    else if (type instanceof ActionDefinition)
        composeActionDefinition(prefix + "ActionDefinition", (ActionDefinition) type);
    else if (type instanceof Address)
        composeAddress(prefix + "Address", (Address) type);
    else if (type instanceof HumanName)
        composeHumanName(prefix + "HumanName", (HumanName) type);
    else if (type instanceof DataRequirement)
        composeDataRequirement(prefix + "DataRequirement", (DataRequirement) type);
    else if (type instanceof Meta)
        composeMeta(prefix + "Meta", (Meta) type);
    else if (type instanceof ParameterDefinition)
        composeParameterDefinition(prefix + "ParameterDefinition", (ParameterDefinition) type);
    else if (type instanceof ContactPoint)
        composeContactPoint(prefix + "ContactPoint", (ContactPoint) type);
    else if (type instanceof MarkdownType) {
        composeMarkdownCore(prefix + "Markdown", (MarkdownType) type, false);
        composeMarkdownExtras(prefix + "Markdown", (MarkdownType) type, false);
    } else if (type instanceof UnsignedIntType) {
        composeUnsignedIntCore(prefix + "UnsignedInt", (UnsignedIntType) type, false);
        composeUnsignedIntExtras(prefix + "UnsignedInt", (UnsignedIntType) type, false);
    } else if (type instanceof CodeType) {
        composeCodeCore(prefix + "Code", (CodeType) type, false);
        composeCodeExtras(prefix + "Code", (CodeType) type, false);
    } else if (type instanceof IdType) {
        composeIdCore(prefix + "Id", (IdType) type, false);
        composeIdExtras(prefix + "Id", (IdType) type, false);
    } else if (type instanceof OidType) {
        composeOidCore(prefix + "Oid", (OidType) type, false);
        composeOidExtras(prefix + "Oid", (OidType) type, false);
    } else if (type instanceof PositiveIntType) {
        composePositiveIntCore(prefix + "PositiveInt", (PositiveIntType) type, false);
        composePositiveIntExtras(prefix + "PositiveInt", (PositiveIntType) type, false);
    } else if (type instanceof UuidType) {
        composeUuidCore(prefix + "Uuid", (UuidType) type, false);
        composeUuidExtras(prefix + "Uuid", (UuidType) type, false);
    } else if (type instanceof IntegerType) {
        composeIntegerCore(prefix + "Integer", (IntegerType) type, false);
        composeIntegerExtras(prefix + "Integer", (IntegerType) type, false);
    } else if (type instanceof DateTimeType) {
        composeDateTimeCore(prefix + "DateTime", (DateTimeType) type, false);
        composeDateTimeExtras(prefix + "DateTime", (DateTimeType) type, false);
    } else if (type instanceof DateType) {
        composeDateCore(prefix + "Date", (DateType) type, false);
        composeDateExtras(prefix + "Date", (DateType) type, false);
    } else if (type instanceof DecimalType) {
        composeDecimalCore(prefix + "Decimal", (DecimalType) type, false);
        composeDecimalExtras(prefix + "Decimal", (DecimalType) type, false);
    } else if (type instanceof UriType) {
        composeUriCore(prefix + "Uri", (UriType) type, false);
        composeUriExtras(prefix + "Uri", (UriType) type, false);
    } else if (type instanceof Base64BinaryType) {
        composeBase64BinaryCore(prefix + "Base64Binary", (Base64BinaryType) type, false);
        composeBase64BinaryExtras(prefix + "Base64Binary", (Base64BinaryType) type, false);
    } else if (type instanceof TimeType) {
        composeTimeCore(prefix + "Time", (TimeType) type, false);
        composeTimeExtras(prefix + "Time", (TimeType) type, false);
    } else if (type instanceof StringType) {
        composeStringCore(prefix + "String", (StringType) type, false);
        composeStringExtras(prefix + "String", (StringType) type, false);
    } else if (type instanceof BooleanType) {
        composeBooleanCore(prefix + "Boolean", (BooleanType) type, false);
        composeBooleanExtras(prefix + "Boolean", (BooleanType) type, false);
    } else if (type instanceof InstantType) {
        composeInstantCore(prefix + "Instant", (InstantType) type, false);
        composeInstantExtras(prefix + "Instant", (InstantType) type, false);
    } else
        throw new Error("Unhandled type");
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 84 with Period

use of org.hl7.fhir.r4.model.Period in project org.hl7.fhir.core by hapifhir.

the class ProfileUtilitiesTests method testSlicingExtensionComplex.

/**
 * we're going to slice Patient.extension and refer to extension by profile. one of the extensions is complex, and we're going to walk into
 * it and make it must support
 *
 * implicit: whether to rely on implicit extension slicing
 */
private void testSlicingExtensionComplex(boolean implicit) throws EOperationOutcome, Exception {
    StructureDefinition focus = new StructureDefinition();
    StructureDefinition base = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy();
    focus.setUrl(Utilities.makeUuidUrn());
    focus.setBase(base.getUrl());
    // set the slice up
    ElementDefinition id;
    if (!implicit) {
        id = focus.getDifferential().addElement();
        id.setPath("Patient.extension");
        id.getSlicing().setOrdered(false).setRules(SlicingRules.OPEN).addDiscriminator("url");
    }
    // first slice  - a simple one to get us going:
    id = focus.getDifferential().addElement();
    id.setPath("Patient.extension");
    id.setName("simple");
    id.addType().setCode("Extension").addProfile("http://hl7.org/fhir/StructureDefinition/patient-birthTime");
    // second slice - the complex one
    // we walk into this and fix properties on the inner extensions
    id = focus.getDifferential().addElement();
    id.setPath("Patient.extension");
    id.setName("complex");
    id.addType().setCode("Extension").addProfile("http://hl7.org/fhir/StructureDefinition/patient-nationality");
    if (!implicit) {
        id = focus.getDifferential().addElement();
        id.setPath("Patient.extension.extension");
        id.getSlicing().setOrdered(false).setRules(SlicingRules.OPEN).addDiscriminator("url");
    }
    id = focus.getDifferential().addElement();
    id.setPath("Patient.extension.extension");
    id.setName("code");
    id.setMustSupport(true);
    id.addType().setCode("Extension").addProfile("http://hl7.org/fhir/StructureDefinition/patient-nationality#code");
    id = focus.getDifferential().addElement();
    id.setPath("Patient.extension.extension");
    id.setName("period");
    id.addType().setCode("Extension").addProfile("http://hl7.org/fhir/StructureDefinition/patient-nationality#period");
    // prohibit this one....
    id.setMax("0");
    List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
    new ProfileUtilities(context, messages, null).generateSnapshot(base, focus, focus.getUrl(), "Simple Test");
    // ok, there's going to 1 (simple) + complex: 1 + id + extnesion.slice + extension.code + (4 inside from that) + extension.period + (4 inside from that) + value + url = 16
    boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size() - 16;
    // custom checks
    ok = ok && rule(focus.getSnapshot().getElement().get(7).getPath().equals("Patient.extension"), "element 7 (base) path");
    ok = ok && rule(focus.getSnapshot().getElement().get(7).hasSlicing(), "element 7 slicing");
    ok = ok && rule(focus.getSnapshot().getElement().get(8).getPath().equals("Patient.extension"), "element 8 (1st slice) path");
    ok = ok && rule(focus.getSnapshot().getElement().get(8).getName().equals("simple"), "element 8 (1st slice) name");
    ok = ok && rule(focus.getSnapshot().getElement().get(8).getType().get(0).getProfile().get(0).getValue().equals("http://hl7.org/fhir/StructureDefinition/patient-birthTime"), "element 9 (2nd slice) profile name");
    ok = ok && rule(focus.getSnapshot().getElement().get(9).getPath().equals("Patient.extension"), "element 9 (2nd slice) path");
    ok = ok && rule(focus.getSnapshot().getElement().get(9).getName().equals("complex"), "element 8 (1st slice) name");
    ok = ok && rule(focus.getSnapshot().getElement().get(9).getType().get(0).getProfile().get(0).getValue().equals("http://hl7.org/fhir/StructureDefinition/patient-nationality"), "element 9 (2nd slice) profile name");
    ok = ok && rule(focus.getSnapshot().getElement().get(10).getPath().equals("Patient.extension.id"), "element 10 (2nd slice).id path");
    ok = ok && rule(focus.getSnapshot().getElement().get(11).getPath().equals("Patient.extension.extension"), "element 11 (2nd slice).extension path");
    ok = ok && rule(focus.getSnapshot().getElement().get(12).getPath().equals("Patient.extension.extension"), "element 12 (2nd slice).extension path");
    ok = ok && rule(focus.getSnapshot().getElement().get(12).getMustSupport(), "element 12 (2nd slice).extension must support");
    ok = ok && rule(focus.getSnapshot().getElement().get(13).getPath().equals("Patient.extension.extension.id"), "element 13 (2nd slice).extension.id path");
    ok = ok && rule(focus.getSnapshot().getElement().get(14).getPath().equals("Patient.extension.extension.extension"), "element 14 (2nd slice).extension.extension path");
    ok = ok && rule(focus.getSnapshot().getElement().get(15).getPath().equals("Patient.extension.extension.url"), "element 15 (2nd slice).extension.url path");
    ok = ok && rule(focus.getSnapshot().getElement().get(16).getPath().equals("Patient.extension.extension.valueCodeableConcept"), "element 16 (2nd slice).extension.valueCodeableConcept path");
    ok = ok && rule(focus.getSnapshot().getElement().get(17).getPath().equals("Patient.extension.extension"), "element 17 (2nd slice).extension path");
    ok = ok && rule(focus.getSnapshot().getElement().get(17).getMax().equals("0"), "element 17 (2nd slice).extension cardinality");
    ok = ok && rule(focus.getSnapshot().getElement().get(18).getPath().equals("Patient.extension.extension.id"), "element 18 (2nd slice).extension.id path");
    ok = ok && rule(focus.getSnapshot().getElement().get(19).getPath().equals("Patient.extension.extension.extension"), "element 19 (2nd slice).extension.extension path");
    ok = ok && rule(focus.getSnapshot().getElement().get(20).getPath().equals("Patient.extension.extension.url"), "element 20 (2nd slice).extension.url path");
    ok = ok && rule(focus.getSnapshot().getElement().get(21).getPath().equals("Patient.extension.extension.valuePeriod"), "element 21 (2nd slice).extension.valuePeriod path");
    ok = ok && rule(focus.getSnapshot().getElement().get(22).getPath().equals("Patient.extension.url"), "element 22 (2nd slice).url path");
    ok = ok && rule(focus.getSnapshot().getElement().get(23).getPath().equals("Patient.extension.value[x]"), "element 23 (2nd slice).url path");
    for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
        if (ok) {
            ElementDefinition b = base.getSnapshot().getElement().get(i);
            ElementDefinition f = focus.getSnapshot().getElement().get(i <= 7 ? i : i + 16);
            if (!f.hasBase() || !b.getPath().equals(f.getBase().getPath()))
                ok = false;
            else {
                f.setBase(null);
                if (f.getPath().equals("Patient.extension")) {
                    ok = f.hasSlicing();
                    if (ok)
                        f.setSlicing(null);
                }
                if (// no compare that because the definitions get overwritten
                !f.getPath().equals("Patient.extension"))
                    ok = Base.compareDeep(b, f, true);
            }
        }
    }
    if (!ok) {
        compareXml(base, focus);
        throw new FHIRException("Snap shot generation slicing extensions complex (" + (implicit ? "implicit" : "not implicit") + ") failed");
    } else
        System.out.println("Snap shot generation slicing extensions complex (" + (implicit ? "implicit" : "not implicit") + ") passed");
}
Also used : StructureDefinition(org.hl7.fhir.dstu2.model.StructureDefinition) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ProfileUtilities(org.hl7.fhir.dstu2.utils.ProfileUtilities) ArrayList(java.util.ArrayList) ElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 85 with Period

use of org.hl7.fhir.r4.model.Period in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeResearchSubject.

protected void composeResearchSubject(Complex parent, String parentType, String name, ResearchSubject element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "ResearchSubject", name, element, index);
    if (element.hasIdentifier())
        composeIdentifier(t, "ResearchSubject", "identifier", element.getIdentifier(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "ResearchSubject", "status", element.getStatusElement(), -1);
    if (element.hasPeriod())
        composePeriod(t, "ResearchSubject", "period", element.getPeriod(), -1);
    if (element.hasStudy())
        composeReference(t, "ResearchSubject", "study", element.getStudy(), -1);
    if (element.hasIndividual())
        composeReference(t, "ResearchSubject", "individual", element.getIndividual(), -1);
    if (element.hasAssignedArmElement())
        composeString(t, "ResearchSubject", "assignedArm", element.getAssignedArmElement(), -1);
    if (element.hasActualArmElement())
        composeString(t, "ResearchSubject", "actualArm", element.getActualArmElement(), -1);
    if (element.hasConsent())
        composeReference(t, "ResearchSubject", "consent", element.getConsent(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Aggregations

Period (org.hl7.fhir.r4.model.Period)87 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)44 Date (java.util.Date)42 Test (org.junit.Test)42 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)40 Coding (org.hl7.fhir.r4.model.Coding)34 Test (org.junit.jupiter.api.Test)34 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)32 Period (org.hl7.fhir.dstu3.model.Period)30 ArrayList (java.util.ArrayList)29 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)27 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)20 Encounter (org.hl7.fhir.r4.model.Encounter)20 Reference (org.hl7.fhir.r4.model.Reference)20 Patient (org.hl7.fhir.r4.model.Patient)19 Reference (org.hl7.fhir.dstu3.model.Reference)18 HashMap (java.util.HashMap)17 Identifier (org.hl7.fhir.r4.model.Identifier)17 NotImplementedException (org.apache.commons.lang3.NotImplementedException)15 List (java.util.List)14