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
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ dependencies {
implementation 'androidx.compose.material3:material3'
implementation platform('androidx.compose:compose-bom:2024.08.00')
implementation platform('androidx.compose:compose-bom:2024.08.00')
implementation 'androidx.activity:activity:1.8.0'


testImplementation 'junit:junit:4.13.2'
Expand Down
47 changes: 18 additions & 29 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- For reading images -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />

<!-- For reading videos -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- For reading images -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <!-- For reading videos -->
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.CAMERA" />


<!-- For reading audio -->
<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" />
<!-- Add the permission here -->
<uses-permission android:name="android.permission.CAMERA" /> <!-- For reading audio -->
<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" /> <!-- 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 +28,12 @@
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=".view.general.NurseProfileActivity"
android:exported="false" />
<activity
android:name=".WelcomeActivity"
android:exported="false" />
Expand All @@ -45,7 +42,7 @@
android:exported="false" />
<activity
android:name=".Training2"
android:exported="false"></activity>
android:exported="false" />
<activity
android:name=".Training"
android:exported="false" />
Expand Down Expand Up @@ -161,7 +158,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 All @@ -187,35 +185,26 @@
<activity
android:name=".view.general.TasksListActivity"
android:exported="false" />

<activity android:name=".ModulesActivity" />


<activity android:name=".Module1CoursesActivity" />
<activity android:name=".HomecareInductionActivity" />
<activity android:name=".InfectionControlActivity" />
<activity android:name=".SupportingMealtimesActivity" />


<activity android:name=".Module2CoursesActivity" />
<activity android:name=".MedicationTechniqueActivity" />
<activity android:name=".MedicationSafetyActivity" />


<activity android:name=".Module3CoursesActivity" />
<activity android:name=".InspiringLeadershipEIActivity" />
<activity android:name=".EmotionalIntelligenceCommunicationActivity" />
<activity android:name="deakin.gopher.guardian.view.general.NurseRosterActivity" />
<activity android:name=".view.general.NurseRosterActivity" />
<activity android:name=".view.falldetection.FallDetectionActivity" />
<activity android:name=".view.falldetection.FallAlertActivity" />
<activity android:name="deakin.gopher.guardian.view.caretaker.notifications.confirmincident.CallAmbulanceActivity" />

<activity android:name=".view.caretaker.notifications.confirmincident.CallAmbulanceActivity" />
<activity
android:name=".PatientExerciseModules"
android:exported="false"
android:label="Patient Exercise Modules" />


<service
android:name=".model.FirebaseMessagingService"
android:exported="false">
Expand All @@ -228,7 +217,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
@@ -0,0 +1,32 @@
package deakin.gopher.guardian.model

data class NurseProfileResponse(
val _id: String?,
val fullname: String?,
val email: String?,
val role: NurseRole?,
val assignedPatients: List<AssignedPatient>?,
val approvalStatus: String?,
val organization: NurseOrganization?
)

data class NurseRole(
val _id: String?,
val name: String?
)

data class AssignedPatient(
val _id: String?,
val fullname: String?,
val gender: String?,
val dateOfBirth: String?,
val age: Int?,
val id: String?
)

data class NurseOrganization(
val _id: String?,
val name: String?,
val staffCount: Int?,
val id: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query
import deakin.gopher.guardian.model.NurseProfileResponse

interface ApiService {
@POST("auth/register")
Expand Down Expand Up @@ -60,6 +61,14 @@ interface ApiService {
@Header("Authorization") token: String,
): Response<List<Patient>>

@GET("nurse/profile")
suspend fun getNurseProfile(
@Header("Authorization") token: String,
@Query("email") email: String,
): Response<NurseProfileResponse>



@Multipart
@POST("patients/add")
suspend fun addPatient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,55 @@ import deakin.gopher.guardian.model.login.SessionManager
import deakin.gopher.guardian.services.EmailPasswordAuthService
import deakin.gopher.guardian.services.NavigationService

import android.content.Intent


class Homepage4nurse : AppCompatActivity() {

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

val user = SessionManager.getCurrentUser()
val titleText: TextView = findViewById(R.id.medicalDiagnosticsTitleTextView)

val titleText: TextView =
findViewById(R.id.medicalDiagnosticsTitleTextView)

titleText.append(" ${user.name.split(" ").getOrNull(0) ?: ""}")

val patientsButton: Button = findViewById(R.id.patientsButton_nurse)
val settingsButton: Button = findViewById(R.id.settingsButton_nurse)
val signOutButton: Button = findViewById(R.id.sighOutButton_nurse)
val patientsButton: Button =
findViewById(R.id.patientsButton_nurse)

val settingsButton: Button =
findViewById(R.id.settingsButton_nurse)

val signOutButton: Button =
findViewById(R.id.sighOutButton_nurse)

val profileButton: Button =
findViewById(R.id.profileButton_nurse)

// My Patients button
patientsButton.setOnClickListener {
NavigationService(this).onLaunchPatientList()
}

// settings button
// Settings button
settingsButton.setOnClickListener {
NavigationService(this).onSettings()
}

// sign out button
// My Profile button
profileButton.setOnClickListener {
val intent = Intent(this, NurseProfileActivity::class.java)
startActivity(intent)
}


// Sign Out button
signOutButton.setOnClickListener {
EmailPasswordAuthService.signOut(this)
finish()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package deakin.gopher.guardian.view.general

import android.os.Bundle
import android.view.View
import android.widget.ProgressBar
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import deakin.gopher.guardian.R
import deakin.gopher.guardian.model.login.SessionManager
import deakin.gopher.guardian.services.api.ApiClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import android.widget.EditText
import android.widget.LinearLayout

class NurseProfileActivity : AppCompatActivity() {

private lateinit var tvNurseName: TextView
private lateinit var tvNurseEmail: TextView
private lateinit var tvNursePhone: TextView
private lateinit var tvNurseRole: TextView
private lateinit var tvError: TextView
private lateinit var progressBar: ProgressBar
private lateinit var tvEditHint: TextView
private lateinit var editFormContainer: LinearLayout
private lateinit var etNurseName: EditText
private lateinit var etNurseEmail: EditText
private lateinit var etNurseRole: EditText
private lateinit var etNurseOrganization: EditText


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

tvNurseName = findViewById(R.id.tvNurseName)
tvNurseEmail = findViewById(R.id.tvNurseEmail)
tvNursePhone = findViewById(R.id.tvNursePhone)
tvNurseRole = findViewById(R.id.tvNurseRole)
tvError = findViewById(R.id.tvError)
tvEditHint = findViewById(R.id.tvEditHint)

editFormContainer = findViewById(R.id.editFormContainer)
etNurseName = findViewById(R.id.etNurseName)
etNurseEmail = findViewById(R.id.etNurseEmail)
etNurseRole = findViewById(R.id.etNurseRole)
etNurseOrganization = findViewById(R.id.etNurseOrganization)

findViewById<View>(R.id.ivEditProfile).setOnClickListener {
tvEditHint.visibility = View.VISIBLE
editFormContainer.visibility = View.VISIBLE

etNurseName.setText(tvNurseName.text.toString())
etNurseEmail.setText(tvNurseEmail.text.toString())
etNurseRole.setText(tvNurseRole.text.toString())
etNurseOrganization.setText(tvNursePhone.text.toString().replace("Organization: ", ""))
}
progressBar = findViewById(R.id.progressBar)

fetchNurseProfile()
}

private fun fetchNurseProfile() {
val token = "Bearer ${SessionManager.getToken()}"
val email = SessionManager.getCurrentUser().email

progressBar.visibility = View.VISIBLE
tvError.visibility = View.GONE

CoroutineScope(Dispatchers.IO).launch {
val response =
try {
ApiClient.apiService.getNurseProfile(token, email)
} catch (e: Exception) {
println("NURSE_PROFILE_EXCEPTION: ${e.message}")
null
}

withContext(Dispatchers.Main) {
progressBar.visibility = View.GONE

if (response?.isSuccessful == true && response.body() != null) {
val nurseProfile = response.body()!!

tvNurseName.text = nurseProfile.fullname ?: "Name not available"
tvNurseEmail.text = nurseProfile.email ?: "Email not available"
tvNurseRole.text = nurseProfile.role?.name ?: "Role not available"
tvNursePhone.text =
"Organization: ${nurseProfile.organization?.name ?: "Not available"}"

tvError.visibility = View.GONE
} else {
tvError.visibility = View.VISIBLE
tvError.text = "Failed to load nurse profile"
}
}
}
}
}
Loading
Loading