Search in sources :

Example 11 with IdType

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

the class SlotResourceProvider method getSlotById.

@Read()
public Slot getSlotById(@IdParam IdType slotId) {
    SlotDetail slotDetail = slotSearch.findSlotByID(slotId.getIdPartAsLong());
    if (slotDetail == null) {
        OperationOutcome operationalOutcome = new OperationOutcome();
        operationalOutcome.addIssue().setSeverity(IssueSeverity.ERROR).setDiagnostics("No slot details found for ID: " + slotId.getIdPart());
        throw new InternalErrorException("No slot details found for ID: " + slotId.getIdPart(), operationalOutcome);
    }
    return slotDetailToSlotResourceConverter(slotDetail);
}
Also used : OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) SlotDetail(uk.gov.hscic.model.appointment.SlotDetail) Read(ca.uhn.fhir.rest.annotation.Read)

Example 12 with IdType

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

the class SlotResourceProvider method slotDetailToSlotResourceConverter.

private Slot slotDetailToSlotResourceConverter(SlotDetail slotDetail) {
    Slot slot = new Slot();
    Date lastUpdated = slotDetail.getLastUpdated() == null ? new Date() : slotDetail.getLastUpdated();
    String resourceId = String.valueOf(slotDetail.getId());
    String versionId = String.valueOf(lastUpdated.getTime());
    String resourceType = slot.getResourceType().toString();
    IdType id = new IdType(resourceType, resourceId, versionId);
    slot.setId(id);
    slot.getMeta().setVersionId(versionId);
    slot.getMeta().setLastUpdated(lastUpdated);
    slot.getMeta().addProfile(SystemURL.SD_GPC_SLOT);
    slot.setIdentifier(Collections.singletonList(new Identifier().setSystem(SystemURL.ID_SDS_USER_ID).setValue(slotDetail.getId().toString())));
    Coding coding = new Coding().setSystem(SystemURL.HL7_VS_C80_PRACTICE_CODES).setCode(String.valueOf(slotDetail.getTypeCode())).setDisplay(slotDetail.getTypeDisply());
    CodeableConcept codableConcept = new CodeableConcept().addCoding(coding);
    codableConcept.setText(slotDetail.getTypeDisply());
    List<CodeableConcept> serviceType = new ArrayList<CodeableConcept>();
    serviceType.add(codableConcept);
    slot.setServiceType(serviceType);
    slot.setSchedule(new Reference("Schedule/" + slotDetail.getScheduleReference()));
    slot.setStart(slotDetail.getStartDateTime());
    slot.setEnd(slotDetail.getEndDateTime());
    switch(slotDetail.getFreeBusyType().toLowerCase(Locale.UK)) {
        case "free":
            slot.setStatus(SlotStatus.FREE);
            break;
        default:
            slot.setStatus(SlotStatus.BUSY);
            break;
    }
    return slot;
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) Slot(org.hl7.fhir.dstu3.model.Slot) Date(java.util.Date) IdType(org.hl7.fhir.dstu3.model.IdType) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 13 with IdType

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

the class LocationResourceProvider method getLocationById.

@Read(version = true)
public Location getLocationById(@IdParam IdType locationId) {
    LocationDetails locationDetails = locationSearch.findLocationById(locationId.getIdPart());
    if (locationDetails == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(new ResourceNotFoundException("No location details found for location ID: " + locationId.getIdPart()), SystemCode.REFERENCE_NOT_FOUND, IssueType.INCOMPLETE);
    }
    Location location = locationDetailsToLocation(locationDetails);
    return location;
}
Also used : LocationDetails(uk.gov.hscic.model.location.LocationDetails) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Location(org.hl7.fhir.dstu3.model.Location) Read(ca.uhn.fhir.rest.annotation.Read)

Example 14 with IdType

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

the class LocationResourceProvider method locationDetailsToLocation.

private Location locationDetailsToLocation(LocationDetails locationDetails) {
    Location location = new Location();
    String resourceId = String.valueOf(locationDetails.getId());
    String versionId = String.valueOf(locationDetails.getLastUpdated().getTime());
    String resourceType = location.getResourceType().toString();
    IdType id = new IdType(resourceType, resourceId, versionId);
    location.setId(id);
    location.getMeta().setVersionId(versionId);
    location.getMeta().setLastUpdated(locationDetails.getLastUpdated());
    location.getMeta().addProfile(SystemURL.SD_GPC_LOCATION);
    location.setName(locationDetails.getName());
    location.setIdentifier(Collections.singletonList(new Identifier().setSystem(SystemURL.ID_ODS_SITE_CODE).setValue(locationDetails.getSiteOdsCode())));
    Coding locationCommTypeCode = new Coding();
    locationCommTypeCode.setCode("COMM");
    locationCommTypeCode.setSystem(SystemURL.VS_CC_SER_DEL_LOCROLETYPE);
    locationCommTypeCode.setDisplay("Community Location");
    Coding locationGachTypeCode = new Coding();
    locationGachTypeCode.setCode("GACH");
    locationGachTypeCode.setSystem(SystemURL.VS_CC_SER_DEL_LOCROLETYPE);
    locationGachTypeCode.setDisplay("Hospitals; General Acute Care Hospital");
    @SuppressWarnings("deprecation") CodeableConcept locationType = new CodeableConcept();
    locationType.addCoding(locationCommTypeCode);
    locationType.addCoding(locationGachTypeCode);
    location.setType(locationType);
    Organization orgz = FindOrganization(locationDetails.getOrgOdsCode());
    if (orgz != null) {
        Reference mngOrg = new Reference();
        mngOrg.setReference("Organization/" + orgz.getId());
        mngOrg.setDisplay(orgz.getName());
        location.setManagingOrganization(mngOrg);
    }
    EnumSet<LocationStatus> statusList = EnumSet.allOf(LocationStatus.class);
    LocationStatus locationStatus = null;
    String status = locationDetails.getStatus();
    if (status != null) {
        for (LocationStatus statusItem : statusList) {
            if (statusItem.toCode().equalsIgnoreCase(status)) {
                locationStatus = statusItem;
                break;
            }
        }
    }
    location.setAddress(createAddress(locationDetails));
    location.setStatus(locationStatus);
    return location;
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) Organization(org.hl7.fhir.dstu3.model.Organization) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) LocationStatus(org.hl7.fhir.dstu3.model.Location.LocationStatus) Location(org.hl7.fhir.dstu3.model.Location) IdType(org.hl7.fhir.dstu3.model.IdType) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 15 with IdType

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

Aggregations

IdType (org.hl7.fhir.dstu3.model.IdType)10 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)7 Coding (org.hl7.fhir.dstu3.model.Coding)7 Identifier (org.hl7.fhir.dstu3.model.Identifier)7 Reference (org.hl7.fhir.dstu3.model.Reference)7 Read (ca.uhn.fhir.rest.annotation.Read)6 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)5 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 Extension (org.hl7.fhir.dstu3.model.Extension)4 Search (ca.uhn.fhir.rest.annotation.Search)3 Appointment (org.hl7.fhir.dstu3.model.Appointment)3 Location (org.hl7.fhir.dstu3.model.Location)3 OperationOutcome (org.hl7.fhir.dstu3.model.OperationOutcome)3 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)2 UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)2 Organization (org.hl7.fhir.dstu3.model.Organization)2 Patient (org.hl7.fhir.dstu3.model.Patient)2 Practitioner (org.hl7.fhir.dstu3.model.Practitioner)2 AppointmentDetail (uk.gov.hscic.model.appointment.AppointmentDetail)2