public PresentAbsentHistoryProblemsVo getHistoryProblems( CareContextRefVo careContextRef) { DomainFactory factory = getDomainFactory(); String strHQL = "from PresentAbsentHistoryProblems p where p.careContext.id = " + careContextRef.getID_CareContext(); List probs = factory.find(strHQL); PresentAbsentHistoryProblemsVoCollection vocollProblems = PresentAbsentHistoryProblemsVoAssembler.createPresentAbsentHistoryProblemsVoCollectionFromPresentAbsentHistoryProblems(probs); if (vocollProblems != null && vocollProblems.size() > 0) return vocollProblems.get(0); else return null; }
public PresentAbsentHistoryProblemsVo save(PresentAbsentHistoryProblemsVo voHistoryProblems) throws StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException { if(!voHistoryProblems.isValidated()) { throw new DomainRuntimeException("History Problems Value Object has not been validated"); } if (voHistoryProblems.getID_PresentAbsentHistoryProblems() == null)//Inserting a record { //WDEV-18556 PresentAbsentHistoryProblemsVo voHP = getHistoryProblems(voHistoryProblems.getCareContext()); if(voHP != null) throw new StaleObjectException(null, "A record exists for this clinical contact, the screen will be refreshed"); } DomainFactory factory = getDomainFactory(); PresentAbsentHistoryProblems domPresentAbsentHistoryProblems = PresentAbsentHistoryProblemsVoAssembler.extractPresentAbsentHistoryProblems(factory,voHistoryProblems); try { factory.save(domPresentAbsentHistoryProblems); } catch(UnqViolationUncheckedException e) { throw new ims.domain.exceptions.UniqueKeyViolationException("A Present Absent history problem already exists for this Clinical Contact.", e); } return PresentAbsentHistoryProblemsVoAssembler.create(domPresentAbsentHistoryProblems); }