Search in sources :

Example 1 with InternalErrorException

use of ca.uhn.fhir.rest.server.exceptions.InternalErrorException 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 InternalErrorException

use of ca.uhn.fhir.rest.server.exceptions.InternalErrorException 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 InternalErrorException

use of ca.uhn.fhir.rest.server.exceptions.InternalErrorException 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)

Aggregations

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