public EmergencyPatientPresentingProblemsVo saveEmergencyPresentingProblems( EmergencyPatientPresentingProblemsVo problems) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException { if (problems == null) throw new CodingRuntimeException("No record to save supplied !"); if (problems.getCareContext() == null) throw new CodingRuntimeException("The care context supplied cannot be null !"); DomainFactory domainFactory = getDomainFactory(); if (problems.getID_PresProblemsProceduresPerformed() == null) { List count = domainFactory.find( "select count(p.id) from PresProblemsProceduresPerformed p where p.careContext.id = :careContextId", new String[] {"careContextId"}, new Object[] {problems.getCareContext().getID_CareContext()}); if (!count.get(0).toString().equals("0")) throw new DomainInterfaceException( "There is already a record saved for this care context !"); } PresProblemsProceduresPerformed patientPresentingProblems = EmergencyPatientPresentingProblemsVoAssembler.extractPresProblemsProceduresPerformed( domainFactory, problems); domainFactory.save(patientPresentingProblems); if (problems.getOrphanProblems() != null) { for (int i = 0; i < problems.getOrphanProblems().size(); i++) { PatientProblemVo orphanVo = problems.getOrphanProblems().get(i); PatientProblem orphan = PatientProblemVoAssembler.extractPatientProblem(domainFactory, orphanVo); domainFactory.delete(orphan); } } if (problems.getOrphanProcedures() != null) { for (int i = 0; i < problems.getOrphanProcedures().size(); i++) { PatientProcedureVo orphanVo = problems.getOrphanProcedures().get(i); PatientProcedure orphan = PatientProcedureVoAssembler.extractPatientProcedure(domainFactory, orphanVo); domainFactory.delete(orphan); } } return EmergencyPatientPresentingProblemsVoAssembler.create(patientPresentingProblems); }
public PatientProblemVoCollection listPatientProblemsByCareContext(CareContextRefVo careContext) { if (careContext == null || careContext.getID_CareContext() == null) throw new CodingRuntimeException("No Care context Supplied"); DomainFactory factory = getDomainFactory(); List problems = factory.find( "from PatientProblem p where p.careContext.id = :careContextId order by p.specialty.text, p.problem.pCName", new String[] {"careContextId"}, new Object[] {careContext.getID_CareContext()}); return PatientProblemVoAssembler.createPatientProblemVoCollectionFromPatientProblem(problems); }