hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.05k stars 1.33k forks source link

Composite Unique Search Parameter with dateTime component does not reject resource duplication #6317

Closed volodymyr-korzh closed 2 months ago

volodymyr-korzh commented 2 months ago

Existing composite unique search parameters with dateTime component stopped working after V7_4_0 release. No longer writing to table HFJ_IDX_CMP_STRING_UNIQ and now duplicate resources are being created.

To Reproduce 1) Create composite unique SP with date component.

Requests Example: `POST {SERVER_URL}/SearchParameter/` 1) ```json { "resourceType": "SearchParameter", "id": "obs-effective", "status": "active", "code": "date", "base": [ "Observation" ], "type": "date", "expression": "Observation.effective" } ``` 2) ```json { "resourceType": "SearchParameter", "id": "obs-code", "status": "active", "code": "code", "base": [ "Observation" ], "type": "token", "expression": "Observation.code" } ``` 3) ```json { "resourceType": "SearchParameter", "id": "observation-date-code", "extension": [ { "url": "http://hapifhir.io/fhir/StructureDefinition/sp-unique", "valueBoolean": true } ], "name": "observation-date-code", "status": "active", "code": "observation-date-code", "base": [ "Observation" ], "type": "composite", "expression": "Observation", "component": [ { "definition": "SearchParameter/obs-effective", "expression": "Observation" }, { "definition": "SearchParameter/obs-code", "expression": "Observation" } ] } ```

2) Create Observation with effective date and code.

Request Example: `POST {SERVER_URL}/Observation/` ```json { "resourceType": "Observation", "status": "final", "code": { "coding": [ { "system": "http://loinc.org", "code": "789-8" } ] }, "effectiveDateTime": "2009-11-26T13:35:08-05:00", "valueQuantity": { "value": 4.12, "system": "http://unitsofmeasure.org", "code": "10*12/L" } } ```

3) Create Observation with same effective date and code as in previous step.

Actual behaviour Second Observation with same effective date and code is created.

Expected behaviour 409 conflicts response

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "error",
            "code": "processing",
            "diagnostics": "HAPI-0550: HAPI-1093: Can not create resource of type Observation as it would create a duplicate unique index matching query: ........."
        }
    ]
}