Comments (6)
the index tables don't currently store the sqlite id directly. are you suggesting we add that as an additional column in each index table?
from android-fhir.
Now ResourceType
+ ResourceID
is used for foreign key of these index tables. But there may be some potential problems:
ResourceID
is a UUID generated locally when resources are saved into the local database. However, this ID may not be unique for remote server as the resources are creating from multiple device and POST
to the remote server.
A better way that be used is as following:
For the reasons of
(1) When inserted into the database, each resource is assigned an SQLite ID
(Long) which is the PrimaryKey
in the database. This primary key is ensured to be unique.
(2) When we search for a resource
, we will need the ResourceType
(eg. searching for a patient
....)
So here we proposed to refactor the database by using databaseID
+ResourceType
, instead of current way of using R esourceID
+ResourceType
as ForeignKey
.
The advantages of using databaseID + ResourceType includes:
(1) The SQLite ID
is ensured to be unique and immutable.
(2) ID
as a Long
can save spaces in the index tables, compare to using the ResouceId
which is a string
. This can improve the searching performance as well.
from android-fhir.
I would actually recommend we go with a local UUID instead as the key (can even ignore resource type). We can have a server id in addition to that to be used for server communications. FYI room 2.4 adds out of the box support for UUID (and saves it as a byte array). And for conflcits, we can simply ignore, it is super super unlikely to happen :)
Also, keep in mind, sqlite ID (which i assume it referes to the auto-generated primary key), is a bit tricky to use. More specifically, if we ever do "insert(onConflict=REPLace)", sqlite will "Delete" the existing item and insert the new one, with a new id. this also means all fkey relationships will be deleted. (not different for UUID except it wouldn't be changing so with defferred fkey checks, we can handle that)
Hence, we should also make sure to never use onConflict=REPLACE
(instead implement a custom upsert in a transaction).
from android-fhir.
- Local UUID does help engine in allowing users to save Resources created on the device without requiring ID. This is useful when Fhir server allows creating resources with POST only.
- In the above case, server assigns an ID to the POSTed Resource and returns it in the response. As such, engine needs to update database with this new Id. PR #775 tackles this issue, but ends up doing multiple db calls as the data is stored in multiple tables as multiple other resources might be referencing the POSTed resource and thus all of them have to be updated in the database.
- Using Local UUID can help by reducing required updates to just the ResourceEntity table.
from android-fhir.
Thanks for @yigit and @aditya-07 point out.
The solution will be have 2 Local UUID.
- One is called
resourceLocalId
, used by index table. - Another one, which is just the original
logicalID
isresourceId
. This will be set as the ID that returned from the server.
from android-fhir.
suggest we call these IDs uuid
and logicalId
rather than local and remote.
from android-fhir.
Related Issues (20)
- Knowledge Manager uses the name instead of URL to fetch resources HOT 15
- Clicking on "manual sync" does not initiate the one-time sync. HOT 5
- Upload on sync fails for LocalChangeResourceReferenceEntity HOT 2
- Upload on sync fails here with HOT 1
- The response metadata is not updated in the payload of the resource. HOT 1
- Resource creation using AllChangesSquashedBundlePost upload strategy. HOT 1
- Sync upload local changes reordering patch issue HOT 7
- Deploy pre-built SNAPSHOT pre-release (dev, unstable) versions of Engine and DataCapture to a Maven repo HOT 7
- Configurable hyphen("-") answer option in dropdown menu. HOT 3
- Speed up initially processing questionnaireStateFlow HOT 1
- Date Picker Constraint Not Enforced on 'Ok' Button Click. HOT 5
- Fix case when we purge a resource with forcePurge and related resource in LocalChange HOT 1
- Several records of resources with same resource Id returned leading to duplication HOT 9
- Troubleshooting failing Kokoro CI checks HOT 1
- Previous button invisible when launched in review mode HOT 3
- Demo app crashes with ServerConfiguration is not provided HOT 1
- Improve initial load for calculated-expression HOT 1
- Open choice missing string value HOT 5
- Improve Readability and Maintainability of Data Purge Function (purge()) HOT 1
- Expose an interface to db.withtransaction through FhirEngine
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-fhir.