Search in sources :

Example 91 with HumanName

use of org.hl7.fhir.r5.model.HumanName in project camel-spring-boot by apache.

the class FhirXmlDataFormatTest method getPatient.

private Patient getPatient() {
    Patient patient = new Patient();
    patient.addName(new HumanName().addGiven("Sherlock").setFamily("Holmes")).addAddress(new Address().addLine("221b Baker St, Marylebone, London NW1 6XE, UK"));
    return patient;
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Address(org.hl7.fhir.r4.model.Address) Patient(org.hl7.fhir.r4.model.Patient)

Example 92 with HumanName

use of org.hl7.fhir.r5.model.HumanName in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method registerPatientResourceConverterToPatientDetail.

private PatientDetails registerPatientResourceConverterToPatientDetail(Patient patientResource) {
    PatientDetails patientDetails = new PatientDetails();
    HumanName name = patientResource.getNameFirstRep();
    String givenNames = name.getGiven().stream().map(n -> n.getValue()).collect(Collectors.joining(","));
    patientDetails.setForename(givenNames);
    patientDetails.setSurname(name.getFamily());
    patientDetails.setDateOfBirth(patientResource.getBirthDate());
    if (patientResource.getGender() != null) {
        patientDetails.setGender(patientResource.getGender().toString());
    }
    patientDetails.setNhsNumber(patientResource.getIdentifierFirstRep().getValue());
    DateTimeType deceased = (DateTimeType) patientResource.getDeceased();
    if (deceased != null) {
        try {
            patientDetails.setDeceased((deceased.getValue()));
        } catch (ClassCastException cce) {
            throwUnprocessableEntity422_InvalidResourceException("The multiple deceased property is expected to be a datetime");
        }
    }
    // activate patient as temporary
    patientDetails.setRegistrationStartDateTime(new Date());
    // patientDetails.setRegistrationEndDateTime(getRegistrationEndDate(patientResource));
    patientDetails.setRegistrationStatus(ACTIVE_REGISTRATION_STATUS);
    patientDetails.setRegistrationType(TEMPORARY_RESIDENT_REGISTRATION_TYPE);
    updateAddressAndTelecom(patientResource, patientDetails);
    // set some standard values for defaults, ensure managing org is always returned
    // added at 1.2.2 7 is A20047 the default GP Practice
    patientDetails.setManagingOrganization("7");
    return patientDetails;
}
Also used : ParametersParameterComponent(org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent) AppointmentResourceProvider(uk.gov.hscic.appointments.AppointmentResourceProvider) Autowired(org.springframework.beans.factory.annotation.Autowired) IdentifierUse(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse) NhsCodeValidator(uk.gov.hscic.util.NhsCodeValidator) OperationOutcomeIssueComponent(org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent) FhirRequestGenericIntercepter.throwInvalidRequest400_BadRequestException(uk.gov.hscic.common.filters.FhirRequestGenericIntercepter.throwInvalidRequest400_BadRequestException) ForbiddenOperationException(ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException) IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) VS_GPC_ERROR_WARNING_CODE(uk.gov.hscic.SystemURL.VS_GPC_ERROR_WARNING_CODE) ParseException(java.text.ParseException) OrganizationSearch(uk.gov.hscic.organization.OrganizationSearch) IdDt(ca.uhn.fhir.model.primitive.IdDt) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) OrganizationDetails(uk.gov.hscic.model.organization.OrganizationDetails) Count(ca.uhn.fhir.rest.annotation.Count) Collectors(java.util.stream.Collectors) UnclassifiedServerFailureException(ca.uhn.fhir.rest.server.exceptions.UnclassifiedServerFailureException) IssueType(org.hl7.fhir.dstu3.model.OperationOutcome.IssueType) AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender) 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) PopulateMedicationBundle(uk.gov.hscic.medications.PopulateMedicationBundle) Pattern(java.util.regex.Pattern) NameUse(org.hl7.fhir.dstu3.model.HumanName.NameUse) PatientSearch(uk.gov.hscic.patient.details.PatientSearch) AddressType(org.hl7.fhir.dstu3.model.Address.AddressType) java.util(java.util) FhirRequestGenericIntercepter.throwUnprocessableEntity422_InvalidResourceException(uk.gov.hscic.common.filters.FhirRequestGenericIntercepter.throwUnprocessableEntity422_InvalidResourceException) PatientStore(uk.gov.hscic.patient.details.PatientStore) SimpleDateFormat(java.text.SimpleDateFormat) PractitionerRoleResourceProvider(uk.gov.hscic.practitioner.PractitionerRoleResourceProvider) SD_CC_EXT_NHS_COMMUNICATION(uk.gov.hscic.SystemURL.SD_CC_EXT_NHS_COMMUNICATION) PractitionerResourceProvider(uk.gov.hscic.practitioner.PractitionerResourceProvider) Value(org.springframework.beans.factory.annotation.Value) UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) TelecomDetails(uk.gov.hscic.model.telecom.TelecomDetails) AddressUse(org.hl7.fhir.dstu3.model.Address.AddressUse) WORK(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK) org.hl7.fhir.dstu3.model(org.hl7.fhir.dstu3.model) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Integer.min(java.lang.Integer.min) ca.uhn.fhir.rest.annotation(ca.uhn.fhir.rest.annotation) PatientDetails(uk.gov.hscic.model.patient.PatientDetails) BundleType(org.hl7.fhir.dstu3.model.Bundle.BundleType) SystemConstants(uk.gov.hscic.SystemConstants) SystemURL(uk.gov.hscic.SystemURL) OLD(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD) TokenParam(ca.uhn.fhir.rest.param.TokenParam) ContactComponent(org.hl7.fhir.dstu3.model.Patient.ContactComponent) OperationOutcomeFactory(uk.gov.hscic.OperationOutcomeFactory) Component(org.springframework.stereotype.Component) StaticElementsHelper(uk.gov.hscic.common.helpers.StaticElementsHelper) DateAndListParam(ca.uhn.fhir.rest.param.DateAndListParam) ContactPointUse(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse) OrganizationResourceProvider(uk.gov.hscic.organization.OrganizationResourceProvider) FHIRException(org.hl7.fhir.exceptions.FHIRException) PatientDetails(uk.gov.hscic.model.patient.PatientDetails)

