Search in sources :

Example 1 with Appointment

use of com.hci.carebase.domain.Appointment in project Carebase by robertsimoes.

the class InboxFragment method buildAppointments.

private void buildAppointments(Patient p) {
    if (p.getAppointments() == null || p.getAppointments().isEmpty()) {
        cvUpcomingAppts.setVisibility(View.GONE);
    } else {
        int in = Commons.getMostUpcomingAppointmentIndex(p);
        Appointment a = p.getAppointments().get(in);
        SimpleDateFormat f = new SimpleDateFormat("EEE, MMM dd yyyy, HH:mm");
        String sdf = f.format(a.getDateFor());
        tvDateAppts.setText(sdf);
        String dr = a.getDoctor().getFirstName() + " " + a.getDoctor().getLastName();
        tvDateAppts.setText(dr);
    }
}
Also used : Appointment(com.hci.carebase.domain.Appointment) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with Appointment

use of com.hci.carebase.domain.Appointment in project Carebase by robertsimoes.

the class LoginRegisterActivity method onExecSignUpButtonClick.

@OnClick(R.id.vs_signup_button_exec_signup)
public void onExecSignUpButtonClick(View v) {
    PatientSource src = CollectionsProvider.patients();
    if (signup_signUpPasswordEt.getText().toString().equals(signup_signUpConfirmEt.getText().toString())) {
        progressDialog = ProgressDialog.show(this, "Please wait...", "Processing...", true);
        (fauth.createUserWithEmailAndPassword(signup_signUpEmailEt.getText().toString(), signup_signUpPasswordEt.getText().toString())).addOnCompleteListener(task -> {
            progressDialog.dismiss();
            if (task.isSuccessful()) {
                Toast.makeText(this, "Registration successful", Toast.LENGTH_LONG).show();
                String uid = fauth.getUid();
                cache.storeUserId(uid);
                Doctor d = new Doctor(signup_signUpDoctorFnameEt.getText().toString(), signup_signUpDoctorLnameEt.getText().toString());
                Appointment a = new Appointment(new Date(), "University Hospital", d, "", "");
                Calendar c = Calendar.getInstance();
                c.add(Calendar.YEAR, 1);
                Date finishDate = c.getTime();
                Patient p = new Patient(signup_patient_fname.getText().toString(), signup_patient_lname.getText().toString(), signup_signUpHCardNum.getText().toString(), d, new ArrayList<Appointment>() {

                    {
                        add(a);
                    }
                }, new ArrayList<Summary>() {

                    {
                        add(Faker.fakeSummary());
                    }
                }, new ArrayList<Prescription>() {

                    {
                        add(Faker.fakeScript());
                    }
                }, Faker.fakeInfo(), finishDate);
                src.createPatient(p, uid, task1 -> {
                    if (task1.isSuccessful()) {
                        Intent intent = new Intent(this, IntroActivity.class);
                        startActivity(intent);
                        finish();
                    } else {
                        Toast.makeText(this, task1.getException().getMessage() != null ? task1.getException().getMessage() : "Error signing up, please try again", Toast.LENGTH_LONG).show();
                    }
                });
            } else {
                Toast.makeText(this, task.getException().getMessage() != null ? task.getException().getMessage() : "Error signing up, please try again", Toast.LENGTH_LONG).show();
            }
        });
    } else {
        Toast.makeText(this, "Passwords not equal!", Toast.LENGTH_LONG).show();
        signup_signUpPasswordEt.getText().clear();
        signup_signUpConfirmEt.getText().clear();
    }
}
Also used : Appointment(com.hci.carebase.domain.Appointment) Prescription(com.hci.carebase.domain.Prescription) Calendar(java.util.Calendar) Patient(com.hci.carebase.domain.Patient) Intent(android.content.Intent) PatientSource(com.hci.carebase.data.interfaces.PatientSource) Doctor(com.hci.carebase.domain.Doctor) Date(java.util.Date) Summary(com.hci.carebase.domain.Summary) OnClick(butterknife.OnClick)

Example 3 with Appointment

use of com.hci.carebase.domain.Appointment in project Carebase by robertsimoes.

the class Commons method getMostUpcomingAppointmentIndex.

public static int getMostUpcomingAppointmentIndex(Patient p) {
    ArrayList<Appointment> appointments = p.getAppointments();
    Date smallest = appointments.get(0).getDateFor();
    int index = 0;
    for (int i = 0; i < appointments.size(); i++) {
        if (appointments.get(i).getDateFor().before(smallest)) {
            index = i;
            smallest = appointments.get(i).getDateFor();
        }
    }
    return index;
}
Also used : Appointment(com.hci.carebase.domain.Appointment) Date(java.util.Date)

Aggregations

Appointment (com.hci.carebase.domain.Appointment)3 Date (java.util.Date)2 Intent (android.content.Intent)1 OnClick (butterknife.OnClick)1 PatientSource (com.hci.carebase.data.interfaces.PatientSource)1 Doctor (com.hci.carebase.domain.Doctor)1 Patient (com.hci.carebase.domain.Patient)1 Prescription (com.hci.carebase.domain.Prescription)1 Summary (com.hci.carebase.domain.Summary)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1