Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import deakin.gopher.guardian.model.Patient

class PatientListAdapter(
private var patients: List<Patient>,
private val showReassignAction: Boolean = false,
private val showAssignNurseAction: Boolean = true,
private val showEditAction: Boolean = true,
private val showDeleteAction: Boolean = false,
private val onPatientClick: ((Patient) -> Unit)? = null,
private val onReassignClick: ((Patient) -> Unit)? = null,
private val onAssignNurseClick: ((Patient) -> Unit)? = null,
private val onEditClick: ((Patient) -> Unit)? = null,
private val onDeleteClick: ((Patient) -> Unit)? = null,
Expand Down Expand Up @@ -62,14 +67,35 @@ class PatientListAdapter(
onPatientClick?.invoke(patient)
}

val hasAssignAction =
(showReassignAction && onReassignClick != null) ||
(showAssignNurseAction && onAssignNurseClick != null)
val hasEditAction = showEditAction && onEditClick != null
val hasDeleteAction = showDeleteAction && onDeleteClick != null
val hasManagementActions = hasAssignAction || hasEditAction || hasDeleteAction
holder.moreIcon.visibility = if (hasManagementActions) View.VISIBLE else View.GONE

holder.moreIcon.setOnClickListener {
if (!hasManagementActions) {
return@setOnClickListener
}
val popupMenu = PopupMenu(holder.itemView.context, it)
popupMenu.inflate(R.menu.menu_patient_item)
popupMenu.menu.findItem(R.id.assign_nurse)?.isVisible =
hasAssignAction
popupMenu.menu.findItem(R.id.action_edit_patient)?.isVisible =
hasEditAction
popupMenu.menu.findItem(R.id.action_delete)?.isVisible =
hasDeleteAction

popupMenu.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.assign_nurse -> {
onAssignNurseClick?.invoke(patient)
if (onReassignClick != null) {
onReassignClick.invoke(patient)
} else {
onAssignNurseClick?.invoke(patient)
}
true
}
R.id.action_edit_patient -> {
Expand All @@ -85,7 +111,9 @@ class PatientListAdapter(
}
}

popupMenu.show()
if (popupMenu.menu.hasVisibleItems()) {
popupMenu.show()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,24 @@ class TaskListAdapter(private var tasks: MutableList<Task>) :
init {
viewTaskDetailsButton.setOnClickListener {
val context = itemView.context
val task = tasks[adapterPosition]
val intent = Intent(context, TaskDetailActivity::class.java)
intent.putExtra("taskId", task.taskId)
context.startActivity(intent)
val position = adapterPosition
if (position != RecyclerView.NO_POSITION) {
val task = tasks[position]
val intent = Intent(context, TaskDetailActivity::class.java)
intent.putExtra("taskId", task.taskId)
context.startActivity(intent)
}
}
}

fun bind(task: Task) {
descriptionTextView.text = task.description
if (task.completed) {
taskCompletedIcon.setImageResource(R.drawable.green_circle)
taskCompletedIcon.setImageResource(R.drawable.ic_checked_item)
descriptionTextView.setTextColor(itemView.context.getColor(R.color.default_text))
} else {
taskCompletedIcon.setImageResource(R.drawable.red_circle)
taskCompletedIcon.setImageResource(R.drawable.ic_circle_outline)
descriptionTextView.setTextColor(itemView.context.getColor(R.color.black))
}
}
}
Expand Down
49 changes: 44 additions & 5 deletions app/src/main/java/deakin/gopher/guardian/model/Patient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import java.time.ZoneId
data class Patient(
@SerializedName("_id") val id: String,
@SerializedName("fullname") val fullname: String,
@SerializedName("photoUrl") val photoUrl: String,
@SerializedName("dateOfBirth") val dateOfBirth: String,
@SerializedName("photoUrl") val photoUrl: String? = null,
@SerializedName("dateOfBirth") val dateOfBirth: String? = null,
@SerializedName("age") val _age: Int,
@SerializedName("gender") val gender: String,
@SerializedName("healthConditions") val healthConditions: List<String>,
@SerializedName("caretaker") val caretaker: User,
@SerializedName("assignedNurses") val assignedNurses: List<User>,
@SerializedName("healthConditions") val healthConditions: List<String> = emptyList(),
@SerializedName("caretaker") val caretaker: User? = null,
@SerializedName("assignedNurses") val assignedNurses: List<User> = emptyList(),
@SerializedName("assignedDoctor") val assignedDoctor: User? = null,
) : Serializable {
val age: Int
get() {
Expand Down Expand Up @@ -65,6 +66,44 @@ data class AddPatientActivityResponse(
@SerializedName("activity") val activity: PatientActivity,
) : BaseModel()

data class AdminPatientListResponse(
@SerializedName("patients") val patients: List<Patient> = emptyList(),
)

data class PatientOverviewResponse(
@SerializedName("patient") val patient: Patient? = null,
)

data class StaffListResponse(
@SerializedName("staff") val staff: List<StaffMember> = emptyList(),
)

data class StaffMember(
@SerializedName(value = "_id", alternate = ["id"]) val id: String,
@SerializedName("fullname") val fullname: String,
@SerializedName("email") val email: String,
@SerializedName("photoUrl") val photoUrl: String? = null,
@SerializedName("role") val role: StaffRole? = null,
) {
fun displayLabel(): String {
return if (email.isBlank()) {
fullname
} else {
"$fullname ($email)"
}
}
}

data class StaffRole(
@SerializedName("name") val name: String? = null,
)

data class ReassignPatientRequest(
@SerializedName("caretakerId") val caretakerId: String,
@SerializedName("nurseId") val nurseId: String,
@SerializedName("doctorId") val doctorId: String,
)

data class UpdatePatientRequest(
@SerializedName("fullName") val fullName: String,
@SerializedName("dateOfBirth") val dateOfBirth: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ class EmailPasswordAuthService(
try {
SessionManager.logoutUser()
FirebaseAuth.getInstance().signOut()
context.startActivity(Intent(context, LoginActivity::class.java))
context.startActivity(
Intent(context, LoginActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
},
)
} catch (e: Exception) {
e.printStackTrace()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package deakin.gopher.guardian.services.api

import com.google.gson.JsonElement
import deakin.gopher.guardian.model.AddPatientActivityResponse
import deakin.gopher.guardian.model.AddPatientResponse
import deakin.gopher.guardian.model.AdminPatientListResponse
import deakin.gopher.guardian.model.AssignNurseRequest
import deakin.gopher.guardian.model.BaseModel
import deakin.gopher.guardian.model.CreatePatientLogRequest
import deakin.gopher.guardian.model.Patient
import deakin.gopher.guardian.model.PatientActivity
import deakin.gopher.guardian.model.PatientLog
import deakin.gopher.guardian.model.PatientOverviewResponse
import deakin.gopher.guardian.model.ReassignPatientRequest
import deakin.gopher.guardian.model.UpdatePatientRequest
import deakin.gopher.guardian.model.register.AuthResponse
import deakin.gopher.guardian.model.register.NurseListResponse
Expand Down Expand Up @@ -66,6 +70,13 @@ interface ApiService {
@Header("Authorization") token: String,
): Response<List<Patient>>

@GET("admin/patients")
suspend fun getAdminPatients(
@Header("Authorization") token: String,
@Query("page") page: Int = 1,
@Query("limit") limit: Int = 100,
): Response<AdminPatientListResponse>

@Multipart
@POST("patients/add")
suspend fun addPatient(
Expand Down Expand Up @@ -124,6 +135,35 @@ interface ApiService {
@Query("patientId") patientId: String,
): Response<List<PatientActivity>>

@GET("admin/patients/{id}/overview")
suspend fun getPatientOverview(
@Header("Authorization") token: String,
@Path("id") patientId: String,
@Query("orgId") organizationId: String? = null,
): Response<PatientOverviewResponse>

@GET("caretaker")
suspend fun getCaretakers(
@Header("Authorization") token: String,
): Response<JsonElement>

@GET("nurse/all")
suspend fun getNurses(
@Header("Authorization") token: String,
): Response<JsonElement>

@GET("doctors")
suspend fun getDoctors(
@Header("Authorization") token: String,
): Response<JsonElement>

@PUT("admin/patients/{id}/reassign")
suspend fun reassignPatient(
@Header("Authorization") token: String,
@Path("id") patientId: String,
@Body request: ReassignPatientRequest,
): Response<BaseModel>

@DELETE("patients/{id}")
suspend fun deletePatient(
@Header("Authorization") token: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import androidx.drawerlayout.widget.DrawerLayout
import com.google.android.material.navigation.NavigationView
import deakin.gopher.guardian.R
import deakin.gopher.guardian.view.general.BaseActivity
import deakin.gopher.guardian.view.general.DrawerNavigationHelper
import deakin.gopher.guardian.view.general.Homepage4caretaker

class CaretakerProfileActivity : BaseActivity() {
private lateinit var backButton: Button
private lateinit var editButton: ImageView
private lateinit var menuButton: ImageView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_caretakerprofile)

backButton = findViewById(R.id.backBtn)
editButton = findViewById(R.id.editButton)
menuButton = findViewById(R.id.menuButton)
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
val navigationView: NavigationView = findViewById(R.id.nav_view)

DrawerNavigationHelper.bindStandardDrawer(this, drawerLayout, navigationView, menuButton)

backButton.setOnClickListener {
val medicalDiagnosticsActivityIntent =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ package deakin.gopher.guardian.view.caretaker
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.Toast
import androidx.drawerlayout.widget.DrawerLayout
import com.google.android.material.navigation.NavigationView
import deakin.gopher.guardian.R
import deakin.gopher.guardian.view.general.BaseActivity
import deakin.gopher.guardian.view.general.DrawerNavigationHelper

class EditCaretakerProfileActivity : BaseActivity() {
private lateinit var saveButton: Button
private lateinit var menuButton: ImageView
val emojiCodePoint = 0x1F97A
val emojiString = String(Character.toChars(emojiCodePoint))

Expand All @@ -17,6 +22,11 @@ class EditCaretakerProfileActivity : BaseActivity() {
setContentView(R.layout.activity_edit_caretakerprofile)

saveButton = findViewById(R.id.btnSave)
menuButton = findViewById(R.id.menuButton)
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
val navigationView: NavigationView = findViewById(R.id.nav_view)

DrawerNavigationHelper.bindStandardDrawer(this, drawerLayout, navigationView, menuButton)

saveButton.setOnClickListener {
Toast.makeText(this, "Why Firebase not working? $emojiString", Toast.LENGTH_LONG).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import com.google.android.material.navigation.NavigationView
import deakin.gopher.guardian.R
import deakin.gopher.guardian.services.EmailPasswordAuthService
import deakin.gopher.guardian.view.general.BaseActivity
import deakin.gopher.guardian.view.general.Homepage4admin
import deakin.gopher.guardian.view.general.DrawerNavigationHelper
import deakin.gopher.guardian.view.general.Homepage4caretaker

class CallAmbulanceActivity : BaseActivity() {
var hospitalSpinner: Spinner? = null
Expand All @@ -34,29 +34,7 @@ class CallAmbulanceActivity : BaseActivity() {
button.setOnClickListener {
drawerLayout.openDrawer(GravityCompat.START)
}
}

navigationView.setNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.nav_home -> {
startActivity(Intent(this, Homepage4admin::class.java))
finish()
true
}
R.id.nav_signout -> {
androidx.appcompat.app.AlertDialog.Builder(this)
.setTitle(R.string.sign_out)
.setMessage(R.string.sign_out_confirmation_message)
.setPositiveButton(R.string.sign_out) { _, _ ->
EmailPasswordAuthService.signOut(this)
finish()
}
.setNegativeButton(R.string.stay_in, null)
.show()
true
}
else -> false
}
DrawerNavigationHelper.bindStandardDrawer(this, drawerLayout, navigationView, button)
}

hospitalSpinner = findViewById(R.id.hospitalSpinner)
Expand Down Expand Up @@ -93,7 +71,7 @@ class CallAmbulanceActivity : BaseActivity() {

fun onConfirmIncidentCancelClick(view: View?) {
val medicalDiagnosticsActivityIntent =
Intent(this@CallAmbulanceActivity, Homepage4admin::class.java)
Intent(this@CallAmbulanceActivity, Homepage4caretaker::class.java)
startActivity(medicalDiagnosticsActivityIntent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import androidx.drawerlayout.widget.DrawerLayout
import androidx.media3.common.util.UnstableApi
import com.google.android.material.navigation.NavigationView
import deakin.gopher.guardian.R
import deakin.gopher.guardian.services.EmailPasswordAuthService
import deakin.gopher.guardian.view.falldetection.FallAlertActivity
import deakin.gopher.guardian.view.general.BaseActivity
import deakin.gopher.guardian.view.general.Homepage4admin
import deakin.gopher.guardian.view.general.DrawerNavigationHelper

class ConfirmIncidentActivity : BaseActivity() {
var hospitalSpinner: Spinner? = null
Expand All @@ -37,29 +36,7 @@ class ConfirmIncidentActivity : BaseActivity() {
button.setOnClickListener {
drawerLayout.openDrawer(GravityCompat.START)
}
}

navigationView.setNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.nav_home -> {
startActivity(Intent(this, Homepage4admin::class.java))
finish()
true
}
R.id.nav_signout -> {
androidx.appcompat.app.AlertDialog.Builder(this)
.setTitle(R.string.sign_out)
.setMessage(R.string.sign_out_confirmation_message)
.setPositiveButton(R.string.sign_out) { _, _ ->
EmailPasswordAuthService.signOut(this)
finish()
}
.setNegativeButton(R.string.stay_in, null)
.show()
true
}
else -> false
}
DrawerNavigationHelper.bindStandardDrawer(this, drawerLayout, navigationView, button)
}

hospitalSpinner = findViewById(R.id.hospitalSpinner)
Expand Down
Loading
Loading