use of org.hl7.fhir.dstu3.model.Identifier in project gpconnect-demonstrator by nhsconnect.
the class OrganizationResourceProvider method convertOrganizaitonDetailsListToOrganizationList.
private List<Organization> convertOrganizaitonDetailsListToOrganizationList(List<OrganizationDetails> organizationDetails) {
Map<String, Organization> map = new HashMap<>();
for (OrganizationDetails organizationDetail : organizationDetails) {
String mapKey = String.format("%s", organizationDetail.getOrgCode());
if (map.containsKey(mapKey)) {
continue;
}
Identifier identifier = new Identifier().setSystem(SystemURL.ID_ODS_ORGANIZATION_CODE).setValue(organizationDetail.getOrgCode());
Organization organization = new Organization().setName(organizationDetail.getOrgName()).addIdentifier(identifier);
String resourceId = String.valueOf(organizationDetail.getId());
String versionId = String.valueOf(organizationDetail.getLastUpdated().getTime());
String resourceType = organization.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
organization.setId(id);
organization.getMeta().setVersionId(versionId);
organization.getMeta().setLastUpdated(organizationDetail.getLastUpdated());
organization.getMeta().addProfile(SystemURL.SD_GPC_ORGANIZATION);
organization = addAdditionalProperties(organization);
map.put(mapKey, organization);
}
return new ArrayList<>(map.values());
}
use of org.hl7.fhir.dstu3.model.Identifier in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method patientDetailsToMinimalPatient.
private Patient patientDetailsToMinimalPatient(PatientDetails patientDetails) throws FHIRException {
Patient patient = new Patient();
Date lastUpdated = patientDetails.getLastUpdated() == null ? new Date() : patientDetails.getLastUpdated();
String resourceId = String.valueOf(patientDetails.getId());
String versionId = String.valueOf(lastUpdated.getTime());
String resourceType = patient.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
patient.setId(id);
patient.getMeta().setVersionId(versionId);
patient.getMeta().setLastUpdated(lastUpdated);
patient.getMeta().addProfile(SystemURL.SD_GPC_PATIENT);
Identifier patientNhsNumber = new Identifier().setSystem(SystemURL.ID_NHS_NUMBER).setValue(patientDetails.getNhsNumber());
Extension extension = createCodingExtension("01", "Number present and verified", SystemURL.CS_CC_NHS_NUMBER_VERIF, SystemURL.SD_CC_EXT_NHS_NUMBER_VERIF);
patientNhsNumber.addExtension(extension);
patient.addIdentifier(patientNhsNumber);
patient.setBirthDate(patientDetails.getDateOfBirth());
String gender = patientDetails.getGender();
if (gender != null) {
patient.setGender(AdministrativeGender.fromCode(gender.toLowerCase(Locale.UK)));
}
Date registrationEndDateTime = patientDetails.getRegistrationEndDateTime();
Date registrationStartDateTime = patientDetails.getRegistrationStartDateTime();
Extension regDetailsExtension = new Extension(SystemURL.SD_EXTENSION_CC_REG_DETAILS);
Period registrationPeriod = new Period().setStart(registrationStartDateTime).setEnd(registrationEndDateTime);
Extension regPeriodExt = new Extension(SystemURL.SD_CC_EXT_REGISTRATION_PERIOD, registrationPeriod);
regDetailsExtension.addExtension(regPeriodExt);
String registrationStatusValue = patientDetails.getRegistrationStatus();
patient.setActive(ACTIVE_REGISTRATION_STATUS.equals(registrationStatusValue) || null == registrationStatusValue);
String registrationTypeValue = patientDetails.getRegistrationType();
if (registrationTypeValue != null) {
Coding regTypeCode = new Coding();
regTypeCode.setCode(registrationTypeValue);
// Should always be Temporary
regTypeCode.setDisplay("Temporary");
regTypeCode.setSystem(SystemURL.CS_REGISTRATION_TYPE);
CodeableConcept regTypeConcept = new CodeableConcept();
regTypeConcept.addCoding(regTypeCode);
Extension regTypeExt = new Extension(SystemURL.SD_CC_EXT_REGISTRATION_TYPE, regTypeConcept);
regDetailsExtension.addExtension(regTypeExt);
}
patient.addExtension(regDetailsExtension);
String maritalStatus = patientDetails.getMaritalStatus();
if (maritalStatus != null) {
CodeableConcept marital = new CodeableConcept();
Coding maritalCoding = new Coding();
maritalCoding.setSystem(SystemURL.VS_CC_MARITAL_STATUS);
maritalCoding.setCode(patientDetails.getMaritalStatus());
maritalCoding.setDisplay("Married");
marital.addCoding(maritalCoding);
patient.setMaritalStatus(marital);
}
patient.setMultipleBirth(patientDetails.isMultipleBirth());
if (patientDetails.isDeceased()) {
DateTimeType decesed = new DateTimeType(patientDetails.getDeceased());
patient.setDeceased(decesed);
}
return patient;
}
Aggregations