use of org.hl7.fhir.r5.model.HumanName in project camel-spring-boot by apache.
the class FhirSimpleTest method testCreateResource.
@Test
public void testCreateResource() throws Exception {
Patient patient = new Patient().addName(new HumanName().addGiven(GIVEN_NAME).setFamily(FAMILY_NAME));
MethodOutcome result = requestBody("direct://RESOURCE", patient);
assertNotNull(result, "resource result");
assertTrue(result.getCreated());
}
use of org.hl7.fhir.r5.model.HumanName in project syndesis by syndesisio.
the class FhirCreateTest method createTest.
@Test
public void createTest() {
stubFhirRequest(post(urlEqualTo("/Patient?_format=xml")).willReturn(okXml(toXml(new OperationOutcome()))));
template.requestBody("direct:start", toXml(new Patient().addName(new HumanName().setFamily("Smith"))), MethodOutcome.class);
}
use of org.hl7.fhir.r5.model.HumanName in project syndesis by syndesisio.
the class FhirUpdateTest method updateTest.
@Test
public void updateTest() {
stubFhirRequest(put(urlEqualTo("/Patient/1234?_format=xml")).willReturn(okXml(toXml(new OperationOutcome()))));
template.requestBody("direct:start", toXml(new Patient().addName(new HumanName().setFamily("Smith")).setId("1234")), MethodOutcome.class);
}
use of org.hl7.fhir.r5.model.HumanName in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method validateNames.
private void validateNames(Patient patient) {
List<HumanName> names = patient.getName();
if (names.size() < 1) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new InvalidRequestException("The patient must have at least one Name."), SystemCode.BAD_REQUEST, IssueType.INVALID);
}
List<HumanName> activeOfficialNames = names.stream().filter(nm -> IsActiveName(nm)).filter(nm -> NameUse.OFFICIAL.equals(nm.getUse())).collect(Collectors.toList());
if (activeOfficialNames.size() != 1) {
InvalidRequestException exception = new InvalidRequestException("The patient must have one Active Name with a Use of OFFICIAL");
throw OperationOutcomeFactory.buildOperationOutcomeException(exception, SystemCode.BAD_REQUEST, IssueType.INVALID);
}
List<String> officialFamilyNames = new ArrayList<>();
for (HumanName humanName : activeOfficialNames) {
if (humanName.getFamily() != null) {
officialFamilyNames.add(humanName.getFamily());
}
}
validateNameCount(officialFamilyNames, "family");
}
use of org.hl7.fhir.r5.model.HumanName in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method getPatientNameFromPatientDetails.
private HumanName getPatientNameFromPatientDetails(PatientDetails patientDetails) {
HumanName name = new HumanName();
name.setText(patientDetails.getName()).setFamily(patientDetails.getSurname()).addPrefix(patientDetails.getTitle()).setUse(NameUse.OFFICIAL);
List<String> givenNames = patientDetails.getForenames();
givenNames.forEach((givenName) -> {
name.addGiven(givenName);
});
return name;
}
Aggregations