public EquipmentVoCollection listEquipment(PatientShort voPrisoner, Boolean activeOnly) { if (voPrisoner == null) throw new RuntimeException("Cannot get EquipmentVoCollection for null patient"); DomainFactory factory = getDomainFactory(); ArrayList<String> params = new ArrayList<String>(); ArrayList<Object> values = new ArrayList<Object>(); String hql = "from Equipment eq where eq.careContext.episodeOfCare.careSpell.patient.id = :patientId"; params.add("patientId"); values.add(voPrisoner.getID_Patient()); if (Boolean.TRUE.equals(activeOnly)) { hql += " and (eq.inactive = :inactive or eq.inactive is null) "; params.add("inactive"); values.add(Boolean.FALSE); } List equipList = factory.find(hql, params, values); return EquipmentVoAssembler.createEquipmentVoCollectionFromEquipment(equipList); }
public EquipmentVo saveEquipmentDetails(EquipmentVo equipment) throws DomainInterfaceException, StaleObjectException { if (!equipment.isValidated()) { throw new DomainRuntimeException("Equipment has not been validated"); } DomainFactory factory = getDomainFactory(); Equipment doEquipment = EquipmentVoAssembler.extractEquipment(factory, equipment); factory.save(doEquipment); return EquipmentVoAssembler.create(doEquipment); }
public EquipmentVoCollection listEquipmentByCareContext(CareContextLiteVo voCareContextLite, Boolean activeOnly) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(); String query = " from Equipment eq "; ArrayList markers= new ArrayList(); ArrayList values = new ArrayList(); String andStr = " "; if(voCareContextLite.getEpisodeOfCareIsNotNull()) { hql.append(andStr + " eq.careContext.id = :ec"); markers.add("ec"); values.add(voCareContextLite.getID_CareContext()); andStr = " and "; } if (Boolean.TRUE.equals(activeOnly)) { hql.append(andStr + " eq.inactive is null "); andStr = " and "; } if (markers.size() > 0) query += " where "; query += hql.toString(); java.util.List edList = factory.find(query,markers,values); EquipmentVoCollection voEquipmentColl = EquipmentVoAssembler.createEquipmentVoCollectionFromEquipment(edList); if(voEquipmentColl.size()>0) return voEquipmentColl; else return null; }
public EquipmentVo getEquipment(EquipmentRefVo equipmentId) { if(equipmentId == null || !equipmentId.getID_EquipmentIsNotNull()) throw new CodingRuntimeException("Can not get Equipment on null Id."); return EquipmentVoAssembler.create((Equipment) getDomainFactory().getDomainObject(Equipment.class, equipmentId.getID_Equipment())); }