use of trial.Clinic in project project1-ICS372 by sandip-rai.
the class ButtonAddReadingListener method actionPerformed.
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(ActionEvent e) {
// Get the new entered values
Patient patient = (Patient) guiController.getMainMenuView().getComboBoxPatients().getSelectedItem();
String readingType = (String) guiController.getMainMenuView().getComboBoxReadingType().getSelectedItem();
String readingValue = guiController.getMainMenuView().getValueInput().getText();
String readingDate = guiController.getMainMenuView().getDateInput().getText();
String dateFormat = guiController.getClinicalTrial().getSettings().getDateFormat();
Clinic clinic = (Clinic) guiController.getMainMenuView().getComboBoxClinics().getSelectedItem();
try {
// Prompt the user if reading values aren't filled
if (readingValue.equals("") || readingDate.equals("")) {
JOptionPane.showMessageDialog(null, "Please fill in the values for every field.");
} else {
// If all values are filled, add them to to corresponding Patient
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
// Change date from String to Date
Date date = formatter.parse(readingDate);
// add the new readings to that patient
if (patient.addReading(null, readingType, readingValue, date, clinic)) {
// Prompt if the reading is added
JOptionPane.showMessageDialog(null, "New reading has been added.");
} else {
// Prompt if patient is not active in trial
JOptionPane.showMessageDialog(null, "Invalid reading.");
}
// Clear the textfields for new input
guiController.getMainMenuView().getValueInput().setText("");
}
} catch (NullPointerException ex) {
// Catch the error if no patient is selected for adding readings.
guiController.getMainMenuView().displayErrorMessage(null, "Please select a Patient to add readings.");
} catch (ParseException e1) {
JOptionPane.showMessageDialog(null, "Please enter a valid date formated " + dateFormat);
e1.printStackTrace();
}
}
use of trial.Clinic in project project1-ICS372 by sandip-rai.
the class ClinicUnitTest method testAll.
/**
* Test all.
*/
@Test
public void testAll() {
nm = "Clinic 1";
i = "001";
c = new Clinic(nm, i);
Assert.assertNotNull(c);
Assert.assertEquals(nm, c.getName());
Assert.assertEquals(i, c.getId());
c.setID("002");
c.setName("Clinic 2");
Assert.assertEquals("002", c.getId());
Assert.assertEquals("Clinic 2", c.getName());
}
use of trial.Clinic in project project1-ICS372 by sandip-rai.
the class AddClinicActivity method onClickAddToClinicList.
public void onClickAddToClinicList(View view) {
// Grab the editText field where the user enters the patientId
EditText editTextClinicId = (EditText) findViewById(R.id.editTextClinicIdinAddClinic);
EditText editTextClinicName = (EditText) findViewById(R.id.editTextClinicNameinAddClinic);
// Get the clinicId
String clinicId = editTextClinicId.getText().toString();
// Get the clinicName
String clinicName = editTextClinicName.getText().toString();
// Try to add the clinic, if added returns the clinic,else returns null
Clinic tempClinic = clinicalTrial.addClinic(clinicName, clinicId);
// make sure the user has entered in the fields
if ((clinicName == null || clinicName.equals(""))) {
makeToast("Please fill the Clinic Name");
} else if (tempClinic != null) {
// clinicalTrial.findPatient(patientId).setActive(true);
makeToast("Successfully Added!");
editTextClinicId.setText("");
editTextClinicName.setText("");
} else {
makeToast("Clinic exists already.");
}
}
use of trial.Clinic 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());
}
use of trial.Clinic in project project1-ICS372 by sandip-rai.
the class AddPatientInfoActivity method onClickAddReadingsToSelectedPatient.
public void onClickAddReadingsToSelectedPatient(View view) {
// get selected patients id from spinner and pass it to clinicalTrial to find that patient
// Spinner patientListSpinner = (Spinner) findViewById(R.id.spinnerReadingPatientId);
// String patientId = patientListSpinner.getSelectedItem().toString();
// Get the patientId from the textView which is passed from PatientListActivity
TextView patientIdText = (TextView) findViewById(R.id.textViewPatientId);
String patientId = patientIdText.getText().toString();
Patient patient = clinicalTrial.findPatient(patientId);
// get selected reading type from spinner
Spinner readingTypeSpinner = (Spinner) findViewById(R.id.spinnerReadingType);
String readingType = readingTypeSpinner.getSelectedItem().toString();
EditText editTextReadingId = (EditText) findViewById(R.id.editTextReadingId);
String readingId = editTextReadingId.getText().toString();
EditText editTextDate = (EditText) findViewById(R.id.editTextDate);
String textDate = editTextDate.getText().toString();
EditText editTextValue = (EditText) findViewById(R.id.editTextValue);
String value = editTextValue.getText().toString();
Spinner spinnerClinicId = (Spinner) findViewById(R.id.spinnerClinicId);
String clinicInSpinner = null;
String[] clinicArray;
String clinicId = null;
try {
clinicInSpinner = spinnerClinicId.getSelectedItem().toString();
clinicArray = clinicInSpinner.split(":");
clinicId = clinicArray[0];
} catch (NullPointerException e) {
makeToast("Patient is not currently active.");
}
Clinic clinic = clinicalTrial.findClinic(clinicId);
String dateFormat = clinicalTrial.getSettings().getDateFormat();
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
// Change date from String to Date
Date date = null;
try {
date = formatter.parse(textDate);
} catch (ParseException e) {
e.printStackTrace();
}
if (value.equals("") || textDate.equals("") || readingId.equals("") || clinicId.equals("")) {
makeToast("Please fill in the values for every field.");
} else if (clinicInSpinner == null) {
makeToast("Please select/add a clinic.");
// }// else if(date == null){
// makeToast("Please enter date in a correct format");
} else if (!patient.getState().toString().equals("Active")) {
makeToast("Patient is not currently active.");
} else {
// add the new readings to that patient
if (patient.addReading(readingId, readingType, value, date, clinic)) {
// Prompt if the reading is added
makeToast("New reading has been added.");
editTextReadingId.setText("");
editTextDate.setText("");
editTextValue.setText("");
}
}
}
Aggregations