Skip to content

Commit

Permalink
add more patient info
Browse files Browse the repository at this point in the history
  • Loading branch information
YassineBOUJNAH committed Jun 4, 2020
1 parent 1503b96 commit 955f89b
Show file tree
Hide file tree
Showing 9 changed files with 281 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<activity android:name=".TestActivity" />
<activity android:name=".AppointementActivity" />
<activity android:name=".FicheInfo" />
<activity android:name=".PatientInfoActivity" />
<activity android:name=".DossierMedical" />
<activity android:name=".ChatActivity" />
<activity android:name=".PatientRequestPage" />
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/ensias/healthcareapp/Common/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ public class Common {
public static String CurrentPhone = "062912361255";
public static SimpleDateFormat simpleFormat = new SimpleDateFormat("dd_MM_yyyy");

public static int convertBloodToInt(String s){
switch (s){
case "A+":
return 0;
case "A-":
return 1;
case "B+":
return 2;
case "B-":
return 3;
case "AB+":
return 4;
case "AB-":
return 5;
case "O+":
return 6;
case "O-":
return 7;
default:
return 0;
}
}
public static String convertTimeSlotToString(int slot) {
switch(slot) {
case 0:
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/ensias/healthcareapp/DossierMedical.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.ensias.healthcareapp.Common.Common;
Expand All @@ -20,6 +21,7 @@ public class DossierMedical extends AppCompatActivity {
private final static String TAG = "DossierMedical";
private FloatingActionButton createNewFicheButton;
private String patient_email;
private Button infobtn;


@Override
Expand All @@ -42,6 +44,13 @@ public void onClick(View view) {
if(Common.CurrentUserType.equals("patient")){
createNewFicheButton.setVisibility(View.GONE);
}
infobtn= findViewById(R.id.infobtn);
infobtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openPatientInfo();
}
});


}
Expand Down Expand Up @@ -105,4 +114,13 @@ private void openPatientFiche(){
startActivity(intent);
}

private void openPatientInfo(){
Intent intent = new Intent(this, PatientInfoActivity.class);
String patient_name = getIntent().getStringExtra("patient_name");
String patient_email = getIntent().getStringExtra("patient_email");
intent.putExtra("patient_email", patient_email);
intent.putExtra("patient_name", patient_name);
startActivity(intent);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.ensias.healthcareapp;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

import androidx.appcompat.app.AppCompatActivity;

import com.ensias.healthcareapp.Common.Common;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;

import java.util.HashMap;

import static com.ensias.healthcareapp.Common.Common.convertBloodToInt;

public class PatientInfoActivity extends AppCompatActivity {

EditText heightBtn;
EditText weightBtn;
Spinner bloodtypeSpinner;
Button updateBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patient_info);
updateBtn = findViewById(R.id.updateInfoBtn);
heightBtn = findViewById(R.id.heightBtn);
weightBtn = findViewById(R.id.weightBtn);
final Spinner specialiteList = (Spinner) findViewById(R.id.bloodType);
ArrayAdapter<CharSequence> adapterSpecialiteList = ArrayAdapter.createFromResource(this,
R.array.blood_spinner, android.R.layout.simple_spinner_item);
adapterSpecialiteList.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
specialiteList.setAdapter(adapterSpecialiteList);

String patient_name = getIntent().getStringExtra("patient_name");
String patient_email = getIntent().getStringExtra("patient_email");

FirebaseFirestore.getInstance().collection("Patient").document(patient_email).collection("moreInfo")
.document(patient_email).get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
weightBtn.setText( ""+documentSnapshot.getString("weight"));
heightBtn.setText( ""+documentSnapshot.getString("height"));
specialiteList.setSelection(convertBloodToInt(documentSnapshot.getString("bloodType")));
}
});

updateBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HashMap<String,Object> map = new HashMap<>();
map.put("height",""+heightBtn.getText());
map.put("weight",""+weightBtn.getText());
map.put("bloodType",""+specialiteList.getSelectedItem().toString());
Log.e("tag", "onClick: "+specialiteList.getTag() );
FirebaseFirestore.getInstance().collection("Patient").document(patient_email).collection("moreInfo")
.document(patient_email).set(map);

}
});
if(Common.CurrentUserType.equals("patient")){
updateBtn.setVisibility(View.GONE);
heightBtn.setEnabled(false);
weightBtn.setEnabled(false);
specialiteList.setEnabled(false);
}
}

}
Binary file added app/src/main/res/drawable-xxxhdpi/healthy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 26 additions & 9 deletions app/src/main/res/layout/activity_dossier_medical.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
android:layout_below="@id/patient_name"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginStart="228dp"
android:layout_marginLeft="228dp"
android:layout_marginTop="0dp"
android:inputType="number"
android:layout_marginStart="169dp"
android:layout_marginLeft="169dp"
android:layout_marginTop="12dp"
android:hint="Height"
android:textColorHint="#b8b8b8"
android:inputType="number"
android:textColor="#000000"
android:textColorHint="#b8b8b8"
android:textSize="14sp" />

<EditText
Expand All @@ -80,12 +80,12 @@
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginStart="228dp"
android:layout_marginLeft="228dp"
android:inputType="number"
android:layout_marginStart="165dp"
android:layout_marginLeft="165dp"
android:hint="Weight"
android:textColorHint="#b8b8b8"
android:inputType="number"
android:textColor="#000000"
android:textColorHint="#b8b8b8"
android:textSize="14sp" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
Expand All @@ -103,6 +103,23 @@
app:backgroundTint="@color/colorPrimaryDark"
app:srcCompat="@android:drawable/ic_menu_edit" />

<Button
android:id="@+id/infobtn"
android:text="Info"
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|end"
android:layout_marginStart="14dp"
android:layout_marginLeft="14dp"
android:layout_marginTop="13dp"
android:layout_marginEnd="91dp"
android:layout_marginRight="91dp"
android:clickable="true"
android:scaleType="center"
app:backgroundTint="@color/colorAccent" />


</RelativeLayout>
<RelativeLayout
Expand Down
121 changes: 121 additions & 0 deletions app/src/main/res/layout/activity_patient_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http:https://schemas.android.com/apk/res/android"
xmlns:app="http:https://schemas.android.com/apk/res-auto"
xmlns:tools="http:https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#22BEA9"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/courgette"
android:text="physical Information"
android:textColor="#FFFFFF"
android:textSize="30dp" />
</LinearLayout>
<EditText
android:id="@+id/heightBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Height"
android:inputType="number"
android:text=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.419"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.149" />

<Spinner
android:id="@+id/bloodType"
android:layout_width="299dp"
android:layout_height="46dp"
android:layout_margin="20dp"
android:background="#ffffff"
android:paddingLeft="20dp"
android:spinnerMode="dropdown"
android:textColor="#000000"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/weightBtn"
app:layout_constraintVertical_bias="0.237" />

<EditText
android:id="@+id/weightBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Weight"
android:inputType="number"
android:text=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.419"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/heightBtn"
app:layout_constraintVertical_bias="0.115" />

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:layout_marginRight="40dp"
android:text="kg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.433"
app:layout_constraintStart_toEndOf="@+id/weightBtn"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.323" />

<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:text="m"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.302"
app:layout_constraintStart_toEndOf="@+id/heightBtn"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.168" />

<Button
android:id="@+id/updateInfoBtn"
android:layout_width="310dp"
android:layout_height="42dp"
android:text="update info"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bloodType"
app:layout_constraintVertical_bias="0.244" />

<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="Blood Type"
app:layout_constraintBottom_toTopOf="@+id/bloodType"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/weightBtn" />

</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_profile_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http:https://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">

</androidx.constraintlayout.widget.ConstraintLayout>
11 changes: 11 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@
<item>Rhumatologue</item>
</string-array>

<string-array name="blood_spinner">
<item>A+</item>
<item>A-</item>
<item>B+</item>
<item>B-</item>
<item>AB+</item>
<item>AB-</item>
<item>O+</item>
<item>O-</item>
</string-array>


<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
Expand Down

0 comments on commit 955f89b

Please sign in to comment.