public MDTPatientCustomListVo saveCustomList(CustomListVo customListVo, MDTPatientCustomListVo patientCustomListVo) throws StaleObjectException { if (!patientCustomListVo.isValidated()) { throw new DomainRuntimeException("CustomList has not been validated"); } DomainFactory factory = getDomainFactory(); CustomList doCustomList = CustomListVoAssembler.extractCustomList(factory, customListVo); factory.save(doCustomList); MDTPatientCustomList doPatientCustomList = MDTPatientCustomListVoAssembler.extractMDTPatientCustomList(factory, patientCustomListVo); doPatientCustomList.setCustomListType(doCustomList); factory.save(doPatientCustomList); return MDTPatientCustomListVoAssembler.create(doPatientCustomList); }
public MDTPatientCustomListVo getCustomList(CustomListRefVo reVoCustomList) { if(reVoCustomList == null) throw new CodingRuntimeException("null type passed to listCustomListTypes() !"); DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" "); String query = "from MDTPatientCustomList as pcl "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String andStr = " "; if (reVoCustomList.getID_CustomListIsNotNull()) { hql.append(andStr + " pcl.customListType.id = :CustomListTypeId"); markers.add("CustomListTypeId"); values.add(reVoCustomList.getID_CustomList()); andStr = " and "; } if (andStr.equals(" and ")) query += " where "; query += hql.toString(); List list = factory.find(query, markers, values); if(list.size() == 0) return null; MDTPatientCustomListVoCollection coll = MDTPatientCustomListVoAssembler.createMDTPatientCustomListVoCollectionFromMDTPatientCustomList(list); return coll.get(0); }