Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Malawi Core] Failing to sign in on the application ID page #1146

Closed
Tracked by #1149
KhumboLihonga opened this issue Mar 17, 2022 · 36 comments
Closed
Tracked by #1149

[Malawi Core] Failing to sign in on the application ID page #1146

KhumboLihonga opened this issue Mar 17, 2022 · 36 comments
Assignees
Labels
Bug Report Something isn't working as expected Malawi CORE Size - M 4-5 days

Comments

@KhumboLihonga
Copy link

Describe the bug
When the app is configured to point to our server, trying to sign in on the application ID page fails. The configuration is done in the local.properties file on the FHIR_BASE_URL attribute. Using the ID 'quest', the app takes a couple of seconds before displaying a toast notification that states, "Error loading configuration. Details: application quest not found."

To Reproduce
Steps to reproduce the behavior:

  1. Go to the local.properties file
  2. Set the FHIR_BASE_URL along with other OAuth configs
  3. Build and run the app
  4. On the application id page, enter 'quest' and press 'load configuration'

Expected behavior
I expect to continue to the user login page

Screenshots
N/A

Smartphone (please complete the following information):

  • Device: Samsung A12
  • Android version: 11
  • Build number: RP1A.200720.012.A127FXXU4AUK1
  • Version: 30

Additional context
When the FHIR_BASE_URL is set to 'https://fhir.labs.smartregister.org/fhir/', signing in works as expected. In addition, I believe this has been caused by a recent change to the repo, it was working 2 weeks ago.

@KhumboLihonga KhumboLihonga added the Bug Report Something isn't working as expected label Mar 17, 2022
@dubdabasoduba
Copy link
Member

When assigned this please ping @dubdabasoduba to help get access to the Dtree oauth creds.

@f-odhiambo f-odhiambo changed the title Quest: Failing to sign in on the application ID page M-Core : Failing to sign in on the application ID page Mar 18, 2022
@f-odhiambo
Copy link
Contributor

@dubdabasoduba @f-odhiambo Could you provide all the necessary configs to run this?

Shared on slack

@FikriMilano
Copy link
Collaborator

Configs received, trying to run the app

@FikriMilano
Copy link
Collaborator

Okay successfully replicated, investigating.

@FikriMilano
Copy link
Collaborator

FikriMilano commented Mar 21, 2022

Possible reason why this happen is because of the recent changes in using Composition resource to carry the configs. Nothing wrong with the code.
But inside the Malawi Core HAPI server's, the Quest Composition resource does not exist, which is a must in order for the Quest app to properly run.
So I will try to add that, and see if that will fix the issue.

cc @dubdabasoduba

@f-odhiambo f-odhiambo changed the title M-Core : Failing to sign in on the application ID page [Malawi Core] Failing to sign in on the application ID page Mar 21, 2022
@FikriMilano
Copy link
Collaborator

@f-odhiambo can you perhaps reach out to the malawi side and see if their app still works? assuming that they use the old codebase that is before this commit? https://github.com/opensrp/fhircore/tree/41069023317777b121aac402922f0aff95b996b8

Because this error happens in our app latest codebase that points to their FHIR_BASE_URL

@f-odhiambo
Copy link
Contributor

f-odhiambo commented Mar 21, 2022

This is noted @FikriMilano. I think we can use a generic config perhaps for ANC

@FikriMilano
Copy link
Collaborator

FikriMilano commented Mar 21, 2022

Will use our ANC configs for the Malawi Core for now.
We can update it in the future if it's needed.

cc @f-odhiambo @dubdabasoduba

@dubdabasoduba
Copy link
Member

@FikriMilano How did this go? Did it work?

@FikriMilano
Copy link
Collaborator

@FikriMilano How did this go? Did it work?

@dubdabasoduba
I was adding that yesterday, but their server suddenly went down.
Continuing today.

@FikriMilano
Copy link
Collaborator

FikriMilano commented Mar 22, 2022

@ellykits @f-odhiambo @dubdabasoduba
I have added the resources.
You need to also add <domain includeSubdomains="true">fhir-dev.d-tree.org</domain>
in https://github.com/opensrp/fhircore/blob/main/android/anc/src/main/res/xml/network_security_config.xml
After that it should work.

