Search in sources :

Example 66 with StringType

use of org.hl7.fhir.r4.model.StringType in project openmrs-module-fhir2 by openmrs.

the class PersonNameTranslatorImplTest method shouldConvertExtensionToFamilyNameSuffix.

@Test
public void shouldConvertExtensionToFamilyNameSuffix() {
    HumanName name = new HumanName();
    Extension nameExtension = name.addExtension();
    nameExtension.setUrl(FhirConstants.OPENMRS_FHIR_EXT_NAME);
    nameExtension.addExtension(FhirConstants.OPENMRS_FHIR_EXT_NAME + "#familyNameSuffix", new StringType(PERSON_MIDDLE_NAME));
    assertThat(personNameTranslator.toOpenmrsType(name).getFamilyNameSuffix(), equalTo(PERSON_MIDDLE_NAME));
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) HumanName(org.hl7.fhir.r4.model.HumanName) StringType(org.hl7.fhir.r4.model.StringType) Test(org.junit.Test)

Example 67 with StringType

use of org.hl7.fhir.r4.model.StringType in project openmrs-module-fhir2 by openmrs.

the class BaseGroupTranslator method toFhirResource.

public Group toFhirResource(@Nonnull Cohort cohort) {
    notNull(cohort, "Cohort object should not be null");
    Group group = new Group();
    group.setId(cohort.getUuid());
    group.setActive(!cohort.getVoided());
    /*
		 * Apparently, cohort.description is a required field
		 */
    group.addExtension(new Extension().setUrl(FhirConstants.OPENMRS_FHIR_EXT_GROUP_DESCRIPTION).setValue(new StringType(cohort.getDescription())));
    // Not sure about this, It's either actual or descriptive
    // I will set actual - true temporarily as it required - valid resource.
    group.setActual(true);
    // Set to always person for now
    group.setType(Group.GroupType.PERSON);
    group.setName(cohort.getName());
    group.setManagingEntity(practitionerReferenceTranslator.toFhirResource(cohort.getCreator()));
    return group;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Group(org.hl7.fhir.r4.model.Group) StringType(org.hl7.fhir.r4.model.StringType)

Example 68 with StringType

use of org.hl7.fhir.r4.model.StringType in project Gravity-SDOH-Exchange-RI by FHIR.

the class AssessmentResponseToDtoConverter2 method convert.

@Override
public List<AssessmentResponse> convert(AseessmentInfoBundleExtractor.AssessmentInfoHolder infoHolder) {
    return infoHolder.getQuestionnaireResponse().getItem().stream().map(qr -> {
        AssessmentResponse assessmentResponse = new AssessmentResponse();
        assessmentResponse.setQuestion(new StringTypeDto(qr.getText()));
        Type itemAnswer = qr.getAnswerFirstRep().getValue();
        if (itemAnswer instanceof StringType) {
            assessmentResponse.setAnswer(new StringTypeDto(((StringType) itemAnswer).getValue()));
        } else if (itemAnswer instanceof Coding) {
            assessmentResponse.setAnswer(new StringTypeDto(((Coding) itemAnswer).getDisplay()));
        } else {
            assessmentResponse.getErrors().add(String.format("Answer cannot be resolved. %s type is not expected.", itemAnswer.getClass().getSimpleName()));
            assessmentResponse.setAnswer(new StringTypeDto("Answer cannot be parsed."));
        }
        return assessmentResponse;
    }).collect(Collectors.toList());
}
Also used : StringTypeDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.StringTypeDto) Converter(org.springframework.core.convert.converter.Converter) List(java.util.List) Type(org.hl7.fhir.r4.model.Type) AssessmentResponse(org.hl7.gravity.refimpl.sdohexchange.dto.response.AssessmentDto.AssessmentResponse) Coding(org.hl7.fhir.r4.model.Coding) StringType(org.hl7.fhir.r4.model.StringType) AseessmentInfoBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.AseessmentInfoBundleExtractor) Collectors(java.util.stream.Collectors) Type(org.hl7.fhir.r4.model.Type) StringType(org.hl7.fhir.r4.model.StringType) StringTypeDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.StringTypeDto) StringType(org.hl7.fhir.r4.model.StringType) Coding(org.hl7.fhir.r4.model.Coding) AssessmentResponse(org.hl7.gravity.refimpl.sdohexchange.dto.response.AssessmentDto.AssessmentResponse)

Example 69 with StringType

use of org.hl7.fhir.r4.model.StringType in project Gravity-SDOH-Exchange-RI by FHIR.

the class EthnicityBundleFactory method createObservation.

@Override
protected Observation createObservation() {
    Observation obs = super.createObservation();
    obs.getMeta().addProfile(UsCorePersonalCharacteristicProfile.ETHNICITY);
    boolean valueIsSet = false;
    if (value != null) {
        valueIsSet = true;
        obs.addComponent().setCode(new CodeableConcept(CharacteristicCode.ETHNICITY.toCoding())).setValue(new CodeableConcept(value.toCoding()));
    }
    if (detailedValues != null && detailedValues.length != 0) {
        valueIsSet = true;
        Lists.newArrayList(detailedValues).stream().distinct().forEach(v -> obs.addComponent().setCode(new CodeableConcept(CharacteristicCode.ETHNICITY.toCoding())).setValue(new CodeableConcept(DetailedEthnicityCode.toCoding(v))));
    }
    if (ObjectUtils.isNotEmpty(description)) {
        valueIsSet = true;
        obs.addComponent().setCode(new CodeableConcept(CharacteristicCode.ETHNICITY.toCoding())).setValue(new StringType(description));
    }
    Assert.isTrue(valueIsSet, "At least one of ethnicity, detailed ethnicity or description must be set.");
    return obs;
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) Observation(org.hl7.fhir.r4.model.Observation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 70 with StringType

use of org.hl7.fhir.r4.model.StringType in project Gravity-SDOH-Exchange-RI by FHIR.

the class RaceBundleFactory method createObservation.

@Override
protected Observation createObservation() {
    Observation obs = super.createObservation();
    obs.getMeta().addProfile(UsCorePersonalCharacteristicProfile.RACE);
    boolean valueIsSet = false;
    if (values != null && values.length != 0) {
        Assert.isTrue(values.length < 6, "Not more than 5 races are expected.");
        valueIsSet = true;
        Lists.newArrayList(values).stream().distinct().forEach(v -> obs.addComponent().setCode(new CodeableConcept(CharacteristicCode.RACE.toCoding())).setValue(new CodeableConcept(v.toCoding())));
    }
    if (detailedValues != null && detailedValues.length != 0) {
        valueIsSet = true;
        Lists.newArrayList(detailedValues).stream().distinct().forEach(v -> obs.addComponent().setCode(new CodeableConcept(CharacteristicCode.RACE.toCoding())).setValue(new CodeableConcept(DetailedRaceCode.toCoding(v))));
    }
    if (ObjectUtils.isNotEmpty(description)) {
        valueIsSet = true;
        obs.addComponent().setCode(new CodeableConcept(CharacteristicCode.RACE.toCoding())).setValue(new StringType(description));
    }
    Assert.isTrue(valueIsSet, "At least one of race, detailed race or description must be set.");
    return obs;
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) Observation(org.hl7.fhir.r4.model.Observation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

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