Search in sources :

Example 1 with Patient

use of com.jexapps.bloodhub.m_Model.Patient in project BloodHub by kazijehangir.

the class PatientListDataAdapter method onBindViewHolder.

// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(PatientListDataAdapter.ViewHolder holder, int position) {
    Patient pat = (Patient) patients.get(position);
    holder.cv.setTag(keys.get(position));
    holder.mName.setText(pat.name);
    holder.mAge.setText(pat.age);
    holder.mBloodgroup.setText(pat.blood_group);
    holder.mCnumber.setText(pat.cnumber);
    holder.mDiagnosis.setText(pat.diagnosis);
    holder.mLastRequest.setText(pat.LastRequest);
    // if (request.date.equals("URGENT")) {
    // holder.mWhen.setTextColor(0xFFFF0000);
    // }
    holder.mImage.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.girl));
}
Also used : Patient(com.jexapps.bloodhub.m_Model.Patient)

Example 2 with Patient

use of com.jexapps.bloodhub.m_Model.Patient in project BloodHub by kazijehangir.

the class AddPatientActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    mAuth = FirebaseAuth.getInstance();
    user = mAuth.getCurrentUser();
    mEmail = user.getEmail();
    // INITIALIZE FIREBASE DB
    db = FirebaseDatabase.getInstance().getReference().child("patients");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_patient);
    setTitle("Add Patient");
    name = (AutoCompleteTextView) findViewById(R.id.name);
    age = (EditText) findViewById(R.id.age);
    bloodgroup = (Spinner) findViewById(R.id.spin);
    number = (EditText) findViewById(R.id.contact_num);
    diagnosis = (Spinner) findViewById(R.id.diagnosis);
    Button submit = (Button) findViewById(R.id.add_patient);
    submit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final Context context = getApplicationContext();
            pname = name.getText().toString();
            a = age.getText().toString();
            bgroup = bloodgroup.getSelectedItem().toString();
            diag = diagnosis.getSelectedItem().toString();
            num = number.getText().toString();
            Patient pat = new Patient(user.getUid(), pname, a, bgroup, num, diag);
            try {
                db.push().setValue(pat);
                dialog = new Dialog(AddPatientActivity.this);
                dialog.setTitle("Add Patient");
                dialog.setContentView(R.layout.popup_patient);
                dialog.show();
                dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                final Button submit = (Button) dialog.findViewById(R.id.button_ok);
                submit.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        Intent intent = new Intent(AddPatientActivity.this, MainActivityOrg.class);
                        startActivity(intent);
                    }
                });
            } catch (DatabaseException e) {
                Toast.makeText(context, "Error occurred", Toast.LENGTH_SHORT).show();
            }
        }
    });
}
Also used : Context(android.content.Context) ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) Dialog(android.app.Dialog) Patient(com.jexapps.bloodhub.m_Model.Patient) Intent(android.content.Intent) AutoCompleteTextView(android.widget.AutoCompleteTextView) View(android.view.View) DatabaseException(com.google.firebase.database.DatabaseException)

Example 3 with Patient

use of com.jexapps.bloodhub.m_Model.Patient in project BloodHub by kazijehangir.

