public DementiaVo rieDementiaRecord(
      DementiaVo voDementia,
      FormName formName,
      Integer patientId,
      Integer contactId,
      Integer careContextId,
      String rieMessage)
      throws DomainInterfaceException, StaleObjectException {
    // RIE the AMTS record
    if (voDementia.getStepOneFindIsNotNull())
      markAsRie(
          voDementia.getStepOneFind(), formName, patientId, contactId, careContextId, rieMessage);

    // RIE AMTS and its Comment
    if (voDementia.getStepTwoAssessIsNotNull()) {
      if (voDementia.getStepTwoAssess().getStepTwoAssessNoteIsNotNull())
        markAsRie(
            voDementia.getStepTwoAssess().getStepTwoAssessNote(),
            formName,
            patientId,
            contactId,
            careContextId,
            rieMessage);

      markAsRie(
          voDementia.getStepTwoAssess(), formName, patientId, contactId, careContextId, rieMessage);
    }

    // RIE HistoricalWorklistStatus records
    for (int i = 0; i < voDementia.getHistoricalWorklistStatus().size(); i++)
      markAsRie(
          voDementia.getHistoricalWorklistStatus().get(i),
          formName,
          patientId,
          contactId,
          careContextId,
          rieMessage);

    //	//RIE CurrentWorklistStatus
    //	markAsRie(voDementia.getCurrentWorklistStatus(), formName, patientId, contactId,
    // careContextId, rieMessage);

    // RIE Dementia
    markAsRie(voDementia, formName, patientId, contactId, careContextId, rieMessage);

    return null;
  }
  public ims.clinical.vo.DementiaVo saveDementia(
      ims.clinical.vo.DementiaVo dementiaToSave, FormName formName)
      throws ims.domain.exceptions.StaleObjectException {
    if (dementiaToSave == null) {
      throw new CodingRuntimeException("Cannot get DementiaVo on null Id ");
    }

    // WDEV-16247
    if (dementiaToSave.getID_DementiaIsNotNull()
        && dementiaToSave.getStepOneFindIsNotNull()
        && dementiaToSave.getStepOneFind().getID_DementiaFindIsNotNull()
        && (YesNo.YES.equals(dementiaToSave.getStepOneFind().getHasFormalDiagnosisOfDementia())
            || (YesNo.NO.equals(dementiaToSave.getStepOneFind().getHasFormalDiagnosisOfDementia())
                && YesNo.NO.equals(dementiaToSave.getStepOneFind().getDeliriumConfirmed())
                && YesNo.NO.equals(dementiaToSave.getStepOneFind().getAwarenessQuestion())))
        && (dementiaToSave.getStepTwoAssessIsNotNull()
            && dementiaToSave.getStepTwoAssess().getID_DementiaAssessAndInvestigateIsNotNull())) {
      String rieMessage =
          "THIS RECORD HAS BEEN MARKED AS RECORDED IN ERROR BY MAXIMS DEMENTIA - REASON : record is not relevant because of Edit to FIND record";
      Integer patientId = dementiaToSave.getPatient().getID_Patient();

      if (dementiaToSave.getStepTwoAssess().getStepTwoAssessNoteIsNotNull()) {
        markAsRie(
            dementiaToSave.getStepTwoAssess().getStepTwoAssessNote(),
            formName,
            patientId,
            null,
            null,
            rieMessage);
      }
      markAsRie(dementiaToSave.getStepTwoAssess(), formName, patientId, null, null, rieMessage);

      dementiaToSave.setStepTwoAssess(null);
      dementiaToSave.setAMTSScore(null);
      //	dementiaToSave.setDeliriumConfirmed(null);
      //	dementiaToSave.setDementiaConfirmed(null);
      dementiaToSave.setConfirmedPatientPutOnDementiaPathway(null);
    }

    String[] arrErrors = dementiaToSave.validate();

    if (arrErrors != null)
      throw new DomainRuntimeException("Error saving voDementia - not validated correctly");

    DomainFactory factory = getDomainFactory();
    Dementia domainDementia = DementiaVoAssembler.extractDementia(factory, dementiaToSave);
    factory.save(domainDementia);
    return DementiaVoAssembler.create(domainDementia);
  }