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;
}
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);
}
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;
}
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);
}
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));
}
Aggregations