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
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.5.1'
classpath 'com.android.tools.build:gradle:8.13.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:1.9.20"
}
Expand Down
20 changes: 15 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<!-- Add WRITE permissions only if necessary -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<!-- Add the permission here -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Expand All @@ -34,9 +36,9 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="ExtraText"
tools:replace="android:allowBackup,android:label"
tools:targetApi="31"
tools:ignore="ExtraText">
tools:targetApi="31">
<activity
android:name=".WelcomeActivity"
android:exported="false" />
Expand Down Expand Up @@ -75,6 +77,9 @@
<activity
android:name=".view.general.TaskDetailActivity"
android:exported="false" />
<activity
android:name=".view.general.AssignNurseActivity"
android:exported="false" />
<activity
android:name=".view.general.TaskAddActivity"
android:exported="false" />
Expand All @@ -93,6 +98,7 @@
<activity
android:name=".view.caretaker.CaretakerProfileActivity"
android:exported="false" />
<activity android:name=".view.general.EditPatientActivity" />
<activity
android:name=".view.caretaker.EditCaretakerProfileActivity"
android:exported="false" />
Expand Down Expand Up @@ -161,7 +167,8 @@
<activity
android:name=".view.general.LoginActivity"
android:exported="false" />
<activity android:name=".view.general.PinCodeActivity"
<activity
android:name=".view.general.PinCodeActivity"
android:exported="false" />
<activity
android:name=".view.general.AddNewPatientActivity"
Expand Down Expand Up @@ -189,6 +196,9 @@
android:exported="false" />

<activity android:name=".ModulesActivity" />
<activity
android:name=".view.general.AddEditPrescriptionActivity"
android:exported="false" />


<activity android:name=".Module1CoursesActivity" />
Expand Down Expand Up @@ -228,7 +238,7 @@
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />

