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

项目:openMAXIMS    文件:WardViewPatientListImpl.java   
private HomeLeaveVo getLatestClosedHomeLeaveForEpisode(InpatientEpisode doInpat)
{
    if (doInpat.getHomeLeaves() == null || doInpat.getHomeLeaves().size() == 0)
        return null;

    InPatientEpisodeADTVo voEpisode = InPatientEpisodeADTVoAssembler.create(doInpat);
    if (voEpisode != null)
    {   
    for (int i=voEpisode.getHomeLeaves().size()-1;i>=0;i--)
    {
        if (voEpisode.getHomeLeaves().get(i).getDateReturnedFromHomeLeave() == null)
            voEpisode.getHomeLeaves().remove(i);
    }
    voEpisode.getHomeLeaves().sort(HomeLeaveVo.getDateOnHomeLeaveComparator(SortOrder.DESCENDING));
    if (voEpisode.getHomeLeaves().size() > 0 && voEpisode.getHomeLeaves().get(0) != null)
            return voEpisode.getHomeLeaves().get(0);
    }
    return null;
}
项目:AvoinApotti    文件:BedInfoDialogImpl.java   
/**
 * @method addConsultantStayIfNeeded
 * @comment does InpatientAssembler call also - MUST BE CALLED
 * 
 */
private InpatientEpisode addConsultantStayIfNeeded(InPatientEpisodeADTVo inpatientEpisode)
{
    if(inpatientEpisode == null)
        throw new CodingRuntimeException("inpatientEpisode is null in method addConsultantStayIfNeeded"); 

    DomainFactory factory = getDomainFactory();
    Medic doExistingCons = null;
    if(inpatientEpisode.getPasEventIsNotNull() && inpatientEpisode.getPasEvent().getBoId() != null)
    {
        PASEvent doExistingPe = (PASEvent)factory.getDomainObject(PASEvent.class, inpatientEpisode.getPasEvent().getBoId());
        doExistingCons = doExistingPe != null ? doExistingPe.getConsultant() : null;
    }

    InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(factory, inpatientEpisode);

    if(inpatientEpisode.getPasEventIsNotNull() && inpatientEpisode.getPasEvent().getConsultantIsNotNull())
    {
        if(doExistingCons != null)
        {
            if(!doInpat.getPasEvent().getConsultant().equals(doExistingCons))
            {
                ConsultantStay doConsStay = new ConsultantStay();
                doConsStay.setConsultant(doInpat.getPasEvent().getConsultant());
                doConsStay.setTransferDateTime(getMostRecentWardStayTransferDate(doInpat));
                doInpat.getConsultantStays().add(doConsStay);
            }
        }   
    }
    return doInpat;
}
项目:AvoinApotti    文件:BedInfoDialogImpl.java   
public InPatientEpisodeADTVo getInpatientEpisode(InpatientEpisodeRefVo inpatientEpisode)
{
    if(inpatientEpisode == null || inpatientEpisode.getID_InpatientEpisode() == null)
        throw new CodingRuntimeException("inpatientEpisode is null or id not provided for getInpatientEpisode");

    return InPatientEpisodeADTVoAssembler.create( (InpatientEpisode) getDomainFactory().getDomainObject(inpatientEpisode));
}
项目:AvoinApotti    文件:BedInfoDialogImpl.java   
private void copyHomeleaveToDto(Homeleave homeLeaveRec, HomeLeaveVo voHomeLeave, InPatientEpisodeADTVo inpatientEpisode)
{
    HomeleaveRecord hlRec = homeLeaveRec.DataCollection.get(0);

    hlRec.Pkey = getPatientIdValue(inpatientEpisode, PatIdType.PKEY);
    hlRec.Hospnum = getPatientIdValue(inpatientEpisode, PatIdType.HOSPNUM);

    InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
    hlRec.Rescode = doInpat.getPasEvent() != null && doInpat.getPasEvent().getLocation() != null ? doInpat.getPasEvent().getLocation().getExtCode(TaxonomyType.PAS.getID()) : null;
    hlRec.Mors = DTOHelper.getPasMapping(doInpat.getWardType());

    hlRec.Leavedt = voHomeLeave.getDateOnHomeLeaveIsNotNull() ? DTOHelper.convertToDtoDate(voHomeLeave.getDateOnHomeLeave().getDate()) : "";
    hlRec.Leavetm =  voHomeLeave.getTimeOnHomeLeaveIsNotNull() ? voHomeLeave.getTimeOnHomeLeave().toString(TimeFormat.FLAT4) : "";

    hlRec.Exdt = voHomeLeave.getExpectedDateOfReturnIsNotNull() ? DTOHelper.convertToDtoDate(voHomeLeave.getExpectedDateOfReturn().getDate()) : "";
    hlRec.Extm = voHomeLeave.getExpectedTimeOfReturnIsNotNull() ? voHomeLeave.getExpectedTimeOfReturn().toString(TimeFormat.FLAT4) : "";
    if(hlRec.Mors.equals("M"))
    {
        if(doInpat.getPasEvent().getPatient().getSex() != null)
        {
            if(doInpat.getPasEvent().getPatient().getSex().equals(getDomLookup(Sex.MALE)))
                hlRec.Btyp = "M";
            else if(doInpat.getPasEvent().getPatient().getSex().equals(getDomLookup(Sex.FEMALE)))
                hlRec.Btyp = "F";
            else
                //defaulting Male for unknown sex
                hlRec.Btyp = "M";
        }
        else
            //defaulting Male for unknown sex
            hlRec.Btyp = "M";   
    }
    else if(hlRec.Mors.equals("S"))
        hlRec.Btyp = "S";


    hlRec.Hlfl = "Y"; //"Y" on an insert

    hlRec.Webadt = "Y";             
}
项目:openMAXIMS    文件:BedInfoDialogImpl.java   
/**
 * @param patientStatus 
 * @method addConsultantStayIfNeeded
 * @comment does InpatientAssembler call also - MUST BE CALLED
 * 
 */
private InpatientEpisode addConsultantStayIfNeeded(InPatientEpisodeADTVo inpatientEpisode, PatientStatus patientStatus)
{
    if(inpatientEpisode == null)
        throw new CodingRuntimeException("inpatientEpisode is null in method addConsultantStayIfNeeded"); 

    DomainFactory factory = getDomainFactory();
    Medic doExistingCons = null;
    LookupInstance doExistingSpecialty = null;
    Service doExistingService = null;
    if (inpatientEpisode.getPasEventIsNotNull() && inpatientEpisode.getPasEvent().getBoId() != null)
    {
        PASEvent doExistingPe = (PASEvent)factory.getDomainObject(PASEvent.class, inpatientEpisode.getPasEvent().getBoId());
        doExistingCons = doExistingPe != null ? doExistingPe.getConsultant() : null;
        doExistingService =  doExistingPe != null ? doExistingPe.getService() : null;
        doExistingSpecialty = doExistingPe != null ? doExistingPe.getSpecialty() : null;
    }

    InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(factory, inpatientEpisode);
    //WDEV-22892
    if (inpatientEpisode.getPasEventIsNotNull())
    {           
        boolean consultantHasChanged = inpatientEpisode.getPasEvent().getConsultantIsNotNull() && doExistingCons != null && !doInpat.getPasEvent().getConsultant().equals(doExistingCons);
        boolean serviceChanged = inpatientEpisode.getPasEvent().getService() != null && !inpatientEpisode.getPasEvent().getService().equals(doExistingService);
        boolean specialtyChanged = inpatientEpisode.getPasEvent().getSpecialty() != null && !inpatientEpisode.getPasEvent().getSpecialty().equals(doExistingSpecialty);

        if (consultantHasChanged || (serviceChanged && consultantHasChanged) || (specialtyChanged && consultantHasChanged))
        {
            addConsultantStay(doInpat,patientStatus);
        }                           
    }

    return doInpat;
}
项目:openMAXIMS    文件:BedInfoDialogImpl.java   
public InPatientEpisodeADTVo getInpatientEpisode(InpatientEpisodeRefVo inpatientEpisode)
{
    if(inpatientEpisode == null || inpatientEpisode.getID_InpatientEpisode() == null)
        throw new CodingRuntimeException("inpatientEpisode is null or id not provided for getInpatientEpisode");

    return InPatientEpisodeADTVoAssembler.create( (InpatientEpisode) getDomainFactory().getDomainObject(inpatientEpisode));
}
项目:openMAXIMS    文件:BedInfoDialogImpl.java   
private void copyHomeleaveToDto(Homeleave homeLeaveRec, HomeLeaveVo voHomeLeave, InPatientEpisodeADTVo inpatientEpisode)
{
    HomeleaveRecord hlRec = homeLeaveRec.DataCollection.get(0);

    hlRec.Pkey = getPatientIdValue(inpatientEpisode, PatIdType.PKEY);
    hlRec.Hospnum = getPatientIdValue(inpatientEpisode, PatIdType.HOSPNUM);

    InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
    hlRec.Rescode = doInpat.getPasEvent() != null && doInpat.getPasEvent().getLocation() != null ? doInpat.getPasEvent().getLocation().getExtCode(TaxonomyType.PAS.getID()) : null;
    hlRec.Mors = DTOHelper.getPasMapping(doInpat.getWardType());

    hlRec.Leavedt = voHomeLeave.getDateOnHomeLeaveIsNotNull() ? DTOHelper.convertToDtoDate(voHomeLeave.getDateOnHomeLeave().getDate()) : "";
    hlRec.Leavetm =  voHomeLeave.getTimeOnHomeLeaveIsNotNull() ? voHomeLeave.getTimeOnHomeLeave().toString(TimeFormat.FLAT4) : "";

    hlRec.Exdt = voHomeLeave.getExpectedDateOfReturnIsNotNull() ? DTOHelper.convertToDtoDate(voHomeLeave.getExpectedDateOfReturn().getDate()) : "";
    hlRec.Extm = voHomeLeave.getExpectedTimeOfReturnIsNotNull() ? voHomeLeave.getExpectedTimeOfReturn().toString(TimeFormat.FLAT4) : "";
    if(hlRec.Mors.equals("M"))
    {
        if(doInpat.getPasEvent().getPatient().getSex() != null)
        {
            if(doInpat.getPasEvent().getPatient().getSex().equals(getDomLookup(Sex.MALE)))
                hlRec.Btyp = "M";
            else if(doInpat.getPasEvent().getPatient().getSex().equals(getDomLookup(Sex.FEMALE)))
                hlRec.Btyp = "F";
            else
                //defaulting Male for unknown sex
                hlRec.Btyp = "M";
        }
        else
            //defaulting Male for unknown sex
            hlRec.Btyp = "M";   
    }
    else if(hlRec.Mors.equals("S"))
        hlRec.Btyp = "S";


    hlRec.Hlfl = "Y"; //"Y" on an insert

    hlRec.Webadt = "Y";             
}
项目:openMAXIMS    文件:AcceptTransferToWardDlgImpl.java   
public InPatientEpisodeADTVo getInpatientEpisodeADT(InpatientEpisodeRefVo inpatientEpisodeRef)
{
    if (inpatientEpisodeRef == null)
        throw new CodingRuntimeException("Invalid argument specified.");

    DomainFactory factory = getDomainFactory();

    InpatientEpisode inpatientEpisode = (InpatientEpisode) factory.getDomainObject(InpatientEpisode.class, inpatientEpisodeRef.getID_InpatientEpisode());

    if (inpatientEpisode == null)
        return null;

    return InPatientEpisodeADTVoAssembler.create(inpatientEpisode);
}
项目:openMAXIMS    文件:BedInfoDialogImpl.java   
/**
 * @method addConsultantStayIfNeeded
 * @comment does InpatientAssembler call also - MUST BE CALLED
 * 
 */
