private boolean addDoseRow(
      DynamicGridRow row, MedicationDose voDose, boolean bHideDiscontinued, Color objColor) {
    if (voDose == null || row == null)
      throw new CodingRuntimeException("Dose or Row not sent - Coding Error");

    if ((bHideDiscontinued)
        && (voDose.getIsStoppedIsNotNull())
        && (voDose.getIsStopped().booleanValue())) return false;

    DynamicGridRow childRow = row.getRows().newRow();
    DynamicGridCell cell1 =
        childRow.getCells().newCell(getColByIdentifier(COL_DOSE_DOSE), DynamicCellType.LABEL);
    cell1.setValue(voDose.getDoseIsNotNull() ? voDose.getDose() : "");
    cell1.setIdentifier(voDose.getDose());
    cell1.setTooltip(voDose.getDiscontinuedTooltip());

    DynamicGridCell cell2 =
        childRow.getCells().newCell(getColByIdentifier(COL_DOSE_ROUTE), DynamicCellType.LABEL);
    cell2.setValue(voDose.getAdminRouteIsNotNull() ? voDose.getAdminRoute().toString() : "");
    cell2.setIdentifier(voDose.getAdminRoute());
    cell2.setTooltip(voDose.getDiscontinuedTooltip());

    DynamicGridCell cell3 =
        childRow.getCells().newCell(getColByIdentifier(COL_DOSE_TIMES), DynamicCellType.LABEL);
    cell3.setValue(
        voDose.getAdminTimesIsNotNull() ? createTimesString(voDose.getAdminTimes()) : "");
    cell3.setTooltip(
        voDose.getAdminTimesIsNotNull() ? createTimesString(voDose.getAdminTimes()) : "");
    cell3.setIdentifier(voDose.getAdminTimes());
    cell3.setTooltip(voDose.getDiscontinuedTooltip());

    DynamicGridCell cell4 =
        childRow
            .getCells()
            .newCell(getColByIdentifier(COL_DOSE_COMMENCED_BY), DynamicCellType.LABEL);
    cell4.setValue(voDose.getDoseStartHcpIsNotNull() ? voDose.getDoseStartHcp().toString() : "");
    cell4.setIdentifier(voDose.getDose());
    cell4.setTooltip(voDose.getDiscontinuedTooltip());

    DynamicGridCell cell5 =
        childRow
            .getCells()
            .newCell(getColByIdentifier(COL_DOSE_COMMENCED_DATE), DynamicCellType.LABEL);
    cell5.setValue(voDose.getDoseStartDateIsNotNull() ? voDose.getDoseStartDate().toString() : "");
    cell5.setIdentifier(voDose.getDose());
    cell5.setTooltip(voDose.getDiscontinuedTooltip());

    // WDEV-20591
    DynamicGridCell cell6 =
        childRow.getCells().newCell(getColByIdentifier(COL_DOSE_COMMENT), DynamicCellType.LABEL);
    cell6.setValue(voDose.getCommentIsNotNull() ? voDose.getComment().toString() : "");
    cell6.setIdentifier(voDose.getComment());
    cell6.setTooltip(voDose.getDiscontinuedTooltip());

    childRow.setValue(voDose);

    childRow.setExpanded(true);
    childRow.setSelectable(false);
    childRow.setBackColor(objColor);
    childRow.setExpandedImage(this.tabletdoseImage);
    childRow.setCollapsedImage(this.tabletdoseImage);

    if ((voDose.getIsStoppedIsNotNull()) && (voDose.getIsStopped().booleanValue()))
      childRow.setBold(false);
    else childRow.setBold(true);

    return true;
  }
  private void addMedicationRow(
      PatientMedicationVo voMed, boolean bHideDiscontinued, Color objColor) {
    if (voMed == null)
      throw new CodingRuntimeException("Coding Error voSnapShot is null addMedicationRow()");

    if ((bHideDiscontinued)
        && (voMed.getIsDiscontinuedIsNotNull())
        && (voMed.getIsDiscontinued().booleanValue())) return;

    boolean bAllDosesAreDiscontinued = true;
    MedicationDose voDose = null;

    // Loop thru to see if collection has any non-discontinued Doses - i.e. current ones.
    for (int k = 0; k < voMed.getPrescribedDoses().size(); k++) {
      voDose = voMed.getPrescribedDoses().get(k);
      if ((voDose.getIsStopped() == null)
          || (voDose.getIsStoppedIsNotNull() && (voDose.getIsStopped().booleanValue() == false)))
        bAllDosesAreDiscontinued = false;
    }

    // If we are not hiding Discontinued Meds and doses the ignore the bAllDosesAreDiscontinued
    // boolean.
    if (!bHideDiscontinued) bAllDosesAreDiscontinued = false;

    if (!bAllDosesAreDiscontinued) {
      DynamicGridRow row = this.grid.getRows().newRow();
      DynamicGridCell cell1 =
          row.getCells().newCell(getColByIdentifier(COL_MED_DESC_OR_DOSE), DynamicCellType.LABEL);
      cell1.setValue(voMed.getOtherMedicationText());
      cell1.setIdentifier(voMed.getOtherMedicationText());
      // WDEV-1204 - add tooltip
      cell1.setTooltip(voMed.getDiscontinuedTooltip());

      DynamicGridCell cell2 =
          row.getCells().newCell(getColByIdentifier(COL_MED_FREQ_OR_TIMES), DynamicCellType.LABEL);
      cell2.setValue(voMed.getFrequencyIsNotNull() ? voMed.getFrequency().toString() : "");
      cell2.setIdentifier(voMed.getFrequency());
      cell2.setTooltip(voMed.getDiscontinuedTooltip());

      if (hasDischargeInfo()) {
        DynamicGridCell cellDo =
            row.getCells().newCell(getColByIdentifier(COL_MED_DO), DynamicCellType.IMAGE);
        cellDo.setValue(
            voMed.getIsInTTOIsNotNull() && voMed.getIsInTTO().booleanValue() ? doImage : null);

        DynamicGridCell cellDays =
            row.getCells().newCell(getColByIdentifier(COL_MED_DAYS), DynamicCellType.INT);
        cellDays.setValue(voMed.getNoDaysSupply());
      }

      DynamicGridCell cell3 =
          row.getCells().newCell(getColByIdentifier(COL_MED_COMMENCED_BY), DynamicCellType.LABEL);
      cell3.setValue(voMed.getHcpCommencedIsNotNull() ? voMed.getHcpCommenced().toString() : "");
      cell3.setIdentifier(voMed.getFrequency());
      cell3.setTooltip(voMed.getDiscontinuedTooltip());

      DynamicGridCell cell4 =
          row.getCells().newCell(getColByIdentifier(COL_MED_COMMENCED_DATE), DynamicCellType.LABEL);
      cell4.setValue(voMed.getCommencedDateIsNotNull() ? voMed.getCommencedDate().toString() : "");
      cell4.setIdentifier(voMed.getFrequency());
      cell4.setTooltip(voMed.getDiscontinuedTooltip());

      DynamicGridCell cellAudit =
          row.getCells().newCell(getColByIdentifier(COL_AUDIT), DynamicCellType.IMAGE);
      if (voMed.getSysInfoIsNotNull() && voMed.getSysInfo().getLastupdateUser() != null) {
        cellAudit.setValue(this.imgAudit);
        cellAudit.setTooltip("This record had been updated.");
      }

      if (this.checkColumn) {
        DynamicGridCell cellChecked =
            row.getCells().newCell(getColByIdentifier(COL_COPY), DynamicCellType.BOOL);
        cellChecked.setValue(Boolean.TRUE);
        cellChecked.setIdentifier(null);
      }

      // WDEV-20591
      DynamicGridCell cell5 =
          row.getCells().newCell(getColByIdentifier(COL_MED_COMMENT), DynamicCellType.LABEL);
      cell5.setValue(voMed.getCommentIsNotNull() ? voMed.getComment() : "");
      cell5.setIdentifier(voMed.getFrequency());
      cell5.setTooltip(voMed.getDiscontinuedTooltip());

      row.setValue(voMed);

      for (int i = 0; i < voMed.getPrescribedDoses().size(); i++)
        addDoseRow(row, voMed.getPrescribedDoses().get(i), bHideDiscontinued, objColor);

      row.setExpanded(true);
      row.setSelectable(true);
      row.setBackColor(objColor);
      row.setExpandedImage(this.blisterpackImage);

      if ((voMed.getIsDiscontinuedIsNotNull()) && (voMed.getIsDiscontinued().booleanValue()))
        row.setBold(false);
      else row.setBold(true);
    }
  }