But instead, I got this error after clicking the load config button:

W/AppSettingViewModel: ca.uhn.fhir.parser.DataFormatException: Failed to parse JSON encoded FHIR content: Content does not appear to be FHIR JSON, first non-whitespace character was: '<' (must be '{')
        at ca.uhn.fhir.parser.json.jackson.JacksonStructure.load(JacksonStructure.java:118)
        at ca.uhn.fhir.parser.json.jackson.JacksonStructure.load(JacksonStructure.java:78)
        at ca.uhn.fhir.parser.JsonParser.doParseResource(JsonParser.java:194)
        at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:603)
        at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:651)
        at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:661)
        at org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirConverter.convert(FhirResourceConverter.kt:40)
        at org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirConverter.convert(FhirResourceConverter.kt:38)
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:153)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: ca.uhn.fhir.parser.DataFormatException: Content does not appear to be FHIR JSON, first non-whitespace character was: '<' (must be '{')
        at ca.uhn.fhir.parser.json.jackson.JacksonStructure.load(JacksonStructure.java:105)
        at ca.uhn.fhir.parser.json.jackson.JacksonStructure.load(JacksonStructure.java:78) 
        at ca.uhn.fhir.parser.JsonParser.doParseResource(JsonParser.java:194) 
        at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:603) 
        at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:651) 
        at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:661) 
        at org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirConverter.convert(FhirResourceConverter.kt:40) 
        at org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirConverter.convert(FhirResourceConverter.kt:38) 
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243) 
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:153) 
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923) 

@FikriMilano
Copy link
Collaborator

You can check the Composition resource in this link https://fhir-dev.d-tree.org/fhir/Composition/1126

@f-odhiambo
Copy link
Contributor

f-odhiambo commented Mar 23, 2022

Fo the above issue we had to exempt the Binary resource from being authenticated via Keycloack token in issues
#1095 and changes the following items in Keycloack as depicted in this PR https://github.com/opensrp/hapi-fhir-keycloak/pull/17/files, that way the binary resource is exempted from auth.

To follow up with the D-Tree team to also add these changes to their HAPI FHIR Server

CC @Gental-Giant

@f-odhiambo
Copy link
Contributor

Based on above comment marking this issues as blocked

@f-odhiambo f-odhiambo added the Blocked Item is blocked by another prerequisite label Mar 23, 2022
@FikriMilano
Copy link
Collaborator

There is also differences in HAPI server version:

Ours (5.7.0)
https://fhir.labs.smartregister.org

D-Tree (5.6.0)
https://fhir-dev.d-tree.org

@gosso22
Copy link

gosso22 commented Mar 23, 2022

@f-odhiambo & @FikriMilano - does this mean that we have to update to version 5.7.0?

@dubdabasoduba
Copy link
Member

Fo the above issue we had to exempt the Binary resource from being authenticated via Keycloack token in issues #1095 and changes the following items in Keycloack as depicted in this PR https://github.com/opensrp/hapi-fhir-keycloak/pull/17/files, that way the binary resource is exempted from auth.

To follow up with the D-Tree team to also add these changes to their HAPI FHIR Server

CC @Gental-Giant

They just need to update their JPA server deployment with the latest hapi-fhir-keycloak dependency this can be found here https://oss.sonatype.org/content/repositories/snapshots/org/smartregister/hapi-fhir-keycloak/

HAPI FHIR also updated to 5.7.0 so they also need to may that update on their JPA-instance too. They can deploy this https://github.com/opensrp/hapi-fhir-jpaserver-starter it has all the above suggested changes on master

cc: @Gental-Giant @f-odhiambo

@gosso22
Copy link

gosso22 commented Mar 23, 2022

@dubdabasoduba - I tried updating from version 5.6.0 to version 5.7.0, getting errors attached.

buildingvFhir5.7.txt

I also found an issue that might be related hapifhir/hapi-fhir#3412. It seems to be coming from the same function ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.getOrCreateTag. Any work around?

