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;
}
use of org.hl7.fhir.dstu3.model.HumanName in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method patientDetailsToPatientResourceConverter.
private Patient patientDetailsToPatientResourceConverter(PatientDetails patientDetails) throws FHIRException {
Patient patient = patientDetailsToMinimalPatient(patientDetails);
HumanName name = getPatientNameFromPatientDetails(patientDetails);
patient.addName(name);
String addressLines = patientDetails.getAddress();
if (addressLines != null) {
patient.addAddress().setUse(AddressUse.HOME).setType(AddressType.PHYSICAL).setText(addressLines);
}
Long gpId = patientDetails.getGpId();
if (gpId != null) {
Practitioner prac = practitionerResourceProvider.getPractitionerById(new IdType(gpId));
HumanName practitionerName = prac.getNameFirstRep();
Reference practitionerReference = new Reference("Practitioner/" + gpId).setDisplay(practitionerName.getPrefix() + " " + practitionerName.getGivenAsSingleString() + " " + practitionerName.getFamily());
// patient.getCareProvider().add(practitionerReference);
}
String telephoneNumber = patientDetails.getTelephone();
if (telephoneNumber != null) {
ContactPoint telephone = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(telephoneNumber).setUse(ContactPointUse.HOME);
patient.setTelecom(Collections.singletonList(telephone));
}
String managingOrganization = patientDetails.getManagingOrganization();
if (managingOrganization != null) {
patient.setManagingOrganization(new Reference("Organization/" + managingOrganization));
}
return patient;
}
use of org.hl7.fhir.dstu3.model.HumanName in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method IsActiveName.
private Boolean IsActiveName(HumanName name) {
Period period = name.getPeriod();
if (null == period) {
return true;
}
Date start = period.getStart();
Date end = period.getEnd();
if ((null == end || end.after(new Date())) && (null == start || start.equals(new Date()) || start.before(new Date()))) {
return true;
}
return false;
}
use of org.hl7.fhir.dstu3.model.HumanName in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method registerPatientResourceConverterToPatientDetail.
private PatientDetails registerPatientResourceConverterToPatientDetail(Patient patientResource) {
PatientDetails patientDetails = new PatientDetails();
HumanName name = patientResource.getNameFirstRep();
String givenNames = name.getGiven().stream().map(n -> n.getValue()).collect(Collectors.joining(","));
patientDetails.setForename(givenNames);
patientDetails.setSurname(name.getFamily());
patientDetails.setDateOfBirth(patientResource.getBirthDate());
if (patientResource.getGender() != null) {
patientDetails.setGender(patientResource.getGender().toString());
}
patientDetails.setNhsNumber(patientResource.getIdentifierFirstRep().getValue());
Type multipleBirth = patientResource.getMultipleBirth();
if (multipleBirth != null) {
try {
patientDetails.setMultipleBirth((multipleBirth));
} catch (ClassCastException cce) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new UnprocessableEntityException("The multiple birth property is expected to be a boolean"), SystemCode.INVALID_RESOURCE, IssueType.INVALID);
}
}
DateTimeType deceased = (DateTimeType) patientResource.getDeceased();
if (deceased != null) {
try {
patientDetails.setDeceased((deceased.getValue()));
} catch (ClassCastException cce) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new UnprocessableEntityException("The multiple deceased property is expected to be a datetime"), SystemCode.INVALID_RESOURCE, IssueType.INVALID);
}
}
patientDetails.setRegistrationStartDateTime(new Date());
// patientDetails.setRegistrationEndDateTime(getRegistrationEndDate(patientResource));
patientDetails.setRegistrationStatus(ACTIVE_REGISTRATION_STATUS);
patientDetails.setRegistrationType(TEMPORARY_RESIDENT_REGISTRATION_TYPE);
return patientDetails;
}
Aggregations