@WSDoc("Gets Full representation of Drug Groups for the uuid path")
@ResponseBody()
public String getAllDrugGroupByUuidFull(@PathVariable("uuid") String uuid, @RequestParam("v") String rep,
HttpServletRequest request) throws ResponseException {
initDrugGroupController();
DrugGroup drugGroup = service.getDrugGroupByUuid(uuid);
SimpleObject obj = new SimpleObject();
obj.add("uuid", drugGroup.getUuid());
obj.add("name", drugGroup.getName());
obj.add("description", drugGroup.getDescription());
ArrayList drugs = new ArrayList();
List<Drug> drugsInDrugGroup = new ArrayList<Drug>(drugGroup.getDrugs());
for (Drug p : drugsInDrugGroup) {
SimpleObject drug = new SimpleObject();
drug.add("uuid", p.getUuid());
drugs.add(drug);
}
obj.add("drugs", drugs);
if (rep.equals("full")) {
obj.add("retired", drugGroup.getRetired());
if (drugGroup.getRetired()) {
obj.add("retiredBy", drugGroup.getRetiredBy().getUuid());
obj.add("retireReason", drugGroup.getRetireReason());
}
SimpleObject auditInfo = new SimpleObject();
auditInfo.add("creator", drugGroup.getCreator().getUuid());
auditInfo.add("dateCreated", df.format(drugGroup.getDateCreated()));
if (drugGroup.getChangedBy() != null) {
auditInfo.add("changedBy", drugGroup.getChangedBy().getUuid());
auditInfo.add("dateChanged", df.format(drugGroup.getDateChanged()));
}
obj.add("auditInfo", auditInfo);
}
obj.add("resourceVersion", getResourceVersion());
return gson.toJson(obj);