Search in sources :

Example 1 with Read

use of ca.uhn.fhir.rest.annotation.Read in project gpconnect-demonstrator by nhsconnect.

the class MedicationResourceProvider method getMedicationById.

@Read()
public Medication getMedicationById(@IdParam IdType medicationId) {
    MedicationEntity medicationEntity = medicationRepository.findOne(medicationId.getIdPartAsLong());
    if (medicationEntity == null) {
        OperationOutcome operationalOutcome = new OperationOutcome();
        operationalOutcome.addIssue().setSeverity(IssueSeverity.ERROR).setDiagnostics("No medication details found for ID: " + medicationId.getIdPart());
        throw new InternalErrorException("No medication details found for ID: " + medicationId.getIdPart(), operationalOutcome);
    }
    Medication medication = new Medication();
    String resourceId = String.valueOf(medicationEntity.getId());
    String versionId = String.valueOf(medicationEntity.getLastUpdated().getTime());
    String resourceType = medication.getResourceType().toString();
    IdType id = new IdType(resourceType, resourceId, versionId);
    medication.setId(id);
    medication.getMeta().setVersionId(versionId);
    medication.getMeta().setLastUpdated(medicationEntity.getLastUpdated());
    return medication;
}
Also used : OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) Medication(org.hl7.fhir.dstu3.model.Medication) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) IdType(org.hl7.fhir.dstu3.model.IdType) Read(ca.uhn.fhir.rest.annotation.Read)

Example 2 with Read

use of ca.uhn.fhir.rest.annotation.Read 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 3 with Read

use of ca.uhn.fhir.rest.annotation.Read 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 4 with Read

use of ca.uhn.fhir.rest.annotation.Read in project gpconnect-demonstrator by nhsconnect.

the class MedicationOrderResourceProvider method getMedicationOrderById.

@Read()
public MedicationRequest getMedicationOrderById(@IdParam IdType medicationOrderId) {
    MedicationOrderDetails medicationOrderDetails = medicationOrderSearch.findMedicationOrderByID(medicationOrderId.getIdPartAsLong());
    if (medicationOrderDetails == null) {
        OperationOutcome operationalOutcome = new OperationOutcome();
        operationalOutcome.addIssue().setSeverity(IssueSeverity.ERROR).setDiagnostics("No medicationOrder details found for ID: " + medicationOrderId.getIdPart());
        throw new InternalErrorException("No medicationOrder details found for ID: " + medicationOrderId.getIdPart(), operationalOutcome);
    }
    return medicationOrderDetailsToMedicationOrderResourceConverter(medicationOrderDetails);
}
Also used : MedicationOrderDetails(uk.gov.hscic.model.medication.MedicationOrderDetails) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) Read(ca.uhn.fhir.rest.annotation.Read)

Example 5 with Read

use of ca.uhn.fhir.rest.annotation.Read in project gpconnect-demonstrator by nhsconnect.

the class OrganizationResourceProvider method getOrganizationById.

@Read(version = true)
public Organization getOrganizationById(@IdParam IdType organizationId) {
    OrganizationDetails organizationDetails = null;
    String idPart = organizationId.getIdPart();
    try {
        Long id = Long.parseLong(idPart);
        organizationDetails = organizationSearch.findOrganizationDetails(id);
        if (organizationDetails == null) {
            throw OperationOutcomeFactory.buildOperationOutcomeException(new ResourceNotFoundException("No organization details found for organization ID: " + idPart), SystemCode.ORGANISATION_NOT_FOUND, IssueType.INVALID);
        }
    } catch (NumberFormatException nfe) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(new ResourceNotFoundException("No organization details found for organization ID: " + idPart), SystemCode.ORGANISATION_NOT_FOUND, IssueType.INVALID);
    }
    return IdentifierValidator.versionComparison(organizationId, convertOrganizatonDetailsListToOrganizationList(Collections.singletonList(organizationDetails)).get(0));
}
Also used : OrganizationDetails(uk.gov.hscic.model.organization.OrganizationDetails) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Read(ca.uhn.fhir.rest.annotation.Read)

Aggregations

Read (ca.uhn.fhir.rest.annotation.Read)5 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)3 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)2 OperationOutcome (org.hl7.fhir.dstu3.model.OperationOutcome)2 IdType (org.hl7.fhir.dstu3.model.IdType)1 Location (org.hl7.fhir.dstu3.model.Location)1 Medication (org.hl7.fhir.dstu3.model.Medication)1 SlotDetail (uk.gov.hscic.model.appointment.SlotDetail)1 LocationDetails (uk.gov.hscic.model.location.LocationDetails)1 MedicationOrderDetails (uk.gov.hscic.model.medication.MedicationOrderDetails)1 OrganizationDetails (uk.gov.hscic.model.organization.OrganizationDetails)1