Search in sources :

Example 16 with Identifier

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());
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) Identifier(org.hl7.fhir.dstu3.model.Identifier) HashMap(java.util.HashMap) OrganizationDetails(uk.gov.hscic.model.organization.OrganizationDetails) ArrayList(java.util.ArrayList) IdType(org.hl7.fhir.dstu3.model.IdType)

Example 17 with Identifier

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;
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) Patient(org.hl7.fhir.dstu3.model.Patient) Period(org.hl7.fhir.dstu3.model.Period) Date(java.util.Date) IdType(org.hl7.fhir.dstu3.model.IdType) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

IdType (org.hl7.fhir.dstu3.model.IdType)7 Identifier (org.hl7.fhir.dstu3.model.Identifier)7 ArrayList (java.util.ArrayList)5 Organization (org.hl7.fhir.dstu3.model.Organization)5 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)4 Coding (org.hl7.fhir.dstu3.model.Coding)4 Extension (org.hl7.fhir.dstu3.model.Extension)4 UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)3 Period (org.hl7.fhir.dstu3.model.Period)3 Reference (org.hl7.fhir.dstu3.model.Reference)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 Search (ca.uhn.fhir.rest.annotation.Search)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 AppointmentParticipantComponent (org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent)2 Location (org.hl7.fhir.dstu3.model.Location)2 DateTimeDt (ca.uhn.fhir.model.primitive.DateTimeDt)1 IdDt (ca.uhn.fhir.model.primitive.IdDt)1 Count (ca.uhn.fhir.rest.annotation.Count)1 IdParam (ca.uhn.fhir.rest.annotation.IdParam)1