@dubdabasoduba
Copy link
Member

@dubdabasoduba - I tried updating from version 5.6.0 to version 5.7.0, getting errors attached.

buildingvFhir5.7.txt

I also found an issue that might be related hapifhir/hapi-fhir#3412. It seems to be coming from the same function ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.getOrCreateTag. Any work around?

@gosso22 Are deploying the https://github.com/opensrp/hapi-fhir-jpaserver-starter project?

@gosso22
Copy link

gosso22 commented Mar 23, 2022

@dubdabasoduba - yes I am deploying the above. Regarding the above error, it was my mistake I hadnt updated the hibernate.dialect in the application.yaml file.

I was able to successfully update the server to the current master HAPI server v5.7.0

@FikriMilano - can you test and confirm if this solves your issue?

cc: @KhumboLihonga @f-odhiambo

@FikriMilano
Copy link
Collaborator

@gosso22 @f-odhiambo @dubdabasoduba @KhumboLihonga
Nice, it works

But, is this supposed to be empty? the sync succeed though

@f-odhiambo
Copy link
Contributor

f-odhiambo commented Mar 23, 2022

@gosso22 @f-odhiambo @dubdabasoduba @KhumboLihonga
Nice, it works

But, is this supposed to be empty? the sync succeed though

@FikriMilano Next step here would be to add a Tag for Malawi Core to save and sync Malawi Core specific data as we do for g6pd as an example

@f-odhiambo
Copy link
Contributor

Also will need to change the following items perhaps in a new ticket

  1. Register Filter name
  2. Config with Registration questionnaire
  3. Config for bottom navigation items
  4. Add a StructureMap for Registration form in order to create the patients

From there we can plug in the other workflows

CC @FikriMilano @dubdabasoduba @ellykits

@FikriMilano
Copy link
Collaborator

FikriMilano commented Mar 24, 2022

@FikriMilano Next step here would be to add a Tag for Malawi Core to save and sync Malawi Core specific data as we do for g6pd as an example

@f-odhiambo @ellykits
What is this 'Tag'? Is it something in HAPI? and do you have any sample for it?

@f-odhiambo
Copy link
Contributor

f-odhiambo commented Mar 24, 2022

@FikriMilano here are a few examples

Patient Management

Quest/G6PD patient: https://fhir.labs.smartregister.org/fhir/Patient/8abe9963-05b7-42d7-9cd3-5f0453c35e99
Uses the tag for managingOrganization 361. Only patient with this Org ID will be synced to Quest/G6PD app

"managingOrganization": {
        "reference": "Organization/361"
      }

Quest Patient:https://fhir.labs.smartregister.org/fhir/Patient/04a1297c-9a2b-4a11-b72d-698c7c923621
Uses the tag for managingOrganization 105. Only patient with this Org ID will be synced to Quest app

"managingOrganization": {
    "reference": "Organization/105"
  }

Quest/G6PD Questionnaire : https://fhir.labs.smartregister.org/fhir/Questionnaire/3435
Uses the tag for publisher and use context .

"publisher": "G6PD",
  "useContext": [ {
    "code": {
      "system": "http://hl7.org/fhir/codesystem-usage-context-type.html",
      "code": "focus"
    },
    "valueCodeableConcept": {
      "coding": [ {
        "system": ["http://fhir.ona.io"](http://fhir.ona.io/),
        "code": "000003",
        "display": "G6PD Patient",
        "_display": {
          "extension": [ {
            "url": "http://hl7.org/fhir/StructureDefinition/translation"],
            "extension": [ {
              "url": "lang",
              "valueCode": "sw"
            }, {
              "url": "content",
              "valueString": "Mgonjwa wa G6PD"
            } ]
          } ]
        }
      } ]
    }
  } ]

Will need to

  1. add publisher attribute for Malawi Core user in Keycloak
  2. create a managing organization for Malawi Core with a distinct ID to manage Patients example
"managingOrganization": {
    "reference": "Organization/110"
  }
  1. User publisher and user context tags with unique name/id i.e
