Search in sources :

Example 6 with PatientDetails

use of uk.gov.hscic.model.patient.PatientDetails in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method getPatientsByPatientId.

@Search
public List<Patient> getPatientsByPatientId(@RequiredParam(name = Patient.SP_IDENTIFIER) TokenParam tokenParam) throws FHIRException {
    Patient patient = getPatientByPatientId(nhsNumber.fromToken(tokenParam));
    if (null != patient) {
        addPreferredBranchSurgeryExtension(patient);
    }
    PatientDetails patientDetails = patientSearch.findPatient(nhsNumber.fromToken(tokenParam));
    // ie does not return a deceased, inactive or sensitive patient in the list
    return null == patient || patient.getDeceased() != null || !patientDetails.isActive() || patientDetails.isSensitive() ? Collections.emptyList() : Collections.singletonList(patient);
}
Also used : PatientDetails(uk.gov.hscic.model.patient.PatientDetails) OrganizationSearch(uk.gov.hscic.organization.OrganizationSearch) PatientSearch(uk.gov.hscic.patient.details.PatientSearch)

Example 7 with PatientDetails

use of uk.gov.hscic.model.patient.PatientDetails in project gpconnect-demonstrator by nhsconnect.

the class PatientEntityToDetailsTransformer method transform.

@Override
public PatientDetails transform(final PatientEntity patientEntity) {
    final PatientDetails patient = new PatientDetails();
    String[] address = new String[] { StringUtils.trimToNull(patientEntity.getAddress1()), StringUtils.trimToNull(patientEntity.getAddress2()), StringUtils.trimToNull(patientEntity.getAddress3()), StringUtils.trimToNull(patientEntity.getAddress4()), StringUtils.trimToNull(patientEntity.getAddress5()) };
    final String name = patientEntity.getFirstName() + " " + patientEntity.getLastName();
    final String patientId = patientEntity.getNhsNumber();
    patient.setId(String.valueOf(patientEntity.getId()));
    patient.setName(name);
    patient.setTitle(patientEntity.getTitle());
    patient.setForename(patientEntity.getFirstName());
    patient.setSurname(patientEntity.getLastName());
    patient.setGender(patientEntity.getGender());
    patient.setDateOfBirth(patientEntity.getDateOfBirth());
    patient.setNhsNumber(patientId);
    patient.setPasNumber(patientEntity.getPasNumber());
    patient.setAddress(address);
    patient.setPostcode(patientEntity.getPostcode());
    patient.setTelephone(patientEntity.getPhone());
    patient.setPasNumber(patientEntity.getPasNumber());
    patient.setLastUpdated(patientEntity.getLastUpdated());
    patient.setRegistrationStartDateTime(patientEntity.getRegistrationStartDateTime());
    patient.setRegistrationEndDateTime(patientEntity.getRegistrationEndDateTime());
    patient.setRegistrationStatus(patientEntity.getRegistrationStatus());
    patient.setRegistrationType(patientEntity.getRegistrationType());
    patient.setMaritalStatus(patientEntity.getMaritalStatus());
    patient.setManagingOrganization(patientEntity.getManagingOrganization());
    PractitionerEntity gp = patientEntity.getPractitioner();
    if (gp != null) {
        patient.setGpDetails(gp.getNamePrefix() + " " + gp.getNameGiven() + " " + gp.getNameFamily());
        patient.setGpId(gp.getId());
    }
    Date deceased = patientEntity.getDeceasedDateTime();
    if (deceased != null) {
        patient.setDeceased(deceased);
    }
    patient.setSensitive(patientEntity.isSensitive());
    populateTelecoms(patient, patientEntity);
    return patient;
}
Also used : PatientDetails(uk.gov.hscic.model.patient.PatientDetails) PractitionerEntity(uk.gov.hscic.practitioner.PractitionerEntity) Date(java.util.Date)

Example 8 with PatientDetails

use of uk.gov.hscic.model.patient.PatientDetails in project gpconnect-demonstrator by nhsconnect.

the class PatientSearch method findPatientByInternalID.

/**
 * @param rawInternalID
 * @return PatientDetails - that match the ID or null if no match could be found
 */
public PatientDetails findPatientByInternalID(final String rawInternalID) {
    PatientDetails patientDetails;
    try {
        Long internaId = Long.valueOf(rawInternalID);
        final PatientEntity patient = patientRepository.findById(internaId);
        patientDetails = patient == null ? null : patientEntityToDetailsTransformer.transform(patient);
    } catch (NumberFormatException nfe) {
        patientDetails = null;
    }
    return patientDetails;
}
Also used : PatientDetails(uk.gov.hscic.model.patient.PatientDetails)

Example 9 with PatientDetails

use of uk.gov.hscic.model.patient.PatientDetails in project gpconnect-demonstrator by nhsconnect.

the class PatientEntityToDetailsTransformerTest method shouldRemoveEmptyLinesFromAddressString.

@Test
public void shouldRemoveEmptyLinesFromAddressString() {
    final PatientEntity patientEntity = dummyPatientEntity();
    patientEntity.setAddress1("line 1");
    patientEntity.setAddress2(null);
    patientEntity.setAddress3("line 3");
    patientEntity.setAddress5("");
    patientEntity.setAddress5("line 5");
    patientEntity.setPostcode("postcode");
    final PatientDetails patientDetails = transformer.transform(patientEntity);
    assertNotNull(patientDetails);
// TODO Commented out for 1.2.2 build. Need to check this, get Address now returns an array of 5 strings one per line
// Changes at 1.2.2 remove the use of teh text field and stupulate a more strcutured address so this test no longer applies
// assertEquals("line 1, line 3, postcode", patientDetails.getAddress());
}
Also used : PatientDetails(uk.gov.hscic.model.patient.PatientDetails) Test(org.junit.Test)

Aggregations

PatientDetails (uk.gov.hscic.model.patient.PatientDetails)9 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)3 UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)3 ForbiddenOperationException (ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException)2 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)2 UnclassifiedServerFailureException (ca.uhn.fhir.rest.server.exceptions.UnclassifiedServerFailureException)2 ParametersParameterComponent (org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent)2 FHIRException (org.hl7.fhir.exceptions.FHIRException)2 PopulateMedicationBundle (uk.gov.hscic.medications.PopulateMedicationBundle)2 OrganizationSearch (uk.gov.hscic.organization.OrganizationSearch)2 PatientSearch (uk.gov.hscic.patient.details.PatientSearch)2 IdDt (ca.uhn.fhir.model.primitive.IdDt)1 ca.uhn.fhir.rest.annotation (ca.uhn.fhir.rest.annotation)1 Count (ca.uhn.fhir.rest.annotation.Count)1 SortSpec (ca.uhn.fhir.rest.api.SortSpec)1 DateAndListParam (ca.uhn.fhir.rest.param.DateAndListParam)1 TokenParam (ca.uhn.fhir.rest.param.TokenParam)1 IResourceProvider (ca.uhn.fhir.rest.server.IResourceProvider)1 Integer.min (java.lang.Integer.min)1 ParseException (java.text.ParseException)1