Java 类ims.core.vo.PatientDocumentLiteVo 实例源码

项目:AvoinApotti    文件:Logic.java   
private void addReferralLetterRow(DynamicGridRow row, PatientDocumentLiteVo doc)
{
    if(row == null || doc == null)
        return;

    String user = doc.getRecordingUserIsNotNull() ? doc.getRecordingUser().toString() : null;
    DateTime date = doc.getRecordingDateTimeIsNotNull() ? doc.getRecordingDateTime() : null;
    String title = "Recorded on <b>" + date + "</b> by <b>" + user + "</b>";

    DynamicGridRow letterRow = row.getRows().newRow();

    letterRow.setSelectable(true);
    letterRow.setExpandedImage(form.getImages().Core.PDFIcon);
    letterRow.setCollapsedImage(form.getImages().Core.PDFIcon);
    letterRow.setReadOnly(true);
    letterRow.setValue(doc);

    DynamicGridCell cell = letterRow.getCells().newCell(getCol(COL_TITLE_HIERARCHICAL), DynamicCellType.STRING);    

    cell.setReadOnly(true);
    cell.setValue(title);
}
项目:AvoinApotti    文件:Logic.java   
@Override
protected void onDyngrdNotesRowSelectionChanged(DynamicGridRow row) throws PresentationLogicException
{
    if(form.dyngrdNotes().getValue() instanceof BookingAppointmentForClinicalNotesVo)
        form.getLocalContext().setSelectedInstance((BookingAppointmentForClinicalNotesVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof AppointmentClinicalNotesVo)
        form.getLocalContext().setSelectedInstance((AppointmentClinicalNotesVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof PatientDiagnosisApptDetailVo)
        form.getLocalContext().setSelectedInstance((PatientDiagnosisApptDetailVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof PatientProcedureApptDetailVo)
        form.getLocalContext().setSelectedInstance((PatientProcedureApptDetailVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof PatientDocumentLiteVo)
    {
        viewPatientDocuments((PatientDocumentLiteVo) form.dyngrdNotes().getValue());
        form.getLocalContext().setSelectedInstance((PatientDocumentLiteVo) form.dyngrdNotes().getValue());
    }

    updateControlsState();
}
项目:AvoinApotti    文件:Logic.java   
private void viewPatientDocuments(PatientDocumentLiteVo doc)
{
    if(doc == null)
        return;

    ServerDocumentVo document = doc.getServerDocument();

    if (document != null)
    {
        String fileName = document.getFileName();
        String fullPath = getMaximsDocumentStorePath();

        fullPath += fileName;

        engine.open(form.getForms().Core.PatientDocumentView, new Object[] {fullPath.replace("/", "\\")});
        //engine.openUrl(fullPath);
    }
}
项目:AvoinApotti    文件:ReferralStatusListImpl.java   
private PatientDocumentLiteVo getReferralLetter(CatsReferralListVo referral)
{
    StringBuilder query = new StringBuilder();

    query.append("SELECT doc FROM CatsReferral as referral left join referral.referralDocuments as doc left join doc.category as cat ");
    query.append(" WHERE referral.id = :REF_ID and cat.id = :CAT_ID ");

    ArrayList<String> paramNames = new ArrayList<String>();
    ArrayList<Object> paramValues = new ArrayList<Object>();

    paramNames.add("REF_ID");
    paramValues.add(referral.getID_CatsReferral());

    paramNames.add("CAT_ID");
    paramValues.add(DocumentCategory.GPLETTER.getID());

    return PatientDocumentLiteVoAssembler.create((PatientDocument) getDomainFactory().findFirst(query.toString(), paramNames, paramValues));
}
项目:openMAXIMS    文件:Logic.java   
private void addReferralLetterRow(DynamicGridRow row, PatientDocumentLiteVo doc)
{
    if(row == null || doc == null)
        return;

    String user = doc.getRecordingUserIsNotNull() ? doc.getRecordingUser().toString() : null;
    DateTime date = doc.getRecordingDateTimeIsNotNull() ? doc.getRecordingDateTime() : null;
    String title = "Recorded on <b>" + date + "</b> by <b>" + user + "</b>";

    DynamicGridRow letterRow = row.getRows().newRow();

    letterRow.setSelectable(true);
    letterRow.setExpandedImage(form.getImages().Core.PDFIcon);
    letterRow.setCollapsedImage(form.getImages().Core.PDFIcon);
    letterRow.setReadOnly(true);
    letterRow.setValue(doc);

    DynamicGridCell cell = letterRow.getCells().newCell(getCol(COL_TITLE_HIERARCHICAL), DynamicCellType.STRING);    

    cell.setReadOnly(true);
    cell.setValue(title);
}
项目:openMAXIMS    文件:Logic.java   
@Override
protected void onDyngrdNotesRowSelectionChanged(DynamicGridRow row) throws PresentationLogicException
{
    if(form.dyngrdNotes().getValue() instanceof BookingAppointmentForClinicalNotesVo)
        form.getLocalContext().setSelectedInstance((BookingAppointmentForClinicalNotesVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof AppointmentClinicalNotesVo)
        form.getLocalContext().setSelectedInstance((AppointmentClinicalNotesVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof PatientDiagnosisApptDetailVo)
        form.getLocalContext().setSelectedInstance((PatientDiagnosisApptDetailVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof PatientProcedureApptDetailVo)
        form.getLocalContext().setSelectedInstance((PatientProcedureApptDetailVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof PatientDocumentLiteVo)
    {
        viewPatientDocuments((PatientDocumentLiteVo) form.dyngrdNotes().getValue());
        form.getLocalContext().setSelectedInstance((PatientDocumentLiteVo) form.dyngrdNotes().getValue());
    }

    updateControlsState();
}
项目:openMAXIMS    文件:Logic.java   
private void viewPatientDocuments(PatientDocumentLiteVo doc)
{
    if(doc == null)
        return;

    ServerDocumentVo document = doc.getServerDocument();

    if (document != null)
    {
        String fileName = document.getFileName();
        String fullPath = getMaximsDocumentStorePath();

        fullPath += fileName;

        engine.open(form.getForms().Core.PatientDocumentView, new Object[] {fullPath.replace("/", "\\")});
        //engine.openUrl(fullPath);
    }
}
项目:openMAXIMS    文件:ReferralStatusListImpl.java   
private PatientDocumentLiteVo getReferralLetter(CatsReferralListVo referral)
{
    StringBuilder query = new StringBuilder();

    query.append("SELECT doc FROM CatsReferral as referral left join referral.referralDocuments as doc left join doc.category as cat ");
    query.append(" WHERE referral.id = :REF_ID and cat.id = :CAT_ID ");

    ArrayList<String> paramNames = new ArrayList<String>();
    ArrayList<Object> paramValues = new ArrayList<Object>();

    paramNames.add("REF_ID");
    paramValues.add(referral.getID_CatsReferral());

    paramNames.add("CAT_ID");
    paramValues.add(DocumentCategory.GPLETTER.getID());

    return PatientDocumentLiteVoAssembler.create((PatientDocument) getDomainFactory().findFirst(query.toString(), paramNames, paramValues));
}
项目:openMAXIMS    文件:Logic.java   
private void addReferralLetterRow(DynamicGridRow row, PatientDocumentLiteVo doc)
{
    if(row == null || doc == null)
        return;

    String user = doc.getRecordingUserIsNotNull() ? doc.getRecordingUser().toString() : null;
    DateTime date = doc.getRecordingDateTimeIsNotNull() ? doc.getRecordingDateTime() : null;
    String title = "Recorded on <b>" + date + "</b> by <b>" + user + "</b>";

    DynamicGridRow letterRow = row.getRows().newRow();

    letterRow.setSelectable(true);
    letterRow.setExpandedImage(form.getImages().Core.PDFIcon);
    letterRow.setCollapsedImage(form.getImages().Core.PDFIcon);
    letterRow.setReadOnly(true);
    letterRow.setValue(doc);

    DynamicGridCell cell = letterRow.getCells().newCell(getCol(COL_TITLE_HIERARCHICAL), DynamicCellType.STRING);    

    cell.setReadOnly(true);
    cell.setValue(title);
}
项目:openMAXIMS    文件:Logic.java   
@Override
protected void onDyngrdNotesRowSelectionChanged(DynamicGridRow row) throws PresentationLogicException
{
    if(form.dyngrdNotes().getValue() instanceof BookingAppointmentForClinicalNotesVo)
        form.getLocalContext().setSelectedInstance((BookingAppointmentForClinicalNotesVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof AppointmentClinicalNotesVo)
        form.getLocalContext().setSelectedInstance((AppointmentClinicalNotesVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof PatientDiagnosisApptDetailVo)
        form.getLocalContext().setSelectedInstance((PatientDiagnosisApptDetailVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof PatientProcedureApptDetailVo)
        form.getLocalContext().setSelectedInstance((PatientProcedureApptDetailVo) form.dyngrdNotes().getValue());
    else if(form.dyngrdNotes().getValue() instanceof PatientDocumentLiteVo)
    {
        viewPatientDocuments((PatientDocumentLiteVo) form.dyngrdNotes().getValue());
        form.getLocalContext().setSelectedInstance((PatientDocumentLiteVo) form.dyngrdNotes().getValue());
    }

    updateControlsState();
}
项目:openMAXIMS    文件:Logic.java   
private void viewPatientDocuments(PatientDocumentLiteVo doc)
{
    if(doc == null)
        return;

    ServerDocumentVo document = doc.getServerDocument();

    if (document != null)
    {
        String fileName = document.getFileName();
        String fullPath = getMaximsDocumentStorePath();

        fullPath += fileName;

        engine.open(form.getForms().Core.PatientDocumentView, new Object[] {fullPath.replace("/", "\\")});
        //engine.openUrl(fullPath);
    }
}
项目:openMAXIMS    文件:ReferralStatusListImpl.java   
private PatientDocumentLiteVo getReferralLetter(CatsReferralListVo referral)
{
    StringBuilder query = new StringBuilder();

    query.append("SELECT doc FROM CatsReferral as referral left join referral.referralDocuments as doc left join doc.category as cat ");
    query.append(" WHERE referral.id = :REF_ID and cat.id = :CAT_ID ");

    ArrayList<String> paramNames = new ArrayList<String>();
    ArrayList<Object> paramValues = new ArrayList<Object>();

    paramNames.add("REF_ID");
    paramValues.add(referral.getID_CatsReferral());

    paramNames.add("CAT_ID");
    paramValues.add(DocumentCategory.GPLETTER.getID());

    return PatientDocumentLiteVoAssembler.create((PatientDocument) getDomainFactory().findFirst(query.toString(), paramNames, paramValues));
}
项目:AvoinApotti    文件:Logic.java   
@Override
protected void onRIEDialogClosed(DialogResult result) throws PresentationLogicException
{
    if (DialogResult.OK.equals(result))
    {
        //wdev-15972
        PatientDocumentLiteVo docPatLiteVo = null;
        Patient_AssessmentVo patAssVo = null;
        if( form.getLocalContext().getCurrentPatientAssessmentIsNotNull())
        {
            patAssVo = domain.getPatientAssessment(form.getLocalContext().getCurrentPatientAssessment());
            docPatLiteVo = domain.getPatientDocumentLiteVo(patAssVo.getAssociatedDocument());
        }

        if( docPatLiteVo != null )
        {
            String comment =  "This PatientDocument has been marked as RIE due to its parent PatientAssessment being marked as RIE"; 
            try 
            {
                domain.markAsRie(docPatLiteVo, engine.getFormName(), form.getGlobalContext().Core.getPatientShort().getID_Patient(),  null, null, comment);
            } 
            catch (StaleObjectException e) 
            {                   
                e.printStackTrace();
            }
        }
        //------------
        form.getGlobalContext().Assessment.setPatientAssessment(null);
        form.getLocalContext().setCurrentPatientAssessment(null);
    }
}
项目:AvoinApotti    文件:DynamicAssessmentsImpl.java   
public PatientDocumentLiteVo getPatientDocumentLiteVo(PatientDocumentRefVo patDocRef) 
{
    if( patDocRef == null )
        return null;

    PatientDocument doPatientDocument = (PatientDocument)getDomainFactory().getDomainObject(PatientDocument.class, patDocRef.getID_PatientDocument());
    return PatientDocumentLiteVoAssembler.create(doPatientDocument);

}
项目:AvoinApotti    文件:Logic.java   
private void populateGridWithReferralLetters()
{
    DynamicGridRow row = addReferralLetterLabel();

    PatientDocumentLiteVoCollection docs = domain.listReferralLetters(form.getGlobalContext().RefMan.getCatsReferral());

    for(PatientDocumentLiteVo doc : docs)
    {
        if(doc == null)
            continue;

        addReferralLetterRow(row, doc);
    }
}
项目:openMAXIMS    文件:Logic.java   
@Override
protected void onRIEDialogClosed(DialogResult result) throws PresentationLogicException
{
    if (DialogResult.OK.equals(result))
    {
        //wdev-15972
        PatientDocumentLiteVo docPatLiteVo = null;
        Patient_AssessmentVo patAssVo = null;
        if( form.getLocalContext().getCurrentPatientAssessmentIsNotNull())
        {
            patAssVo = domain.getPatientAssessment(form.getLocalContext().getCurrentPatientAssessment());
            docPatLiteVo = domain.getPatientDocumentLiteVo(patAssVo.getAssociatedDocument());
        }

        if( docPatLiteVo != null )
        {
            String comment =  "This PatientDocument has been marked as RIE due to its parent PatientAssessment being marked as RIE"; 
            try 
            {
                domain.markAsRie(docPatLiteVo, engine.getFormName(), form.getGlobalContext().Core.getPatientShort().getID_Patient(),  null, null, comment);
            } 
            catch (StaleObjectException e) 
            {                   
                e.printStackTrace();
            }
        }
        //------------
        form.getGlobalContext().Assessment.setPatientAssessment(null);
        form.getLocalContext().setCurrentPatientAssessment(null);
    }
}
项目:openMAXIMS    文件:DynamicAssessmentsImpl.java   
public PatientDocumentLiteVo getPatientDocumentLiteVo(PatientDocumentRefVo patDocRef) 
{
    if( patDocRef == null )
        return null;

    PatientDocument doPatientDocument = (PatientDocument)getDomainFactory().getDomainObject(PatientDocument.class, patDocRef.getID_PatientDocument());
    return PatientDocumentLiteVoAssembler.create(doPatientDocument);

}
项目:openMAXIMS    文件:Logic.java   
private void populateGridWithReferralLetters()
{
    DynamicGridRow row = addReferralLetterLabel();

    PatientDocumentLiteVoCollection docs = domain.listReferralLetters(form.getGlobalContext().RefMan.getCatsReferral());

    for(PatientDocumentLiteVo doc : docs)
    {
        if(doc == null)
            continue;

        addReferralLetterRow(row, doc);
    }
}
项目:openMAXIMS    文件:Logic.java   
@Override
protected void onRIEDialogClosed(DialogResult result) throws PresentationLogicException
{
    if (DialogResult.OK.equals(result))
    {
        //wdev-15972
        PatientDocumentLiteVo docPatLiteVo = null;
        Patient_AssessmentVo patAssVo = null;
        if( form.getLocalContext().getCurrentPatientAssessmentIsNotNull())
        {
            patAssVo = domain.getPatientAssessment(form.getLocalContext().getCurrentPatientAssessment());
            docPatLiteVo = domain.getPatientDocumentLiteVo(patAssVo.getAssociatedDocument());
        }

        if( docPatLiteVo != null )
        {
            String comment =  "This PatientDocument has been marked as RIE due to its parent PatientAssessment being marked as RIE"; 
            try 
            {
                domain.markAsRie(docPatLiteVo, engine.getFormName(), form.getGlobalContext().Core.getPatientShort().getID_Patient(),  null, null, comment);
            } 
            catch (StaleObjectException e) 
            {                   
                e.printStackTrace();
            }
        }
        //------------
        form.getGlobalContext().Assessment.setPatientAssessment(null);
        form.getLocalContext().setCurrentPatientAssessment(null);
    }
}
项目:openMAXIMS    文件:DynamicAssessmentsImpl.java   
public PatientDocumentLiteVo getPatientDocumentLiteVo(PatientDocumentRefVo patDocRef) 
{
    if( patDocRef == null )
        return null;

    PatientDocument doPatientDocument = (PatientDocument)getDomainFactory().getDomainObject(PatientDocument.class, patDocRef.getID_PatientDocument());
    return PatientDocumentLiteVoAssembler.create(doPatientDocument);

}
项目:openMAXIMS    文件:Logic.java   
private void populateGridWithReferralLetters()
{
    DynamicGridRow row = addReferralLetterLabel();

    PatientDocumentLiteVoCollection docs = domain.listReferralLetters(form.getGlobalContext().RefMan.getCatsReferral());

    for(PatientDocumentLiteVo doc : docs)
    {
        if(doc == null)
            continue;

        addReferralLetterRow(row, doc);
    }
}
项目:openmaxims-linux    文件:Logic.java   
@Override
protected void onRIEDialogClosed(DialogResult result) throws PresentationLogicException
{
    if (DialogResult.OK.equals(result))
    {
        //wdev-15972
        PatientDocumentLiteVo docPatLiteVo = null;
        Patient_AssessmentVo patAssVo = null;
        if( form.getLocalContext().getCurrentPatientAssessmentIsNotNull())
        {
            patAssVo = domain.getPatientAssessment(form.getLocalContext().getCurrentPatientAssessment());
            docPatLiteVo = domain.getPatientDocumentLiteVo(patAssVo.getAssociatedDocument());
        }

        if( docPatLiteVo != null )
        {
            String comment =  "This PatientDocument has been marked as RIE due to its parent PatientAssessment being marked as RIE"; 
            try 
            {
                domain.markAsRie(docPatLiteVo, engine.getFormName(), form.getGlobalContext().Core.getPatientShort().getID_Patient(),  null, null, comment);
            } 
            catch (StaleObjectException e) 
            {                   
                e.printStackTrace();
            }
        }
        //------------
        form.getGlobalContext().Assessment.setPatientAssessment(null);
        form.getLocalContext().setCurrentPatientAssessment(null);
    }
}
项目:openmaxims-linux    文件:DynamicAssessmentsImpl.java   
public PatientDocumentLiteVo getPatientDocumentLiteVo(PatientDocumentRefVo patDocRef) 
{
    if( patDocRef == null )
        return null;

    PatientDocument doPatientDocument = (PatientDocument)getDomainFactory().getDomainObject(PatientDocument.class, patDocRef.getID_PatientDocument());
    return PatientDocumentLiteVoAssembler.create(doPatientDocument);

}
项目:AvoinApotti    文件:ReferralStatusListImpl.java   
public void undoProviderCancellation(CatsReferralListVo referral, ReferralNoteVo referralNote) throws StaleObjectException, ForeignKeyViolationException
{

    if (!(referral.getCurrentStatusIsNotNull() && 
            ReferralApptStatus.REFERRAL_CANCELLED_BY_PROVIDER.equals(referral.getCurrentStatus().getReferralStatus())))
    {
        throw new DomainRuntimeException("The referral is not cancelled by provided !");
    }

    //referral.get
    DomainFactory factory = getDomainFactory();


    CatsReferralStatusVoCollection statusHistory = referral.getStatusHistory();
    if (statusHistory == null)
    {
        throw new DomainRuntimeException("Cats referral doesn't have any history");
    }

    //Hold the current status so that remove can be done in db
    CatsReferralStatusVo removeStatus = referral.getCurrentStatus();

    //Remove the current status from the history and set the current status to the latest
    statusHistory.remove(removeStatus);

    CatsReferralStatusVo latestStatus = getLatestStatus(statusHistory);

    // Check for a referral letter associated to referral
    PatientDocumentLiteVo referralLetter = getReferralLetter(referral);

    if (ReferralApptStatus.REFERRAL_RECEIVED.equals(latestStatus.getReferralStatus()) && referralLetter != null)
    {
        // Create new status for referral
        CatsReferralStatusVo status = new CatsReferralStatusVo();

        status.setReferralStatus(ReferralApptStatus.AWAITING_TRIAGE);
        status.setAuthoringUser(referralLetter.getRecordingUser());
        status.setComment("");
        status.setStatusDateTime(new DateTime());

        referral.setCurrentStatus(status);
        statusHistory.add(status);
    }
    else
    {
        referral.setCurrentStatus(latestStatus);
    }



    CatsReferral referralBo = CatsReferralListVoAssembler.extractCatsReferral(factory, referral);

    ProviderCancellation pCancellation = referralBo.getProviderCancellation();

    referralBo.setProviderCancellation(null);

    factory.save(referralBo);

    factory.delete(CatsReferralStatusVoAssembler.extractCATSReferralStatus(factory, removeStatus));

    if (pCancellation != null)
        factory.delete(pCancellation);

    //WDEV-12088
    ims.core.domain.objects.CorrespondenceNote domainObject = ReferralNoteVoAssembler.extractCorrespondenceNote(factory, referralNote);     
    factory.save(domainObject);
}
项目:openMAXIMS    文件:ReferralStatusListImpl.java   
public void undoProviderCancellation(CatsReferralListVo referral, ReferralNoteVo referralNote) throws StaleObjectException, ForeignKeyViolationException
{

    if (!(referral.getCurrentStatusIsNotNull() && 
            ReferralApptStatus.REFERRAL_CANCELLED_BY_PROVIDER.equals(referral.getCurrentStatus().getReferralStatus())))
    {
        throw new DomainRuntimeException("The referral is not cancelled by provided !");
    }

    //referral.get
    DomainFactory factory = getDomainFactory();


    CatsReferralStatusVoCollection statusHistory = referral.getStatusHistory();
    if (statusHistory == null)
    {
        throw new DomainRuntimeException("Cats referral doesn't have any history");
    }

    //Hold the current status so that remove can be done in db
    CatsReferralStatusVo removeStatus = referral.getCurrentStatus();

    //Remove the current status from the history and set the current status to the latest
    statusHistory.remove(removeStatus);

    CatsReferralStatusVo latestStatus = getLatestStatus(statusHistory);

    // Check for a referral letter associated to referral
    PatientDocumentLiteVo referralLetter = getReferralLetter(referral);

    if (ReferralApptStatus.REFERRAL_RECEIVED.equals(latestStatus.getReferralStatus()) && referralLetter != null)
    {
        // Create new status for referral
        CatsReferralStatusVo status = new CatsReferralStatusVo();

        status.setReferralStatus(ReferralApptStatus.AWAITING_TRIAGE);
        status.setAuthoringUser(referralLetter.getRecordingUser());
        status.setComment("");
        status.setStatusDateTime(new DateTime());

        referral.setCurrentStatus(status);
        statusHistory.add(status);
    }
    else
    {
        referral.setCurrentStatus(latestStatus);
    }



    CatsReferral referralBo = CatsReferralListVoAssembler.extractCatsReferral(factory, referral);

    ProviderCancellation pCancellation = referralBo.getProviderCancellation();

    referralBo.setProviderCancellation(null);

    factory.save(referralBo);

    factory.delete(CatsReferralStatusVoAssembler.extractCATSReferralStatus(factory, removeStatus));

    if (pCancellation != null)
        factory.delete(pCancellation);

    //WDEV-12088
    ims.core.domain.objects.CorrespondenceNote domainObject = ReferralNoteVoAssembler.extractCorrespondenceNote(factory, referralNote);     
    factory.save(domainObject);
}
项目:openMAXIMS    文件:ReferralStatusListImpl.java   
public void undoProviderCancellation(CatsReferralListVo referral, ReferralNoteVo referralNote) throws StaleObjectException, ForeignKeyViolationException
{

    if (!(referral.getCurrentStatusIsNotNull() && 
            ReferralApptStatus.REFERRAL_CANCELLED_BY_PROVIDER.equals(referral.getCurrentStatus().getReferralStatus())))
    {
        throw new DomainRuntimeException("The referral is not cancelled by provided !");
    }

    //referral.get
    DomainFactory factory = getDomainFactory();


    CatsReferralStatusVoCollection statusHistory = referral.getStatusHistory();
    if (statusHistory == null)
    {
        throw new DomainRuntimeException("Cats referral doesn't have any history");
    }

    //Hold the current status so that remove can be done in db
    CatsReferralStatusVo removeStatus = referral.getCurrentStatus();

    //Remove the current status from the history and set the current status to the latest
    statusHistory.remove(removeStatus);

    CatsReferralStatusVo latestStatus = getLatestStatus(statusHistory);

    // Check for a referral letter associated to referral
    PatientDocumentLiteVo referralLetter = getReferralLetter(referral);

    if (ReferralApptStatus.REFERRAL_RECEIVED.equals(latestStatus.getReferralStatus()) && referralLetter != null)
    {
        // Create new status for referral
        CatsReferralStatusVo status = new CatsReferralStatusVo();

        status.setReferralStatus(ReferralApptStatus.AWAITING_TRIAGE);
        status.setAuthoringUser(referralLetter.getRecordingUser());
        status.setComment("");
        status.setStatusDateTime(new DateTime());

        referral.setCurrentStatus(status);
        statusHistory.add(status);
    }
    else
    {
        referral.setCurrentStatus(latestStatus);
    }



    CatsReferral referralBo = CatsReferralListVoAssembler.extractCatsReferral(factory, referral);

    ProviderCancellation pCancellation = referralBo.getProviderCancellation();

    referralBo.setProviderCancellation(null);

    factory.save(referralBo);

    factory.delete(CatsReferralStatusVoAssembler.extractCATSReferralStatus(factory, removeStatus));

    if (pCancellation != null)
        factory.delete(pCancellation);

    //WDEV-12088
    ims.core.domain.objects.CorrespondenceNote domainObject = ReferralNoteVoAssembler.extractCorrespondenceNote(factory, referralNote);     
    factory.save(domainObject);
}