*
* @param di
* @return SimpleObject the representation of Drug Inventory
*/
private SimpleObject getFieldsFromDrugInventory(DrugInventory di) {
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());
obj.add("expiryDate", di.getExpiryDate());
obj.add("batch", di.getBatch());
obj.add("supplier", di.getSupplier());
obj.add("value", di.getValue());
obj.add("status", di.getStatus());
obj.add("roomLocation", di.getRoomLocation());
SimpleObject pObj = new SimpleObject();
Provider p = di.getProvider();
if (p != null) {
pObj.add("uuid", p.getUuid());
pObj.add("display", p.getName());
}
obj.add("provider", pObj);
SimpleObject lObj = new SimpleObject();
Location l = di.getLocation();
if (l != null) {
lObj.add("uuid", l.getUuid());
lObj.add("display", l.getName());
}
obj.add("location", lObj);
SimpleObject dPOObj = new SimpleObject();
DrugPurchaseOrder dPO = di.getDrugPurchaseOrder();
if (dPO != null) {
dPOObj.add("uuid", dPO.getUuid());
dPOObj.add("display", dPO.getName());
}
obj.add("drugPurchaseOrder", dPOObj);
return obj;
}