the class AddRequestOrgActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    mAuth = FirebaseAuth.getInstance();
    user = mAuth.getCurrentUser();
    mEmail = user.getEmail();
    // INITIALIZE FIREBASE DB
    db = FirebaseDatabase.getInstance().getReference().child("bloodrequests");
    mStorageRef = FirebaseStorage.getInstance().getReference().child("bloodrequests");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_request_org);
    setTitle("Add Request for Patient");
    location = (AutoCompleteTextView) findViewById(R.id.loc);
    when = (EditText) findViewById(R.id.editText);
    transport_group = (RadioGroup) findViewById(R.id.transport);
    quantity = (Spinner) findViewById(R.id.spin1);
    String[] hospitals = getResources().getStringArray(R.array.organizations_array);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, hospitals);
    location.setAdapter(adapter);
    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            patient = null;
        } else {
            patient = extras.getString("patient");
        }
    }
    final EditText set = (EditText) findViewById(R.id.editText);
    set.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dialog = new Dialog(AddRequestOrgActivity.this);
            dialog.setTitle("Set Date and Time");
            dialog.setContentView(R.layout.set_date);
            dialog.show();
            final Button setDate = (Button) dialog.findViewById(R.id.set_date);
            final DatePicker datePicker = (DatePicker) dialog.findViewById(R.id.datePicker);
            datePicker.setMinDate(System.currentTimeMillis() - 1000);
            setDate.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    date = datePicker.getDayOfMonth();
                    month = datePicker.getMonth();
                    year = datePicker.getYear();
                    Calendar calendar = Calendar.getInstance();
                    calendar.set(year, month, date);
                    pdate = calendar.getTime();
                    String date = DateFormat.getDateInstance().format(pdate);
                    set.setText(date);
                    dialog.cancel();
                }
            });
        }
    });
    // name = null;
    // age = null;
    // needs = null;
    // when = null;
    // diagnosis = null;
    // gender = null;
    // mEmail = null;
    // } else {
    // //
    // name = extras.getString("name");
    // age = extras.getString("age");
    // needs = extras.getString("bgroup");
    // when = extras.getString("lastRequest");
    // diagnosis = extras.getString("diagnosis");
    // gender = extras.getString("gender");
    // mEmail = extras.getString("mEmail");
    // Toast.makeText(this,gender,Toast.LENGTH_SHORT).show();
    // }
    // } else {
    // //            Toast.makeText(this, "getting strings from savedInstance",
    // //                    Toast.LENGTH_SHORT).show();
    // name = (String) savedInstanceState.getSerializable("name");
    // age = (String) savedInstanceState.getSerializable("age");
    // needs = (String) savedInstanceState.getSerializable("bgroup");
    // when = (String) savedInstanceState.getSerializable("lastRequest");
    // diagnosis = (String) savedInstanceState.getSerializable("diagnosis");
    // gender = (String) savedInstanceState.getSerializable("gender");
    // mEmail = (String) savedInstanceState.getSerializable("mEmail");
    // 
    // }
    // 
    // //        TextView mName = (TextView) findViewById(R.id.name);
    // //        mName.setText("Name: "+name);
    // //        TextView mAge = (TextView) findViewById(R.id.age);
    // //        mName.setText("Age: "+age);
    // //        TextView mWhen = (TextView) findViewById(R.id.blood_g);
    // //        mWhen.setText("Blood Group: "+needs);
    // //        TextView mDiagnosis = (TextView) findViewById(R.id.con_num);
    // //        mDiagnosis.setText("Diagnosis: "+diagnosis);
    // //        TextView mTransport = (TextView) findViewById(R.id.last);
    // mTransport.setText("Last Request: "+when);
    // ImageView image = (ImageView) findViewById(R.id.image1);
    // if (gender.equals("Female")){
    // image.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.girl));
    // }
    // else {
    // image.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.boy));
    // }
    // db = FirebaseDatabase.getInstance().getReference().child("patient details");
    FirebaseDatabase.getInstance().getReference().child("patients").child(patient).addListenerForSingleValueEvent(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Patient data = dataSnapshot.getValue(Patient.class);
            TextView mName = (TextView) findViewById(R.id.user_profile_name);
            mName.setText(data.name);
            pname = data.name;
            TextView mAge = (TextView) findViewById(R.id.user_profile_age);
            mAge.setText("Age: " + data.age);
            TextView mCnumber = (TextView) findViewById(R.id.user_profile_number);
            mCnumber.setText("Contact Number: " + data.cnumber);
            num = data.cnumber;
            TextView mBloodgroup = (TextView) findViewById(R.id.user_profile_bgroup);
            mBloodgroup.setText("Blood Group: " + data.blood_group);
            bgroup = data.blood_group;
            TextView mDiagnosis = (TextView) findViewById(R.id.user_profile_Diagnosis);
            mDiagnosis.setText("Diagnosis: " + data.diagnosis);
            diag = data.diagnosis;
        // Spinner mNeeds = (Spinner) findViewById(R.id.spin1);
        // mNeeds.getSelectedItem().toString();
        // 
        // TextView mLocation = (TextView) findViewById(R.id.request_detail_location);
        // mLocation.setText(data.location);
        // TextView mWhen = (TextView) findViewById(R.id.request_detail_when);
        // String date = DateFormat.getDateInstance().format(new Date(data.date));
        // mWhen.setText(date);
        // if (date.equals(DateFormat.getDateInstance().format(new Date()))) {
        // mWhen.setText("URGENT");
        // mWhen.setTextColor(0xFFFF0000);
        // }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
    Button add = (Button) findViewById(R.id.add_button);
    add.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            loc = location.getText().toString();
            transport_btn = (RadioButton) findViewById(transport_group.getCheckedRadioButtonId());
            quan = quantity.getSelectedItem().toString();
            String transport_text = (String) transport_btn.getText();
            if (transport_text.equals("Available")) {
                transport = true;
            } else if (transport_text.equals("Not Available")) {
                transport = false;
            }
            final Context context = getApplicationContext();
            new_request = db.push();
            String address = loc + ", Lahore, Pakistan";
            new GetCoordinates().execute(address.replace(" ", "+"));
            // BloodRequest request = new BloodRequest(user.getUid(), pname, bgroup, quan, num, loc, lat, lng, diag, pdate.getTime(), transport);
            // new_request.setValue(request);
            dialog = new Dialog(AddRequestOrgActivity.this);
            dialog.setTitle("Add Request");
            dialog.setContentView(R.layout.popup_submit);
            dialog.show();
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            final Button add_request = (Button) dialog.findViewById(R.id.button_ok);
            add_request.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(AddRequestOrgActivity.this, MainActivityOrg.class);
                    intent.putExtra("mEmail", mEmail);
                    startActivity(intent);
                }
            });
        }
    });
}
Also used : EditText(android.widget.EditText) Context(android.content.Context) Bundle(android.os.Bundle) Calendar(java.util.Calendar) Patient(com.jexapps.bloodhub.m_Model.Patient) Intent(android.content.Intent) RadioButton(android.widget.RadioButton) DataSnapshot(com.google.firebase.database.DataSnapshot) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) DatabaseError(com.google.firebase.database.DatabaseError) ColorDrawable(android.graphics.drawable.ColorDrawable) RadioButton(android.widget.RadioButton) Button(android.widget.Button) Dialog(android.app.Dialog) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) DatePicker(android.widget.DatePicker) ValueEventListener(com.google.firebase.database.ValueEventListener) ArrayAdapter(android.widget.ArrayAdapter)

