Java 类ims.core.vo.domain.HomeLeaveVoAssembler 实例源码

项目:AvoinApotti    文件:BedInfoDialogImpl.java   
public CareContextShortVo saveHomeLeave(BedSpaceStateLiteVo voBedSpaceStateLite, InPatientEpisodeADTVo inpatientEpisode, HomeLeaveVo homeLeaveVo) throws DomainInterfaceException, StaleObjectException 
{
    if(inpatientEpisode == null)
        throw new CodingRuntimeException("inpatientEpisode is null in method saveTransfer");
    if(!inpatientEpisode.isValidated())
        throw new CodingRuntimeException("inpatientEpisode has not been validated in method saveTransfer");

    if(homeLeaveVo == null)
        throw new CodingRuntimeException("homeLeaveVo is null in method saveHomeLeave");

    DomainFactory factory = getDomainFactory();

    if (Boolean.FALSE.equals(ConfigFlag.GEN.USE_ELECTIVE_LIST_FUNCTIONALITY.getValue()))
    {
        Homeleave hlRec = (Homeleave)getDTOInstance(Homeleave.class);
        hlRec.DataCollection.add();

        copyHomeleaveToDto(hlRec, homeLeaveVo, inpatientEpisode);

        //Update Home Leave on PAS 
        Result res = hlRec.insert();
        if (res != null && res.getId() < 0 )
        {
            if (res.getId() == -5)
                throw new DomainInterfaceException("Error occurred saving Home Leave record to PAS " + res.getMessage());
            else 
                throw new DTODomainInterfaceException(res.getId(), "Error occurred saving Home Leave record to PAS " + res.getMessage());   
        }
    }       
    //Save MAXIMS HomeLeave
    HomeLeave doHL = HomeLeaveVoAssembler.extractHomeLeave(factory, homeLeaveVo);

    //Save IP details
    InpatientEpisode doInpatEpis = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
    doInpatEpis.getHomeLeaves().add(doHL);

    doInpatEpis.setIsOnHomeLeave(true);
    doInpatEpis.setDateOnHomeLeave(homeLeaveVo.getDateOnHomeLeaveIsNotNull() ? homeLeaveVo.getDateOnHomeLeave().getDate() : null);
    doInpatEpis.setTimeOnHomeLeave(homeLeaveVo.getTimeOnHomeLeaveIsNotNull() ? homeLeaveVo.getTimeOnHomeLeave().toString() : null);
    doInpatEpis.setExpectedDateOfReturn(homeLeaveVo.getExpectedDateOfReturnIsNotNull() ? homeLeaveVo.getExpectedDateOfReturn().getDate() : null);
    doInpatEpis.setExpectedTimeOfReturn(homeLeaveVo.getExpectedTimeOfReturnIsNotNull() ? homeLeaveVo.getExpectedTimeOfReturn().toString() : null);
    doInpatEpis.setVacatedBedNumber(homeLeaveVo.getVacatedBedNumberIsNotNull() ? homeLeaveVo.getVacatedBedNumber() : "");

    factory.save(doInpatEpis);

    //Vacate the bed.
    if(voBedSpaceStateLite != null)
    {
        BedSpaceState doBed = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBedSpaceStateLite);
        factory.save(doBed);
    }
    return null;
}
项目:openMAXIMS    文件:BedInfoDialogImpl.java   
public void cancelHomeLeaveReturn(InpatientEpisodeLiteVo voInpat,BedSpaceStateLiteVo voBedSpaceState, HomeLeaveVo voHlToReOpen) throws DomainInterfaceException,StaleObjectException
{
    if (voInpat == null)
        throw new CodingRuntimeException("The InpatientEpisodeLiteVo argument cannot be null in method cancelHomeLeaveReturn()");
    if (voHlToReOpen == null)
        throw new CodingRuntimeException("The HomeLeaveVo argument cannot be null in method cancelHomeLeaveReturn()");
    if (!voHlToReOpen.isValidated())
        throw new CodingRuntimeException("The HomeLeaveVo is not validated in method cancelHomeLeaveReturn()");
    DomainFactory factory = getDomainFactory();

    InpatientEpisode inpatEpisodeDO = (InpatientEpisode) factory.getDomainObject(InpatientEpisode.class, voInpat.getID_InpatientEpisode());

    if (inpatEpisodeDO == null)
        throw new DomainInterfaceException("This patient is no longer an inpatient. The screen will be refreshed.");
    if (inpatEpisodeDO != null && inpatEpisodeDO.getVersion() > voInpat.getVersion_InpatientEpisode() &&  Boolean.TRUE.equals(inpatEpisodeDO.isIsOnHomeLeave()))
        throw new DomainInterfaceException("This inpatient has been sent on home leave or their home leave return was cancelled by another user. The screen will be refreshed.");

    if (inpatEpisodeDO.getHomeLeaves() != null && !inpatEpisodeDO.getHomeLeaves().isEmpty())
    {   
        HomeLeave homeLeaveDO = HomeLeaveVoAssembler.extractHomeLeave(factory, voHlToReOpen);

        if (homeLeaveDO != null)
        {
            if (inpatEpisodeDO.getHomeLeaves().contains(homeLeaveDO))
                inpatEpisodeDO.getHomeLeaves().set(inpatEpisodeDO.getHomeLeaves().indexOf(homeLeaveDO), homeLeaveDO);

            inpatEpisodeDO.setIsOnHomeLeave(true);
            inpatEpisodeDO.setDateOnHomeLeave(homeLeaveDO.getDateOnHomeLeave() != null ? homeLeaveDO.getDateOnHomeLeave() : null);
            inpatEpisodeDO.setTimeOnHomeLeave(homeLeaveDO.getTimeOnHomeLeave() != null ? homeLeaveDO.getTimeOnHomeLeave() : null);
            inpatEpisodeDO.setExpectedDateOfReturn(homeLeaveDO.getExpectedDateOfReturn() != null ? homeLeaveDO.getExpectedDateOfReturn() : null);
            inpatEpisodeDO.setExpectedTimeOfReturn(homeLeaveDO.getExpectedTimeOfReturn() != null ? homeLeaveDO.getExpectedTimeOfReturn()  : null);
            inpatEpisodeDO.setVacatedBedNumber(homeLeaveDO.getVacatedBedNumber() != null ? homeLeaveDO.getVacatedBedNumber() : null);

            if (voBedSpaceState != null && !Boolean.TRUE.equals(homeLeaveDO.isBedRetained()))
            {
                if (voBedSpaceState.getCurrentBedStatusIsNotNull())
                {
                    voBedSpaceState.setPreviousBedStatus((BedSpaceStateStatusLiteVo) voBedSpaceState.getCurrentBedStatus().clone());
                    voBedSpaceState.setCurrentBedStatus(new BedSpaceStateStatusLiteVo());
                    voBedSpaceState.getCurrentBedStatus().setStatusDateTime(new DateTime());
                    voBedSpaceState.getCurrentBedStatus().setBedStatus(BedStatus.AVAILABLE);                        
                }

                voBedSpaceState.setInpatientEpisode(null);

                inpatEpisodeDO.setBed(null);
            }
        }
        if (inpatEpisodeDO.getPasEvent() != null)
        {
            ADT adtimpl = (ADT) getDomainImpl(ADTImpl.class);
            adtimpl.triggerCancelReturnFromLeaveOfAbsenceEvent(new PASEventRefVo(inpatEpisodeDO.getPasEvent().getId(), inpatEpisodeDO.getPasEvent().getVersion()));
        }
        factory.save(inpatEpisodeDO);

        if (voBedSpaceState != null)
        {
            BedSpaceState doBed = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBedSpaceState);
            factory.save(doBed);                
        }

        if (voBedSpaceState != null && !Boolean.TRUE.equals(voHlToReOpen.getBedRetained()))
            updateOccupiedBedsForWardAndBay(voBedSpaceState.getWard(), voBedSpaceState.getBay(), null);

        if (ConfigFlag.UI.BED_INFO_UI_TYPE.getValue().equals("MAXIMS") && voBedSpaceState != null && !Boolean.TRUE.equals(voHlToReOpen.getBedRetained()))
        {
            Sex tempGender = voInpat.getPasEvent() != null && voInpat.getPasEvent().getPatientIsNotNull() && voInpat.getPasEvent().getPatient().getSexIsNotNull() && !Sex.UNKNOWN.equals(voInpat.getPasEvent().getPatient().getSex())? voInpat.getPasEvent().getPatient().getSex() : null;
            checkAndUpdateBayConfig(factory, voBedSpaceState,tempGender);
        }
    }       
}
项目:openMAXIMS    文件:BedInfoDialogImpl.java   
public void vacateBedSpace(InPatientEpisodeADTVo voInpat, BedSpaceStateLiteVo voBedSpaceStateLite, HomeLeaveVo voCurrentHomeLeave) throws DomainInterfaceException, StaleObjectException
{
    if (voInpat == null)
        throw new CodingRuntimeException("InPatientEpisodeADTVo argument cannot be null in method vacateBedSpace()");

    if (voCurrentHomeLeave == null)
        throw new CodingRuntimeException("HomeLeaveVo argument cannot be null in method vacateBedSpace()");

    DomainFactory domainFactory = getDomainFactory();

    InpatientEpisode inpatientEpisodeDO = (InpatientEpisode) domainFactory.getDomainObject(InpatientEpisode.class, voInpat.getID_InpatientEpisode());

    if (inpatientEpisodeDO == null || inpatientEpisodeDO.getVersion() > voInpat.getVersion_InpatientEpisode())
        throw new DomainInterfaceException("The patient record was updated by another user. The screen will refresh.");
    if (inpatientEpisodeDO.getBed() == null)
        throw new DomainInterfaceException("The bed was vacated by another user. The screen will refresh.");

    InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(domainFactory, voInpat);
    HomeLeave doHomeLeave = HomeLeaveVoAssembler.extractHomeLeave(domainFactory, voCurrentHomeLeave);

    int currentHomeLeaveIndex = -1;
    if (doHomeLeave != null)
    {   
        currentHomeLeaveIndex = doInpat.getHomeLeaves().indexOf(doHomeLeave);
        if (currentHomeLeaveIndex != -1)
        {
            HomeLeave doHLForUpdate = (HomeLeave) doInpat.getHomeLeaves().get(currentHomeLeaveIndex);
            if (doHLForUpdate != null)
            {   
                doHLForUpdate.setBedRetained(doHomeLeave.isBedRetained());
            }   
        }
    }
    else
    {
        throw new DomainInterfaceException("The home leave was cancelled by another user. The screen will refresh.");
    }

    domainFactory.save(doInpat);

    if (voBedSpaceStateLite != null)
    {   
        BedSpaceState doBedSpaceState = BedSpaceStateLiteVoAssembler.extractBedSpaceState(domainFactory,voBedSpaceStateLite);
        domainFactory.save(doBedSpaceState);
    }
    updateOccupiedBedsForWardAndBay(voBedSpaceStateLite.getWard(), voBedSpaceStateLite.getBay(), null);         

    if (ConfigFlag.UI.BED_INFO_UI_TYPE.getValue().equals("MAXIMS") && voBedSpaceStateLite != null )
    {
        Sex tempGender = voInpat.getPasEvent() != null && voInpat.getPasEvent().getPatientIsNotNull() && voInpat.getPasEvent().getPatient().getSexIsNotNull() && !Sex.UNKNOWN.equals(voInpat.getPasEvent().getPatient().getSex())  ? voInpat.getPasEvent().getPatient().getSex() : null;
        checkAndUpdateBayConfig(domainFactory, voBedSpaceStateLite,tempGender);
    }
}
项目:openMAXIMS    文件:BedInfoDialogImpl.java   
public CareContextShortVo saveHomeLeave(BedSpaceStateLiteVo voBedSpaceStateLite, InPatientEpisodeADTVo inpatientEpisode, HomeLeaveVo homeLeaveVo) throws DomainInterfaceException, StaleObjectException 
{
    if(inpatientEpisode == null)
        throw new CodingRuntimeException("inpatientEpisode is null in method saveTransfer");
    if(!inpatientEpisode.isValidated())
        throw new CodingRuntimeException("inpatientEpisode has not been validated in method saveTransfer");

    if(homeLeaveVo == null)
        throw new CodingRuntimeException("homeLeaveVo is null in method saveHomeLeave");

    DomainFactory factory = getDomainFactory();

    if (Boolean.FALSE.equals(ConfigFlag.GEN.USE_ELECTIVE_LIST_FUNCTIONALITY.getValue()))
    {
        Homeleave hlRec = (Homeleave)getDTOInstance(Homeleave.class);
        hlRec.DataCollection.add();

        copyHomeleaveToDto(hlRec, homeLeaveVo, inpatientEpisode);

        //Update Home Leave on PAS 
        Result res = hlRec.insert();
        if (res != null && res.getId() < 0 )
        {
            if (res.getId() == -5)
                throw new DomainInterfaceException("Error occurred saving Home Leave record to PAS " + res.getMessage());
            else 
                throw new DTODomainInterfaceException(res.getId(), "Error occurred saving Home Leave record to PAS " + res.getMessage());   
        }
    }       
    //Save MAXIMS HomeLeave
    HomeLeave doHL = HomeLeaveVoAssembler.extractHomeLeave(factory, homeLeaveVo);

    //Save IP details
    InpatientEpisode doInpatEpis = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
    doInpatEpis.getHomeLeaves().add(doHL);

    doInpatEpis.setIsOnHomeLeave(true);
    doInpatEpis.setDateOnHomeLeave(homeLeaveVo.getDateOnHomeLeaveIsNotNull() ? homeLeaveVo.getDateOnHomeLeave().getDate() : null);
    doInpatEpis.setTimeOnHomeLeave(homeLeaveVo.getTimeOnHomeLeaveIsNotNull() ? homeLeaveVo.getTimeOnHomeLeave().toString() : null);
    doInpatEpis.setExpectedDateOfReturn(homeLeaveVo.getExpectedDateOfReturnIsNotNull() ? homeLeaveVo.getExpectedDateOfReturn().getDate() : null);
    doInpatEpis.setExpectedTimeOfReturn(homeLeaveVo.getExpectedTimeOfReturnIsNotNull() ? homeLeaveVo.getExpectedTimeOfReturn().toString() : null);
    doInpatEpis.setVacatedBedNumber(homeLeaveVo.getVacatedBedNumberIsNotNull() ? homeLeaveVo.getVacatedBedNumber() : "");

    factory.save(doInpatEpis);

    //Vacate the bed.
    if(voBedSpaceStateLite != null)
    {
        BedSpaceState doBed = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBedSpaceStateLite);
        factory.save(doBed);
    }
    return null;
}
项目:openmaxims-linux    文件:BedInfoDialogImpl.java   
public CareContextShortVo saveHomeLeave(BedSpaceStateLiteVo voBedSpaceStateLite, InPatientEpisodeADTVo inpatientEpisode, HomeLeaveVo homeLeaveVo) throws DomainInterfaceException, StaleObjectException 
{
    if(inpatientEpisode == null)
        throw new CodingRuntimeException("inpatientEpisode is null in method saveTransfer");
    if(!inpatientEpisode.isValidated())
        throw new CodingRuntimeException("inpatientEpisode has not been validated in method saveTransfer");

    if(homeLeaveVo == null)
        throw new CodingRuntimeException("homeLeaveVo is null in method saveHomeLeave");

    DomainFactory factory = getDomainFactory();

    if (Boolean.FALSE.equals(ConfigFlag.GEN.USE_ELECTIVE_LIST_FUNCTIONALITY.getValue()))
    {
        Homeleave hlRec = (Homeleave)getDTOInstance(Homeleave.class);
        hlRec.DataCollection.add();

        copyHomeleaveToDto(hlRec, homeLeaveVo, inpatientEpisode);

        //Update Home Leave on PAS 
        Result res = hlRec.insert();
        if (res != null && res.getId() < 0 )
        {
            if (res.getId() == -5)
                throw new DomainInterfaceException("Error occurred saving Home Leave record to PAS " + res.getMessage());
            else 
                throw new DTODomainInterfaceException(res.getId(), "Error occurred saving Home Leave record to PAS " + res.getMessage());   
        }
    }       
    //Save MAXIMS HomeLeave
    HomeLeave doHL = HomeLeaveVoAssembler.extractHomeLeave(factory, homeLeaveVo);

    //Save IP details
    InpatientEpisode doInpatEpis = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
    doInpatEpis.getHomeLeaves().add(doHL);

    doInpatEpis.setIsOnHomeLeave(true);
    doInpatEpis.setDateOnHomeLeave(homeLeaveVo.getDateOnHomeLeaveIsNotNull() ? homeLeaveVo.getDateOnHomeLeave().getDate() : null);
    doInpatEpis.setTimeOnHomeLeave(homeLeaveVo.getTimeOnHomeLeaveIsNotNull() ? homeLeaveVo.getTimeOnHomeLeave().toString() : null);
    doInpatEpis.setExpectedDateOfReturn(homeLeaveVo.getExpectedDateOfReturnIsNotNull() ? homeLeaveVo.getExpectedDateOfReturn().getDate() : null);
    doInpatEpis.setExpectedTimeOfReturn(homeLeaveVo.getExpectedTimeOfReturnIsNotNull() ? homeLeaveVo.getExpectedTimeOfReturn().toString() : null);
    doInpatEpis.setVacatedBedNumber(homeLeaveVo.getVacatedBedNumberIsNotNull() ? homeLeaveVo.getVacatedBedNumber() : "");

    factory.save(doInpatEpis);

    //Vacate the bed.
    if(voBedSpaceStateLite != null)
    {
        BedSpaceState doBed = BedSpaceStateLiteVoAssembler.extractBedSpaceState(factory, voBedSpaceStateLite);
        factory.save(doBed);
    }
    return null;
}
项目:openMAXIMS    文件:HomeLeaveDetailsDialogImpl.java   
public ims.core.vo.HomeLeaveVo getCurrentHomeLeave(ims.core.admin.pas.vo.InpatientEpisodeRefVo inpatRef)
{
    if (inpatRef == null || inpatRef.getID_InpatientEpisode() == null)
        return null;

    DomainFactory factory = getDomainFactory();

    String hql = "select hl from InpatientEpisode as inp left join inp.homeLeaves as hl where (hl.isRIE is null or hl.isRIE = 0) and hl.dateReturnedFromHomeLeave is null and inp.id = :INPAT_ID"; 

    HomeLeave doHL = (HomeLeave) factory.findFirst(hql, "INPAT_ID" , inpatRef.getID_InpatientEpisode());

    return doHL != null ? HomeLeaveVoAssembler.create(doHL) : null;
}