Search in sources :

Example 61 with HumanName

use of org.hl7.fhir.r4b.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());
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName) Patient(org.hl7.fhir.dstu3.model.Patient) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) CamelSpringBootTest(org.apache.camel.test.spring.junit5.CamelSpringBootTest)

Example 62 with HumanName

use of org.hl7.fhir.r4b.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);
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName) OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) Patient(org.hl7.fhir.dstu3.model.Patient) Test(org.junit.Test)

Example 63 with HumanName

use of org.hl7.fhir.r4b.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);
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName) OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) Patient(org.hl7.fhir.dstu3.model.Patient) Test(org.junit.Test)

Example 64 with HumanName

use of org.hl7.fhir.r4b.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");
}
Also used : IdParam(ca.uhn.fhir.rest.annotation.IdParam) ParametersParameterComponent(org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent) Type(org.hl7.fhir.dstu3.model.Type) Bundle(org.hl7.fhir.dstu3.model.Bundle) ContactDetail(org.hl7.fhir.dstu3.model.ContactDetail) AppointmentResourceProvider(uk.gov.hscic.appointments.AppointmentResourceProvider) MedicationAdministration(org.hl7.fhir.dstu3.model.MedicationAdministration) Date(java.util.Date) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) IdType(org.hl7.fhir.dstu3.model.IdType) Autowired(org.springframework.beans.factory.annotation.Autowired) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Operation(ca.uhn.fhir.rest.annotation.Operation) Extension(org.hl7.fhir.dstu3.model.Extension) IdentifierUse(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse) NhsCodeValidator(uk.gov.hscic.util.NhsCodeValidator) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) Locale(java.util.Locale) IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) Map(java.util.Map) EnumSet(java.util.EnumSet) IdDt(ca.uhn.fhir.model.primitive.IdDt) Reference(org.hl7.fhir.dstu3.model.Reference) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) Set(java.util.Set) Count(ca.uhn.fhir.rest.annotation.Count) Collectors(java.util.stream.Collectors) Appointment(org.hl7.fhir.dstu3.model.Appointment) IssueType(org.hl7.fhir.dstu3.model.OperationOutcome.IssueType) AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender) List(java.util.List) SortSpec(ca.uhn.fhir.rest.api.SortSpec) IdentifierValidator(uk.gov.hscic.common.validators.IdentifierValidator) PostConstruct(javax.annotation.PostConstruct) ContactPointSystem(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem) SystemCode(uk.gov.hscic.SystemCode) OptionalParam(ca.uhn.fhir.rest.annotation.OptionalParam) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) NameUse(org.hl7.fhir.dstu3.model.HumanName.NameUse) PatientSearch(uk.gov.hscic.patient.details.PatientSearch) AddressType(org.hl7.fhir.dstu3.model.Address.AddressType) MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest) PatientStore(uk.gov.hscic.patient.details.PatientStore) HashMap(java.util.HashMap) PractitionerResourceProvider(uk.gov.hscic.practitioner.PractitionerResourceProvider) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) RequiredParam(ca.uhn.fhir.rest.annotation.RequiredParam) Calendar(java.util.Calendar) UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) MedicationOrderResourceProvider(uk.gov.hscic.medications.MedicationOrderResourceProvider) AddressUse(org.hl7.fhir.dstu3.model.Address.AddressUse) Search(ca.uhn.fhir.rest.annotation.Search) Period(org.hl7.fhir.dstu3.model.Period) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Read(ca.uhn.fhir.rest.annotation.Read) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) Sort(ca.uhn.fhir.rest.annotation.Sort) PatientDetails(uk.gov.hscic.model.patient.PatientDetails) BundleType(org.hl7.fhir.dstu3.model.Bundle.BundleType) SystemURL(uk.gov.hscic.SystemURL) TokenParam(ca.uhn.fhir.rest.param.TokenParam) MedicationAdministrationResourceProvider(uk.gov.hscic.medications.MedicationAdministrationResourceProvider) OperationOutcomeFactory(uk.gov.hscic.OperationOutcomeFactory) Component(org.springframework.stereotype.Component) ResourceParam(ca.uhn.fhir.rest.annotation.ResourceParam) StaticElementsHelper(uk.gov.hscic.common.helpers.StaticElementsHelper) MedicationDispenseResourceProvider(uk.gov.hscic.medications.MedicationDispenseResourceProvider) Patient(org.hl7.fhir.dstu3.model.Patient) DateAndListParam(ca.uhn.fhir.rest.param.DateAndListParam) ContactPointUse(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse) Parameters(org.hl7.fhir.dstu3.model.Parameters) OrganizationResourceProvider(uk.gov.hscic.organization.OrganizationResourceProvider) MedicationDispense(org.hl7.fhir.dstu3.model.MedicationDispense) FHIRException(org.hl7.fhir.exceptions.FHIRException) Collections(java.util.Collections) HumanName(org.hl7.fhir.dstu3.model.HumanName) HumanName(org.hl7.fhir.dstu3.model.HumanName) ArrayList(java.util.ArrayList) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)

Example 65 with HumanName

use of org.hl7.fhir.r4b.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;
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName)

Aggregations

HumanName (org.hl7.fhir.r4.model.HumanName)84 HumanName (org.hl7.fhir.dstu3.model.HumanName)37 Patient (org.hl7.fhir.r4.model.Patient)37 Test (org.junit.jupiter.api.Test)29 ArrayList (java.util.ArrayList)27 Patient (org.hl7.fhir.dstu3.model.Patient)27 Test (org.junit.Test)26 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)23 Address (org.hl7.fhir.r4.model.Address)20 Identifier (org.hl7.fhir.r4.model.Identifier)20 PersonName (org.openmrs.PersonName)17 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 GET (javax.ws.rs.GET)15 Path (javax.ws.rs.Path)15 Produces (javax.ws.rs.Produces)15 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 StringType (org.hl7.fhir.r4.model.StringType)14 Date (java.util.Date)13