Hi ,
Thanks for reaching out to Microsoft Q&A.
This is a known limitation in Azure FHIR service related to the $import operation, particularly when importing multiple versions of the same resource ID.
- FHIR Versioning Support: The FHIR spec allows for multiple versions of a resource. However, many FHIR server implementations (including Azure's) do not fully support importing historical versions in one
$importbatch. - Azure FHIR Service
$importBehavior:- If
initialImportMode = false, the server assumes data being imported may already exist and should respect existing IDs and versions. - When you include
meta.versionIdandmeta.lastUpdated, the server tries to persist the exact version history. - Azure FHIR Server does not support creating multiple historical versions of the same resource via import. It only keeps the latest resource version when importing.
- If
- Specific Errors:
-
Unable to generate internal IDs: This is a throttling or limitation issue triggered when too many resources have the same timestamp to the millisecond, even if resource IDs are the same. -
Failed to import duplicate resource: When you omitmeta.lastUpdated, the server assumes all resources are version #1. Any duplicate resource ID is rejected.
-
Root Cause
The $import operation on Azure FHIR Server is designed to:
Load initial resource states into the system.
Not support importing historical versions (multiple meta.versionIds of the same resource).
Even if initialImportMode is set to false, the server:
Cannot reconstruct version history from the import file.
Always considers resource IDs to be current versions only.
Workarounds
- Load only the latest version of the resource
Simply include the latest resource version per ID.
Do not try to simulate or import older versions.
Let the FHIR server auto-manage meta.versionId.
- Manually replay changes via FHIR API (not via
$import)
For use cases where you must preserve version history, consider a script that:
Sends each version sequentially via PUT to /Patient/{id}.
Ensures correct order and timing to let the server assign `versionId` automatically.
- Avoid setting
meta.versionIdin the$import
This will not give you version history but will import one version only.
- All duplicates (same
id) will be rejected after the first one.
Please 'Upvote'(Thumbs-up) and 'Accept' as answer if the reply was helpful. This will be benefitting other community members who face the same issue.