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