# health.hats.requestAccess

> Pick options from the menu for one patient. The coordinator decides by policy and returns, per pick, the space address or pending while a patient or circle approval is outstanding. It never says whether a space holds records; the requester learns that by syncing. Authenticated as the clinician (service auth) and the institution node (client attestation).

- Kind: procedure
- Authority: hats.health
- Lexicon: 1
- Published by [hats.health](https://lexicon.garden/identity/did:plc:uvvhtareovj2oaregs7vsibv), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:uvvhtareovj2oaregs7vsibv/health.hats.requestAccess)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:uvvhtareovj2oaregs7vsibv/health.hats.requestAccess/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:uvvhtareovj2oaregs7vsibv/health.hats.requestAccess/analytics)

## Procedure (`health.hats.requestAccess`)

Type: procedure · POST

### Input (application/json)

- `patient` (string · did, required): The patient: the authority of the spaces asked for.
- `picks` (array, required): Option ids from listAccessOptions under the same reason. 'tier' picks every option on the menu.
  - Constraints: minLength: 1
  - `items` (string)
- `reason` (ref, required)
  - Reference: `#reason`

### Output (application/json)

- `results` (array, required)
  - `items` (ref)
    - Reference: `#result`

### Errors

- `InvalidReason`: The reason code is not one the coordinator accepts.
- `InvalidPick`: A pick is not on the caller's menu for this reason.

## #reason (`health.hats.requestAccess#reason`)

Type: object

### Properties

- `code` (string, required): HL7 PurposeOfUse code, in the code system's case. Matched exactly: a policy for ETREAT does not cover ERTREAT or BTG.
  - Constraints: knownValues: TREAT | ETREAT | ERTREAT | BTG
- `description` (string): Free-text justification. A BTG renewal needs a new one.

## #result (`health.hats.requestAccess#result`)

Type: object

The outcome of one picked option.

### Properties

- `option` (string, required): The option id.
- `space` (string · space-ref): The space address, at://{patient}/space/{spaceType}/{skey}. Present when granted.
- `status` (string, required)
  - Constraints: knownValues: granted | pending

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Pick options from the menu for one patient. The coordinator decides by policy and returns, per pick, the space address or pending while a patient or circle approval is outstanding. It never says whether a space holds records; the requester learns that by syncing. Authenticated as the clinician (service auth) and the institution node (client attestation).",
      "errors": [
        {
          "description": "The reason code is not one the coordinator accepts.",
          "name": "InvalidReason"
        },
        {
          "description": "A pick is not on the caller's menu for this reason.",
          "name": "InvalidPick"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "patient": {
              "description": "The patient: the authority of the spaces asked for.",
              "format": "did",
              "type": "string"
            },
            "picks": {
              "description": "Option ids from listAccessOptions under the same reason. 'tier' picks every option on the menu.",
              "items": {
                "type": "string"
              },
              "minLength": 1,
              "type": "array"
            },
            "reason": {
              "ref": "#reason",
              "type": "ref"
            }
          },
          "required": [
            "patient",
            "reason",
            "picks"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "results": {
              "items": {
                "ref": "#result",
                "type": "ref"
              },
              "type": "array"
            }
          },
          "required": [
            "results"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    },
    "reason": {
      "properties": {
        "code": {
          "description": "HL7 PurposeOfUse code, in the code system's case. Matched exactly: a policy for ETREAT does not cover ERTREAT or BTG.",
          "knownValues": [
            "TREAT",
            "ETREAT",
            "ERTREAT",
            "BTG"
          ],
          "type": "string"
        },
        "description": {
          "description": "Free-text justification. A BTG renewal needs a new one.",
          "type": "string"
        }
      },
      "required": [
        "code"
      ],
      "type": "object"
    },
    "result": {
      "description": "The outcome of one picked option.",
      "properties": {
        "option": {
          "description": "The option id.",
          "type": "string"
        },
        "space": {
          "description": "The space address, at://{patient}/space/{spaceType}/{skey}. Present when granted.",
          "format": "space-ref",
          "type": "string"
        },
        "status": {
          "knownValues": [
            "granted",
            "pending"
          ],
          "type": "string"
        }
      },
      "required": [
        "option",
        "status"
      ],
      "type": "object"
    }
  },
  "id": "health.hats.requestAccess",
  "lexicon": 1
}
```
