Skip to content

Commit

Permalink
added chat and minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mnb27 committed Apr 27, 2021
1 parent 9ade734 commit 2247176
Show file tree
Hide file tree
Showing 15 changed files with 384 additions and 32 deletions.
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


<application
android:allowBackup="true"
android:icon="@drawable/appicon"
android:label="@string/app_name"
android:roundIcon="@drawable/appicon"
android:supportsRtl="true"
android:theme="@style/Theme.PGIDoctor">
<activity android:name=".AddNewReportByDoctor"></activity>
<activity android:name=".AssignedDoctorsAdapter"></activity>
<activity android:name=".AssignedDoctors" />
<activity android:name=".AddNewReportByDoctor" />
<activity android:name=".ViewAllTestsActivity" />
<activity android:name=".ViewUserPatientRecordsActivity" />
<activity android:name=".PatientPortalActivity" />
Expand Down
78 changes: 78 additions & 0 deletions app/src/main/java/com/example/pgidoctor/AssignedDoctors.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.example.pgidoctor

import android.R.attr.button
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.FirebaseFirestore
import kotlinx.android.synthetic.main.activity_search_by_name.*


class AssignedDoctors : AppCompatActivity() {
lateinit var recyclerView: RecyclerView
lateinit var assignedDoctorsAdapter: AssignedDoctorsAdapter
var list: MutableList<User> = mutableListOf()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_assigned_doctors)
val fireStore = FirebaseFirestore.getInstance()
val auth = FirebaseAuth.getInstance()
val goback: ImageView = findViewById(R.id.backB)

goback.setOnClickListener {
val intent = Intent(this, PatientPortalActivity::class.java)
startActivity(intent)
}


recyclerView = findViewById(R.id.recyclerView)
assignedDoctorsAdapter = AssignedDoctorsAdapter(this,list)


recyclerView.adapter = assignedDoctorsAdapter

recyclerView.layoutManager = LinearLayoutManager(this)

var unit = ""
var hospital = ""

auth.currentUser?.uid?.let {
fireStore.collection("Users").document(it).get()
.addOnSuccessListener { it ->
if(it.exists()){
hospital = it.getString("hospital").toString()
unit = it.getString("unit").toString()

fireStore.collection("Users").whereEqualTo("type","Doctor").whereEqualTo("hospital",hospital).whereEqualTo("unit",unit).get()
.addOnSuccessListener { documents->
for(document in documents) {
list.add(document.toObject(User::class.java))
}
list.sortBy { det->det.name }
(recyclerView.adapter as AssignedDoctorsAdapter).notifyDataSetChanged()
if(list.isEmpty()) {
Toast.makeText(this,"No Doctor records",Toast.LENGTH_LONG).show()
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
}
}
.addOnFailureListener{
Toast.makeText(this,"Error",Toast.LENGTH_LONG).show()
}

}
}
}


}
}
56 changes: 56 additions & 0 deletions app/src/main/java/com/example/pgidoctor/AssignedDoctorsAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.example.pgidoctor

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.TextView
import androidx.core.content.ContextCompat.startActivity
import androidx.recyclerview.widget.RecyclerView


class AssignedDoctorsAdapter(var context: Context, var detailsList: MutableList<User>):
RecyclerView.Adapter<AssignedDoctorsAdapter.DetailsViewHolder>() {

class DetailsViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
var nameText: TextView = itemView.findViewById(R.id.nameOfTask)
var hospital: TextView = itemView.findViewById(R.id.hospital)
var unit: TextView = itemView.findViewById(R.id.unit)
var whatsapp: Button = itemView.findViewById(R.id.whatsapp)
}
override fun onBindViewHolder(holder: AssignedDoctorsAdapter.DetailsViewHolder, position: Int) {
var details = detailsList[position]
holder.nameText.text = "Name: " + details.name
holder.hospital.text = details.email
holder.unit.text = "Hospital: " + details.hospital + " , Unit: " + details.unit

var number = "+91"+details.mobile

holder.whatsapp.setOnClickListener {
val url = "https://api.whatsapp.com/send?phone=$number"
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
context.startActivity(i)
}
}

