use of trial.Patient in project project1-ICS372 by sandip-rai.
the class ComboBoxPatientsListener method actionPerformed.
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(ActionEvent e) {
String format = guiController.getClinicalTrial().getSettings().getDateFormat();
DisplayPatientListView view = guiController.getDisplayPatientListView();
if ((Patient) guiController.getDisplayPatientListView().getComboBoxPatients().getSelectedItem() != null) {
Patient patient = (Patient) guiController.getDisplayPatientListView().getComboBoxPatients().getSelectedItem();
boolean active = patient.isActive();
String text = patient.toString(format);
view.setActive(active);
view.setPatientInfo(text);
} else {
}
view.getFrame().pack();
}
use of trial.Patient in project project1-ICS372 by sandip-rai.
the class MainMenuView method setupFrame.
/**
* Sets the up frame.
*
* @param clinicalTrial the new up frame
*/
// setup Frame
@SuppressWarnings("unchecked")
public void setupFrame(ClinicalTrial clinicalTrial) {
comboBoxPatients.removeAllItems();
for (Patient patient : clinicalTrial.getAllPatients()) {
// Fill the comboBox from the ClinicalTrial arrayList
comboBoxPatients.addItem(patient);
}
for (Clinic clinic : clinicalTrial.getAllClinics()) {
// Fill the comboBox from the ClinicalTrial arrayList
comboBoxClinics.addItem(clinic);
}
comboBoxPatients.setRenderer(new PatientRenderer());
comboBoxClinics.setRenderer(new ClinicRenderer());
Date date = new Date();
String dateFormat = clinicalTrial.getSettings().getDateFormat();
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
dateInput.setText(formatter.format(date));
PanelAndFrame.setupFrame(frame, panels, menuBar);
}
use of trial.Patient in project project1-ICS372 by sandip-rai.
the class PatientRenderer method getListCellRendererComponent.
/* (non-Javadoc)
* @see javax.swing.plaf.basic.BasicComboBoxRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
*/
@SuppressWarnings("rawtypes")
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Patient) {
Patient patient = (Patient) value;
// set display value to the patient ID
setText(patient.getPatientId());
}
return this;
}
use of trial.Patient 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();
}
}
use of trial.Patient in project project1-ICS372 by sandip-rai.
the class PatientListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patient_list);
// Get the toolbar and assign
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.patient_list);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Grab the spinner
final Spinner patientListSpinner = (Spinner) findViewById(R.id.spinnerPatientIdinPatientList);
ArrayAdapter<Patient> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, clinicalTrial.getAllPatients());
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
patientListSpinner.setAdapter(adapter);
// Status spinner
final Spinner patientStatusSpinner = (Spinner) findViewById(R.id.spinnerStatusPatientList);
final ArrayAdapter<CharSequence> adapterStatus = ArrayAdapter.createFromResource(this, R.array.statusList, android.R.layout.simple_spinner_item);
adapterStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
patientStatusSpinner.setAdapter(adapterStatus);
// Update status spinner on patient spinner selection
patientListSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (clinicalTrial.getAllPatients().size() > 0) {
Patient p = (Patient) patientListSpinner.getSelectedItem();
String state = p.getState().toString();
if (state != null) {
int spinnerPosition = adapterStatus.getPosition(state);
patientStatusSpinner.setSelection(spinnerPosition);
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
// Update patient state on status spinner selection
patientStatusSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (clinicalTrial.getAllPatients().size() > 0) {
Patient p = (Patient) patientListSpinner.getSelectedItem();
switch((String) patientStatusSpinner.getSelectedItem()) {
case "Active":
p.setState(new PatientStateActive(p));
break;
case "Withdrawn":
p.setState(new PatientStateWithdrawn(p));
break;
case "Failed":
p.setState(new PatientStateFailed(p));
break;
case "Completed":
p.setState(new PatientStateCompleted(p));
break;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
Aggregations