|
21 | 21 | import org.openmrs.Patient; |
22 | 22 | import org.openmrs.api.context.Context; |
23 | 23 | import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty; |
| 24 | +import org.openmrs.module.webservices.rest.SimpleObject; |
24 | 25 | import org.openmrs.module.webservices.rest.web.ConversionUtil; |
25 | 26 | import org.openmrs.module.webservices.rest.web.RequestContext; |
26 | 27 | import org.openmrs.module.webservices.rest.web.RestConstants; |
27 | 28 | import org.openmrs.module.webservices.rest.web.annotation.Resource; |
28 | 29 | import org.openmrs.module.webservices.rest.web.api.RestService; |
| 30 | +import org.openmrs.module.webservices.rest.web.representation.CustomRepresentation; |
29 | 31 | import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; |
30 | 32 | import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; |
31 | 33 | import org.openmrs.module.webservices.rest.web.representation.Representation; |
|
36 | 38 | import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; |
37 | 39 | import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; |
38 | 40 | import org.openmrs.module.webservices.rest.web.response.ResponseException; |
| 41 | +import org.openmrs.module.webservices.rest.web.response.ConversionException; |
39 | 42 | import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.OrderResource1_8; |
40 | 43 | import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; |
41 | 44 |
|
@@ -310,6 +313,27 @@ public int compare(Order o1, Order o2) { |
310 | 313 | }); |
311 | 314 | return sortedList; |
312 | 315 | } |
| 316 | + |
| 317 | + /** |
| 318 | + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#asRepresentation(Object, Representation) |
| 319 | + */ |
| 320 | + @Override |
| 321 | + public SimpleObject asRepresentation(Order delegate, Representation representation) throws ConversionException { |
| 322 | + DelegatingResourceDescription repDescription; |
| 323 | + if (representation instanceof CustomRepresentation) { |
| 324 | + repDescription = ConversionUtil.getCustomRepresentationDescription((CustomRepresentation) representation); |
| 325 | + return convertDelegateToRepresentation(delegate, repDescription); |
| 326 | + } |
| 327 | + |
| 328 | + SimpleObject simple = super.asRepresentation(delegate, representation); |
| 329 | + OrderType drugOrderType = Context.getOrderService().getOrderTypeByName("Drug order"); |
| 330 | + if (delegate.getOrderType().equals(drugOrderType)) { |
| 331 | + String strength = (String) findAndInvokeSubclassHandlerMethod("drugorder", |
| 332 | + "getStrength", delegate); |
| 333 | + simple.add(RestConstants.PROPERTY_FOR_STRENGTH, strength); |
| 334 | + } |
| 335 | + return simple; |
| 336 | + } |
313 | 337 |
|
314 | 338 | /** |
315 | 339 | * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getResourceVersion() |
|
0 commit comments