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