Skip to content

Commit

Permalink
U4X-574: Add check on accession api for sample id to be required. (mo…
Browse files Browse the repository at this point in the history
  • Loading branch information
slubwama authored May 17, 2024
1 parent 50d9668 commit b425d57
Showing 1 changed file with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.openmrs.module.ugandaemr.web.resource;

import org.json.JSONObject;
import org.openmrs.Encounter;
import org.openmrs.Order;
import org.openmrs.Patient;
import org.openmrs.TestOrder;
import org.openmrs.api.OrderService;
import org.openmrs.api.context.Context;
Expand Down Expand Up @@ -53,24 +49,27 @@ public Object update(String uuid, SimpleObject propertiesToUpdate, RequestContex
OrderService orderService = Context.getOrderService();
UgandaEMRService ugandaEMRService = Context.getService(UgandaEMRService.class);
PatientQueueingService patientQueueingService = Context.getService(PatientQueueingService.class);
TestOrder testOrder = ugandaEMRService.accessionLabTest(uuid, propertiesToUpdate.get("sampleId").toString(), propertiesToUpdate.get("specimenSourceId").toString(), propertiesToUpdate.get("referenceLab").toString());

if (propertiesToUpdate.get("unProcessedOrders").toString().equals(1)) {
patientQueueingService.completePatientQueue(patientQueueingService.getPatientQueueByUuid(propertiesToUpdate.get("patientQueueId").toString()));
}

AccessionOrder delegate = new AccessionOrder();

delegate.setOrder(testOrder);

ValidateUtil.validate(delegate);
SimpleObject ret = (SimpleObject) ConversionUtil.convertToRepresentation(testOrder, context.getRepresentation());
// add the 'type' discriminator if we support subclasses
if (hasTypesDefined()) {
ret.add(RestConstants.PROPERTY_FOR_TYPE, getTypeName(delegate));
if (propertiesToUpdate.get("sampleId") != null || propertiesToUpdate.get("sampleId") != "null" || propertiesToUpdate.get("sampleId") != "") {
TestOrder testOrder = ugandaEMRService.accessionLabTest(uuid, propertiesToUpdate.get("sampleId").toString(), propertiesToUpdate.get("specimenSourceId").toString(), propertiesToUpdate.get("referenceLab").toString());

if (propertiesToUpdate.get("unProcessedOrders").toString().equals(1)) {
patientQueueingService.completePatientQueue(patientQueueingService.getPatientQueueByUuid(propertiesToUpdate.get("patientQueueId").toString()));
}

AccessionOrder delegate = new AccessionOrder();

delegate.setOrder(testOrder);

ValidateUtil.validate(delegate);
SimpleObject ret = (SimpleObject) ConversionUtil.convertToRepresentation(testOrder, context.getRepresentation());
// add the 'type' discriminator if we support subclasses
if (hasTypesDefined()) {
ret.add(RestConstants.PROPERTY_FOR_TYPE, getTypeName(delegate));
}
return ret;
}else {
throw new ResourceDoesNotSupportOperationException("The accession number or the barcode or the sample id is required");
}

return ret;
}

@Override
Expand Down

0 comments on commit b425d57

Please sign in to comment.