Example 93 with HumanName

use of org.hl7.fhir.r5.model.HumanName in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method IsActiveName.

private Boolean IsActiveName(HumanName name) {
    Period period = name.getPeriod();
    if (null == period) {
        return true;
    }
    Date start = period.getStart();
    Date end = period.getEnd();
    if ((null == end || end.after(new Date())) && (null == start || start.equals(new Date()) || start.before(new Date()))) {
        return true;
    }
    return false;
}
Also used : Period(org.hl7.fhir.dstu3.model.Period) Date(java.util.Date)

Example 94 with HumanName

use of org.hl7.fhir.r5.model.HumanName in project wildfly-camel by wildfly-extras.

the class FhirJsonIntegrationTest method createPatient.

private Patient createPatient() {
    Patient patient = new Patient();
    patient.addName(new HumanName().addGiven("Sherlock").setFamily("Holmes")).addAddress(new Address().addLine("221b Baker St, Marylebone, London NW1 6XE, UK"));
    return patient;
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName) Address(org.hl7.fhir.dstu3.model.Address) Patient(org.hl7.fhir.dstu3.model.Patient)

Example 95 with HumanName

use of org.hl7.fhir.r5.model.HumanName in project camel-quarkus by apache.

the class FhirR4Resource method validateResource.

// ///////////////////
// Validate
// ///////////////////
@Path("/validate/resource")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String validateResource() {
    Patient patient = new Patient().addName(new HumanName().addGiven(PATIENT_FIRST_NAME).setFamily(PATIENT_LAST_NAME));
    patient.getText().setStatus(NarrativeStatus.GENERATED);
    patient.getText().setDivAsString("<div>This is the narrative text</div>");
    MethodOutcome result = producerTemplate.requestBody("direct:validateResource-r4", patient, MethodOutcome.class);
    OperationOutcome operationOutcome = (OperationOutcome) result.getOperationOutcome();
    return operationOutcome.getIssue().get(0).getDiagnostics();
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) IBaseOperationOutcome(org.hl7.fhir.instance.model.api.IBaseOperationOutcome) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) Patient(org.hl7.fhir.r4.model.Patient) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

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