opensrp / fhircore

FHIR Core / OpenSRP 2 is a Kotlin application for delivering offline-capable, mobile-first healthcare project implementations from local community to national and international scale using FHIR and WHO Smart Guidelines on Android.
https://smartregister.org
Apache License 2.0
54 stars 41 forks source link

App crashing while syncing Observation resources #663

Closed f-odhiambo closed 2 years ago

f-odhiambo commented 2 years ago

Describe the bug Error while syncing observation details causing the app to crash

Additional context

2021-10-25 16:49:15.821 5444-5907/org.smartregister.fhircore.anc W/System.err: com.google.android.fhir.ConverterException: org.fhir.ucum.UcumException: Error processing unit 'μg Hb/': unexpected character 'μ' at position 0
2021-10-25 16:49:15.822 5444-5907/org.smartregister.fhircore.anc W/System.err: Caused by: org.fhir.ucum.UcumException: Error processing unit 'μg Hb/': unexpected character 'μ' at position 0
2021-10-25 16:49:15.822 5444-5907/org.smartregister.fhircore.anc W/System.err:     at org.fhir.ucum.Lexer.consume(Lexer.java:52)
2021-10-25 16:49:15.822 5444-5907/org.smartregister.fhircore.anc W/System.err:     at org.fhir.ucum.Lexer.<init>(Lexer.java:36)
maimoonak commented 2 years ago

Impact:

The sync state received is Success which means that syncing is successful (ResourceIndexer catching exception), however, this resource might have failed indexing (which help indexing on searchable properties to make select faster)

There is only one resource on Ona server which has this char 658 Observation 3544 {"resourceType":"Observation","id":"3544","meta":{"versionId":"2","lastUpdated":"2021-10-22T08:30:05.782+00:00","source":"#99a9ea901b0386f8"},"status":"final","code":{"coding":[{"system":"http://loinc.org","code":"718-7","display":"G6PD levels in Blood"}],"text":"G6PD"},"subject":{"reference":"Patient/3536"},"performer":[{"reference":"Practitioner/3539","display":"Nurse Jane"}],"valueQuantity":{"value":6.3,"unit":"μg Hb/","system":"http://unitsofmeasure.org","code":"μg Hb/"},"referenceRange":[{"low":{"value":1,"unit":"μg Hb/","system":"http://unitsofmeasure.org","code":"μg Hb/"},"high":{"value":6.6,"unit":"μg Hb/","system":"http://unitsofmeasure.org","code":"μg Hb/"}}]} Full stacktrace is as follows

org.fhir.ucum.UcumException: Error processing unit 'μg Hb/': unexpected character 'μ' at position 0
12:55:35.807 fhircore.anc   at org.fhir.ucum.Lexer.consume(Lexer.java:52)
12:55:35.807 fhircore.anc   at org.fhir.ucum.Lexer.<init>(Lexer.java:36)
12:55:35.807 fhircore.anc   at org.fhir.ucum.ExpressionParser.parse(ExpressionParser.java:27)
12:55:35.808 fhircore.anc   at org.fhir.ucum.UcumEssenceService.getCanonicalForm(UcumEssenceService.java:249)
12:55:35.808 fhircore.anc   at com.google.android.fhir.UnitConverter.getCanonicalForm$engine_release(UnitConverter.kt:44)
12:55:35.808 fhircore.anc   at com.google.android.fhir.index.ResourceIndexer.quantityIndex(ResourceIndexer.kt:310)
12:55:35.808 fhircore.anc   at com.google.android.fhir.index.ResourceIndexer.extractIndexValues(ResourceIndexer.kt:99)
12:55:35.808 fhircore.anc   at com.google.android.fhir.index.ResourceIndexer.index(ResourceIndexer.kt:69)
12:55:35.808 fhircore.anc   at com.google.android.fhir.db.impl.dao.ResourceDao.insertResource(ResourceDao.kt:202)
12:55:35.808 fhircore.anc   at com.google.android.fhir.db.impl.dao.ResourceDao.insertAll$suspendImpl(ResourceDao.kt:74)
12:55:35.808 fhircore.anc   at com.google.android.fhir.db.impl.dao.ResourceDao.insertAll(Unknown Source:0)
12:55:35.808 fhircore.anc   at com.google.android.fhir.db.impl.DatabaseImpl.insertRemote(DatabaseImpl.kt:68)
12:55:35.808 fhircore.anc   at com.google.android.fhir.db.impl.DatabaseImpl$insertSyncedResources$2.invokeSuspend(DatabaseImpl.kt:97)
12:55:35.808 fhircore.anc   at com.google.android.fhir.db.impl.DatabaseImpl$insertSyncedResources$2.invoke(Unknown Source:10)
12:55:35.808 fhircore.anc   at androidx.room.RoomDatabaseKt$withTransaction$2.invokeSuspend(RoomDatabase.kt:58)
maimoonak commented 2 years ago

The G6PD is also represented by U/gHb which due to special character is deformed into above obs. We can replace the char 'μ' with 'U' as well, however, SDK needs to handle the special characters.

pld commented 2 years ago

cool, so we need to create an SDK issue and that's where this must be fixed?

maimoonak commented 2 years ago

Yes. Its although not a blocker for us.

pld commented 2 years ago

By not a blocker, do you mean that we can fix µ handling without an SDK change? Or that this error is only effecting indexing so it's not a blocker in general?

maimoonak commented 2 years ago
pld commented 2 years ago

K, I'm trying to understand if we should close this issue, or remove it from the milestone, and if there's remaining work for us to do right now on this. What do you think?

maimoonak commented 2 years ago

Oh. Ok. Yeah, we can not anything further on this from our end so can close issue.

f-odhiambo commented 2 years ago

I will create an issue for this on SDK and raise it on Thu on the developers call CC @pld @maimoonak