Search in sources :

Example 1 with HumanName

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

the class PatientResourceProvider method validateNames.

private void validateNames(Patient patient) {
    List<HumanName> names = patient.getName();
    if (names.size() < 1) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(new InvalidRequestException("The patient must have at least one Name."), SystemCode.BAD_REQUEST, IssueType.INVALID);
    }
    List<HumanName> activeOfficialNames = names.stream().filter(nm -> IsActiveName(nm)).filter(nm -> NameUse.OFFICIAL.equals(nm.getUse())).collect(Collectors.toList());
    if (activeOfficialNames.size() != 1) {
        InvalidRequestException exception = new InvalidRequestException("The patient must have one Active Name with a Use of OFFICIAL");
        throw OperationOutcomeFactory.buildOperationOutcomeException(exception, SystemCode.BAD_REQUEST, IssueType.INVALID);
    }
    List<String> officialFamilyNames = new ArrayList<>();
    for (HumanName humanName : activeOfficialNames) {
        if (humanName.getFamily() != null) {
            officialFamilyNames.add(humanName.getFamily());
        }
    }
    validateNameCount(officialFamilyNames, "family");
}
Also used : IdParam(ca.uhn.fhir.rest.annotation.IdParam) ParametersParameterComponent(org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent) Type(org.hl7.fhir.dstu3.model.Type) Bundle(org.hl7.fhir.dstu3.model.Bundle) ContactDetail(org.hl7.fhir.dstu3.model.ContactDetail) AppointmentResourceProvider(uk.gov.hscic.appointments.AppointmentResourceProvider) MedicationAdministration(org.hl7.fhir.dstu3.model.MedicationAdministration) Date(java.util.Date) 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) Operation(ca.uhn.fhir.rest.annotation.Operation) Extension(org.hl7.fhir.dstu3.model.Extension) IdentifierUse(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse) NhsCodeValidator(uk.gov.hscic.util.NhsCodeValidator) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) Locale(java.util.Locale) IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) Map(java.util.Map) EnumSet(java.util.EnumSet) IdDt(ca.uhn.fhir.model.primitive.IdDt) Reference(org.hl7.fhir.dstu3.model.Reference) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) Set(java.util.Set) Count(ca.uhn.fhir.rest.annotation.Count) Collectors(java.util.stream.Collectors) Appointment(org.hl7.fhir.dstu3.model.Appointment) IssueType(org.hl7.fhir.dstu3.model.OperationOutcome.IssueType) AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender) List(java.util.List) 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) OptionalParam(ca.uhn.fhir.rest.annotation.OptionalParam) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) NameUse(org.hl7.fhir.dstu3.model.HumanName.NameUse) PatientSearch(uk.gov.hscic.patient.details.PatientSearch) AddressType(org.hl7.fhir.dstu3.model.Address.AddressType) MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest) PatientStore(uk.gov.hscic.patient.details.PatientStore) HashMap(java.util.HashMap) PractitionerResourceProvider(uk.gov.hscic.practitioner.PractitionerResourceProvider) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) RequiredParam(ca.uhn.fhir.rest.annotation.RequiredParam) Calendar(java.util.Calendar) UnprocessableEntityException(ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException) MedicationOrderResourceProvider(uk.gov.hscic.medications.MedicationOrderResourceProvider) AddressUse(org.hl7.fhir.dstu3.model.Address.AddressUse) Search(ca.uhn.fhir.rest.annotation.Search) Period(org.hl7.fhir.dstu3.model.Period) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Read(ca.uhn.fhir.rest.annotation.Read) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) Sort(ca.uhn.fhir.rest.annotation.Sort) PatientDetails(uk.gov.hscic.model.patient.PatientDetails) BundleType(org.hl7.fhir.dstu3.model.Bundle.BundleType) SystemURL(uk.gov.hscic.SystemURL) TokenParam(ca.uhn.fhir.rest.param.TokenParam) MedicationAdministrationResourceProvider(uk.gov.hscic.medications.MedicationAdministrationResourceProvider) OperationOutcomeFactory(uk.gov.hscic.OperationOutcomeFactory) Component(org.springframework.stereotype.Component) ResourceParam(ca.uhn.fhir.rest.annotation.ResourceParam) StaticElementsHelper(uk.gov.hscic.common.helpers.StaticElementsHelper) MedicationDispenseResourceProvider(uk.gov.hscic.medications.MedicationDispenseResourceProvider) Patient(org.hl7.fhir.dstu3.model.Patient) DateAndListParam(ca.uhn.fhir.rest.param.DateAndListParam) ContactPointUse(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse) Parameters(org.hl7.fhir.dstu3.model.Parameters) OrganizationResourceProvider(uk.gov.hscic.organization.OrganizationResourceProvider) MedicationDispense(org.hl7.fhir.dstu3.model.MedicationDispense) FHIRException(org.hl7.fhir.exceptions.FHIRException) Collections(java.util.Collections) HumanName(org.hl7.fhir.dstu3.model.HumanName) HumanName(org.hl7.fhir.dstu3.model.HumanName) ArrayList(java.util.ArrayList) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)

