Skip to content

Validation errors when creating a User resource, on Organization route #11

@timciep

Description

@timciep

When trying to replicate the following, in my app, using hosted Aidbox,

// Step 7: Create User using organization-based API
const userResponse = await fetch(`${AIDBOX_URL}/Organization/${organization.id}/fhir/User`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${orgToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
resourceType: 'User',
email,
password, // Aidbox will hash this
fhirUser: {
reference: `PractitionerRole/${practitionerRole.id}`
}
})
})

I get a 422 response. At the bottom, I'll give a full request/response example.

I am also including sub, based on the token introspection documentation, in the hope that this will cause requests made via my JWT (with sub claim) will be associated with the user.

Request:

POST https://yckpelctdh.aidbox.app/Organization/e:staging-i:solo-u:1646602/fhir/User

{
  "id": "e:staging-u:1646602",
  "sub": "e:staging-u:1646602",
  "name": "Tim Cieplowski",
  "email": "tim.cieplowski@doxy.me",
  "fhirUser": {
    "reference": "PractitionerRole/e:staging-u:1646602--e:staging-i:solo-u:1646602"
  }
}

Response:

{
    "resourceType": "OperationOutcome",
    "text": {
        "status": "generated",
        "div": "Invalid resource"
    },
    "issue": [
        {
            "severity": "fatal",
            "code": "invalid",
            "expression": [
                "User.sub"
            ],
            "details": {
                "coding": [
                    {
                        "system": "http://aidbox.app/CodeSystem/operation-outcome-type",
                        "code": "unknown-key"
                    }
                ]
            },
            "diagnostics": "Unrecognized property 'sub'"
        },
        {
            "severity": "fatal",
            "code": "invalid",
            "expression": [
                "User.name"
            ],
            "details": {
                "coding": [
                    {
                        "system": "http://aidbox.app/CodeSystem/operation-outcome-type",
                        "code": "invalid-type"
                    },
                    {
                        "system": "http://aidbox.app/CodeSystem/schema-id",
                        "code": "User"
                    }
                ]
            },
            "diagnostics": "Invalid type for the field. Expected 'BackboneElement', but got 'string'"
        },
        {
            "severity": "fatal",
            "code": "invalid",
            "expression": [
                "User.fhirUser"
            ],
            "details": {
                "coding": [
                    {
                        "system": "http://aidbox.app/CodeSystem/operation-outcome-type",
                        "code": "invalid-target-profile"
                    }
                ]
            },
            "diagnostics": "Referenced resource PractitionerRole/e:staging-u:1646602--e:staging-i:solo-u:1646602 content doesn't conform to any of target profiles: http://hl7.org/fhir/StructureDefinition/Practitioner,http://hl7.org/fhir/StructureDefinition/Person,http://hl7.org/fhir/StructureDefinition/Patient"
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions