use of com.hci.carebase.domain.Patient in project Carebase by robertsimoes.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* Set Toolbar
*/
Toolbar myToolbar = (Toolbar) findViewById(R.id.general_fragments_toolbar);
setSupportActionBar(myToolbar);
ILocalCache cache = new LocalCacheDb(this);
String userId = cache.getUserId();
boolean isFirstInstall = cache.isFirstInstall();
if (isFirstInstall) {
cache.setFirstInstall(false);
startActivity(new Intent(this, IntroActivity.class));
}
/* Get Patient Info */
src.getPatient(userId, new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Toast.makeText(MainActivity.this, "Welcome Back!", Toast.LENGTH_SHORT).show();
Log.d("TAG", "SUCCESS \n\n\n\n ------");
Patient p = dataSnapshot.getValue(Patient.class);
fragmentArgs = new Bundle();
fragmentArgs.putSerializable(Const.BUNDLE_KEY_PATIENT, p);
BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.main_bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch(item.getItemId()) {
case R.id.action_inbox:
invalidateOptionsMenu();
selectedFragment = InboxFragment.newInstance(fragmentArgs);
currentFragment = Frag.INBOX;
break;
case R.id.action_appointments:
invalidateOptionsMenu();
AppointmentsFragment f = AppointmentsFragment.newInstance(fragmentArgs);
f.setCallback(MainActivity.this);
selectedFragment = f;
currentFragment = Frag.APPOINTMENTS;
break;
case R.id.action_rx:
invalidateOptionsMenu();
selectedFragment = RxFragment.newInstance(fragmentArgs);
currentFragment = Frag.RX;
break;
case R.id.action_profile:
invalidateOptionsMenu();
selectedFragment = ProfileFragment.newInstance(fragmentArgs);
currentFragment = Frag.PROFILE_EDIT;
break;
}
refreshFragmentUI(selectedFragment);
return true;
}
});
// Before the application or user has picked anything to display
// Let's just display the inbox fragment by default so that when the app loads up
// we pick that.
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.e("ERR", "Could not load patient snapshot" + databaseError.getDetails());
}
});
}
use of com.hci.carebase.domain.Patient in project Carebase by robertsimoes.
the class DebugFragment method onPatientCreate.
@OnClick(R.id.debug_but_patient_create)
public void onPatientCreate(View v) {
final Patient p = Faker.fakePatient();
Log.d("Patient", p.toString());
String fakeUser = UUID.randomUUID().toString();
provider.createPatient(p, fakeUser, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
String result = "Create Patient " + p.getFirstName() + " " + p.getLastName();
results.setText(result);
}
});
}
use of com.hci.carebase.domain.Patient in project Carebase by robertsimoes.
the class Faker method fakePatient.
public static Patient fakePatient() {
int num = (int) Math.floor(Math.random() * 2);
Patient p = patients[num];
p.getSummaries().add(summaries[num]);
// p.getHealthInfo().getMedicalConditions() = conditions[num];
p.getScripts().add(scripts[num]);
return p;
}
use of com.hci.carebase.domain.Patient 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();
}
}
use of com.hci.carebase.domain.Patient in project Carebase by robertsimoes.
the class DebugFragment method onPatientGet.
@OnClick(R.id.debug_but_patient_get)
public void onPatientGet(View v) {
String id = patientGet.getText().toString();
// String id = "-L8bwHp6Kr6GoU1DvU4Z";
provider.getPatient(id, new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Patient p = dataSnapshot.getValue(Patient.class);
if (p != null) {
Log.d("Fetched: ", p.toString());
results.setText("Fetched! " + p.toString());
} else {
Log.d("Fetched: ", "No user");
results.setText("No user");
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
Aggregations