{
  "resourceType": "Bundle",
  "type": "transaction",
  "entry": [
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "member-can-read-own-patient",
        "engine": "matcho",
        "description": "A patient-linked user may read its own Patient (Data sharing page prefill). Aidbox exposes the read id as params.resource/id, not params.id.",
        "matcho": {
          "user": {
            "fhirUser": {
              "resourceType": "Patient"
            }
          },
          "request-method": "get",
          "uri": "#^/fhir/Patient/[^/]+$",
          "params": {
            "resource/id": ".user.fhirUser.id"
          }
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/member-can-read-own-patient"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "member-consent-read",
        "engine": "matcho",
        "description": "Members read their own Consents (FHIR and Aidbox format; the latter feeds the retirements inside the save transaction), QuestionnaireResponses and DocumentReferences (#847).",
        "matcho": {
          "$one-of": [
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "get",
              "uri": "/fhir/Consent",
              "params": {
                "patient": ".user.fhirUser.id"
              }
            },
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "get",
              "uri": "/fhir/QuestionnaireResponse",
              "params": {
                "subject": ".user.fhirUser.id"
              }
            },
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "get",
              "uri": "/fhir/DocumentReference",
              "params": {
                "subject": ".user.fhirUser.id"
              }
            },
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "get",
              "uri": "/Consent",
              "params": {
                "patient": ".user.fhirUser.id"
              }
            }
          ]
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/member-consent-read"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "member-consent-write",
        "engine": "matcho",
        "description": "Member Data sharing page (#847): a patient-linked user may write one consent-capture transaction (Aidbox-format POST /) whose entries are all bound to its own Patient; Aidbox authorizes every entry against the PUT clauses below, so a foreign patient in any entry fails the whole transaction. Absent on read-only deployments (VillageCare). NOTE: matcho ignores keys that sit next to a top-level $one-of, so every alternative repeats the caller condition (verified on aidboxone edge, 2026-09-23).",
        "matcho": {
          "$one-of": [
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "post",
              "uri": "/",
              "body": {
                "resourceType": "Bundle",
                "type": "transaction"
              }
            },
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "put",
              "uri": "#^/Consent/[A-Za-z0-9-]+$",
              "body": {
                "resourceType": "Consent",
                "patient": {
                  "id": ".user.fhirUser.id",
                  "resourceType": "Patient"
                }
              }
            },
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "put",
              "uri": "#^/QuestionnaireResponse/[A-Za-z0-9-]+$",
              "body": {
                "resourceType": "QuestionnaireResponse",
                "subject": {
                  "id": ".user.fhirUser.id",
                  "resourceType": "Patient"
                }
              }
            },
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "put",
              "uri": "#^/DocumentReference/[A-Za-z0-9-]+$",
              "body": {
                "resourceType": "DocumentReference",
                "subject": {
                  "id": ".user.fhirUser.id",
                  "resourceType": "Patient"
                }
              }
            },
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "put",
              "uri": "#^/RelatedPerson/[A-Za-z0-9-]+$",
              "body": {
                "resourceType": "RelatedPerson",
                "patient": {
                  "id": ".user.fhirUser.id",
                  "resourceType": "Patient"
                }
              }
            },
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "put",
              "uri": "#^/Provenance/[A-Za-z0-9-]+$",
              "body": {
                "resourceType": "Provenance",
                "agent": {
                  "$contains": {
                    "$one-of": [
                      {
                        "who": {
                          "id": ".user.fhirUser.id",
                          "resourceType": "Patient"
                        }
                      },
                      {
                        "onBehalfOf": {
                          "id": ".user.fhirUser.id",
                          "resourceType": "Patient"
                        }
                      }
                    ]
                  }
                }
              }
            },
            {
              "user": {
                "fhirUser": {
                  "resourceType": "Patient"
                }
              },
              "request-method": "put",
              "uri": "#^/Binary/[A-Za-z0-9-]+$",
              "body": {
                "resourceType": "Binary",
                "securityContext": {
                  "id": ".user.fhirUser.id",
                  "resourceType": "Patient"
                }
              }
            }
          ]
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/member-consent-write"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-role-consent",
        "engine": "matcho",
        "description": "Portal admins read member consent records for the Data sharing card on Member Details (#847).",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "request-method": "get",
          "uri": "#^/fhir/(Consent|QuestionnaireResponse|DocumentReference|RelatedPerson|Provenance|Binary)(/[^/?]+)?$"
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-consent"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-consent-mode",
        "engine": "matcho",
        "description": "BFF (admin-api) reads the two member consent policies by id to derive the deployment's capture mode (#847): read present = read-only, both = read-write, neither = off.",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": "get",
          "uri": "#^/AccessPolicy/member-consent-(read|write)$"
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-consent-mode"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-consent",
        "engine": "matcho",
        "description": "BFF (admin-api) records review decisions as one FHIR transaction (PUT Consent + retirements + Provenance), and reads the consent resources and Questionnaires (#847).",
        "matcho": {
          "$one-of": [
            {
              "client": {
                "id": "admin-api"
              },
              "request-method": "post",
              "uri": "/fhir",
              "body": {
                "resourceType": "Bundle",
                "type": "transaction"
              }
            },
            {
              "client": {
                "id": "admin-api"
              },
              "request-method": "put",
              "uri": "#^/fhir/Consent/[^/]+$"
            },
            {
              "client": {
                "id": "admin-api"
              },
              "request-method": "patch",
              "uri": "#^/fhir/Consent/[^/]+$"
            },
            {
              "client": {
                "id": "admin-api"
              },
              "request-method": "put",
              "uri": "#^/fhir/Provenance/[^/]+$"
            },
            {
              "client": {
                "id": "admin-api"
              },
              "request-method": "get",
              "uri": "#^/fhir/(Consent|QuestionnaireResponse|DocumentReference|RelatedPerson|Provenance|Questionnaire|Binary)(/[^/?]+)?$"
            }
          ]
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-consent"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-access-policy",
        "engine": "matcho",
        "description": "Allow admin-api client to manage per-backend-service AccessPolicies (bs-policy-*) created/removed on app approval/deactivation (#478) and per-admin AccessPolicies (admin-*) created with each portal admin (#580)",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": {
            "$one-of": [
              "get",
              "put",
              "post",
              "delete"
            ]
          },
          "uri": {
            "$one-of": [
              "#^/AccessPolicy/bs-policy-.*",
              "#^/fhir/AccessPolicy/bs-policy-.*",
              "#^/AccessPolicy/admin-[a-zA-Z0-9._-]+$",
              "#^/fhir/AccessPolicy/admin-[a-zA-Z0-9._-]+$"
            ]
          }
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-access-policy"
      }
    },
    {
      "resource": {
        "resourceType": "StructureDefinition",
        "id": "client-created-by",
        "url": "http://aidbox.app/StructureDefinition/Client/created-by",
        "name": "client-created-by",
        "status": "active",
        "kind": "complex-type",
        "abstract": false,
        "type": "Extension",
        "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Extension",
        "derivation": "constraint",
        "context": [
          {
            "type": "element",
            "expression": "Client"
          }
        ],
        "differential": {
          "element": [
            {
              "id": "Extension",
              "path": "Extension",
              "min": 0,
              "max": "1"
            },
            {
              "id": "Extension.extension",
              "path": "Extension.extension",
              "max": "0"
            },
            {
              "id": "Extension.url",
              "path": "Extension.url",
              "fixedUri": "http://aidbox.app/StructureDefinition/Client/created-by"
            },
            {
              "id": "Extension.value[x]",
              "path": "Extension.value[x]",
              "min": 1,
              "max": "1",
              "type": [
                {
                  "code": "Reference",
                  "targetProfile": [
                    "http://health-samurai.io/fhir/core/StructureDefinition/User"
                  ]
                }
              ]
            }
          ]
        }
      },
      "request": {
        "method": "PUT",
        "url": "StructureDefinition/client-created-by"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "Client.created-by",
        "url": "http://aidbox.app/StructureDefinition/Client/created-by",
        "name": "created-by",
        "status": "active",
        "code": "created-by",
        "base": [
          "Client"
        ],
        "type": "token",
        "description": "Client created-by User",
        "expression": "Client.meta.extension.where(url='http://aidbox.app/StructureDefinition/Client/created-by').value.Reference.id"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/Client.created-by"
      }
    },
    {
      "resource": {
        "resourceType": "StructureDefinition",
        "id": "client-status",
        "url": "http://aidbox.app/StructureDefinition/Client/status",
        "name": "client-status",
        "status": "active",
        "kind": "complex-type",
        "abstract": false,
        "type": "Extension",
        "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Extension",
        "derivation": "constraint",
        "context": [
          {
            "type": "element",
            "expression": "Client"
          }
        ],
        "differential": {
          "element": [
            {
              "id": "Extension",
              "path": "Extension",
              "min": 0,
              "max": "1"
            },
            {
              "id": "Extension.extension",
              "path": "Extension.extension",
              "max": "0"
            },
            {
              "id": "Extension.url",
              "path": "Extension.url",
              "fixedUri": "http://aidbox.app/StructureDefinition/Client/status"
            },
            {
              "id": "Extension.value[x]",
              "path": "Extension.value[x]",
              "min": 1,
              "max": "1",
              "type": [
                {
                  "code": "code"
                }
              ],
              "constraint": [
                {
                  "key": "enum-client-status",
                  "severity": "error",
                  "human": "status must be one of draft | review | active | rejected",
                  "expression": "$this.subsetOf('draft' | 'review' | 'active' | 'rejected')"
                }
              ]
            }
          ]
        }
      },
      "request": {
        "method": "PUT",
        "url": "StructureDefinition/client-status"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "Client.status",
        "url": "http://aidbox.app/StructureDefinition/Client/status",
        "name": "status",
        "status": "active",
        "code": "status",
        "base": [
          "Client"
        ],
        "type": "token",
        "description": "Client status (draft, review, active, rejected)",
        "expression": "Client.meta.extension.where(url='http://aidbox.app/StructureDefinition/Client/status').value.code"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/Client.status"
      }
    },
    {
      "resource": {
        "resourceType": "Client",
        "id": "smartbox-admin-portal",
        "first_party": true,
        "grant_types": [
          "code",
          "password"
        ],
        "scope": [
          "openid",
          "profile",
          "email"
        ],
        "auth": {
          "authorization_code": {
            "redirect_uri": "http://localhost:8095/api/admin/auth/callback",
            "access_token_expiration": 3600,
            "token_format": "jwt",
            "pkce": true,
            "refresh_token": true,
            "refresh_token_expiration": 86400
          },
          "password": {
            "access_token_expiration": 300
          }
        }
      },
      "request": {
        "method": "PUT",
        "url": "Client/smartbox-admin-portal"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-session"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-session",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": {
            "$one-of": [
              "get",
              "post",
              "put",
              "patch",
              "delete"
            ]
          },
          "uri": {
            "$one-of": [
              "#^/fhir/Session.*",
              "#^/Session.*"
            ]
          }
        },
        "description": "Full CRUD access to Session for admin API client"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-oauth-state"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-oauth-state",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": {
            "$one-of": [
              "get",
              "post",
              "delete"
            ]
          },
          "uri": "#^/Basic.*"
        },
        "description": "OAuth login state (PKCE) stored as Basic resources by the portal backend; without this policy the write 403s and state falls back to per-pod memory, breaking the OAuth callback when the portal runs more than one replica"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-identity-provider"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-identity-provider",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": "get",
          "uri": "#^/IdentityProvider.*"
        },
        "description": "Read-only IdentityProvider access for admin API client (backend maps OIDC third-party initiated login iss to an IdP id)"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-grant"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-grant",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": {
            "$one-of": [
              "get",
              "post",
              "put",
              "patch",
              "delete"
            ]
          },
          "uri": {
            "$one-of": [
              "#^/fhir/Grant.*",
              "#^/Grant.*"
            ]
          }
        },
        "description": "Full CRUD access to Grant for admin API client"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-batch"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-batch",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": "post",
          "uri": "#^/fhir$"
        },
        "description": "Allow batch/transaction operations for admin API client"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-organization"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-organization",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "params": {
            "resource/type": "Organization"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead"
              ]
            }
          }
        },
        "description": "Scoped access for admin API client (organizations)"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-organization-create"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-organization-create",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": "post",
          "uri": "/fhir/Organization"
        }
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-client"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-client",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "params": {
            "resource/type": "Client"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead",
                "FhirDelete"
              ]
            }
          }
        },
        "description": "Scoped access for admin API client (clients, incl. E2E teardown)"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-user"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-user",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "params": {
            "resource/type": "User"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead",
                "FhirCreate",
                "FhirUpdate",
                "FhirPatch",
                "FhirDelete",
                "Search",
                "Read",
                "Create",
                "Update",
                "Patch",
                "Delete"
              ]
            }
          }
        },
        "description": "Full CRUD access to User for admin API client (FHIR and native Aidbox API)"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-force-reset-password"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-force-reset-password",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": "post",
          "uri": "#^/auth/force-reset-password.*"
        },
        "description": "Allow admin API client to issue password reset links via /auth/force-reset-password"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-document-reference"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-document-reference",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "params": {
            "resource/id": {
              "$one-of": [
                "smartbox-tos",
                "smartbox-privacy",
                "smartbox-theme",
                "smartbox-enrollment-message",
                "smartbox-app-name",
                "smartbox-app-logo",
                "mpf-export-scope",
                "member-consent-settings"
              ]
            },
            "resource/type": "DocumentReference"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirRead",
                "FhirUpdate",
                "FhirCreate"
              ]
            }
          }
        },
        "description": "Scoped access for admin-api client to DocumentReference resources (tos, privacy, theme, enrollment message)"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-footer-config"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-footer-config",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "params": {
            "resource/id": "#^footer-config-.*",
            "resource/type": "DocumentReference"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirRead",
                "FhirUpdate",
                "FhirCreate"
              ]
            }
          }
        },
        "description": "Allow admin-api client to read/write footer config DocumentReference (id prefix footer-config-*)"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "allow-read-settings",
        "engine": "matcho",
        "description": "Allow admin-api client to read Aidbox settings",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "uri": {
            "$one-of": [
              "/api/v1/settings/introspect",
              "^/api/v1/settings/.*"
            ]
          }
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/allow-read-settings"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-sql",
        "engine": "matcho",
        "description": "Allow admin-api client to execute SQL queries for patient enrollment lookup",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "uri": "/$sql",
          "request-method": "post"
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-sql"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-audit-event",
        "engine": "matcho",
        "description": "Allow admin-api client to create and read AuditEvent resources for enrollment audit logging",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "params": {
            "resource/type": "AuditEvent"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirCreate",
                "FhirSearch",
                "FhirRead"
              ]
            }
          }
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-audit-event"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-notification",
        "engine": "matcho",
        "description": "Allow admin-api client to create, send, and delete Notification resources for email notifications",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": {
            "$one-of": [
              "put",
              "post",
              "delete"
            ]
          },
          "uri": {
            "$one-of": [
              "#^/Notification.*"
            ]
          }
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-notification"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "Communication.about",
        "url": "http://smartbox.hs/sp/Communication-about",
        "name": "communication-about",
        "status": "active",
        "code": "about",
        "base": [
          "Communication"
        ],
        "type": "reference",
        "description": "Search Communication by Communication.about (any reference, incl. Aidbox system resources)",
        "expression": "Communication.about"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/Communication.about"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "Communication.identifier",
        "url": "http://smartbox.hs/sp/Communication-identifier",
        "name": "communication-identifier",
        "status": "active",
        "code": "identifier",
        "base": [
          "Communication"
        ],
        "type": "token",
        "description": "Search Communication by identifier (system|value)",
        "expression": "Communication.identifier"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/Communication.identifier"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "Session.client",
        "url": "http://smartbox.hs/sp/Session-client",
        "name": "session-client",
        "status": "active",
        "code": "client",
        "base": [
          "Session"
        ],
        "type": "reference",
        "description": "Search Session by client reference",
        "expression": "Session.client",
        "target": [
          "Client"
        ]
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/Session.client"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "Session.refresh-token-exp",
        "url": "http://smartbox.hs/sp/Session-refresh-token-exp",
        "name": "session-refresh-token-exp",
        "status": "active",
        "code": "refresh_token_exp",
        "base": [
          "Session"
        ],
        "type": "number",
        "description": "Search Session by refresh token expiration time (unix epoch seconds)",
        "expression": "Session.refresh_token_exp"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/Session.refresh-token-exp"
      }
    },
    {
      "resource": {
        "roles": [
          {
            "type": "admin"
          }
        ]
      },
      "request": {
        "method": "PATCH",
        "url": "User/admin"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/patient-can-get-launch-uri"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "patient-can-get-launch-uri",
        "type": "rpc",
        "engine": "matcho-rpc",
        "rpc": {
          "aidbox.smart/get-launch-uri": {
            "user": {
              "fhirUser": {
                "resourceType": "Patient"
              }
            }
          }
        }
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/patient-can-get-smart-apps"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "patient-can-get-smart-apps",
        "engine": "matcho",
        "matcho": {
          "user": {
            "fhirUser": {
              "resourceType": "Patient"
            }
          },
          "params": {
            "status": "active",
            ".type": "smart-app",
            "resource/type": "Client"
          },
          "operation": {
            "id": "FhirSearch"
          }
        }
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/patient-can-create-communication"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "patient-can-create-communication",
        "engine": "matcho",
        "matcho": {
          "user": {
            "fhirUser": {
              "resourceType": "Patient"
            }
          },
          "params": {
            "resource/type": "Communication"
          },
          "operation": {
            "id": "FhirCreate"
          }
        }
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/smart-app-can-read-patient-api"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "smart-app-can-read-patient-api",
        "engine": "matcho",
        "matcho": {
          "jwt": {
            "atv": 2,
            "scope": "present?",
            "context": {
              "patient": "present?"
            }
          },
          "client": {
            "type": "smart-app",
            "active": true
          }
        }
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "DocumentReference/smartbox-tos"
      },
      "resource": {
        "resourceType": "DocumentReference",
        "id": "smartbox-tos",
        "status": "current",
        "type": {
          "text": "Terms of Service"
        },
        "category": [
          {
            "text": "legal"
          }
        ],
        "content": [
          {
            "attachment": {
              "url": "http://localhost:3001/change-me-smartbox-tos.pdf",
              "contentType": "application/pdf"
            }
          }
        ]
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "DocumentReference/smartbox-privacy"
      },
      "resource": {
        "resourceType": "DocumentReference",
        "id": "smartbox-privacy",
        "status": "current",
        "type": {
          "text": "Privacy Policy"
        },
        "category": [
          {
            "text": "legal"
          }
        ],
        "content": [
          {
            "attachment": {
              "contentType": "text/html"
            }
          }
        ]
      }
    },
    {
      "resource": {
        "resourceType": "AidboxConfig",
        "id": "smartbox",
        "smartbox": {
          "logoUrl": "https://storage.googleapis.com/aidbox-public/smartbox/health-system-logo.png"
        }
      },
      "request": {
        "method": "PUT",
        "url": "AidboxConfig/smartbox"
      }
    },
    {
      "resource": {
        "resourceType": "StructureDefinition",
        "id": "FaqPage",
        "url": "http://aidbox.app/StructureDefinition/FaqPage",
        "name": "FaqPage",
        "status": "active",
        "kind": "resource",
        "abstract": false,
        "type": "FaqPage",
        "baseDefinition": "http://hl7.org/fhir/StructureDefinition/DomainResource",
        "derivation": "specialization",
        "differential": {
          "element": [
            {
              "id": "FaqPage",
              "path": "FaqPage",
              "min": 0,
              "max": "*"
            },
            {
              "id": "FaqPage.items",
              "path": "FaqPage.items",
              "min": 0,
              "max": "*",
              "type": [
                {
                  "code": "BackboneElement"
                }
              ]
            },
            {
              "id": "FaqPage.items.id",
              "path": "FaqPage.items.id",
              "min": 0,
              "max": "1",
              "type": [
                {
                  "code": "string"
                }
              ]
            },
            {
              "id": "FaqPage.items.question",
              "path": "FaqPage.items.question",
              "min": 0,
              "max": "1",
              "type": [
                {
                  "code": "string"
                }
              ]
            },
            {
              "id": "FaqPage.items.answer",
              "path": "FaqPage.items.answer",
              "min": 0,
              "max": "1",
              "type": [
                {
                  "code": "markdown"
                }
              ]
            }
          ]
        }
      },
      "request": {
        "method": "PUT",
        "url": "StructureDefinition/FaqPage"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-faqpage"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-faqpage",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "params": {
            "resource/type": "FaqPage"
          },
          "operation": {
            "id": "Read"
          }
        },
        "description": "Scoped access for admin API client (FAQ pages - read only)"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/box-ui-faqpage"
      },
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "box-ui-faqpage",
        "engine": "matcho",
        "matcho": {
          "client": {
            "id": "box-ui"
          },
          "params": {
            "resource/type": "FaqPage"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirRead",
                "FhirSearch"
              ]
            }
          }
        },
        "description": "Allow Aidbox UI to read FAQ pages"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "provider-directory-public-read",
        "engine": "matcho",
        "description": "Allow admin-api client to read provider directory resources",
        "matcho": {
          "uri": {
            "$one-of": [
              "#^/fhir/PractitionerRole($|/|\\?)",
              "#^/fhir/Practitioner($|/|\\?)",
              "#^/fhir/Location($|/|\\?)",
              "#^/fhir/Organization($|/|\\?)",
              "#^/fhir/HealthcareService($|/|\\?)"
            ]
          },
          "request-method": "get",
          "client": {
            "id": "admin-api"
          }
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/provider-directory-public-read"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-member-history-read",
        "engine": "matcho",
        "description": "Allow admin-api client to read Patient/Coverage/InsurancePlan/MedicationKnowledge for member history (#844)",
        "matcho": {
          "uri": {
            "$one-of": [
              "#^/fhir/Patient($|/|\\?)",
              "#^/fhir/Coverage($|/|\\?)",
              "#^/fhir/InsurancePlan($|/|\\?)",
              "#^/fhir/MedicationKnowledge($|/|\\?)"
            ]
          },
          "request-method": "get",
          "client": {
            "id": "admin-api"
          }
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-member-history-read"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-patient-write",
        "engine": "matcho",
        "description": "Allow admin-api client to write Patient resources for enrollment telecom updates",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": {
            "$one-of": [
              "patch",
              "put"
            ]
          },
          "uri": "#^/fhir/Patient($|/|\\?)"
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-patient-write"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-client-patch",
        "engine": "matcho",
        "description": "Allow the admin-api client to PATCH a single Client resource by id in the admin (PHI) box. The backend uses this to propagate developer-portal changes to approved clients into the production box. Single-resource PATCH only; collection/conditional PATCH, full-resource replace, and other write methods are denied.",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": "patch",
          "uri": "#^/fhir/Client/[^/?]+$"
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-client-patch"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "admin-api-registration-read",
        "engine": "matcho",
        "description": "Allow admin-api client to read Registration resources for enrollment status lookup",
        "matcho": {
          "client": {
            "id": "admin-api"
          },
          "request-method": "get",
          "uri": "#^/fhir/Registration($|/|\\?)"
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-api-registration-read"
      }
    },
    {
      "resource": {
        "resourceType": "AccessPolicy",
        "id": "allow-license-activation",
        "engine": "matcho",
        "description": "Allow unauthenticated access to license activation endpoints",
        "matcho": {
          "uri": {
            "$one-of": [
              "/api/v1/license/activate",
              "/api/v1/license/status",
              "/"
            ]
          }
        }
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/allow-license-activation"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "User.role",
        "url": "http://smartbox.hs/sp/User-role",
        "name": "user-role",
        "status": "active",
        "code": "role",
        "base": [
          "User"
        ],
        "type": "token",
        "description": "Search User by role type (User.roles[].type), e.g. /User?role=admin. FHIRPath traverses the roles array, so a role at any index matches.",
        "expression": "User.roles.type"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/User.role"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "User.patient",
        "url": "http://smartbox.hs/sp/User-patient",
        "name": "user-patient",
        "status": "active",
        "code": "patient",
        "base": [
          "User"
        ],
        "type": "reference",
        "target": [
          "Patient"
        ],
        "description": "Linked Patient for an enrolled member. Covers both link shapes: the enrollment flow writes User.fhirUser ({id,resourceType}) and legacy/imported members link via User.data.patient. Powers the enrolled-members list, which pages enrolled Users with /fhir/User?patient:missing=false (matches both shapes) and then fetches that page's Patients. NOTE: avoid reverse chaining (Patient?_has:User:patient:...) — it is too slow on large datasets; and Aidbox value-matches only Aidbox-format references, so :missing is the reliable modifier here. Index for scale: GIN on the User resource (see aidbox.index/suggest-index).",
        "expression": "User.fhirUser | User.data.patient"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/User.patient"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin access to Client resources",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "Client"
          }
        },
        "id": "admin-role-client",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-client"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin search and read Session resources",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "Session"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead"
              ]
            }
          }
        },
        "id": "admin-role-session",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-session"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin access to Organization resources",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "Organization"
          }
        },
        "id": "admin-role-organization",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-organization"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin read Patient with ORGBAC",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "Patient"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead",
                "orgbac-fhir-search",
                "orgbac-fhir-read"
              ]
            }
          }
        },
        "id": "admin-role-patient",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-patient"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin read User with ORGBAC",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "User"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead",
                "orgbac-fhir-search",
                "orgbac-fhir-read"
              ]
            }
          }
        },
        "id": "admin-role-user",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-user"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin read Group with ORGBAC",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "Group"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead",
                "orgbac-fhir-search",
                "orgbac-fhir-read"
              ]
            }
          }
        },
        "id": "admin-role-group",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-group"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin manage DocumentReference",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "DocumentReference"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead",
                "FhirUpdate"
              ]
            }
          }
        },
        "id": "admin-role-document-reference",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-document-reference"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin access to settings endpoints",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "request": {
            "uri": {
              "$one-of": [
                "/api/v1/settings/introspect",
                "^/api/v1/settings/.*"
              ]
            }
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead",
                "FhirUpdate"
              ]
            }
          }
        },
        "id": "admin-role-settings-introspect",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-settings-introspect"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin access to AwsAccount resources",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "AwsAccount"
          }
        },
        "id": "admin-role-aws-account",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-aws-account"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin access to GcpServiceAccount resources",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "GcpServiceAccount"
          }
        },
        "id": "admin-role-gcp-service-account",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-gcp-service-account"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin search and read AuditEvent resources",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "AuditEvent"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead"
              ]
            }
          }
        },
        "id": "admin-role-audit-event",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-audit-event"
      }
    },
    {
      "resource": {
        "engine": "matcho",
        "description": "Admin search and read Communication resources",
        "matcho": {
          "user": {
            "roles": {
              "$contains": {
                "type": "admin"
              }
            }
          },
          "params": {
            "resource/type": "Communication"
          },
          "operation": {
            "id": {
              "$one-of": [
                "FhirSearch",
                "FhirRead"
              ]
            }
          }
        },
        "id": "admin-role-communication",
        "resourceType": "AccessPolicy"
      },
      "request": {
        "method": "PUT",
        "url": "AccessPolicy/admin-role-communication"
      }
    },
    {
      "resource": {
        "url": "http://aidbox.app/StructureDefinition/AuditEvent/client",
        "id": "AuditEvent.client",
        "base": [
          "AuditEvent"
        ],
        "expression": "AuditEvent.agent.who.identifier.value",
        "name": "client",
        "status": "active",
        "type": "token",
        "resourceType": "SearchParameter",
        "code": "client",
        "description": "Filter AuditEvent by client identifier (agent.who.identifier.value)"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/AuditEvent.client"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "plannet-practitionerrole-network",
        "url": "http://hl7.org/fhir/us/davinci-pdex-plan-net/SearchParameter/practitionerrole-network",
        "version": "1.2.0-aidbox-fixed",
        "name": "Plannet_sp_practitionerrole_network",
        "status": "active",
        "description": "Select roles where the practitioner is a member of the specified health insurance provider network. NOTE: the IG 1.2.0 expression is missing the trailing .value (selects the Extension, not the Reference) and Aidbox cannot compile it - fixed here.",
        "code": "network",
        "base": [
          "PractitionerRole"
        ],
        "type": "reference",
        "expression": "PractitionerRole.extension.where(url='http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/network-reference').value"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/plannet-practitionerrole-network"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "AuthConfig/smartbox"
      },
      "resource": {
        "id": "smartbox",
        "resourceType": "AuthConfig",
        "theme": {
          "styleUrl": "http://localhost:8095/auth.css"
        }
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "NotificationTemplate/auth-signup-email"
      },
      "resource": {
        "resourceType": "NotificationTemplate",
        "subject": "Confirm your Member Account",
        "template": "\n<h3>Confirm your Member Account</h3>\n<p>Hi {{params.resource.firstName}},</p>\n<p>Thank you for registering on the FHIR Access Portal.</p>\n<p><a target=\"_blank\" href=\"{{params.base-url}}/auth/signup/confirm/{{id}}?redirect_to=aHR0cDovL2xvY2FsaG9zdDo4MDk1L2FkbWluL2F1dGgvc2lnbnVwP2NvbmZpcm1QYXNzd29yZD10cnVl\">Confirm your account</a></p>\n<p>After confirmation, you'll be able to access and manage your connected apps.</p>\n<p>If you didn't request this, please ignore this email.</p>"
      }
    },
    {
      "resource": {
        "resourceType": "SearchParameter",
        "id": "Consent-provision-type",
        "url": "http://hl7.org/fhir/SearchParameter/Consent-provision-type",
        "name": "provision-type",
        "status": "active",
        "description": "Type of consent provision (deny or permit)",
        "code": "provision-type",
        "base": [
          "Consent"
        ],
        "type": "token",
        "expression": "Consent.provision.type"
      },
      "request": {
        "method": "PUT",
        "url": "SearchParameter/Consent-provision-type"
      }
    },
    {
      "request": {
        "method": "PUT",
        "url": "CodeSystem/rfc3986-hrex-consent-policy"
      },
      "resource": {
        "resourceType": "CodeSystem",
        "id": "rfc3986-hrex-consent-policy",
        "url": "urn:ietf:rfc:3986",
        "name": "RFC3986HRexConsentPolicyFragment",
        "title": "RFC 3986 URIs of the HRex consent policies",
        "status": "active",
        "experimental": false,
        "description": "Fragment of the URI code system (urn:ietf:rfc:3986) holding the two HRex consent policy URIs, so the hrex-consent-policy value set expands and the hrex-consent profile validates on this box. Needed while the terminology server does not define urn:ietf:rfc:3986 (smartbox docs/issue-847/HREX_PROFILE_ENABLEMENT_PLAN.md).",
        "caseSensitive": true,
        "content": "fragment",
        "concept": [
          {
            "code": "http://hl7.org/fhir/us/davinci-hrex/StructureDefinition-hrex-consent.html#regular"
          },
          {
            "code": "http://hl7.org/fhir/us/davinci-hrex/StructureDefinition-hrex-consent.html#sensitive"
          }
        ]
      }
    },
    {
      "resource": {
        "description": "Member opt-in consent for Payer-to-Payer data exchange under CMS-0057-F (42 CFR 422.121(b)(2)). Captures the member's decision to authorize their current health plan to request health records from previous and concurrent payers, the sharing scope (all data or only non-sensitive data), a withdrawal of an earlier authorization, the other plans named, and an authorized-representative workflow with document upload. Answers are recorded as a QuestionnaireResponse; an opt-in becomes a Da Vinci HRex Consent. Reference copy branded for a fictional \"Example Health Plan\"; deployments ship their own branded copy under the same canonical URL.",
        "subjectType": [
          "Patient"
        ],
        "date": "2026-10-12",
        "publisher": "Example Health Plan",
        "name": "P2PMemberConsent",
        "item": [
          {
            "text": "Sharing your data can help better coordinate your care, make your medical records more complete if you change insurance carriers, and reduce disruptions in your care.",
            "type": "display",
            "linkId": "intro"
          },
          {
            "item": [
              {
                "text": "First name",
                "type": "string",
                "linkId": "member-given-name",
                "required": true
              },
              {
                "text": "Last name",
                "type": "string",
                "linkId": "member-family-name",
                "required": true
              },
              {
                "text": "Date of birth",
                "type": "date",
                "linkId": "member-dob",
                "required": true
              },
              {
                "text": "Member ID (current plan)",
                "type": "string",
                "linkId": "member-id",
                "required": true
              },
              {
                "text": "Phone number",
                "type": "string",
                "linkId": "member-phone"
              },
              {
                "text": "Email address",
                "type": "string",
                "linkId": "member-email"
              }
            ],
            "text": "Member information",
            "type": "group",
            "linkId": "member"
          },
          {
            "item": [
              {
                "linkId": "prior-plan-organization",
                "text": "Health plan",
                "type": "reference",
                "required": true,
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource",
                    "valueCode": "Organization"
                  }
                ]
              },
              {
                "text": "Member ID with that plan (optional)",
                "type": "string",
                "linkId": "prior-plan-member-id"
              },
              {
                "text": "How were you covered under that plan?",
                "type": "choice",
                "linkId": "prior-plan-relationship",
                "required": true,
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                    "valueCodeableConcept": {
                      "coding": [
                        {
                          "code": "radio-button",
                          "system": "http://hl7.org/fhir/questionnaire-item-control",
                          "display": "Radio Button"
                        }
                      ]
                    }
                  }
                ],
                "answerOption": [
                  {
                    "valueCoding": {
                      "code": "self",
                      "system": "http://terminology.hl7.org/CodeSystem/subscriber-relationship",
                      "display": "In my own name"
                    }
                  },
                  {
                    "valueCoding": {
                      "code": "spouse",
                      "system": "http://terminology.hl7.org/CodeSystem/subscriber-relationship",
                      "display": "Through my spouse or partner"
                    }
                  },
                  {
                    "valueCoding": {
                      "code": "child",
                      "system": "http://terminology.hl7.org/CodeSystem/subscriber-relationship",
                      "display": "Through my parent"
                    }
                  },
                  {
                    "valueCoding": {
                      "code": "other",
                      "system": "http://terminology.hl7.org/CodeSystem/subscriber-relationship",
                      "display": "Another way"
                    }
                  }
                ]
              },
              {
                "linkId": "prior-plan-kind",
                "type": "choice",
                "required": true,
                "text": "Do you still have that plan?",
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                    "valueCodeableConcept": {
                      "coding": [
                        {
                          "code": "radio-button",
                          "system": "http://hl7.org/fhir/questionnaire-item-control",
                          "display": "Radio Button"
                        }
                      ]
                    }
                  }
                ],
                "answerOption": [
                  {
                    "valueCoding": {
                      "code": "previous",
                      "display": "No, I had it before"
                    }
                  },
                  {
                    "valueCoding": {
                      "code": "concurrent",
                      "display": "Yes, I have it now too"
                    }
                  }
                ]
              }
            ],
            "text": "Previous or concurrent health plan",
            "type": "group",
            "linkId": "prior-plan",
            "repeats": true,
            "enableWhen": [
              {
                "question": "consent-choice",
                "operator": "!=",
                "answerCoding": {
                  "code": "withdraw"
                }
              }
            ]
          },
          {
            "item": [
              {
                "text": "Some health information receives extra protection under federal and state law: for example, behavioral health and substance use disorder treatment records, HIV/AIDS, and genetic information.",
                "type": "display",
                "linkId": "sensitive-info-note"
              },
              {
                "text": "What information do you give us permission to request from your other health plans?",
                "type": "choice",
                "linkId": "consent-choice",
                "required": true,
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                    "valueCodeableConcept": {
                      "coding": [
                        {
                          "code": "radio-button",
                          "system": "http://hl7.org/fhir/questionnaire-item-control",
                          "display": "Radio Button"
                        }
                      ]
                    }
                  }
                ],
                "answerOption": [
                  {
                    "valueCoding": {
                      "code": "opt-in-full",
                      "display": "All of my health information, including sensitive information."
                    }
                  },
                  {
                    "valueCoding": {
                      "code": "opt-in-non-sensitive",
                      "display": "Only non-sensitive information. Do not request my sensitive information."
                    }
                  },
                  {
                    "valueCoding": {
                      "code": "withdraw",
                      "display": "Withdraw my permission. Do not request my records from my other health plans."
                    }
                  }
                ]
              },
              {
                "linkId": "authorization-end-date",
                "type": "date",
                "readOnly": true,
                "text": "Your permission runs until this date unless you withdraw it earlier",
                "enableWhen": [
                  {
                    "question": "consent-choice",
                    "operator": "!=",
                    "answerCoding": {
                      "code": "withdraw"
                    }
                  }
                ]
              },
              {
                "text": "Records we already received stay in your file.",
                "type": "display",
                "linkId": "decision-note"
              }
            ],
            "text": "Your decision",
            "type": "group",
            "linkId": "decision"
          },
          {
            "item": [
              {
                "text": "Who is completing this form?",
                "type": "choice",
                "linkId": "signer-relationship",
                "required": true,
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                    "valueCodeableConcept": {
                      "coding": [
                        {
                          "code": "radio-button",
                          "system": "http://hl7.org/fhir/questionnaire-item-control",
                          "display": "Radio Button"
                        }
                      ]
                    }
                  }
                ],
                "answerOption": [
                  {
                    "valueCoding": {
                      "code": "self",
                      "display": "Member (myself)"
                    }
                  },
                  {
                    "valueCoding": {
                      "code": "representative",
                      "display": "Authorized representative"
                    }
                  }
                ]
              },
              {
                "item": [
                  {
                    "text": "Representative name and relationship to member",
                    "type": "string",
                    "linkId": "representative-name",
                    "required": true
                  },
                  {
                    "text": "Basis of authority",
                    "type": "choice",
                    "linkId": "representative-authority",
                    "required": true,
                    "extension": [
                      {
                        "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                        "valueCodeableConcept": {
                          "coding": [
                            {
                              "code": "radio-button",
                              "system": "http://hl7.org/fhir/questionnaire-item-control",
                              "display": "Radio Button"
                            }
                          ]
                        }
                      }
                    ],
                    "answerOption": [
                      {
                        "valueCoding": {
                          "code": "power-of-attorney",
                          "display": "Power of Attorney"
                        }
                      },
                      {
                        "valueCoding": {
                          "code": "legal-guardian",
                          "display": "Legal guardian"
                        }
                      },
                      {
                        "valueCoding": {
                          "code": "other",
                          "display": "Other"
                        }
                      }
                    ]
                  },
                  {
                    "text": "Describe your authority",
                    "type": "string",
                    "linkId": "representative-authority-other",
                    "required": true,
                    "enableWhen": [
                      {
                        "answerCoding": {
                          "code": "other"
                        },
                        "operator": "=",
                        "question": "representative-authority"
                      }
                    ]
                  },
                  {
                    "text": "Document that shows your authority",
                    "type": "attachment",
                    "linkId": "representative-doc",
                    "required": true
                  }
                ],
                "text": "Authorized representative details",
                "type": "group",
                "linkId": "representative",
                "enableWhen": [
                  {
                    "answerCoding": {
                      "code": "representative"
                    },
                    "operator": "=",
                    "question": "signer-relationship"
                  }
                ]
              },
              {
                "text": "Date",
                "type": "date",
                "linkId": "signature-date",
                "required": true
              }
            ],
            "text": "Confirmation",
            "type": "group",
            "linkId": "signature"
          },
          {
            "text": "Questions? Call Member Services at 1-800-555-0123 (TTY 711), Monday through Friday, 8 a.m. to 8 p.m.",
            "type": "display",
            "linkId": "questions-note"
          },
          {
            "text": "If you speak a language other than English, free language assistance services are available to you. Call 1-800-555-0123 (TTY 711).",
            "type": "display",
            "linkId": "form-footer"
          }
        ],
        "resourceType": "Questionnaire",
        "title": "Example Health Plan: Payer-to-Payer Data Exchange Consent",
        "status": "active",
        "id": "p2p-member-consent",
        "url": "http://healthsamurai.io/fhir/Questionnaire/p2p-member-consent",
        "version": "1.3.0",
        "experimental": false
      },
      "request": {
        "method": "PUT",
        "url": "Questionnaire/p2p-member-consent"
      }
    },
    {
      "resource": {
        "description": "Member opt-out form for Provider Access API data sharing under CMS-0057-F (42 CFR 422.121(a)(4)). Sharing with in-network treating providers is on by default; this form captures the member's choice to opt out or to resume sharing, with an authorized-representative workflow with document upload. Answers are recorded as a QuestionnaireResponse; the choice becomes a Da Vinci PDex Provider Consent (provision.type deny = opt out, permit = share). Reference copy branded for a fictional \"Example Health Plan\"; deployments ship their own branded copy under the same canonical URL.",
        "subjectType": [
          "Patient"
        ],
        "date": "2026-10-12",
        "publisher": "Example Health Plan",
        "name": "ProviderAccessMemberOptOut",
        "item": [
          {
            "text": "Sharing your data can help your providers better coordinate your care, improve prior authorization processes, and make sure you receive care in a timely manner.",
            "type": "display",
            "linkId": "intro"
          },
          {
            "item": [
              {
                "text": "Full name",
                "type": "string",
                "linkId": "member-name",
                "required": true
              },
              {
                "text": "Date of birth",
                "type": "date",
                "linkId": "member-dob",
                "required": true
              },
              {
                "text": "Member ID",
                "type": "string",
                "linkId": "member-id",
                "required": true
              },
              {
                "text": "Phone number",
                "type": "string",
                "linkId": "member-phone"
              },
              {
                "text": "Email address",
                "type": "string",
                "linkId": "member-email"
              }
            ],
            "text": "Member information",
            "type": "group",
            "linkId": "member"
          },
          {
            "item": [
              {
                "linkId": "coverage-note",
                "type": "display",
                "text": "Opting out does not affect your coverage, your benefits, or your providers' ability to treat you."
              },
              {
                "text": "Some health information receives extra protection under federal and state law: for example, behavioral health and substance use disorder treatment records, HIV/AIDS, and genetic information. Your choice applies to all of your health records: sharing with your in-network providers is either on or off.",
                "type": "display",
                "linkId": "sensitive-info-note"
              },
              {
                "text": "Do you want us to share your health information with the in-network providers who treat you?",
                "type": "choice",
                "linkId": "sharing-choice",
                "required": true,
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                    "valueCodeableConcept": {
                      "coding": [
                        {
                          "code": "radio-button",
                          "system": "http://hl7.org/fhir/questionnaire-item-control",
                          "display": "Radio Button"
                        }
                      ]
                    }
                  }
                ],
                "answerOption": [
                  {
                    "valueCoding": {
                      "code": "share-all",
                      "display": "Share my health information with my in-network providers."
                    }
                  },
                  {
                    "valueCoding": {
                      "code": "opt-out",
                      "display": "Opt out: do not share my health information with my in-network providers."
                    }
                  }
                ]
              },
              {
                "text": "Even if you opt out, laws such as HIPAA may still allow your providers to get information they need to treat you.",
                "type": "display",
                "linkId": "decision-note"
              }
            ],
            "text": "Your choice",
            "type": "group",
            "linkId": "decision"
          },
          {
            "item": [
              {
                "text": "Who is completing this form?",
                "type": "choice",
                "linkId": "signer-relationship",
                "required": true,
                "extension": [
                  {
                    "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                    "valueCodeableConcept": {
                      "coding": [
                        {
                          "code": "radio-button",
                          "system": "http://hl7.org/fhir/questionnaire-item-control",
                          "display": "Radio Button"
                        }
                      ]
                    }
                  }
                ],
                "answerOption": [
                  {
                    "valueCoding": {
                      "code": "self",
                      "display": "Member (myself)"
                    }
                  },
                  {
                    "valueCoding": {
                      "code": "representative",
                      "display": "Authorized representative"
                    }
                  }
                ]
              },
              {
                "item": [
                  {
                    "text": "Representative name and relationship to member",
                    "type": "string",
                    "linkId": "representative-name",
                    "required": true
                  },
                  {
                    "text": "Basis of authority",
                    "type": "choice",
                    "linkId": "representative-authority",
                    "required": true,
                    "extension": [
                      {
                        "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                        "valueCodeableConcept": {
                          "coding": [
                            {
                              "code": "radio-button",
                              "system": "http://hl7.org/fhir/questionnaire-item-control",
                              "display": "Radio Button"
                            }
                          ]
                        }
                      }
                    ],
                    "answerOption": [
                      {
                        "valueCoding": {
                          "code": "power-of-attorney",
                          "display": "Power of Attorney"
                        }
                      },
                      {
                        "valueCoding": {
                          "code": "legal-guardian",
                          "display": "Legal guardian"
                        }
                      },
                      {
                        "valueCoding": {
                          "code": "other",
                          "display": "Other"
                        }
                      }
                    ]
                  },
                  {
                    "text": "Describe your authority",
                    "type": "string",
                    "linkId": "representative-authority-other",
                    "required": true,
                    "enableWhen": [
                      {
                        "answerCoding": {
                          "code": "other"
                        },
                        "operator": "=",
                        "question": "representative-authority"
                      }
                    ]
                  },
                  {
                    "text": "Document that shows your authority",
                    "type": "attachment",
                    "linkId": "representative-doc",
                    "required": true
                  }
                ],
                "text": "Authorized representative details",
                "type": "group",
                "linkId": "representative",
                "enableWhen": [
                  {
                    "answerCoding": {
                      "code": "representative"
                    },
                    "operator": "=",
                    "question": "signer-relationship"
                  }
                ]
              },
              {
                "text": "Date",
                "type": "date",
                "linkId": "signature-date",
                "required": true
              }
            ],
            "text": "Confirmation",
            "type": "group",
            "linkId": "signature"
          },
          {
            "text": "Questions? Call Member Services at 1-800-555-0123 (TTY 711), Monday through Friday, 8 a.m. to 8 p.m.",
            "type": "display",
            "linkId": "questions-note"
          },
          {
            "text": "If you speak a language other than English, free language assistance services are available to you. Call 1-800-555-0123 (TTY 711).",
            "type": "display",
            "linkId": "form-footer"
          }
        ],
        "resourceType": "Questionnaire",
        "title": "Example Health Plan: Provider Access Data Sharing Opt-Out",
        "status": "active",
        "id": "provider-access-member-opt-out",
        "url": "http://healthsamurai.io/fhir/Questionnaire/provider-access-member-opt-out",
        "version": "1.2.0",
        "experimental": false
      },
      "request": {
        "method": "PUT",
        "url": "Questionnaire/provider-access-member-opt-out"
      }
    },
    {
      "resource": {
        "resourceType": "Client",
        "id": "admin-api",
        "secret": "admin-api-secret-change-in-production",
        "grant_types": [
          "client_credentials"
        ]
      },
      "request": {
        "method": "PUT",
        "url": "Client/admin-api"
      }
    },
    {
      "resource": {
        "resourceType": "User",
        "id": "portal-admin",
        "roles": [
          {
            "type": "admin"
          }
        ],
        "password": "$s0$f0801$B3jOpXU2PUyd3iHLOi1qnw==$AJkfwK1Xu+dYkXWS5dRtrJK2CR3ztWos7NuNDIdtVAU="
      },
      "request": {
        "method": "PUT",
        "url": "User/portal-admin"
      }
    }
  ]
}
