Search in sources :

Example 1 with Reading

use of trial.Reading in project project1-ICS372 by sandip-rai.

the class ReadingUnitTest method testAll.

/**
 * Test all.
 */
@Test
public void testAll() {
    rid = "001";
    t = "Weight";
    v = "180.1";
    bpv = null;
    d = new Date();
    cid = "001";
    c = new Clinic("Clinic 1", cid);
    r = new Reading(rid, t, v, d, c);
    Assert.assertNull(bpv);
    Assert.assertNotNull(c);
    Assert.assertNotNull(r);
    Assert.assertEquals("001", r.getReadingId());
    Assert.assertEquals("Weight", r.getType());
    Assert.assertEquals("180.1", r.getValue());
    Assert.assertEquals(d, r.getDate());
    Assert.assertEquals(c, r.getClinic());
    bpv = "135/85";
    t = "Blood Pressure";
    rid = "002";
    Date dd = new Date();
    cid = "002";
    c = new Clinic("Clinic 2", cid);
    r1 = new Reading(rid, t, bpv, dd, c);
    Assert.assertNotNull(c);
    Assert.assertNotNull(r1);
    Assert.assertEquals("002", r1.getReadingId());
    Assert.assertEquals("Blood Pressure", r1.getType());
    Assert.assertEquals("135/85", r1.getValue());
    Assert.assertEquals(dd, r1.getDate());
    Assert.assertEquals(c, r1.getClinic());
}
Also used : Clinic(trial.Clinic) Reading(trial.Reading) Date(java.util.Date) Test(org.junit.Test)

Example 2 with Reading

use of trial.Reading in project project1-ICS372 by sandip-rai.

the class PatientReadingsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_patient_readings);
    // Get the toolbar and assign
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.patient_readings);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Get the Patient object using the selected_patientId
    String selectedPatientId = (String) getIntent().getExtras().get(SELECTED_PATIENTID);
    Patient patient = clinicalTrial.findPatient(selectedPatientId);
    // Fill the textView with the selectedPatient
    TextView textViewPatientId = (TextView) findViewById(R.id.textViewPatientIdinPatientReadings);
    textViewPatientId.setText(selectedPatientId);
    if (patient.getState().getReadings() != null) {
        // Get the TableLayout
        TableLayout table = (TableLayout) findViewById(R.id.readingsTable);
        // Counter to count number of rows and setting colors to even rows
        int count = 0;
        for (Reading reading : patient.getReadings()) {
            // Get all the readings of the Patient
            // Create a table row using the readings_row XML
            TableRow row = (TableRow) LayoutInflater.from(PatientReadingsActivity.this).inflate(R.layout.readings_row, null);
            if (count % 2 == 0) {
                // set the color to even rows
                row.setBackgroundColor(Color.LTGRAY);
            }
            // Fill the TextViews in the rows using the reading of the Patient Object
            ((TextView) row.findViewById(R.id.readingIdColumn)).setText(reading.getReadingId());
            ((TextView) row.findViewById(R.id.typeColumn)).setText(reading.getType());
            ((TextView) row.findViewById(R.id.valueColumn)).setText(reading.getValue());
            ((TextView) row.findViewById(R.id.dateColumn)).setText(reading.getDate().toString());
            ((TextView) row.findViewById(R.id.clinicIdColumn)).setText(reading.getClinic().getId());
            ((TextView) row.findViewById(R.id.clinicNameColumn)).setText(reading.getClinic().getName());
            // Add the row to the TableLayout
            table.addView(row);
            count++;
        }
        table.requestLayout();
    }
}
Also used : Reading(trial.Reading) TableRow(android.widget.TableRow) Patient(trial.Patient) TextView(android.widget.TextView) TableLayout(android.widget.TableLayout) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Reading (trial.Reading)2 Toolbar (android.support.v7.widget.Toolbar)1 TableLayout (android.widget.TableLayout)1 TableRow (android.widget.TableRow)1 TextView (android.widget.TextView)1 Date (java.util.Date)1 Test (org.junit.Test)1 Clinic (trial.Clinic)1 Patient (trial.Patient)1