Example 4 with Patient

use of com.jexapps.bloodhub.m_Model.Patient in project BloodHub by kazijehangir.

the class OrgPatientListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_org_patient_list, container, false);
    db = FirebaseDatabase.getInstance().getReference().child("patients");
    patients = new ArrayList<Patient>();
    keys = new ArrayList<String>();
    fetchData();
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.org_patient_list_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new RecycleMarginDecoration(getActivity()));
    mAdapter = new PatientListDataAdapter(patients, keys, getContext());
    mRecyclerView.setAdapter(mAdapter);
    return rootView;
}
Also used : Patient(com.jexapps.bloodhub.m_Model.Patient) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) PatientListDataAdapter(com.jexapps.bloodhub.m_UI.PatientListDataAdapter)

Aggregations

Patient (com.jexapps.bloodhub.m_Model.Patient)4 View (android.view.View)3 Dialog (android.app.Dialog)2 Context (android.content.Context)2 Intent (android.content.Intent)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 AutoCompleteTextView (android.widget.AutoCompleteTextView)2 Button (android.widget.Button)2 Bundle (android.os.Bundle)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ArrayAdapter (android.widget.ArrayAdapter)1 DatePicker (android.widget.DatePicker)1 EditText (android.widget.EditText)1 RadioButton (android.widget.RadioButton)1 TextView (android.widget.TextView)1 DataSnapshot (com.google.firebase.database.DataSnapshot)1 DatabaseError (com.google.firebase.database.DatabaseError)1 DatabaseException (com.google.firebase.database.DatabaseException)1