Ejemplo n.º 1
0
 private void initMultipleBar(List<double[]> xValues, List<double[]> yValues) {
   for (int i = 0; i < xValues.size(); i++) {
     XYSeries series = mDataset.getSeriesAt(i);
     double[] xValue = xValues.get(i);
     double[] yValue = yValues.get(i);
     initBar(series, xValue, yValue);
   }
 }
  private void getObservations(Integer patientId, String fieldName) {

    ClinicAdapter ca = new ClinicAdapter();
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    ca.open();
    Cursor c = ca.fetchPatientObservation(patientId, fieldName);

    if (c != null && c.getCount() >= 0) {

      XYSeries series;
      if (mDataset.getSeriesCount() > 0) {
        series = mDataset.getSeriesAt(0);
        series.clear();
      } else {
        series = new XYSeries(fieldName);
        mDataset.addSeries(series);
      }

      int valueIntIndex = c.getColumnIndex(ClinicAdapter.KEY_VALUE_INT);
      int valueNumericIndex = c.getColumnIndex(ClinicAdapter.KEY_VALUE_NUMERIC);
      int encounterDateIndex = c.getColumnIndex(ClinicAdapter.KEY_ENCOUNTER_DATE);
      int dataTypeIndex = c.getColumnIndex(ClinicAdapter.KEY_DATA_TYPE);

      do {
        try {
          Date encounterDate = df.parse(c.getString(encounterDateIndex));
          int dataType = c.getInt(dataTypeIndex);

          double value;
          if (dataType == Constants.TYPE_INT) {
            value = c.getInt(valueIntIndex);
            series.add(encounterDate.getTime(), value);
          } else if (dataType == Constants.TYPE_DOUBLE) {
            value = c.getFloat(valueNumericIndex);
            series.add(encounterDate.getTime(), value);
          }
        } catch (ParseException e) {
          e.printStackTrace();
        }

      } while (c.moveToNext());
    }

    if (c != null) {
      c.close();
    }
    ca.close();
  }