Unable to write resource after applying access pol...
# support
a
Hi, I am working on a project where I've created an Access policy with criteria It's working for me but I am unable to create new Resource after applying the access policy with criteria. Here is my example access policy - "resource": [ { "resourceType": "Patient", "criteria": "Patient?organization=%provider_organization" }, { "resourceType": "DiagnosticReport", "criteria": "DiagnosticReport?performer=%provider_organization" }, { "resourceType": "ServiceRequest", "criteria": "ServiceRequest?requester=%provider_physician" } ]
r
What resource are you trying to make? This looks like a Parameterized accesss policy - so can you share the ProjectMembership as well?
a
Yes, I am using the parameterized access policy I am sharing my example ProjectMembership JSON "access": [ { "policy": { "reference": "AccessPolicy/policyid", "display": "Test Policy" }, "parameter": [ { "name": "provider_organization", "valueReference": { "reference": "Organization/id" } } ] }, { "policy": { "reference": "AccessPolicy/policyid", "display": "Test Policy" }, "parameter": [ { "name": "provider_physician", "valueReference": { "reference": "Practitioner/id" } } ] }, { "policy": { "reference": "AccessPolicy/policyid", "display": "Test Policy" }, "parameter": [ { "name": "partof_organization", "valueReference": { "reference": "Organization/id" } } ] } ]
r
Can you share the error you are getting?
a
403 forbidden error and I am unable to create any resource.
r
Can you also share an example resource that you are creating? This access policy will block you from creating any resource other than Organizations, Patients, or DiagnosticReports with the appropriate fields populated
a
I cannot create only that resource in the Access policy. I am applying a parameterized access policy with a particular resource. I am unable to create only those. resources that are present in the access policy.
r
@akshaytc , can you share the JSON of an example resource you are trying (and failing) to create?
I can try to reproduce the error on my end
a
I am sharing the example resource type JSON. { "resourceType": "ServiceRequest", "status": "active", "subject": { "reference": "Patient/xxxxx", "display": "xxxxx" }, "intent": "original-order", "requester": { "reference": "Patient/xxxxx", "display": "xxxxx" }, "priority": "routine", "occurrenceDateTime": "2023-10-04T01:26:42.000Z", "code": { "coding": [ { "system": "code url", "code": "1003-16", "display": "xxxxx" }, { "code": "10001-13", "system": "code url", "display": "xxxxx" } ] }, "identifier": [ { "system": "xxxxxx", "value": "LUMB-GWT-04" } ], "performer": [ { "reference": "Organization/xxxxx", "display": "Lab" } ], "specimen": [ { "reference": "Specimen/xxxxx", "display": "xxxx" } ], "id": "xxxxx" }
r
@akshaytc I think I see the problem. In the block in your
ProjectMembership
, you instantiate the same policy multiple times, but each time only fill in a single variable. Therefore, the %placeholders and in place. Instead, you should instantiate the policy ONCE, but with multiple parameters. See this example
Copy code
"access": [
    {
      "policy": {
        "reference": "AccessPolicy/policyid",
        "display": "Test Policy"
      },
      "parameter": [
        {
          "name": "provider_organization",
          "valueReference": {
            "reference": "Organization/id"
          }
        },
     
        {
          "name": "provider_physician",
          "valueReference": {
            "reference": "Practitioner/id"
          }
        },

        {
          "name": "partof_organization",
          "valueReference": {
            "reference": "Organization/id"
          }
        }
      ]
    }
  ]
169 Views