/** * saveClinicalCorrespondence */ public ims.clinical.vo.ClinicalCorrespondenceVo saveClinicalCorrespondence(ims.clinical.vo.ClinicalCorrespondenceVo clinicalCorrespondence) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException { if(clinicalCorrespondence == null) throw new CodingRuntimeException("null clinicalCorrespondence passed to saveClinicalCorrespondence() !"); if(!clinicalCorrespondence.isValidated()) throw new CodingRuntimeException("clinicalCorrespondence not validated !"); DomainFactory factory = getDomainFactory(); ClinicalCorrespondence boClinicalCorrespondence = ClinicalCorrespondenceVoAssembler.extractClinicalCorrespondence(factory, clinicalCorrespondence); InpatientDischargeNoteFollowup idsBo = boClinicalCorrespondence.getInpatientDischargeSummary(); OutpatientNotesOutcome opdBo = boClinicalCorrespondence.getOPDNotes(); if(idsBo != null) { factory.save(idsBo); boClinicalCorrespondence.setInpatientDischargeSummary(idsBo); } if(opdBo != null) { factory.save(opdBo); boClinicalCorrespondence.setOPDNotes(opdBo); } factory.save(boClinicalCorrespondence); return ClinicalCorrespondenceVoAssembler.create(boClinicalCorrespondence); }
/** * getLastClinicalCorrespondence */ public ClinicalCorrespondenceVo getLastClinicalCorrespondence(CareContextRefVo careContext, ClinicalCorrespondenceType type, ClinicalContactRefVo clinicalContact) { /* if(careContext == null) throw new CodingRuntimeException("null careContext passed to getLastClinicalCorrespondence() !"); */ ArrayList names = new ArrayList(); ArrayList values = new ArrayList(); if(type == null) throw new CodingRuntimeException("null type passed to getLastClinicalCorrespondence() !"); DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer("from ClinicalCorrespondence as c1_1 "); hql.append(" where c1_1.type.id = :TYPEID"); names.add("TYPEID"); values.add(new Integer(type.getId())); if (careContext != null) { hql.append (" and c1_1.careContext.id = :CONTEXTID"); names.add("CONTEXTID"); values.add(careContext.getID_CareContext()); } if (clinicalContact != null) { hql.append (" and c1_1.clinicalContact.id = :CONTACTID"); names.add("CONTACTID"); values.add(clinicalContact.getID_ClinicalContact()); } List list = factory.find(hql.toString(), names, values); if(list.size() == 0) return null; ClinicalCorrespondenceVo voClinicalCorrespondence = ClinicalCorrespondenceVoAssembler.create((ClinicalCorrespondence)list.get(0)); if (type.equals(ClinicalCorrespondenceType.MEDICALOUTPATIENTLETTER)) { if(voClinicalCorrespondence.getOPDNotes() == null && clinicalContact != null && clinicalContact.getID_ClinicalContactIsNotNull()) voClinicalCorrespondence.setOPDNotes(getOPDSummary(clinicalContact)); } return voClinicalCorrespondence; }