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
Resource Creation using POST http verb (SingleResourcePost) #2464
base: master
Are you sure you want to change the base?
Resource Creation using POST http verb (SingleResourcePost) #2464
Conversation
engine/src/main/java/com/google/android/fhir/sync/upload/ResourceConsolidator.kt
Outdated
Show resolved
Hide resolved
engine/src/androidTest/java/com/google/android/fhir/sync/upload/ResourceConsolidatorTest.kt
Outdated
Show resolved
Hide resolved
engine/src/androidTest/java/com/google/android/fhir/sync/upload/ResourceConsolidatorTest.kt
Outdated
Show resolved
Hide resolved
engine/src/main/java/com/google/android/fhir/db/impl/DatabaseImpl.kt
Outdated
Show resolved
Hide resolved
engine/src/main/java/com/google/android/fhir/db/impl/DatabaseImpl.kt
Outdated
Show resolved
Hide resolved
engine/src/main/java/com/google/android/fhir/db/impl/DatabaseImpl.kt
Outdated
Show resolved
Hide resolved
engine/src/main/java/com/google/android/fhir/db/impl/DatabaseImpl.kt
Outdated
Show resolved
Hide resolved
engine/src/main/java/com/google/android/fhir/db/impl/DatabaseImpl.kt
Outdated
Show resolved
Hide resolved
engine/src/main/java/com/google/android/fhir/db/impl/DatabaseImpl.kt
Outdated
Show resolved
Hide resolved
engine/src/main/java/com/google/android/fhir/db/impl/DatabaseImpl.kt
Outdated
Show resolved
Hide resolved
@santosh-pingle How is this going to work? Are we making it the default behaviour for all CREATEs. Right now if you POST to a HAPI server, the server assigns the resource its own e.g posting the following resource {
"resourceType": "List",
"id": "af17fe86-561a-44b0-84d3-5e75c753f6f8",
"meta": {
"versionId" : "1" ,
"lastUpdated": "2024-03-13T15:41:42.808+00:00",
"source" : "#fd2dc30247cf61b8"
},
"identifier": [
{"use": "official", "value": "f39c5f68-ab0f-4ae5-a9e2-47b0beb73d8e"}
],
"status": "current",
"code": {
"coding": [
{
"system" : "http://smartregister.org/",
"code" : "22138876" ,
"display": "Supply Inventory List"
}
],
"text": "Supply Inventory List"
}
} will result in {
"resourceType": "List",
"id": "1759",
"meta": {
"versionId" : "1" ,
"lastUpdated": "2024-04-04T09:09:05.431+00:00",
"source" : "#fd2dc30247cf61b8"
},
"identifier": [
{"use": "official", "value": "f39c5f68-ab0f-4ae5-a9e2-47b0beb73d8e"}
],
"status": "current",
"code": {
"coding": [
{
"system" : "http://smartregister.org/",
"code" : "22138876" ,
"display": "Supply Inventory List"
}
],
"text": "Supply Inventory List"
}
} The above behaviour is going to distort the resource references for any resources created on the mobile application |
engine/src/main/java/com/google/android/fhir/sync/upload/ResourceConsolidator.kt
Show resolved
Hide resolved
This was clarified on the SDK dev call. I think this is a good addition |
engine/src/main/java/com/google/android/fhir/sync/upload/ResourceConsolidator.kt
Outdated
Show resolved
Hide resolved
engine/src/main/java/com/google/android/fhir/db/impl/DatabaseImpl.kt
Outdated
Show resolved
Hide resolved
engine/src/main/java/com/google/android/fhir/sync/upload/ResourceConsolidator.kt
Show resolved
Hide resolved
...src/androidTest/java/com/google/android/fhir/sync/upload/HttpPostResourceConsolidatorTest.kt
Outdated
Show resolved
Hide resolved
...src/androidTest/java/com/google/android/fhir/sync/upload/HttpPostResourceConsolidatorTest.kt
Outdated
Show resolved
Hide resolved
...src/androidTest/java/com/google/android/fhir/sync/upload/HttpPostResourceConsolidatorTest.kt
Outdated
Show resolved
Hide resolved
...src/androidTest/java/com/google/android/fhir/sync/upload/HttpPostResourceConsolidatorTest.kt
Outdated
Show resolved
Hide resolved
We have kept existing DefaultConsolidator as it is. |
engine/src/androidTest/java/com/google/android/fhir/db/impl/DatabaseImplTest.kt
Show resolved
Hide resolved
* @param preSyncResourceId The [Resource.id] of the resource before synchronization. | ||
* @param postSyncResource The [Resource] after synchronization. | ||
*/ | ||
suspend fun updateResourcesAndLocalChangesPostSync( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this API different from updateResourceAndReferences
we already have in Database ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was something that was not updated or included in the old API. Let me check what was not included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially, the old API was not updating metadata such as version ID, last updated time, and the new resource ID in the payload of the resource, and meta data externally also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we modify the existing API to update metadata instead of creating a new API ?
Or in case if this is not possible then rename the APIs to distinguish them properly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking of renaming api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the kdoc for both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed version id issue in existing api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing api you mean updateResourceAndReferences
which is already there in DatabaseImpl ?
I don't see any changes in that.
Like we discussed in eng meeting, updating this API is better than creating a new API updateResourcesAndLocalChangesPostSync
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please confirm if you have the latest code changes? For me it looks like you are referring outdated code which is no more present in the pr.
updateResourcesAndLocalChangesPostSync
is no longer valid, and the Database
file does not contain any changes in the PR.
Actual fix is here
engine/src/main/java/com/google/android/fhir/db/impl/dao/ResourceDao.kt
Checkout this PR which added bunch of stuffs for POST upload strategy. |
Yes, I am using the core logic as it is. Only delta changes are added on top of it to achieve the end-to-end use case for resource consolidation. |
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes #2440
Description
The resource is created locally, and the HTTP POST verb is used to synchronize the resource with the FHIR server. In return, the server sends a response containing the resource with the newly assigned resource ID. Subsequently, the local database is updated with the provided resource.
Upload strategy : SingleResourcePost
Update the resource with the received resourceId in the local database
Update the resource with the received meta data in the local database
Update the resource with the received resource json string in the local database
Update the resource with the received reference id in the local database.
Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?
Type
Choose one: (Bug fix | Feature | Documentation | Testing | Code health | Builds | Releases | Other)
Screenshots (if applicable)
Checklist
./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the style guide of this project../gradlew check
and./gradlew connectedCheck
to test my changes locally.