public ElectrotherapyUltrasoundVo save(ElectrotherapyUltrasoundVo voElectroUltrasound) throws StaleObjectException, UniqueKeyViolationException { if(!voElectroUltrasound.isValidated()) throw new DomainRuntimeException("This Ultrasound has not been validated"); DomainFactory factory = getDomainFactory(); if (voElectroUltrasound.getID_ElectrotherapyUltrasound() == null)//Inserting a record { ElectrotherapyUltrasoundVo vo = getUltrasoundByClinicalContact(voElectroUltrasound.getClinicalContact()); if(vo != null) throw new UniqueKeyViolationException("The screen will be refreshed"); } ElectrotherapyUltrasound doUltrasound = ElectrotherapyUltrasoundVoAssembler.extractElectrotherapyUltrasound(factory, voElectroUltrasound); factory.save(doUltrasound); return ElectrotherapyUltrasoundVoAssembler.create(doUltrasound); }
/** * WDEV-13648 * Get ElectrotherapyUltrasoundVo record by id */ public ElectrotherapyUltrasoundVo getUltrasound(ElectrotherapyUltrasoundRefVo ultrasound) { // Check parameter if (ultrasound == null || !ultrasound.getID_ElectrotherapyUltrasoundIsNotNull()) return null; return ElectrotherapyUltrasoundVoAssembler.create((ElectrotherapyUltrasound) getDomainFactory().getDomainObject(ElectrotherapyUltrasound.class, ultrasound.getID_ElectrotherapyUltrasound())); }
private ElectrotherapyUltrasoundVo getUltrasoundByClinicalContact(ClinicalContactShortVo voClinicalContact) { if(voClinicalContact == null) throw new CodingRuntimeException("ElectrotherapyUltrasound Filter not provided for get call. "); String hql = "from ElectrotherapyUltrasound e where e.clinicalContact.id = :CLINICAL_CONTACT_ID and e.isRIE is null"; return ElectrotherapyUltrasoundVoAssembler.create((ElectrotherapyUltrasound) getDomainFactory().findFirst(hql, "CLINICAL_CONTACT_ID", voClinicalContact.getID_ClinicalContact())); }