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
17 changes: 12 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 @@ -72,6 +74,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 @@ -90,6 +95,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 @@ -158,7 +164,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 @@ -225,7 +232,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,6 +16,7 @@ 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,
) : RecyclerView.Adapter<PatientListAdapter.PatientViewHolder>() {
inner class PatientViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
Expand Down Expand Up @@ -71,6 +72,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
11 changes: 11 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,9 @@ 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,
)
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package deakin.gopher.guardian.services.api


import deakin.gopher.guardian.model.AddPatientActivityResponse
import deakin.gopher.guardian.model.AddPatientResponse
import deakin.gopher.guardian.model.AssignNurseRequest
import deakin.gopher.guardian.model.UpdatePatientRequest
import deakin.gopher.guardian.model.BaseModel
import deakin.gopher.guardian.model.Patient
import deakin.gopher.guardian.model.PatientActivity
import deakin.gopher.guardian.model.register.AuthResponse
import deakin.gopher.guardian.model.register.RegisterRequest
import deakin.gopher.guardian.model.register.NurseListResponse
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Call
Expand All @@ -19,6 +23,7 @@ import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query
Expand Down Expand Up @@ -70,6 +75,38 @@ interface ApiService {
@Part photo: MultipartBody.Part?,
): Response<AddPatientResponse>

@GET("nurse/all")
suspend fun getAllNurses(
@Header("Authorization") token: String,
@Query("q") query: String? = null,
@Query("page") page: Int = 1,
@Query("limit") limit: Int = 50,
): Response<NurseListResponse>

@PUT("patients/{patientId}")
suspend fun updatePatient(
@Header("Authorization") token: String,
@Path("patientId") patientId: String,
@Body request: UpdatePatientRequest,
): Response<BaseModel>

@Multipart
@PUT("patients/{patientId}")
suspend fun updatePatientWithPhoto(
@Header("Authorization") token: String,
@Path("patientId") patientId: String,
@Part("fullName") fullName: RequestBody,
@Part("dateOfBirth") dateOfBirth: RequestBody,
@Part("gender") gender: RequestBody,
@Part photo: MultipartBody.Part,
): Response<BaseModel>

@POST("patients/assign-nurse")
suspend fun assignNurseToPatient(
@Header("Authorization") token: String,
@Body request: AssignNurseRequest,
): Response<BaseModel>

@FormUrlEncoded
@POST("patients/entryreport")
suspend fun logPatientActivity(
Expand All @@ -91,4 +128,4 @@ interface ApiService {
@Header("Authorization") token: String,
@Path("id") patientId: String,
): Response<BaseModel>
}
}
Loading
Loading