Search in sources :

Example 6 with Patient

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();
}
Also used : Patient(trial.Patient) DisplayPatientListView(gui.views.DisplayPatientListView)

Example 7 with Patient

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);
}
Also used : Clinic(trial.Clinic) Patient(trial.Patient) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 8 with Patient

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;
}
Also used : Patient(trial.Patient)

Example 9 with Patient

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();
    }
}
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)

Example 10 with Patient

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) {
        }
    });
}
Also used : PatientStateFailed(trial.PatientStateFailed) Spinner(android.widget.Spinner) Patient(trial.Patient) View(android.view.View) AdapterView(android.widget.AdapterView) PatientStateWithdrawn(trial.PatientStateWithdrawn) PatientStateCompleted(trial.PatientStateCompleted) PatientStateActive(trial.PatientStateActive) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Patient (trial.Patient)10 Date (java.util.Date)5 SimpleDateFormat (java.text.SimpleDateFormat)3 Clinic (trial.Clinic)3 PatientStateActive (trial.PatientStateActive)3 Toolbar (android.support.v7.widget.Toolbar)2 EditText (android.widget.EditText)2 Spinner (android.widget.Spinner)2 TextView (android.widget.TextView)2 ParseException (java.text.ParseException)2 Test (org.junit.Test)2 PatientStateCompleted (trial.PatientStateCompleted)2 PatientStateFailed (trial.PatientStateFailed)2 PatientStateWithdrawn (trial.PatientStateWithdrawn)2 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ArrayAdapter (android.widget.ArrayAdapter)1 TableLayout (android.widget.TableLayout)1 TableRow (android.widget.TableRow)1 DisplayPatientListView (gui.views.DisplayPatientListView)1