Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 50 additions & 3 deletions app/src/main/java/com/project/mednudge/AddEditMedicine.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.project.mednudge;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
Expand All @@ -11,34 +9,83 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.Toast;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;


public class AddEditMedicine extends Fragment implements View.OnClickListener {
Button alarm;
FragmentTransaction fragmentTransaction;
Fragment fragment;
Toolbar toolbar;
DatabaseReference mDatabase;
EditText editMedicineName;
EditText editPrescribedBy;
EditText editDose;
Spinner editUnit;
RadioGroup editInstruction;
RadioButton instruction1;
EditText editRemark;
View view;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view=inflater.inflate(R.layout.fragment_add_edit_medicine, container, false);
view=inflater.inflate(R.layout.fragment_add_edit_medicine, container, false);
alarm=(Button) view.findViewById(R.id.button);
alarm.setOnClickListener(this);
toolbar=(Toolbar)view.findViewById(R.id.toolbar);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
activity.getSupportActionBar().setTitle("Add Medicine");
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDatabase = FirebaseDatabase.getInstance().getReference("medicines");
editMedicineName=(EditText)view.findViewById(R.id.medicine_name);
editPrescribedBy=(EditText)view.findViewById(R.id.prescribed_by);
editDose=(EditText)view.findViewById(R.id.edit_dose);
editUnit=(Spinner)view.findViewById(R.id.select_unit);
editInstruction=(RadioGroup)view.findViewById(R.id.instruction);
editRemark=(EditText)view.findViewById(R.id.remark);
return view;


}
public void onClick(View v)
{
ImageView medicineImage=null;
String medicineName = editMedicineName.getText().toString().trim();
String prescribedBy = editPrescribedBy.getText().toString().trim();
String dose=editDose.getText().toString().trim()+" "+editUnit.getSelectedItem().toString();
int selectedId = editInstruction.getCheckedRadioButtonId();

// find the radiobutton by returned id
instruction1 = (RadioButton) view.findViewById(selectedId);
String instruction=(String)instruction1.getText();
String remark=editRemark.getText().toString().trim();



// Creating new user node, which returns the unique key value
// new user node would be /users/$userid/
String medicineId = mDatabase.push().getKey();

// creating user object
Medicine medicine = new Medicine(medicineId,medicineImage,medicineName,prescribedBy,dose,instruction,remark);

// pushing user to 'users' node using the userId
mDatabase.child(medicineId).setValue(medicine);
Toast.makeText(getContext(),"Medicine Added",Toast.LENGTH_SHORT);
fragmentTransaction = getFragmentManager().beginTransaction();
fragment = new Alarm();//the fragment you want to show
fragmentTransaction.replace(R.id.content_frame, fragment);//R.id.content_frame is the layout you want to replace
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/project/mednudge/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void onClick(View v) {
fragmentTransaction = getFragmentManager().beginTransaction();
fragment = new DoctorPatientSignup();//the fragment you want to show
fragmentTransaction.replace(R.id.content_frame, fragment);//R.id.content_frame is the layout you want to replace
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
});
Expand All @@ -46,11 +47,13 @@ public void onClick(View v)
case R.id.button2: fragmentTransaction = getFragmentManager().beginTransaction();
fragment = new DoctorProfile();//the fragment you want to show
fragmentTransaction.replace(R.id.content_frame, fragment);//R.id.content_frame is the layout you want to replace
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
break;
case R.id.button3: fragmentTransaction = getFragmentManager().beginTransaction();
fragment = new PatientProfile();//the fragment you want to show
fragmentTransaction.replace(R.id.content_frame, fragment);//R.id.content_frame is the layout you want to replace
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
break;
}
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/com/project/mednudge/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ protected void onCreate(Bundle savedInstanceState) {
public void onBackPressed()

{
super.onBackPressed();
int count=getFragmentManager().getBackStackEntryCount();
if (count==0) {
super.onBackPressed();
}
else
{
getFragmentManager().popBackStack();
}
}
}

59 changes: 59 additions & 0 deletions app/src/main/java/com/project/mednudge/Medicine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.project.mednudge;

import android.widget.ImageView;

/**
* Created by MEGHA on 09-11-2017.
*/

public class Medicine {
ImageView medicineImage;
String medicineId;
String medicineName;
String doctorName;
String dose;
String instruction;
String remark;
public Medicine(){

}
public Medicine(String medicineId, ImageView medicineImage, String medicineName, String doctorName, String dose, String instruction, String remark)
{
this.medicineId=medicineId;
this.medicineImage=medicineImage;
this.medicineName=medicineName;
this.doctorName=doctorName;
this.dose=dose;
this.instruction=instruction;
this.remark=remark;
}
public String getMedicineId()
{
return medicineId;
}
public ImageView getMedicineImage()
{
return medicineImage;
}
public String getMedicineName()
{
return medicineName;
}
public String getDoctorName()
{
return doctorName;
}
public String getDose()
{
return dose;
}
public String getInstruction()
{
return instruction;
}
public String getRemark()
{
return remark;
}

}
3 changes: 3 additions & 0 deletions app/src/main/java/com/project/mednudge/PatientProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void onClick(View v) {
fragmentTransaction = getFragmentManager().beginTransaction();
fragment = new History();//the fragment you want to show
fragmentTransaction.replace(R.id.content_frame, fragment);//R.id.content_frame is the layout you want to replace
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();

break;
Expand All @@ -69,13 +70,15 @@ public void onClick(View v) {
fragmentTransaction = getFragmentManager().beginTransaction();
fragment = new AddEditMedicine();//the fragment you want to show
fragmentTransaction.replace(R.id.content_frame, fragment);//R.id.content_frame is the layout you want to replace
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
break;
case R.id.fab3:

fragmentTransaction = getFragmentManager().beginTransaction();
fragment = new Prescription();//the fragment you want to show
fragmentTransaction.replace(R.id.content_frame, fragment);//R.id.content_frame is the layout you want to replace
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
break;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_add_edit_medicine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
android:layout_below="@+id/card_view"
android:layout_marginTop="40dp"
android:ems="10"
android:hint="Mediciene Name"
android:hint="Medicine Name"
android:textColor="@color/black"
android:textSize="15sp" />

Expand Down