Search in sources :

Example 11 with StringType

use of org.hl7.fhir.dstu2016may.model.StringType in project kindling by HL7.

the class ProfileGenerator method buildDefinitionFromElement.

private void buildDefinitionFromElement(String path, ElementDefinition ce, ElementDefn e, Profile ap, StructureDefinition p, String inheritedType, boolean isInterface) throws Exception {
    if (!Utilities.noString(e.getComments()))
        ce.setComment(preProcessMarkdown(e.getComments(), "Element Comments"));
    if (!Utilities.noString(e.getShortDefn()))
        ce.setShort(e.getShortDefn());
    if (!Utilities.noString(e.getDefinition())) {
        ce.setDefinition(preProcessMarkdown(e.getDefinition(), "Element Definition"));
        if (!Utilities.noString(e.getShortDefn()))
            ce.setShort(e.getShortDefn());
    }
    if (path.contains(".") && !Utilities.noString(e.getRequirements()))
        ce.setRequirements(preProcessMarkdown(e.getRequirements(), "Element Requirements"));
    if (e.hasMustSupport())
        ce.setMustSupport(e.isMustSupport());
    if (!Utilities.noString(e.getMaxLength()))
        ce.setMaxLength(Integer.parseInt(e.getMaxLength()));
    // no purpose here
    if (e.getMinCardinality() != null)
        ce.setMin(e.getMinCardinality());
    if (e.getMaxCardinality() != null)
        ce.setMax(e.getMaxCardinality() == Integer.MAX_VALUE ? "*" : e.getMaxCardinality().toString());
    // we don't know mustSupport here
    if (e.hasModifier())
        ce.setIsModifier(e.isModifier());
    if (ce.getIsModifier())
        ce.setIsModifierReason(e.getModifierReason());
    // ce.setConformance(getType(e.getConformance()));
    for (Invariant id : e.getStatedInvariants()) {
        ce.addCondition(id.getId());
    }
    ce.setFixed(e.getFixed());
    ce.setPattern(e.getPattern());
    // ce.setDefaultValue(e.getDefaultValue());
    ce.setMeaningWhenMissing(e.getMeaningWhenMissing());
    if (e.getExample() != null)
        ce.addExample().setLabel("General").setValue(e.getExample());
    for (Integer i : e.getOtherExamples().keySet()) {
        Extension ex = ce.addExtension();
        ex.setUrl("http://hl7.org/fhir/StructureDefinition/structuredefinition-example");
        ex.addExtension().setUrl("index").setValue(new StringType(i.toString()));
        ex.addExtension().setUrl("exValue").setValue(e.getOtherExamples().get(i));
    }
    for (String s : e.getAliases()) ce.addAlias(s);
    if (e.hasSummaryItem() && ce.getPath().contains("."))
        ce.setIsSummaryElement(Factory.newBoolean(e.isSummary()));
    for (String n : definitions.getMapTypes().keySet()) {
        addMapping(p, ce, n, e.getMapping(n), null);
    }
    if (ap != null) {
        for (String n : ap.getMappingSpaces().keySet()) {
            addMapping(p, ce, n, e.getMapping(n), ap);
        }
    }
    ToolingExtensions.addDisplayHint(ce, e.getDisplayHint());
    if (!isInterface) {
        convertConstraints(e, ce, inheritedType == null ? p.getUrl() : "http://hl7.org/fhir/StructureDefinition/" + inheritedType);
    }
// we don't have anything to say about constraints on resources
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) Invariant(org.hl7.fhir.definitions.model.Invariant) StringType(org.hl7.fhir.r5.model.StringType)

Example 12 with StringType

use of org.hl7.fhir.dstu2016may.model.StringType in project kindling by HL7.

the class ProfileGenerator method produceOpParam.

private void produceOpParam(String path, List<OperationDefinitionParameterComponent> opd, OperationParameter p, OperationParameterUse defUse) throws Exception {
    OperationDefinitionParameterComponent pp = new OperationDefinitionParameterComponent();
    pp.setName(p.getName());
    if (path.contains("."))
        pp.setUse(defUse);
    else if (p.getUse().equals("in"))
        pp.setUse(OperationParameterUse.IN);
    else if (p.getUse().equals("out"))
        pp.setUse(OperationParameterUse.OUT);
    else
        // but this is validated elsewhere
        throw new Exception("Unable to determine parameter use: " + p.getUse() + " at " + path + "." + p.getName());
    pp.setDocumentation(preProcessMarkdown(p.getDoc(), "Operation Parameter Doco"));
    pp.setMin(p.getMin());
    pp.setMax(p.getMax());
    if (p.getBs() != null) {
        if (p.getBs().hasMax())
            throw new Error("Max binding not handled yet");
        pp.setBinding(new OperationDefinitionParameterBindingComponent().setStrength(p.getBs().getStrength()).setValueSet(buildValueSetReference(p.getBs())));
        if (!Utilities.noString(p.getBinding().getName())) {
            pp.getBinding().addExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName", new StringType(p.getBinding().getName()));
        }
    }
    if (!Utilities.noString(p.getProfile())) {
        pp.addTargetProfile(p.getProfile());
    }
    opd.add(pp);
    if (p.getFhirType().equals("Tuple")) {
        for (OperationParameter part : p.getParts()) {
            produceOpParam(path + "." + p.getName(), pp.getPart(), part, pp.getUse());
        }
    } else {
        List<TypeRef> trs = new TypeParser(version.toCode()).parse(p.getFhirType(), false, null, null, false);
        if (trs.size() > 1) {
            if (p.getSearchType() != null)
                pp.setSearchType(SearchParamType.fromCode(p.getSearchType()));
            pp.setType(Enumerations.FHIRAllTypes.fromCode("Element"));
            for (TypeRef tr : trs) {
                pp.addExtension(ToolingExtensions.EXT_ALLOWED_TYPE, new UriType(tr.getName()));
                if (tr.getParams().size() > 0)
                    throw new Error("Multiple types for an operation parameter, where one is a reference, is not supported by the build tools");
            }
        } else {
            TypeRef tr = trs.get(0);
            if (definitions.getConstraints().containsKey(tr.getName())) {
                ProfiledType pt = definitions.getConstraints().get(tr.getName());
                pp.setType(Enumerations.FHIRAllTypes.fromCode(pt.getBaseType().equals("*") ? "Type" : pt.getBaseType()));
                pp.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + pt.getName());
            } else {
                if (p.getSearchType() != null)
                    pp.setSearchType(SearchParamType.fromCode(p.getSearchType()));
                pp.setType(Enumerations.FHIRAllTypes.fromCode(tr.getName().equals("*") ? "Type" : tr.getName()));
                if (tr.getParams().size() == 1 && !tr.getParams().get(0).equals("Any"))
                    pp.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + tr.getParams().get(0));
            }
        }
    }
}
Also used : TypeParser(org.hl7.fhir.definitions.parsers.TypeParser) ProfiledType(org.hl7.fhir.definitions.model.ProfiledType) StringType(org.hl7.fhir.r5.model.StringType) TypeRef(org.hl7.fhir.definitions.model.TypeRef) OperationDefinitionParameterBindingComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterBindingComponent) OperationParameter(org.hl7.fhir.definitions.model.OperationParameter) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent) UriType(org.hl7.fhir.r5.model.UriType)

