use of uk.gov.hscic.model.practitioner.PractitionerDetails in project gpconnect-demonstrator by nhsconnect.
the class PractitionerResourceProvider method practitionerDetailsToPractitionerResourceConverter.
private Practitioner practitionerDetailsToPractitionerResourceConverter(PractitionerDetails practitionerDetails) {
Identifier identifier = new Identifier().setSystem(SystemURL.ID_SDS_USER_ID).setValue(practitionerDetails.getUserId());
Practitioner practitioner = new Practitioner().addIdentifier(identifier);
practitionerDetails.getRoleIds().stream().distinct().map(roleId -> new Identifier().setSystem(SystemURL.ID_SDS_ROLE_PROFILE_ID).setValue(roleId)).forEach(practitioner::addIdentifier);
String resourceId = String.valueOf(practitionerDetails.getId());
String versionId = String.valueOf(practitionerDetails.getLastUpdated().getTime());
String resourceType = practitioner.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
practitioner.setId(id);
practitioner.getMeta().setVersionId(versionId);
practitioner.getMeta().setLastUpdated(practitionerDetails.getLastUpdated());
practitioner.getMeta().addProfile(SystemURL.SD_GPC_PRACTITIONER);
HumanName name = new HumanName().setFamily(practitionerDetails.getNameFamily()).addGiven(practitionerDetails.getNameGiven()).addPrefix(practitionerDetails.getNamePrefix()).setUse(NameUse.USUAL);
practitioner.addName(name);
switch(practitionerDetails.getGender().toLowerCase(Locale.UK)) {
case "male":
practitioner.setGender(AdministrativeGender.MALE);
break;
case "female":
practitioner.setGender(AdministrativeGender.FEMALE);
break;
case "other":
practitioner.setGender(AdministrativeGender.OTHER);
break;
default:
practitioner.setGender(AdministrativeGender.UNKNOWN);
break;
}
Coding roleCoding = new Coding(SystemURL.VS_SDS_JOB_ROLE_NAME, practitionerDetails.getRoleCode(), practitionerDetails.getRoleDisplay());
for (int i = 0; i < practitionerDetails.getComCode().size(); i++) {
Coding comCoding = new Coding(SystemURL.VS_HUMAN_LANGUAGE, practitionerDetails.getComCode().get(i), null).setDisplay(practitionerDetails.getComDisplay().get(i));
practitioner.addCommunication().addCoding(comCoding);
}
return practitioner;
}
use of uk.gov.hscic.model.practitioner.PractitionerDetails in project gpconnect-demonstrator by nhsconnect.
the class AppointmentValidation method validateParticipantActor.
/**
* check the resource exists
* @param participantActor
*/
public void validateParticipantActor(Reference participantActor) {
String resourcePart = participantActor.getReference().replaceFirst("^(.*)/.*$", "$1");
idPart = participantActor.getReference().replaceFirst("^.*/(.*)$", "$1");
Boolean participantFailedSearch = false;
switch(resourcePart) {
case "Patient":
PatientDetails patient = patientSearch.findPatientByInternalID(idPart);
participantFailedSearch = (patient == null);
break;
case "Practitioner":
PractitionerDetails practitioner = practitionerSearch.findPractitionerDetails(idPart);
participantFailedSearch = (practitioner == null);
break;
case "Location":
LocationDetails location = locationSearch.findLocationById(idPart);
participantFailedSearch = (location == null);
break;
default:
System.err.println("Unhandled resourcePart " + resourcePart);
}
if (participantFailedSearch) {
throwUnprocessableEntity422_InvalidResourceException(String.format("%s resource reference %s is not a valid resource", resourcePart, idPart));
}
}
use of uk.gov.hscic.model.practitioner.PractitionerDetails in project gpconnect-demonstrator by nhsconnect.
the class PractitionerEntityToObjectTransformer method transform.
@Override
public PractitionerDetails transform(final PractitionerEntity practitionerEntity) {
PractitionerDetails practitioner = new PractitionerDetails();
List<String> roleIds = Arrays.asList(practitionerEntity.getRoleIds().split("\\|")).stream().filter(roleId -> !roleId.isEmpty()).collect(Collectors.toList());
List<String> comCodes = Arrays.asList(practitionerEntity.getComCode().split("\\|")).stream().filter(comCode -> !comCode.isEmpty()).collect(Collectors.toList());
List<String> comDisplays = Arrays.asList(practitionerEntity.getComDisplay().split("\\|")).stream().filter(comDisplay -> !comDisplay.isEmpty()).collect(Collectors.toList());
practitioner.setId(practitionerEntity.getId());
practitioner.setUserId(practitionerEntity.getUserId());
practitioner.setRoleIds(roleIds);
practitioner.setNameFamily(practitionerEntity.getNameFamily());
practitioner.setNameGiven(practitionerEntity.getNameGiven());
practitioner.setNamePrefix(practitionerEntity.getNamePrefix());
practitioner.setGender(practitionerEntity.getGender());
practitioner.setOrganizationId(practitionerEntity.getOrganizationId());
practitioner.setRoleCode(practitionerEntity.getRoleCode());
practitioner.setRoleDisplay(practitionerEntity.getRoleDisplay());
practitioner.setComCode(comCodes);
practitioner.setComDisplay(comDisplays);
practitioner.setLastUpdated(practitionerEntity.getLastUpdated());
return practitioner;
}
Aggregations