private InpatientEpisode addConsultantStayIfNeeded(InPatientEpisodeADTVo inpatientEpisode)
{
    if(inpatientEpisode == null)
        throw new CodingRuntimeException("inpatientEpisode is null in method addConsultantStayIfNeeded"); 

    DomainFactory factory = getDomainFactory();
    Medic doExistingCons = null;
    if(inpatientEpisode.getPasEventIsNotNull() && inpatientEpisode.getPasEvent().getBoId() != null)
    {
        PASEvent doExistingPe = (PASEvent)factory.getDomainObject(PASEvent.class, inpatientEpisode.getPasEvent().getBoId());
        doExistingCons = doExistingPe != null ? doExistingPe.getConsultant() : null;
    }

    InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(factory, inpatientEpisode);

    if(inpatientEpisode.getPasEventIsNotNull() && inpatientEpisode.getPasEvent().getConsultantIsNotNull())
    {
        if(doExistingCons != null)
        {
            if(!doInpat.getPasEvent().getConsultant().equals(doExistingCons))
            {
                ConsultantStay doConsStay = new ConsultantStay();
                doConsStay.setConsultant(doInpat.getPasEvent().getConsultant());
                doConsStay.setTransferDateTime(getMostRecentWardStayTransferDate(doInpat));
                doInpat.getConsultantStays().add(doConsStay);
            }
        }   
    }
    return doInpat;
}
项目:openMAXIMS    文件:BedInfoDialogImpl.java   
public InPatientEpisodeADTVo getInpatientEpisode(InpatientEpisodeRefVo inpatientEpisode)
{
    if(inpatientEpisode == null || inpatientEpisode.getID_InpatientEpisode() == null)
        throw new CodingRuntimeException("inpatientEpisode is null or id not provided for getInpatientEpisode");

    return InPatientEpisodeADTVoAssembler.create( (InpatientEpisode) getDomainFactory().getDomainObject(inpatientEpisode));
}
项目:openMAXIMS    文件:BedInfoDialogImpl.java   
private void copyHomeleaveToDto(Homeleave homeLeaveRec, HomeLeaveVo voHomeLeave, InPatientEpisodeADTVo inpatientEpisode)
{
    HomeleaveRecord hlRec = homeLeaveRec.DataCollection.get(0);

    hlRec.Pkey = getPatientIdValue(inpatientEpisode, PatIdType.PKEY);
    hlRec.Hospnum = getPatientIdValue(inpatientEpisode, PatIdType.HOSPNUM);

    InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
    hlRec.Rescode = doInpat.getPasEvent() != null && doInpat.getPasEvent().getLocation() != null ? doInpat.getPasEvent().getLocation().getExtCode(TaxonomyType.PAS.getID()) : null;
    hlRec.Mors = DTOHelper.getPasMapping(doInpat.getWardType());

    hlRec.Leavedt = voHomeLeave.getDateOnHomeLeaveIsNotNull() ? DTOHelper.convertToDtoDate(voHomeLeave.getDateOnHomeLeave().getDate()) : "";
    hlRec.Leavetm =  voHomeLeave.getTimeOnHomeLeaveIsNotNull() ? voHomeLeave.getTimeOnHomeLeave().toString(TimeFormat.FLAT4) : "";

    hlRec.Exdt = voHomeLeave.getExpectedDateOfReturnIsNotNull() ? DTOHelper.convertToDtoDate(voHomeLeave.getExpectedDateOfReturn().getDate()) : "";
    hlRec.Extm = voHomeLeave.getExpectedTimeOfReturnIsNotNull() ? voHomeLeave.getExpectedTimeOfReturn().toString(TimeFormat.FLAT4) : "";
    if(hlRec.Mors.equals("M"))
    {
        if(doInpat.getPasEvent().getPatient().getSex() != null)
        {
            if(doInpat.getPasEvent().getPatient().getSex().equals(getDomLookup(Sex.MALE)))
                hlRec.Btyp = "M";
            else if(doInpat.getPasEvent().getPatient().getSex().equals(getDomLookup(Sex.FEMALE)))
                hlRec.Btyp = "F";
            else
                //defaulting Male for unknown sex
                hlRec.Btyp = "M";
        }
        else
            //defaulting Male for unknown sex
            hlRec.Btyp = "M";   
    }
    else if(hlRec.Mors.equals("S"))
        hlRec.Btyp = "S";


    hlRec.Hlfl = "Y"; //"Y" on an insert

    hlRec.Webadt = "Y";             
}
项目:openmaxims-linux    文件:BedInfoDialogImpl.java   
/**
 * @method addConsultantStayIfNeeded
 * @comment does InpatientAssembler call also - MUST BE CALLED
 * 
 */
