Search in sources :

Example 1 with PractitionerDetails

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;
}
Also used : Practitioner(org.hl7.fhir.dstu3.model.Practitioner) IdParam(ca.uhn.fhir.rest.annotation.IdParam) 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) Extension(org.hl7.fhir.dstu3.model.Extension) RequiredParam(ca.uhn.fhir.rest.annotation.RequiredParam) Locale(java.util.Locale) Search(ca.uhn.fhir.rest.annotation.Search) IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Location(org.hl7.fhir.dstu3.model.Location) Read(ca.uhn.fhir.rest.annotation.Read) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) Sort(ca.uhn.fhir.rest.annotation.Sort) Count(ca.uhn.fhir.rest.annotation.Count) Collectors(java.util.stream.Collectors) SystemURL(uk.gov.hscic.SystemURL) IssueType(org.hl7.fhir.dstu3.model.OperationOutcome.IssueType) TokenParam(ca.uhn.fhir.rest.param.TokenParam) PractitionerDetails(uk.gov.hscic.model.practitioner.PractitionerDetails) AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender) OperationOutcomeFactory(uk.gov.hscic.OperationOutcomeFactory) List(java.util.List) Component(org.springframework.stereotype.Component) SortSpec(ca.uhn.fhir.rest.api.SortSpec) IdentifierValidator(uk.gov.hscic.common.validators.IdentifierValidator) SystemCode(uk.gov.hscic.SystemCode) Collections(java.util.Collections) HumanName(org.hl7.fhir.dstu3.model.HumanName) NameUse(org.hl7.fhir.dstu3.model.HumanName.NameUse) HumanName(org.hl7.fhir.dstu3.model.HumanName) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) IdType(org.hl7.fhir.dstu3.model.IdType)

Example 2 with PractitionerDetails

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));
    }
}
Also used : PractitionerDetails(uk.gov.hscic.model.practitioner.PractitionerDetails) LocationDetails(uk.gov.hscic.model.location.LocationDetails) PatientDetails(uk.gov.hscic.model.patient.PatientDetails)

Example 3 with PractitionerDetails

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;
}
Also used : PractitionerDetails(uk.gov.hscic.model.practitioner.PractitionerDetails) Arrays(java.util.Arrays) List(java.util.List) Transformer(org.apache.commons.collections4.Transformer) Collectors(java.util.stream.Collectors) PractitionerDetails(uk.gov.hscic.model.practitioner.PractitionerDetails)

Aggregations

PractitionerDetails (uk.gov.hscic.model.practitioner.PractitionerDetails)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Count (ca.uhn.fhir.rest.annotation.Count)1 IdParam (ca.uhn.fhir.rest.annotation.IdParam)1 Read (ca.uhn.fhir.rest.annotation.Read)1 RequiredParam (ca.uhn.fhir.rest.annotation.RequiredParam)1 Search (ca.uhn.fhir.rest.annotation.Search)1 Sort (ca.uhn.fhir.rest.annotation.Sort)1 SortSpec (ca.uhn.fhir.rest.api.SortSpec)1 TokenParam (ca.uhn.fhir.rest.param.TokenParam)1 IResourceProvider (ca.uhn.fhir.rest.server.IResourceProvider)1 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Locale (java.util.Locale)1 Transformer (org.apache.commons.collections4.Transformer)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 AdministrativeGender (org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender)1