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));
}
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;
}
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());
}
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;
}
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;
}
Aggregations