private InpatientEpisode addConsultantStayIfNeeded(InPatientEpisodeADTVo inpatientEpisode)
{
    if(inpatientEpisode == null)
        throw new CodingRuntimeException("inpatientEpisode is null in method addConsultantStayIfNeeded"); 

    DomainFactory factory = getDomainFactory();
    Medic doExistingCons = null;
    if(inpatientEpisode.getPasEventIsNotNull() && inpatientEpisode.getPasEvent().getBoId() != null)
    {
        PASEvent doExistingPe = (PASEvent)factory.getDomainObject(PASEvent.class, inpatientEpisode.getPasEvent().getBoId());
        doExistingCons = doExistingPe != null ? doExistingPe.getConsultant() : null;
    }

    InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(factory, inpatientEpisode);

    if(inpatientEpisode.getPasEventIsNotNull() && inpatientEpisode.getPasEvent().getConsultantIsNotNull())
    {
        if(doExistingCons != null)
        {
            if(!doInpat.getPasEvent().getConsultant().equals(doExistingCons))
            {
                ConsultantStay doConsStay = new ConsultantStay();
                doConsStay.setConsultant(doInpat.getPasEvent().getConsultant());
                doConsStay.setTransferDateTime(getMostRecentWardStayTransferDate(doInpat));
                doInpat.getConsultantStays().add(doConsStay);
            }
        }   
    }
    return doInpat;
}
项目:openmaxims-linux    文件:BedInfoDialogImpl.java   
public InPatientEpisodeADTVo getInpatientEpisode(InpatientEpisodeRefVo inpatientEpisode)
{
    if(inpatientEpisode == null || inpatientEpisode.getID_InpatientEpisode() == null)
        throw new CodingRuntimeException("inpatientEpisode is null or id not provided for getInpatientEpisode");

    return InPatientEpisodeADTVoAssembler.create( (InpatientEpisode) getDomainFactory().getDomainObject(inpatientEpisode));
}
项目:openmaxims-linux    文件:BedInfoDialogImpl.java   
private void copyHomeleaveToDto(Homeleave homeLeaveRec, HomeLeaveVo voHomeLeave, InPatientEpisodeADTVo inpatientEpisode)
{
    HomeleaveRecord hlRec = homeLeaveRec.DataCollection.get(0);

    hlRec.Pkey = getPatientIdValue(inpatientEpisode, PatIdType.PKEY);
    hlRec.Hospnum = getPatientIdValue(inpatientEpisode, PatIdType.HOSPNUM);

    InpatientEpisode doInpat = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(getDomainFactory(), inpatientEpisode);
    hlRec.Rescode = doInpat.getPasEvent() != null && doInpat.getPasEvent().getLocation() != null ? doInpat.getPasEvent().getLocation().getExtCode(TaxonomyType.PAS.getID()) : null;
    hlRec.Mors = DTOHelper.getPasMapping(doInpat.getWardType());

    hlRec.Leavedt = voHomeLeave.getDateOnHomeLeaveIsNotNull() ? DTOHelper.convertToDtoDate(voHomeLeave.getDateOnHomeLeave().getDate()) : "";
    hlRec.Leavetm =  voHomeLeave.getTimeOnHomeLeaveIsNotNull() ? voHomeLeave.getTimeOnHomeLeave().toString(TimeFormat.FLAT4) : "";

    hlRec.Exdt = voHomeLeave.getExpectedDateOfReturnIsNotNull() ? DTOHelper.convertToDtoDate(voHomeLeave.getExpectedDateOfReturn().getDate()) : "";
    hlRec.Extm = voHomeLeave.getExpectedTimeOfReturnIsNotNull() ? voHomeLeave.getExpectedTimeOfReturn().toString(TimeFormat.FLAT4) : "";
    if(hlRec.Mors.equals("M"))
    {
        if(doInpat.getPasEvent().getPatient().getSex() != null)
        {
            if(doInpat.getPasEvent().getPatient().getSex().equals(getDomLookup(Sex.MALE)))
                hlRec.Btyp = "M";
            else if(doInpat.getPasEvent().getPatient().getSex().equals(getDomLookup(Sex.FEMALE)))
                hlRec.Btyp = "F";
            else
                //defaulting Male for unknown sex
                hlRec.Btyp = "M";
        }
        else
            //defaulting Male for unknown sex
            hlRec.Btyp = "M";   
    }
    else if(hlRec.Mors.equals("S"))
        hlRec.Btyp = "S";


    hlRec.Hlfl = "Y"; //"Y" on an insert

    hlRec.Webadt = "Y";             
}
项目: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 cancelHomeLeave(BedSpaceStateLiteVo voBedSpaceState,InpatientEpisodeLiteVo voInpat) throws StaleObjectException, DomainInterfaceException
{
    if (voInpat == null)
        throw new CodingRuntimeException("InpatientEpisodeLiteVo argument cannot be null in method cancelHomeLeave()");
    DomainFactory factory = getDomainFactory();
    WardView impl = (WardView) getDomainImpl(WardViewImpl.class);
    CareContextShortVo voCareContext = impl.getCareContextForPasEvent(voInpat.getPasEvent());
    InPatientEpisodeADTVo voInpatADTVo = getInpatientEpisode(voInpat);
    if (voInpatADTVo == null)
        throw new DomainInterfaceException("This patient is no longer an inpatient. The screen will be refreshed.");
    if (voInpatADTVo != null && voInpatADTVo.getVersion_InpatientEpisode() > voInpat.getVersion_InpatientEpisode() &&  !Boolean.TRUE.equals(voInpatADTVo.getIsOnHomeLeave()))
        throw new DomainInterfaceException("This inpatient is no longer on home leave. The screen will be refreshed.");

    HomeLeaveVo homeLeaveToCancel = getLatestOngoingHomeLeave(voInpatADTVo);

    if (homeLeaveToCancel != null)
    {
        factory.markAsRie(HomeLeave.class, homeLeaveToCancel.getID_HomeLeave(), null, voInpat.getPasEvent() != null && voInpat.getPasEvent().getPatientIsNotNull() ?  voInpat.getPasEvent().getPatient().getID_Patient() : null, null, voCareContext != null ? voCareContext.getID_CareContext() : null, "Cancellation of Sending on Home Leave");

        InpatientEpisode doInpatientEpisode = InPatientEpisodeADTVoAssembler.extractInpatientEpisode(factory, voInpatADTVo);

        doInpatientEpisode.setIsOnHomeLeave(false);
        doInpatientEpisode.setDateOnHomeLeave(null);
        doInpatientEpisode.setTimeOnHomeLeave(null);
        doInpatientEpisode.setExpectedDateOfReturn(null);
        doInpatientEpisode.setExpectedTimeOfReturn(null);

        if (doInpatientEpisode.getPasEvent() != null)
        {
            ADT adtimpl = (ADT) getDomainImpl(ADTImpl.class);
            adtimpl.triggerCancelLeaveOfAbsenceEvent(new PASEventRefVo(doInpatientEpisode.getPasEvent().getId(), doInpatientEpisode.getPasEvent().getVersion()));
        }
        factory.save(doInpatientEpisode);
        if (ConfigFlag.UI.BED_INFO_UI_TYPE.getValue().equals("MAXIMS") && voBedSpaceState != null && !Boolean.TRUE.equals(homeLeaveToCancel.getBedRetained()))
        {
            Sex tempGender = voInpat.getPasEvent() != null && voInpat.getPasEvent().getPatientIsNotNull() ? 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;
}