Skip to content

Commit

Permalink
chore(TestServer) provide fhir test server credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSaruni committed Nov 12, 2024
1 parent fb35083 commit a77964f
Show file tree
Hide file tree
Showing 8 changed files with 348 additions and 8 deletions.
329 changes: 329 additions & 0 deletions .idea/other.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.annotation.ColorInt
object Constants {

const val DEMO_API_SERVER="http://10.1.57.245:8080/fhir/"
const val DEMO_SERVER="http://10.1.57.245:8080/fhir/"
const val DEMO_SERVER="http://41.89.93.172/fhir/"

// const val DEMO_API_SERVER="https://api.mamashub.co.ke/"
// const val DEMO_SERVER="https://api.mamashub.co.ke/fhir/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ interface Interface {
fun getAllQuestionnaireResponses(): Call<ResponseBody>


@PUT("fhir/QuestionnaireResponse/{id}")
@PUT("QuestionnaireResponse/{id}")
fun submitQuestionnaireResponse(
@Path("id") id: String,
@Body requestBody: RequestBody
): Call<ResponseBody>



}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.ProgressDialog
import android.content.Context
import android.util.Log
import android.widget.Toast
import com.kabarak.kabarakmhis.fhir.data.Constants.DEMO_API_SERVER
import com.kabarak.kabarakmhis.fhir.data.Constants.DEMO_SERVER
import com.kabarak.kabarakmhis.fhir.data.SYNC_VALUE
import com.kabarak.kabarakmhis.helperclass.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import com.kabarak.kabarakmhis.fhir.FhirApplication
import com.kabarak.kabarakmhis.helperclass.*
import com.kabarak.kabarakmhis.new_designs.chw.viewmodel.AddChwPatientViewModel
import com.kabarak.kabarakmhis.new_designs.data_class.*
import com.kabarak.kabarakmhis.new_designs.new_patient.FragmentConfirmPatient.Companion.EXTRA_QUESTIONNAIRE_JSON_STRING
import com.kabarak.kabarakmhis.new_designs.roomdb.KabarakViewModel
import com.kabarak.kabarakmhis.new_designs.screens.ConfirmParentAdapter
import com.kabarak.kabarakmhis.new_designs.screens.FragmentConfirmDetails
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/kabarak/kabarakmhis/pnc/ChildAdd.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ChildAdd : AppCompatActivity() {
retrofitCallsFhir = RetrofitCallsFhir()

// Load the questionnaire JSON
questionnaireJsonString = getStringFromAssets("congenital_abnormalities.json")
questionnaireJsonString = getStringFromAssets("new-patient-registration.json")

if (savedInstanceState == null && questionnaireJsonString != null) {
supportFragmentManager.commit {
Expand Down Expand Up @@ -92,6 +92,7 @@ class ChildAdd : AppCompatActivity() {
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
if (response.isSuccessful) {
Toast.makeText(this@ChildAdd, "Successfully submitted!", Toast.LENGTH_SHORT).show()
finish()
Log.d("ChildAdd", "Successfully submitted the questionnaire response.")
} else {
Toast.makeText(this@ChildAdd, "Submission failed: ${response.message()}", Toast.LENGTH_SHORT).show()
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/kabarak/kabarakmhis/pnc/ChildEdit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ class ChildEdit : AppCompatActivity() {
val jsonParser = fhirContext.newJsonParser()
val updatedResponseString = jsonParser.encodeResourceToString(updatedQuestionnaireResponse)

// Log the response (you can replace this with saving to a database or sending to a server)
Log.d("submitUpdatedResponse", updatedResponseString)

// Submit the updated response back to the server
retrofitCallsFhir.updateQuestionnaireResponse(responseId, updatedResponseString, object : Callback<ResponseBody> {
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
Expand All @@ -185,6 +188,7 @@ class ChildEdit : AppCompatActivity() {
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
CoroutineScope(Dispatchers.Main).launch {
Toast.makeText(this@ChildEdit, "Error occurred while updating: ${t.message}", Toast.LENGTH_SHORT).show()
Log.e("Error", "Error occurred while updating questionnaire response", t)
}
}
})
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

<!-- Development Servers-->
<string name="base_url">http://10.1.57.245:5000/</string>
<string name="fhir_url">http://10.1.57.245:8080/fhir/</string>

<string name="fhir_url">http://41.89.93.172/fhir/</string>


<!-- Live Servers-->
Expand Down Expand Up @@ -69,8 +68,14 @@
<string name="facility_from_facility">Facility from facility referral</string>
<string name="clients_records">Clients Records</string>
<string name="referrals_to_facility">Referrals to Facility</string>
<string name="first_fragment_label">hh</string>
<string name="second_fragment_label">fragment 2</string>
<string name="add_child">add child</string>
<string name="child_added_success">add child success</string>
<string name="child_saved_success">save child success</string>
<string name="child_saved_failed">save child failed</string>
<string name="child_deleted_success">delete child success</string>
<string name="child_deleted_failed">delete child failed</string>
<string name="child_updated_success">update child success</string>
<string name="child_updated_failed">update child failed</string>

<string-array name="array_marital">
<item>Married</item>
Expand Down

0 comments on commit a77964f

Please sign in to comment.