Skip to content

Instantly share code, notes, and snippets.

@djazayeri
Created May 12, 2015 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djazayeri/690a5b36845993af8993 to your computer and use it in GitHub Desktop.
Save djazayeri/690a5b36845993af8993 to your computer and use it in GitHub Desktop.
OrderEntryConfigResource1_10
@Resource(name = RestConstants.VERSION_1 + "/orderentryconfig", supportedClass = Object.class, supportedOpenmrsVersions = {"1.10.*", "1.11.*"})
public class OrderEntryConfigResource1_10 implements Listable {
@Override
public SimpleObject getAll(RequestContext context) throws ResponseException {
OrderService orderService = Context.getOrderService();
SimpleObject ret = new SimpleObject();
// try/catch each of these to avoid failing in the case where one of these is not configured
try {
ret.put("drugRoutes", ConversionUtil.convertToRepresentation(orderService.getDrugRoutes(), context.getRepresentation()));
} catch (Exception ex) { }
try {
ret.put("drugDosingUnits", ConversionUtil.convertToRepresentation(orderService.getDrugDosingUnits(), context.getRepresentation()));
} catch (Exception ex) { }
try {
ret.put("drugDispensingUnits", ConversionUtil.convertToRepresentation(orderService.getDrugDispensingUnits(), context.getRepresentation()));
} catch (Exception ex) { }
try {
ret.put("durationUnits", ConversionUtil.convertToRepresentation(orderService.getDurationUnits(), context.getRepresentation()));
} catch (Exception ex) { }
try {
ret.put("testSpecimenSources", ConversionUtil.convertToRepresentation(orderService.getTestSpecimenSources(), context.getRepresentation()));
} catch (Exception ex) { }
try {
ret.put("orderFrequencies", ConversionUtil.convertToRepresentation(orderService.getOrderFrequencies(false), context.getRepresentation()));
} catch (Exception ex) { }
return ret;
}
@Override
public String getUri(Object instance) {
return RestConstants.URI_PREFIX + "/orderentryconfig";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment