SimpleObject obj = new SimpleObject();
obj.add("uuid", di.getUuid());
obj.add("name", di.getName());
obj.add("description", di.getDescription());
SimpleObject drugObj = new SimpleObject();
Drug d = di.getDrug();
if (d != null) {
drugObj.add("uuid", d.getUuid());
drugObj.add("display", d.getName());
if (d.getDosageForm() != null) {
drugObj.add("dosageForm", d.getDosageForm().getName().getName());
}
}
obj.add("drug", drugObj);
obj.add("quantity", di.getQuantity());
obj.add("originalQuantity", di.getOriginalQuantity());