Java 类ims.clinical.vo.domain.DischargeReadyToLeaveVoAssembler 实例源码

项目:openMAXIMS    文件:EDischargePatientReadyToLeaveComponentImpl.java   
public DischargeReadyToLeaveVo saveReadyToLeave(DischargeReadyToLeaveVo voReady, RTLSummaryVo rTLSummaryVo) throws DomainInterfaceException, StaleObjectException 
{
    if(voReady == null)
        throw new CodingRuntimeException("DischargeReadyToLeaveVo is null");

    if(!voReady.isValidated())
        throw new CodingRuntimeException("DischargeReadyToLeaveVo Value Object has not been validated");

    DomainFactory factory = getDomainFactory();
    ReadyToLeave doRTL = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);
    RTLSummary doRTLSummary = RTLSummaryVoAssembler.extractRTLSummary(factory, rTLSummaryVo); //WDEV-18622

    factory.save(doRTL);
    factory.save(doRTLSummary); //WDEV-18622 
    return DischargeReadyToLeaveVoAssembler.create(doRTL);
}
项目:AvoinApotti    文件:EDischargePatientReadyToLeaveSTHKComponentImpl.java   
public DischargeReadyToLeaveVo saveReadyToLeave(DischargeReadyToLeaveVo voReady, SummaryRefVo voSummary) throws DomainInterfaceException, StaleObjectException 
{
    if(voReady == null)
        throw new CodingRuntimeException("DischargeReadyToLeaveVo is null");

    if(!voReady.isValidated())
        throw new CodingRuntimeException("DischargeReadyToLeaveVo Value Object has not been validated");

    DomainFactory factory = getDomainFactory();

    //There is a situation where is possible that the scheduled jobs have run while you
    //are editing the ready to leave record. This should be dealt with by throwing a StaleObjectException
    String hql = "select count(summa.id) from Summary as summa where (summa.id=:sumId and (summa.dischargeLetterStatus.id =:dischLettId  or summa.dischargeSupplementaryLetterStatus.id = :dischSuppLettId))";
    long isCompleted = factory.countWithHQL(hql, new String[]{"sumId","dischLettId","dischSuppLettId"}, new Object[]{voSummary.getID_Summary(),DischargeLetterStatus.GENERATED.getId(),DischargeSupplementaryLetterStatus.GENERATED.getID()});
    if (isCompleted > 0)
    {
        throw new StaleObjectException(null);
    }

    ReadyToLeave doRTL = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);
    factory.save(doRTL);

    //updating summary WDEV-11348
    IEDischargeHelper impl = (IEDischargeHelper) getDomainImpl(EDischargeHelper.class); 
    impl.updateSummaryIfRequired(voReady, voSummary, factory);

    return DischargeReadyToLeaveVoAssembler.create(doRTL);
}
项目:AvoinApotti    文件:EDischargePatientReadyToLeaveSTHKComponentImpl.java   
public DischargeReadyToLeaveVo getReadyToLeave(CareContextRefVo careContextRefvo) 
{
    if(careContextRefvo == null)
        throw new CodingRuntimeException("careContextRefVo Filter not provided for list call. ");

    if(careContextRefvo != null)
    {
        DomainFactory factory = getDomainFactory();
        StringBuffer hql = new StringBuffer(" from ReadyToLeave rtl where "); 
        String andStr = " ";

        ArrayList<String> markers = new ArrayList<String>();
        ArrayList<Serializable> values = new ArrayList<Serializable>();

        hql.append(andStr + " rtl.careContext.id = :careContextId");
            markers.add("careContextId");
        values.add(careContextRefvo.getID_CareContext());
        andStr = " and ";   

        List list = factory.find(hql.toString(), markers,values);
        if(list != null && list.size() > 0)
        { 
            DischargeReadyToLeaveVoCollection voColl = DischargeReadyToLeaveVoAssembler.createDischargeReadyToLeaveVoCollectionFromReadyToLeave(list);
            if(voColl != null && voColl.size() > 0)
                return voColl.get(0);
        }
    }
    return null;
}
项目:AvoinApotti    文件:EDischargePatientReadyToLeaveComponentImpl.java   
public DischargeReadyToLeaveVo saveReadyToLeave(DischargeReadyToLeaveVo voReady) throws DomainInterfaceException, StaleObjectException 
{
    if(voReady == null)
        throw new CodingRuntimeException("DischargeReadyToLeaveVo is null");

    if(!voReady.isValidated())
        throw new CodingRuntimeException("DischargeReadyToLeaveVo Value Object has not been validated");

    DomainFactory factory = getDomainFactory();
    ReadyToLeave doRTL = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);

    factory.save(doRTL);
    return DischargeReadyToLeaveVoAssembler.create(doRTL);
}
项目:AvoinApotti    文件:EDischargePatientReadyToLeaveComponentImpl.java   
public DischargeReadyToLeaveVo getReadyToLeave(CareContextRefVo careContextRefvo) 
{
    if(careContextRefvo == null)
        throw new CodingRuntimeException("careContextRefVo Filter not provided for list call. ");

    if(careContextRefvo != null)
    {
        DomainFactory factory = getDomainFactory();
        StringBuffer hql = new StringBuffer(" from ReadyToLeave rtl where "); 
        String andStr = " ";

        ArrayList<String> markers = new ArrayList<String>();
        ArrayList<Serializable> values = new ArrayList<Serializable>();

        hql.append(andStr + " rtl.careContext.id = :careContextId");
            markers.add("careContextId");
        values.add(careContextRefvo.getID_CareContext());
        andStr = " and ";   

        List list = factory.find(hql.toString(), markers,values);
        if(list != null && list.size() > 0)
        { 
            DischargeReadyToLeaveVoCollection voColl = DischargeReadyToLeaveVoAssembler.createDischargeReadyToLeaveVoCollectionFromReadyToLeave(list);
            if(voColl != null && voColl.size() > 0)
                return voColl.get(0);
        }
    }
    return null;
}
项目:AvoinApotti    文件:EDischargePreViewComponentImpl.java   
public DischargeReportDetailVo saveDischargeReportDetail(DischargeReportDetailVo record, DischargeReadyToLeaveVo voReady) throws StaleObjectException
{
    if (record != null)
    {
        if (!record.isValidated())
            throw new DomainRuntimeException("PatientDocumentVo not validated");
    }
    DomainFactory factory = getDomainFactory();
    if  (!record.getID_DischargeReportDetailIsNotNull())
    {

        List<?> dischargeDetails = factory.find("select dd from DischargeReportDetail as dd left join dd.careContext as cc where cc.id = :idCareContext and dd.isRIE is null ", new String[]{"idCareContext"}, new Object[]{record.getCareContext().getID_CareContext()});
        if (dischargeDetails != null && dischargeDetails.size()>0)
        {
            throw new StaleObjectException(null);
        }
    }

    DischargeReportDetail dom = DischargeReportDetailVoAssembler.extractDischargeReportDetail(factory, record);
    factory.save(dom);              

    if (voReady != null)
    {
        ReadyToLeave domReady = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);
        factory.save(domReady);             
    }

    return DischargeReportDetailVoAssembler.create(dom);
}
项目:openMAXIMS    文件:EDischargePatientReadyToLeaveSTHKComponentImpl.java   
public DischargeReadyToLeaveVo saveReadyToLeave(DischargeReadyToLeaveVo voReady, SummaryRefVo voSummary) throws DomainInterfaceException, StaleObjectException 
{
    if(voReady == null)
        throw new CodingRuntimeException("DischargeReadyToLeaveVo is null");

    if(!voReady.isValidated())
        throw new CodingRuntimeException("DischargeReadyToLeaveVo Value Object has not been validated");

    DomainFactory factory = getDomainFactory();

    //There is a situation where is possible that the scheduled jobs have run while you
    //are editing the ready to leave record. This should be dealt with by throwing a StaleObjectException
    String hql = "select count(summa.id) from Summary as summa where (summa.id=:sumId and (summa.dischargeLetterStatus.id =:dischLettId  or summa.dischargeSupplementaryLetterStatus.id = :dischSuppLettId))";
    long isCompleted = factory.countWithHQL(hql, new String[]{"sumId","dischLettId","dischSuppLettId"}, new Object[]{voSummary.getID_Summary(),DischargeLetterStatus.GENERATED.getId(),DischargeSupplementaryLetterStatus.GENERATED.getID()});
    if (isCompleted > 0)
    {
        throw new StaleObjectException(null);
    }

    ReadyToLeave doRTL = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);
    factory.save(doRTL);

    //updating summary WDEV-11348
    IEDischargeHelper impl = (IEDischargeHelper) getDomainImpl(EDischargeHelper.class); 
    impl.updateSummaryIfRequired(voReady, voSummary, factory);

    return DischargeReadyToLeaveVoAssembler.create(doRTL);
}
项目:openMAXIMS    文件:EDischargePatientReadyToLeaveSTHKComponentImpl.java   
public DischargeReadyToLeaveVo getReadyToLeave(CareContextRefVo careContextRefvo) 
{
    if(careContextRefvo == null)
        throw new CodingRuntimeException("careContextRefVo Filter not provided for list call. ");

    if(careContextRefvo != null)
    {
        DomainFactory factory = getDomainFactory();
        StringBuffer hql = new StringBuffer(" from ReadyToLeave rtl where "); 
        String andStr = " ";

        ArrayList<String> markers = new ArrayList<String>();
        ArrayList<Serializable> values = new ArrayList<Serializable>();

        hql.append(andStr + " rtl.careContext.id = :careContextId");
            markers.add("careContextId");
        values.add(careContextRefvo.getID_CareContext());
        andStr = " and ";   

        List list = factory.find(hql.toString(), markers,values);
        if(list != null && list.size() > 0)
        { 
            DischargeReadyToLeaveVoCollection voColl = DischargeReadyToLeaveVoAssembler.createDischargeReadyToLeaveVoCollectionFromReadyToLeave(list);
            if(voColl != null && voColl.size() > 0)
                return voColl.get(0);
        }
    }
    return null;
}
项目:openMAXIMS    文件:EDischargePatientReadyToLeaveComponentImpl.java   
public DischargeReadyToLeaveVo getReadyToLeave(CareContextRefVo careContextRefvo) 
{
    if(careContextRefvo == null)
        throw new CodingRuntimeException("careContextRefVo Filter not provided for list call. ");

    if(careContextRefvo != null)
    {
        DomainFactory factory = getDomainFactory();
        StringBuffer hql = new StringBuffer(" from ReadyToLeave rtl where "); 
        String andStr = " ";

        ArrayList<String> markers = new ArrayList<String>();
        ArrayList<Serializable> values = new ArrayList<Serializable>();

        hql.append(andStr + " rtl.careContext.id = :careContextId");
            markers.add("careContextId");
        values.add(careContextRefvo.getID_CareContext());
        andStr = " and ";   

        List list = factory.find(hql.toString(), markers,values);
        if(list != null && list.size() > 0)
        { 
            DischargeReadyToLeaveVoCollection voColl = DischargeReadyToLeaveVoAssembler.createDischargeReadyToLeaveVoCollectionFromReadyToLeave(list);
            if(voColl != null && voColl.size() > 0)
                return voColl.get(0);
        }
    }
    return null;
}
项目:openMAXIMS    文件:EDischargePreViewComponentImpl.java   
public DischargeReportDetailVo saveDischargeReportDetail(DischargeReportDetailVo record, DischargeReadyToLeaveVo voReady, RTLSummaryVo rTLSummaryVo, PatientNoDiagInfoForCCVo patientNoDiagInfo) throws StaleObjectException
{
    if (record != null)
    {
        if (!record.isValidated())
            throw new DomainRuntimeException("PatientDocumentVo not validated");
    }
    DomainFactory factory = getDomainFactory();
    if  (!record.getID_DischargeReportDetailIsNotNull())
    {

        List<?> dischargeDetails = factory.find("select dd from DischargeReportDetail as dd left join dd.careContext as cc where cc.id = :idCareContext and dd.isRIE is null ", new String[]{"idCareContext"}, new Object[]{record.getCareContext().getID_CareContext()});
        if (dischargeDetails != null && dischargeDetails.size()>0)
        {
            throw new StaleObjectException(null);
        }
    }

    DischargeReportDetail dom = DischargeReportDetailVoAssembler.extractDischargeReportDetail(factory, record);
    RTLSummary doRTLSummary = RTLSummaryVoAssembler.extractRTLSummary(factory, rTLSummaryVo); //WDEV-18622 
    factory.save(dom);
    factory.save(doRTLSummary); //WDEV-18622 

    //WDEV-18627
    if (patientNoDiagInfo != null)
    {
        PatientNoDiagInfoForCC patientNoDiagInfoDo = PatientNoDiagInfoForCCVoAssembler.extractPatientNoDiagInfoForCC(factory, patientNoDiagInfo);
        factory.save(patientNoDiagInfoDo);
    }

    if (voReady != null)
    {
        ReadyToLeave domReady = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);
        factory.save(domReady);             
    }

    return DischargeReportDetailVoAssembler.create(dom);
}
项目:openMAXIMS    文件:EDischargePatientReadyToLeaveSTHKComponentImpl.java   
public DischargeReadyToLeaveVo saveReadyToLeave(DischargeReadyToLeaveVo voReady, SummaryRefVo voSummary) throws DomainInterfaceException, StaleObjectException 
{
    if(voReady == null)
        throw new CodingRuntimeException("DischargeReadyToLeaveVo is null");

    if(!voReady.isValidated())
        throw new CodingRuntimeException("DischargeReadyToLeaveVo Value Object has not been validated");

    DomainFactory factory = getDomainFactory();

    //There is a situation where is possible that the scheduled jobs have run while you
    //are editing the ready to leave record. This should be dealt with by throwing a StaleObjectException
    String hql = "select count(summa.id) from Summary as summa where (summa.id=:sumId and (summa.dischargeLetterStatus.id =:dischLettId  or summa.dischargeSupplementaryLetterStatus.id = :dischSuppLettId))";
    long isCompleted = factory.countWithHQL(hql, new String[]{"sumId","dischLettId","dischSuppLettId"}, new Object[]{voSummary.getID_Summary(),DischargeLetterStatus.GENERATED.getId(),DischargeSupplementaryLetterStatus.GENERATED.getID()});
    if (isCompleted > 0)
    {
        throw new StaleObjectException(null);
    }

    ReadyToLeave doRTL = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);
    factory.save(doRTL);

    //updating summary WDEV-11348
    IEDischargeHelper impl = (IEDischargeHelper) getDomainImpl(EDischargeHelper.class); 
    impl.updateSummaryIfRequired(voReady, voSummary, factory);

    return DischargeReadyToLeaveVoAssembler.create(doRTL);
}
项目:openMAXIMS    文件:EDischargePatientReadyToLeaveSTHKComponentImpl.java   
public DischargeReadyToLeaveVo getReadyToLeave(CareContextRefVo careContextRefvo) 
{
    if(careContextRefvo == null)
        throw new CodingRuntimeException("careContextRefVo Filter not provided for list call. ");

    if(careContextRefvo != null)
    {
        DomainFactory factory = getDomainFactory();
        StringBuffer hql = new StringBuffer(" from ReadyToLeave rtl where "); 
        String andStr = " ";

        ArrayList<String> markers = new ArrayList<String>();
        ArrayList<Serializable> values = new ArrayList<Serializable>();

        hql.append(andStr + " rtl.careContext.id = :careContextId");
            markers.add("careContextId");
        values.add(careContextRefvo.getID_CareContext());
        andStr = " and ";   

        List list = factory.find(hql.toString(), markers,values);
        if(list != null && list.size() > 0)
        { 
            DischargeReadyToLeaveVoCollection voColl = DischargeReadyToLeaveVoAssembler.createDischargeReadyToLeaveVoCollectionFromReadyToLeave(list);
            if(voColl != null && voColl.size() > 0)
                return voColl.get(0);
        }
    }
    return null;
}
项目:openMAXIMS    文件:EDischargePatientReadyToLeaveComponentImpl.java   
public DischargeReadyToLeaveVo saveReadyToLeave(DischargeReadyToLeaveVo voReady) throws DomainInterfaceException, StaleObjectException 
{
    if(voReady == null)
        throw new CodingRuntimeException("DischargeReadyToLeaveVo is null");

    if(!voReady.isValidated())
        throw new CodingRuntimeException("DischargeReadyToLeaveVo Value Object has not been validated");

    DomainFactory factory = getDomainFactory();
    ReadyToLeave doRTL = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);

    factory.save(doRTL);
    return DischargeReadyToLeaveVoAssembler.create(doRTL);
}
项目:openMAXIMS    文件:EDischargePatientReadyToLeaveComponentImpl.java   
public DischargeReadyToLeaveVo getReadyToLeave(CareContextRefVo careContextRefvo) 
{
    if(careContextRefvo == null)
        throw new CodingRuntimeException("careContextRefVo Filter not provided for list call. ");

    if(careContextRefvo != null)
    {
        DomainFactory factory = getDomainFactory();
        StringBuffer hql = new StringBuffer(" from ReadyToLeave rtl where "); 
        String andStr = " ";

        ArrayList<String> markers = new ArrayList<String>();
        ArrayList<Serializable> values = new ArrayList<Serializable>();

        hql.append(andStr + " rtl.careContext.id = :careContextId");
            markers.add("careContextId");
        values.add(careContextRefvo.getID_CareContext());
        andStr = " and ";   

        List list = factory.find(hql.toString(), markers,values);
        if(list != null && list.size() > 0)
        { 
            DischargeReadyToLeaveVoCollection voColl = DischargeReadyToLeaveVoAssembler.createDischargeReadyToLeaveVoCollectionFromReadyToLeave(list);
            if(voColl != null && voColl.size() > 0)
                return voColl.get(0);
        }
    }
    return null;
}
项目:openMAXIMS    文件:EDischargePreViewComponentImpl.java   
public DischargeReportDetailVo saveDischargeReportDetail(DischargeReportDetailVo record, DischargeReadyToLeaveVo voReady) throws StaleObjectException
{
    if (record != null)
    {
        if (!record.isValidated())
            throw new DomainRuntimeException("PatientDocumentVo not validated");
    }
    DomainFactory factory = getDomainFactory();
    if  (!record.getID_DischargeReportDetailIsNotNull())
    {

        List<?> dischargeDetails = factory.find("select dd from DischargeReportDetail as dd left join dd.careContext as cc where cc.id = :idCareContext and dd.isRIE is null ", new String[]{"idCareContext"}, new Object[]{record.getCareContext().getID_CareContext()});
        if (dischargeDetails != null && dischargeDetails.size()>0)
        {
            throw new StaleObjectException(null);
        }
    }

    DischargeReportDetail dom = DischargeReportDetailVoAssembler.extractDischargeReportDetail(factory, record);
    factory.save(dom);              

    if (voReady != null)
    {
        ReadyToLeave domReady = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);
        factory.save(domReady);             
    }

    return DischargeReportDetailVoAssembler.create(dom);
}
项目:openmaxims-linux    文件:EDischargePatientReadyToLeaveSTHKComponentImpl.java   
public DischargeReadyToLeaveVo saveReadyToLeave(DischargeReadyToLeaveVo voReady, SummaryRefVo voSummary) throws DomainInterfaceException, StaleObjectException 
{
    if(voReady == null)
        throw new CodingRuntimeException("DischargeReadyToLeaveVo is null");

    if(!voReady.isValidated())
        throw new CodingRuntimeException("DischargeReadyToLeaveVo Value Object has not been validated");

    DomainFactory factory = getDomainFactory();

    //There is a situation where is possible that the scheduled jobs have run while you
    //are editing the ready to leave record. This should be dealt with by throwing a StaleObjectException
    String hql = "select count(summa.id) from Summary as summa where (summa.id=:sumId and (summa.dischargeLetterStatus.id =:dischLettId  or summa.dischargeSupplementaryLetterStatus.id = :dischSuppLettId))";
    long isCompleted = factory.countWithHQL(hql, new String[]{"sumId","dischLettId","dischSuppLettId"}, new Object[]{voSummary.getID_Summary(),DischargeLetterStatus.GENERATED.getId(),DischargeSupplementaryLetterStatus.GENERATED.getID()});
    if (isCompleted > 0)
    {
        throw new StaleObjectException(null);
    }

    ReadyToLeave doRTL = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);
    factory.save(doRTL);

    //updating summary WDEV-11348
    IEDischargeHelper impl = (IEDischargeHelper) getDomainImpl(EDischargeHelper.class); 
    impl.updateSummaryIfRequired(voReady, voSummary, factory);

    return DischargeReadyToLeaveVoAssembler.create(doRTL);
}
项目:openmaxims-linux    文件:EDischargePatientReadyToLeaveSTHKComponentImpl.java   
public DischargeReadyToLeaveVo getReadyToLeave(CareContextRefVo careContextRefvo) 
{
    if(careContextRefvo == null)
        throw new CodingRuntimeException("careContextRefVo Filter not provided for list call. ");

    if(careContextRefvo != null)
    {
        DomainFactory factory = getDomainFactory();
        StringBuffer hql = new StringBuffer(" from ReadyToLeave rtl where "); 
        String andStr = " ";

        ArrayList<String> markers = new ArrayList<String>();
        ArrayList<Serializable> values = new ArrayList<Serializable>();

        hql.append(andStr + " rtl.careContext.id = :careContextId");
            markers.add("careContextId");
        values.add(careContextRefvo.getID_CareContext());
        andStr = " and ";   

        List list = factory.find(hql.toString(), markers,values);
        if(list != null && list.size() > 0)
        { 
            DischargeReadyToLeaveVoCollection voColl = DischargeReadyToLeaveVoAssembler.createDischargeReadyToLeaveVoCollectionFromReadyToLeave(list);
            if(voColl != null && voColl.size() > 0)
                return voColl.get(0);
        }
    }
    return null;
}
项目:openmaxims-linux    文件:EDischargePatientReadyToLeaveComponentImpl.java   
public DischargeReadyToLeaveVo saveReadyToLeave(DischargeReadyToLeaveVo voReady) throws DomainInterfaceException, StaleObjectException 
{
    if(voReady == null)
        throw new CodingRuntimeException("DischargeReadyToLeaveVo is null");

    if(!voReady.isValidated())
        throw new CodingRuntimeException("DischargeReadyToLeaveVo Value Object has not been validated");

    DomainFactory factory = getDomainFactory();
    ReadyToLeave doRTL = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);

    factory.save(doRTL);
    return DischargeReadyToLeaveVoAssembler.create(doRTL);
}
项目:openmaxims-linux    文件:EDischargePatientReadyToLeaveComponentImpl.java   
public DischargeReadyToLeaveVo getReadyToLeave(CareContextRefVo careContextRefvo) 
{
    if(careContextRefvo == null)
        throw new CodingRuntimeException("careContextRefVo Filter not provided for list call. ");

    if(careContextRefvo != null)
    {
        DomainFactory factory = getDomainFactory();
        StringBuffer hql = new StringBuffer(" from ReadyToLeave rtl where "); 
        String andStr = " ";

        ArrayList<String> markers = new ArrayList<String>();
        ArrayList<Serializable> values = new ArrayList<Serializable>();

        hql.append(andStr + " rtl.careContext.id = :careContextId");
            markers.add("careContextId");
        values.add(careContextRefvo.getID_CareContext());
        andStr = " and ";   

        List list = factory.find(hql.toString(), markers,values);
        if(list != null && list.size() > 0)
        { 
            DischargeReadyToLeaveVoCollection voColl = DischargeReadyToLeaveVoAssembler.createDischargeReadyToLeaveVoCollectionFromReadyToLeave(list);
            if(voColl != null && voColl.size() > 0)
                return voColl.get(0);
        }
    }
    return null;
}
项目:openmaxims-linux    文件:EDischargePreViewComponentImpl.java   
public DischargeReportDetailVo saveDischargeReportDetail(DischargeReportDetailVo record, DischargeReadyToLeaveVo voReady) throws StaleObjectException
{
    if (record != null)
    {
        if (!record.isValidated())
            throw new DomainRuntimeException("PatientDocumentVo not validated");
    }
    DomainFactory factory = getDomainFactory();
    if  (!record.getID_DischargeReportDetailIsNotNull())
    {

        List<?> dischargeDetails = factory.find("select dd from DischargeReportDetail as dd left join dd.careContext as cc where cc.id = :idCareContext and dd.isRIE is null ", new String[]{"idCareContext"}, new Object[]{record.getCareContext().getID_CareContext()});
        if (dischargeDetails != null && dischargeDetails.size()>0)
        {
            throw new StaleObjectException(null);
        }
    }

    DischargeReportDetail dom = DischargeReportDetailVoAssembler.extractDischargeReportDetail(factory, record);
    factory.save(dom);              

    if (voReady != null)
    {
        ReadyToLeave domReady = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady);
        factory.save(domReady);             
    }

    return DischargeReportDetailVoAssembler.create(dom);
}