<activity android:name=".view.general.DashboardActivity"/>
<activity android:name=".view.general.DashboardActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class PatientListAdapter(
private var patients: List<Patient>,
private val onPatientClick: ((Patient) -> Unit)? = null,
private val onAssignNurseClick: ((Patient) -> Unit)? = null,
private val onEditClick: ((Patient) -> Unit)? = null,
private val onDeleteClick: ((Patient) -> Unit)? = null,
private val showMoreMenu: Boolean = true
) : RecyclerView.Adapter<PatientListAdapter.PatientViewHolder>() {
inner class PatientViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val nameText: TextView = itemView.findViewById(R.id.tvName)
Expand Down Expand Up @@ -61,6 +63,8 @@ class PatientListAdapter(
onPatientClick?.invoke(patient)
}

holder.moreIcon.visibility = if (showMoreMenu) View.VISIBLE else View.GONE

holder.moreIcon.setOnClickListener {
val popupMenu = PopupMenu(holder.itemView.context, it)
popupMenu.inflate(R.menu.menu_patient_item)
Expand All @@ -71,6 +75,10 @@ class PatientListAdapter(
onAssignNurseClick?.invoke(patient)
true
}
R.id.action_edit_patient -> {
onEditClick?.invoke(patient)
true
}
R.id.action_delete -> { // Handle delete click
onDeleteClick?.invoke(patient)
true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package deakin.gopher.guardian.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import deakin.gopher.guardian.databinding.ItemPrescriptionBinding
import deakin.gopher.guardian.model.Prescription
import java.util.Locale

class PrescriptionAdapter(
private var prescriptions: List<Prescription>,
private val showEditButton: Boolean,
private val onEditClick: (Prescription) -> Unit
) : RecyclerView.Adapter<PrescriptionAdapter.PrescriptionViewHolder>() {

inner class PrescriptionViewHolder(
private val binding: ItemPrescriptionBinding
) : RecyclerView.ViewHolder(binding.root) {

fun bind(prescription: Prescription) {
val firstItem = prescription.items.firstOrNull()

binding.tvPrescriptionTitle.text = firstItem?.name ?: "Prescription"

binding.tvPrescriptionItems.text = if (prescription.items.isNotEmpty()) {
prescription.items.joinToString("\n") { item ->
"• ${item.name} - ${item.dose}, ${item.frequency}, for ${item.durationDays} days"
}
} else {
"No medicine details available"
}

binding.tvPrescriptionStatus.text = "Status: ${
prescription.status?.replaceFirstChar {
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
} ?: "Unknown"
}"

binding.tvPrescriptionDate.text = "Created: ${
prescription.createdAt?.substringBefore("T") ?: "N/A"
}"

binding.btnEditPrescription.visibility = if (showEditButton) {
View.VISIBLE
} else {
View.GONE
}

binding.btnEditPrescription.setOnClickListener {
onEditClick(prescription)
}
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PrescriptionViewHolder {
val binding = ItemPrescriptionBinding.inflate(
LayoutInflater.from(parent.context), parent, false
)
return PrescriptionViewHolder(binding)
}

override fun onBindViewHolder(holder: PrescriptionViewHolder, position: Int) {
holder.bind(prescriptions[position])
}

override fun getItemCount(): Int = prescriptions.size

fun updateData(newPrescriptions: List<Prescription>) {
prescriptions = newPrescriptions
notifyDataSetChanged()
}
}
28 changes: 28 additions & 0 deletions app/src/main/java/deakin/gopher/guardian/model/Patient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ private fun calculateAge(
}
}

data class AssignNurseRequest(
@SerializedName("nurseId") val nurseId: String,
@SerializedName("patientId") val patientId: String,
)

data class AddPatientResponse(
@SerializedName("patient") val patient: Patient,
) : BaseModel()
Expand All @@ -59,3 +64,26 @@ data class PatientActivity(
data class AddPatientActivityResponse(
@SerializedName("activity") val activity: PatientActivity,
) : BaseModel()

data class UpdatePatientRequest(
@SerializedName("fullName") val fullName: String,
@SerializedName("dateOfBirth") val dateOfBirth: String,
@SerializedName("gender") val gender: String,
)

data class PatientListResponse(
@SerializedName("page")
val page: Int = 1,

@SerializedName("limit")
val limit: Int = 50,

@SerializedName("total")
val total: Int = 0,

@SerializedName("totalPages")
val totalPages: Int = 1,

@SerializedName("patients")
val patients: List<Patient> = emptyList()
)
64 changes: 64 additions & 0 deletions app/src/main/java/deakin/gopher/guardian/model/Prescription.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package deakin.gopher.guardian.model

import com.google.gson.annotations.SerializedName
import java.io.Serializable

data class PrescriptionListResponse(
@SerializedName("prescriptions") val prescriptions: List<Prescription> = emptyList()
)

data class Prescription(
@SerializedName("_id") val id: String,

@SerializedName("patient") val patientId: String? = null,

@SerializedName("prescriber") val prescriber: PrescriptionPrescriber? = null,

@SerializedName("items") val items: List<PrescriptionItem> = emptyList(),

@SerializedName("status") val status: String? = null,

@SerializedName("createdAt") val createdAt: String? = null,

@SerializedName("updatedAt") val updatedAt: String? = null
) : Serializable

data class PrescriptionPrescriber(
@SerializedName("_id") val id: String? = null,

@SerializedName("fullName") val fullName: String? = null,

@SerializedName("email") val email: String? = null
) : Serializable

data class PrescriptionItem(
@SerializedName("name") val name: String,

@SerializedName("dose") val dose: String,

@SerializedName("frequency") val frequency: String,

@SerializedName("durationDays") val durationDays: Int
) : Serializable

data class CreatePrescriptionRequest(
@SerializedName("patientId") val patientId: String,

@SerializedName("items") val items: List<PrescriptionItemRequest>
)

data class UpdatePrescriptionRequest(
@SerializedName("patientId") val patientId: String? = null,

@SerializedName("items") val items: List<PrescriptionItemRequest>
)

data class PrescriptionItemRequest(
@SerializedName("name") val name: String,

@SerializedName("dose") val dose: String,

@SerializedName("frequency") val frequency: String,

@SerializedName("durationDays") val durationDays: Int
)
49 changes: 40 additions & 9 deletions app/src/main/java/deakin/gopher/guardian/model/register/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,50 @@ import deakin.gopher.guardian.model.login.Role
import java.io.Serializable

data class User(
@SerializedName("id") val id: String,
@SerializedName("email") val email: String,
@SerializedName("fullname") val name: String,
@SerializedName("role") val roleName: String,
@SerializedName("photoUrl") val photoUrl: String,
@SerializedName(value = "id", alternate = ["_id"]) val id: String = "",

@SerializedName(value = "fullname", alternate = ["fullName"]) val name: String = "",

@SerializedName("email") val email: String = "",

@SerializedName("role") val roleName: String? = null,

@SerializedName("photoUrl") val photoUrl: String? = null,

@SerializedName("organization") val organization: String? = null,
) : Serializable {
val role: Role
get() {
return Role.create(roleName)
}
get() = Role.create(roleName ?: "")
}

data class NurseListResponse(
@SerializedName("nurses") val nurses: List<NurseListItem>,
)

data class NurseListItem(
@SerializedName("_id") val id: String,
@SerializedName("fullname") val fullName: String?,
@SerializedName("email") val email: String?,
@SerializedName("photoUrl") val photoUrl: String? = null,
@SerializedName("role") val role: NurseRole?,
) {
fun toUser(): User {
return User(
id = id,
email = email.orEmpty(),
name = fullName.orEmpty(),
roleName = role?.name.orEmpty(),
photoUrl = photoUrl.orEmpty(),
organization = null,
)
}
}

data class NurseRole(
@SerializedName("_id") val id: String,
@SerializedName("name") val name: String,
)

data class RegisterRequest(
@SerializedName("email") val email: String,
@SerializedName("password") val password: String,
Expand All @@ -29,4 +60,4 @@ data class RegisterRequest(
data class AuthResponse(
@SerializedName("user") val user: User,
@SerializedName("token") val token: String,
) : BaseModel()
) : BaseModel()
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import retrofit2.converter.gson.GsonConverterFactory

object RetrofitClient {
// private const val BASE_URL = "http://10.0.2.2:3000/api/v1/"

private const val BASE_URL = "https://guardian-backend-ashen.vercel.app/api/v1/"

// private const val BASE_URL = "https://guardian-backend-git-fix-cors-patelrudra2306-5873s-projects.vercel.app/api/v1/"

private val client = OkHttpClient()
private val interceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
private val clientBuilder = client.newBuilder().addInterceptor(interceptor)

val retrofit: Retrofit by lazy {
Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(clientBuilder.build())
.build()
Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create())
.client(clientBuilder.build()).build()
}
}

Expand Down
Loading
Loading