Example 13 with StringType

use of org.hl7.fhir.dstu2016may.model.StringType in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7PatientFHIRConversionTest method patientNameTest.

@Test
void patientNameTest() {
    String patientHasMiddleName = "MSH|^~\\&|MyEMR|DE-000001| |CAIRLO|20160701123030-0700||VXU^V04^VXU_V04|CA0001|P|2.6|||ER|AL|||||Z22^CDCPHINVS|DE-000001\r" + // PID 5 fields (name) are extracted and tested
    "PID|1||PA123456^^^MYEMR^MR||JONES^GEORGE^Q^III^MR^^B||||||||||||||||||||\r";
    Patient patientObjUsualName = PatientUtils.createPatientFromHl7Segment(ftv, patientHasMiddleName);
    java.util.List<org.hl7.fhir.r4.model.HumanName> name = patientObjUsualName.getName();
    List<StringType> givenName = name.get(0).getGiven();
    List<StringType> suffixes = name.get(0).getSuffix();
    assertThat(suffixes).hasSize(1);
    List<StringType> prefixes = name.get(0).getPrefix();
    assertThat(prefixes).hasSize(1);
    String fullName = name.get(0).getText();
    assertThat(prefixes.get(0).toString()).hasToString("MR");
    assertThat(givenName.get(0).toString()).hasToString("GEORGE");
    assertThat(givenName.get(1).toString()).hasToString("Q");
    assertThat(suffixes.get(0).toString()).hasToString("III");
    assertThat(fullName).isEqualTo("MR GEORGE Q JONES III");
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) StringType(org.hl7.fhir.r4.model.StringType) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with StringType

use of org.hl7.fhir.dstu2016may.model.StringType in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ObservationFHIRConversionTest method testObservationSTMultiplePartsResult.

@Test
void testObservationSTMultiplePartsResult() throws IOException {
    String hl7message = baseMessage + "OBX|1|ST|^Type of protein feed^L||HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%~Fifth line, as part of a repeated field||||||F||";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(1);
    Observation obs = (Observation) obsResource.get(0);
    assertThat(obs.getValueStringType()).isNotNull();
    StringType q = obs.getValueStringType();
    assertThat(q.asStringValue()).isEqualTo("HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%. Fifth line, as part of a repeated field.");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) StringType(org.hl7.fhir.r4.model.StringType) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with StringType

use of org.hl7.fhir.dstu2016may.model.StringType in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ObservationFHIRConversionTest method testObservationSTResult.

@Test
void testObservationSTResult() throws IOException {
    String hl7message = baseMessage + "OBX|1|ST|^Type of protein feed^L||Fourth Line: HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%||||||F||||Alex||";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(1);
    Observation obs = (Observation) obsResource.get(0);
    assertThat(obs.getValueStringType()).isNotNull();
    StringType q = obs.getValueStringType();
    assertThat(q.asStringValue()).isEqualTo("Fourth Line: HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) StringType(org.hl7.fhir.r4.model.StringType) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

StringType (org.hl7.fhir.r4.model.StringType)158 ArrayList (java.util.ArrayList)77 Test (org.junit.jupiter.api.Test)77 StringType (org.hl7.fhir.dstu3.model.StringType)65 Parameters (org.hl7.fhir.r4.model.Parameters)62 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)62 StringType (org.hl7.fhir.r5.model.StringType)61 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)58 StringType (org.hl7.fhir.r4b.model.StringType)45 FHIRException (org.hl7.fhir.exceptions.FHIRException)43 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)42 HashMap (java.util.HashMap)28 StringType (org.hl7.fhir.dstu2.model.StringType)27 StringType (org.hl7.fhir.dstu2016may.model.StringType)26 Coding (org.hl7.fhir.r4.model.Coding)26 Extension (org.hl7.fhir.r4.model.Extension)25 Measure (org.hl7.fhir.r4.model.Measure)23 Test (org.junit.Test)23 Base (org.hl7.fhir.r5.model.Base)20 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19