override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): AssignedDoctorsAdapter.DetailsViewHolder {
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.activity_assigned_doctors_adapter,parent,false)
return DetailsViewHolder(itemView)
}

override fun getItemCount(): Int {
return detailsList.size
}

fun setList(list: MutableList<User>){
detailsList = list
notifyDataSetChanged()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class AssignedPatients : AppCompatActivity() {

when (item!!.itemId) {
R.id.header1 -> {
list.sortBy{det -> det.name}
list.sortBy{det -> det.name.toLowerCase()}
(recyclerView.adapter as AssignedPatientsAdapter).notifyDataSetChanged()
}
R.id.header2 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.example.pgidoctor
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
Expand All @@ -27,6 +28,7 @@ class AssignedPatientsAdapter(var context: Context, var detailsList: MutableList
var hospital: TextView = itemView.findViewById(R.id.hospital)
var unit: TextView = itemView.findViewById(R.id.unit)
var viewMore: Button = itemView.findViewById(R.id.viewMore)
var whatsapp: Button = itemView.findViewById(R.id.whatsapp)
var collectdiagnosisdata: Button = itemView.findViewById(R.id.collectdiagnosisdata)
var starred: Button = itemView.findViewById(R.id.starred)
var important: Button = itemView.findViewById(R.id.important)
Expand All @@ -38,10 +40,22 @@ class AssignedPatientsAdapter(var context: Context, var detailsList: MutableList
override fun onBindViewHolder(holder: AssignedPatientsAdapter.DetailsViewHolder, position: Int) {
var details = detailsList[position]
holder.nameText.text = "Name: " + details.name
holder.date.text = "Collection Date: " + details.date

var datee = details.date
holder.date.text = "Taken On: " + datee.substring(6,8) + " / " + datee.substring(4,6) + " / " + datee.substring(0,4)
holder.hospital.text = "Hospital: " + details.hospitalText
holder.unit.text = "Unit: " + details.unitText


var number = "+91"+details.mobile

holder.whatsapp.setOnClickListener {
val url = "https://api.whatsapp.com/send?phone=$number"
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
context.startActivity(i)
}

var clickStarred = true
var clickImportant = true
var clickNearby = true
Expand Down
24 changes: 21 additions & 3 deletions app/src/main/java/com/example/pgidoctor/CollectDataActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,31 @@ class CollectDataActivity : AppCompatActivity() {
val month = c.get(Calendar.MONTH)
val day = c.get(Calendar.DAY_OF_MONTH)

var dateChoose = ""

mPickTimeBtn.setOnClickListener {
val dpd = DatePickerDialog(this, DatePickerDialog.OnDateSetListener { view, year, month, day ->
var dpd = DatePickerDialog(this, DatePickerDialog.OnDateSetListener { view, year, monthOfYear, dayOfMonth ->
// Display Selected date in TextView
date.getEditText()?.setText("" + day + " / " + (month.toInt() + 1).toString() + " / " + year)
date.editText?.setText("" + dayOfMonth + " / " + (monthOfYear.toInt()+1).toString() + " / " + year)
var daynumber = ""
var monthnumber = (monthOfYear+1).toString()
var correctMonth = monthOfYear + 1
if (correctMonth < 10) {
monthnumber = "0$correctMonth"
}
if (dayOfMonth < 10) {
daynumber = "0$dayOfMonth"
dateChoose = year.toString() + monthnumber + daynumber
}
else {dateChoose = year.toString() + monthnumber + dayOfMonth.toString()}
}, year, month, day)

val now = System.currentTimeMillis() - 1000
//dpd.datePicker.minDate = now
dpd.datePicker.maxDate = now + (1000*60*60*24*7)
dpd.show()
}

//////end

val name: TextInputLayout = findViewById(R.id.one)
Expand All @@ -161,7 +179,7 @@ class CollectDataActivity : AppCompatActivity() {
var nameText = name.editText?.text.toString()
var emailText = email.editText?.text.toString()
var fathernameText = fathername.editText?.text.toString()
var datecollectedText = datecollected.editText?.text.toString()
var datecollectedText = dateChoose
var crnoText = crno.editText?.text.toString()
var mobileText = mobile.editText?.text.toString()
var ageText = age.editText?.text.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class PatientPortalActivity : AppCompatActivity() {
editProfile.setOnClickListener {
startActivity(Intent(this, ProfileActivity::class.java))
}
Chat.setOnClickListener {
startActivity(Intent(this, AssignedDoctors::class.java))
}
if(auth.currentUser == null){
startActivity(Intent(this,LoginActivity::class.java))
finish()
Expand Down
18 changes: 16 additions & 2 deletions app/src/main/java/com/example/pgidoctor/SearchActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class SearchActivity : AppCompatActivity() {
nameT.isEnabled = true
search.setOnClickListener {
list1.clear()
var nameentered = nameT.editText?.text.toString()
var nameentered = nameT.editText?.text.toString().toLowerCase()
for(item in list){
if(item.name.startsWith(nameentered)){
if(item.name.toLowerCase().startsWith(nameentered)){
list1.add(item)
}
}
Expand Down Expand Up @@ -218,6 +218,20 @@ class SearchActivity : AppCompatActivity() {
}
(recyclerView.adapter as AssignedPatientsAdapter).notifyDataSetChanged()

//val intent = Intent(this,AssignedPatientsByDate::class.java)
//startActivity(intent)
}
R.id.header7 -> {
spinner.adapter = null

list1.clear()
for(item in list){
if(item.isnearby == "yes"){
list1.add(item)
}
}
(recyclerView.adapter as AssignedPatientsAdapter).notifyDataSetChanged()

//val intent = Intent(this,AssignedPatientsByDate::class.java)
//startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SearchByNameActivity : AppCompatActivity() {
}

val intent = Intent(this,ViewByNameActivity::class.java)
intent.putExtra("name",name.editText?.text.toString())
intent.putExtra("name",name.editText?.text.toString().toLowerCase())
startActivity(intent)
}
}
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/whatsapp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="58dp"
android:height="58dp"
android:viewportWidth="58"
android:viewportHeight="58">

<path
android:fillColor="#2CB742"
android:pathData="M0,58l4.988-14.963C2.457,38.78,1,33.812,1,28.5C1,12.76,13.76,0,29.5,0S58,12.76,58,28.5 S45.24,57,29.5,57c-4.789,0-9.299-1.187-13.26-3.273L0,58z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M47.683,37.985c-1.316-2.487-6.169-5.331-6.169-5.331c-1.098-0.626-2.423-0.696-3.049,0.42 c0,0-1.577,1.891-1.978,2.163c-1.832,1.241-3.529,1.193-5.242-0.52l-3.981-3.981l-3.981-3.981c-1.713-1.713-1.761-3.41-0.52-5.242 c0.272-0.401,2.163-1.978,2.163-1.978c1.116-0.627,1.046-1.951,0.42-3.049c0,0-2.844-4.853-5.331-6.169 c-1.058-0.56-2.357-0.364-3.203,0.482l-1.758,1.758c-5.577,5.577-2.831,11.873,2.746,17.45l5.097,5.097l5.097,5.097 c5.577,5.577,11.873,8.323,17.45,2.746l1.758-1.758C48.048,40.341,48.243,39.042,47.683,37.985z" />
</vector>
57 changes: 57 additions & 0 deletions app/src/main/res/layout/activity_assigned_doctors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
tools:context=".AssignedDoctors">

<LinearLayout
android:id="@+id/layout0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:ignore="MissingConstraints">

<ImageButton
android:id="@+id/backB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="#3192F4"
android:padding="8dp"
android:src="@drawable/ic_back"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_marginStart="80dp"
android:layout_marginTop="24dp"
android:text="DOCTOR LIST"
android:textColor="#3192F4"
android:textStyle="bold"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</LinearLayout>


<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="414dp"
android:layout_height="683dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 2247176

Please sign in to comment.