"publisher": "MalawiCore",
  "useContext": [ {
    "code": {
      "system": "http://hl7.org/fhir/codesystem-usage-context-type.html",
      "code": "focus"
    },
    "valueCodeableConcept": {
      "coding": [ {
        "system": ["https://fhir-dev.d-tree.org/"](https://fhir-dev.d-tree.org/),
        "code": "00000005",
        "display": "Add client on Malawi Core",
        "_display": {
          "extension": [ {
            "url": "http://hl7.org/fhir/StructureDefinition/translation",
            "extension": [ {
              "url": "lang",
              "valueCode": "sw"
            }, {
              "url": "content",
              "valueString": "Ongeza Mteja kwa Malawi Core "
            } ]
          } ]
        }
      } ]
    }
  } ]
  1. Update the app config to be able to filter the correct resources once the user is authenticated

@f-odhiambo
Copy link
Contributor

@FikriMilano, additionally the patient will be created and the tags (managing ID) will be added via a structure map while the other resources will be synced from HAPI based on the Tags during Questionnaire authoring before posting to HAPI

@FikriMilano
Copy link
Collaborator

FikriMilano commented Mar 24, 2022

@f-odhiambo @dubdabasoduba
Question 1:
For add publisher attribute for Malawi Core user in Keycloak
Are we the one who should update it? or D-Tree? It's their Keycloak after all.

Question 2:
... the tags (managing ID) will be added via a structure map ...
So this process is automatic, right after creating a Patient?

Question 3:
What if we want to update the current Patients in batch? to add the necessary tags, assuming they don't have those tags.
Because there may be hundreds of records.

@f-odhiambo
Copy link
Contributor

Question 1:
For add publisher attribute for Malawi Core user in Keycloak
Are we the one who should update it? or D-Tree? It's their Keycloak after all.

I will liase with @Gental-Giant to give an instruction onhow to go about this

Question 2:
... the tags (managing ID) will be added via a structure map ...
So this process is automatic, right after creating a Patient?

Yes

Question 3:
What if we want to update the current Patients in batch? to add the necessary tags, assuming they don't have those tags.
Because there may be hundreds of records.

I think for now most data is experimental , test data so we can create new data , if we need to do batch then will need to check how to go about it from HAPI/server side

@FikriMilano
Copy link
Collaborator

Nice, thank you

@f-odhiambo f-odhiambo removed the Blocked Item is blocked by another prerequisite label Mar 24, 2022
@FikriMilano
Copy link
Collaborator

FikriMilano commented Mar 25, 2022

@f-odhiambo @Gental-Giant
The publisher and organization for Malawi Core demo user, are still empty.
I have created an Organization resource, which we can use for the user organization
http://fhir-dev.d-tree.org/fhir/Organization/10173
For the publisher perhaps you can use something like mcore

Kindly update that, so I can add the other resource with the proper tags.

@FikriMilano
Copy link
Collaborator

FikriMilano commented Mar 25, 2022

Here's some Patients that I have created.
https://fhir-dev.d-tree.org/fhir/Patient?organization=10173
For Questionnaire it will need publisher

@f-odhiambo
Copy link
Contributor

f-odhiambo commented Mar 25, 2022

This is noted. Working on it

@FikriMilano
Copy link
Collaborator

FikriMilano commented Mar 25, 2022

@f-odhiambo @dubdabasoduba @AbdulWahabMemon
I updated the configs from ANC to Quest.
As well the Patient and Questionnaire resources.
And now we are able to view the Patient and Questionnaire in Malawi Core.

@FikriMilano
Copy link
Collaborator

FikriMilano commented Mar 25, 2022

All configs are saved here https://fhir-dev.d-tree.org/fhir/Composition/1126

@f-odhiambo
Copy link
Contributor

@AbdulWahabMemon Check this out

@FikriMilano
Copy link
Collaborator

I think this is solved (?)
Closing this for now, feel free to open it if anything new comes up.

@FikriMilano FikriMilano added the Size - M 4-5 days label May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Something isn't working as expected Malawi CORE Size - M 4-5 days
Projects
None yet
Development

No branches or pull requests

6 participants