Skip to content
Merged
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 @@ -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 @@ -229,7 +236,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,8 +72,11 @@ class PatientListAdapter(
onAssignNurseClick?.invoke(patient)
true
}

R.id.action_delete -> {
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,
)
42 changes: 34 additions & 8 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,45 @@ 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 Down
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
Expand Up @@ -2,12 +2,15 @@ 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.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.UpdatePatientRequest
import deakin.gopher.guardian.model.register.AuthResponse
import deakin.gopher.guardian.model.register.NurseListResponse
import deakin.gopher.guardian.model.register.RegisterRequest
import okhttp3.MultipartBody
import okhttp3.RequestBody
Expand All @@ -21,6 +24,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 @@ -72,6 +76,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 Down
Loading
Loading