Skip to content

Serialization of UUID value strips urn:uuid: #180

@xanrag

Description

@xanrag

fhir-core==1.0.1
fhir.resources==8.0.0
pydantic==2.10.6
pydantic_core==2.27.2

I'm using a FHIR extension that includes a valueUuid field, but when I serialize it to JSON (e.g. for sending with requests), Pydantic seems to strip the required urn:uuid: prefix. I presume this happens because it parses the value as a uuid.UUID object, and when converting it back to a string, the prefix is removed—violating the FHIR standard for that field.

Creating an object with:
"extension": [ { "url": "http://electronichealth.se/fhir/StructureDefinition/NLLPrescriptionChain", "valueUuid": "urn:uuid:5f633a6a-398f-423c-a0d5-d254b51f487c", }, ],
and then doing model_dump_json() returns it as
"extension": [ { "url": "http://electronichealth.se/fhir/StructureDefinition/NLLPrescriptionChain", "valueUuid": "f633a6a-398f-423c-a0d5-d254b51f487c", }, ],
which does not pass the regex in the structureDefinition of the uuid field in HL7. http://hl7.org/fhir/StructureDefinition/uuid

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions