SimpleObject newInvObj = new SimpleObject();
newInvObj.add("name", inventories.get(i).getName());
newInvObj.add("description", inventories.get(i).getDescription());
newInvObj.add("uuid", inventories.get(i).getUuid());
SimpleObject drugObj = new SimpleObject();
Drug d = inventories.get(i).getDrug();
if (d != null) {
drugObj.add("uuid", d.getUuid());
drugObj.add("display", d.getName());
}
newInvObj.add("drug", drugObj);
newInvObj.add("quantity", inventories.get(i).getQuantity());
newInvObj.add("originalQuantity", inventories.get(i).getOriginalQuantity());
newInvObj.add("expiryDate", inventories.get(i).getExpiryDate());