Example 2 with HumanName

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

the class PatientResourceProvider method getPatientNameFromPatientDetails.

private HumanName getPatientNameFromPatientDetails(PatientDetails patientDetails) {
    HumanName name = new HumanName();
    name.setText(patientDetails.getName()).setFamily(patientDetails.getSurname()).addPrefix(patientDetails.getTitle()).setUse(NameUse.OFFICIAL);
    List<String> givenNames = patientDetails.getForenames();
    givenNames.forEach((givenName) -> {
        name.addGiven(givenName);
    });
    return name;
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName)

Example 3 with HumanName

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

the class PatientResourceProvider method getValidContact.

private ContactDetail getValidContact() {
    HumanName ctName = new HumanName();
    ctName.setUse(NameUse.OFFICIAL);
    ctName.setFamily("FamilyName");
    List<CodeableConcept> ctRelList = new ArrayList<>();
    ctRelList.add(createCoding("family", "Family", SystemURL.VS_PATIENT_CONTACT_REL));
    ContactDetail contact = new ContactDetail();
    contact.setName(ctName.toString());
    contact.addTelecom(staticElHelper.getValidTelecom());
    return contact;
}
Also used : ContactDetail(org.hl7.fhir.dstu3.model.ContactDetail) HumanName(org.hl7.fhir.dstu3.model.HumanName) ArrayList(java.util.ArrayList) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 4 with HumanName

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

the class PatientResourceProvider method patientDetailsToRegisterPatientResourceConverter.

// a cut-down Patient
private Patient patientDetailsToRegisterPatientResourceConverter(PatientDetails patientDetails) throws FHIRException {
    Patient patient = patientDetailsToMinimalPatient(patientDetails);
    HumanName name = getPatientNameFromPatientDetails(patientDetails);
    patient.addName(name);
    patient = setStaticPatientData(patient);
    return patient;
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName) Patient(org.hl7.fhir.dstu3.model.Patient)

Example 5 with HumanName

use of org.hl7.fhir.dstu3.model.HumanName 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)

Aggregations

HumanName (org.hl7.fhir.dstu3.model.HumanName)6 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)4 Count (ca.uhn.fhir.rest.annotation.Count)3 SortSpec (ca.uhn.fhir.rest.api.SortSpec)3 TokenParam (ca.uhn.fhir.rest.param.TokenParam)3 IResourceProvider (ca.uhn.fhir.rest.server.IResourceProvider)3 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)3 Collectors (java.util.stream.Collectors)3 Coding (org.hl7.fhir.dstu3.model.Coding)3 ContactDetail (org.hl7.fhir.dstu3.model.ContactDetail)3 AdministrativeGender (org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender)3 NameUse (org.hl7.fhir.dstu3.model.HumanName.NameUse)3 IssueType (org.hl7.fhir.dstu3.model.OperationOutcome.IssueType)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Component (org.springframework.stereotype.Component)3 IdDt (ca.uhn.fhir.model.primitive.IdDt)2 IdParam (ca.uhn.fhir.rest.annotation.IdParam)2 Read (ca.uhn.fhir.rest.annotation.Read)2 RequiredParam (ca.uhn.fhir.rest.annotation.RequiredParam)2 Search (ca.uhn.fhir.rest.annotation.Search)2