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

Resource Creation using POST http verb (SingleResourcePost) #2464

Merged
merged 23 commits into from
May 28, 2024

Conversation

santosh-pingle
Copy link
Collaborator

@santosh-pingle santosh-pingle commented Mar 6, 2024

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

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

@santosh-pingle santosh-pingle marked this pull request as ready for review March 19, 2024 05:03
@santosh-pingle santosh-pingle requested a review from a team as a code owner March 19, 2024 05:03
@santosh-pingle santosh-pingle changed the title In progress : Resource Creation using POST http verb Resource Creation using POST http verb Mar 19, 2024
@santosh-pingle santosh-pingle changed the title Resource Creation using POST http verb Resource Creation using POST http verb (SingleResourcePost) Mar 19, 2024
@dubdabasoduba
Copy link
Collaborator

dubdabasoduba commented Apr 4, 2024

@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 id.

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

cc: @ellykits @qiarie @ndegwamartin

@dubdabasoduba
Copy link
Collaborator

@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 id.

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

cc: @ellykits @qiarie @ndegwamartin

This was clarified on the SDK dev call. I think this is a good addition

@santosh-pingle
Copy link
Collaborator Author

@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 id.

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

cc: @ellykits @qiarie @ndegwamartin

We have kept existing DefaultConsolidator as it is.

@MJ1998
Copy link
Collaborator

MJ1998 commented May 2, 2024

Checkout this PR which added bunch of stuffs for POST upload strategy.

@santosh-pingle
Copy link
Collaborator Author

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.

@santosh-pingle santosh-pingle requested a review from MJ1998 May 8, 2024 10:51
Copy link
Collaborator

@MJ1998 MJ1998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this looks good now!
Can we add few integration tests as well ? Maybe in FhirEngineImplTest ?

Copy link
Collaborator

@MJ1998 MJ1998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One nit.

@santosh-pingle santosh-pingle dismissed jingtang10’s stale review May 28, 2024 07:35

Addressed review comments, reviewed and approved by code owner @MJ1998, hence dismissing review.

@santosh-pingle santosh-pingle merged commit d83692e into google:master May 28, 2024
4 checks passed
ndegwamartin added a commit to opensrp/android-fhir that referenced this pull request Jun 4, 2024
       - With unmerged PR #9
       - WUP PR google#2178
       - WUP PR google#2511
       - WUP PR google#2464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Allow Resource Creation using POST http verb.
5 participants