{
  "info": {
    "name": "MedFlo AI Connect API",
    "description": "MedFlo integration (Connect) API — OAuth2 client-credentials, FHIR-aligned reads, and signed webhooks. Set the collection variables (baseUrl, clientId, clientSecret, orgId, facilityId), run 'Get an access token' first, then any resource request.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Get an access token (OAuth2 client-credentials)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/x-www-form-urlencoded"
          }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            {
              "key": "grant_type",
              "value": "client_credentials"
            },
            {
              "key": "client_id",
              "value": "{{clientId}}"
            },
            {
              "key": "client_secret",
              "value": "{{clientSecret}}"
            },
            {
              "key": "scope",
              "value": "residents.read coverage.read clinical.read"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/oauth/token",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "oauth",
            "token"
          ]
        },
        "description": "Exchange your issued client credentials for a short-lived bearer token. The test script below captures access_token into {{token}} for the other requests."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const json = pm.response.json();",
              "if (json.access_token) { pm.collectionVariables.set('token', json.access_token); }"
            ]
          }
        }
      ]
    },
    {
      "name": "Patient (Residents)",
      "item": [
        {
          "name": "List residents (FHIR Patient search)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/residents?q=&page=1&page_size=50",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "residents"
              ],
              "query": [
                {
                  "key": "q",
                  "value": ""
                },
                {
                  "key": "page",
                  "value": "1"
                },
                {
                  "key": "page_size",
                  "value": "50"
                }
              ]
            },
            "description": "Requires scope: residents.read"
          }
        },
        {
          "name": "Read a resident (FHIR Patient/{id})",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/residents/:resident_id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "residents",
                ":resident_id"
              ]
            },
            "description": "Requires scope: residents.read"
          }
        }
      ]
    },
    {
      "name": "Coverage",
      "item": [
        {
          "name": "List coverage records (FHIR Coverage search)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/coverage?resident_id=&page=1&page_size=50",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "coverage"
              ],
              "query": [
                {
                  "key": "resident_id",
                  "value": ""
                },
                {
                  "key": "page",
                  "value": "1"
                },
                {
                  "key": "page_size",
                  "value": "50"
                }
              ]
            },
            "description": "Requires scope: coverage.read"
          }
        },
        {
          "name": "Read a coverage record (FHIR Coverage/{id})",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/coverage/:coverage_id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "coverage",
                ":coverage_id"
              ]
            },
            "description": "Requires scope: coverage.read"
          }
        }
      ]
    },
    {
      "name": "Condition",
      "item": [
        {
          "name": "List conditions (FHIR Condition search)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/clinical/Condition?resident_id=&page=1&page_size=50",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "clinical",
                "Condition"
              ],
              "query": [
                {
                  "key": "resident_id",
                  "value": ""
                },
                {
                  "key": "page",
                  "value": "1"
                },
                {
                  "key": "page_size",
                  "value": "50"
                }
              ]
            },
            "description": "Requires scope: clinical.read"
          }
        },
        {
          "name": "Read a condition (FHIR Condition/{id})",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/clinical/Condition/:resource_id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "clinical",
                "Condition",
                ":resource_id"
              ]
            },
            "description": "Requires scope: clinical.read"
          }
        }
      ]
    },
    {
      "name": "MedicationRequest",
      "item": [
        {
          "name": "List medication requests (FHIR search)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/clinical/MedicationRequest?resident_id=&page=1&page_size=50",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "clinical",
                "MedicationRequest"
              ],
              "query": [
                {
                  "key": "resident_id",
                  "value": ""
                },
                {
                  "key": "page",
                  "value": "1"
                },
                {
                  "key": "page_size",
                  "value": "50"
                }
              ]
            },
            "description": "Requires scope: clinical.read"
          }
        },
        {
          "name": "Read a medication request (FHIR read)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/clinical/MedicationRequest/:resource_id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "clinical",
                "MedicationRequest",
                ":resource_id"
              ]
            },
            "description": "Requires scope: clinical.read"
          }
        }
      ]
    },
    {
      "name": "AllergyIntolerance",
      "item": [
        {
          "name": "List allergies (FHIR search)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/clinical/AllergyIntolerance?resident_id=&page=1&page_size=50",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "clinical",
                "AllergyIntolerance"
              ],
              "query": [
                {
                  "key": "resident_id",
                  "value": ""
                },
                {
                  "key": "page",
                  "value": "1"
                },
                {
                  "key": "page_size",
                  "value": "50"
                }
              ]
            },
            "description": "Requires scope: clinical.read"
          }
        },
        {
          "name": "Read an allergy (FHIR read)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/clinical/AllergyIntolerance/:resource_id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "clinical",
                "AllergyIntolerance",
                ":resource_id"
              ]
            },
            "description": "Requires scope: clinical.read"
          }
        }
      ]
    },
    {
      "name": "Observation",
      "item": [
        {
          "name": "List observations (FHIR search)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/clinical/Observation?resident_id=&page=1&page_size=50",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "clinical",
                "Observation"
              ],
              "query": [
                {
                  "key": "resident_id",
                  "value": ""
                },
                {
                  "key": "page",
                  "value": "1"
                },
                {
                  "key": "page_size",
                  "value": "50"
                }
              ]
            },
            "description": "Requires scope: clinical.read"
          }
        },
        {
          "name": "Read an observation (FHIR read)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{:orgId}/{:facilityId}/clinical/Observation/:resource_id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{:orgId}",
                "{:facilityId}",
                "clinical",
                "Observation",
                ":resource_id"
              ]
            },
            "description": "Requires scope: clinical.read"
          }
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "Register a subscription",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"callback_url\": \"https://example.com/hooks/medflo\",\n  \"event_types\": [\n    \"resident.admitted\",\n    \"coverage.updated\"\n  ],\n  \"description\": \"prod ingest\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{{orgId}}/webhooks",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{{orgId}}",
                "webhooks"
              ]
            },
            "description": "Requires scope: webhooks.manage. signing_secret is returned once."
          }
        },
        {
          "name": "List subscriptions",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{{orgId}}/webhooks",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{{orgId}}",
                "webhooks"
              ]
            }
          }
        },
        {
          "name": "Fire a signed test event",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"event_type\": \"resident.admitted\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{{orgId}}/webhooks/:id/test",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{{orgId}}",
                "webhooks",
                ":id",
                "test"
              ]
            }
          }
        },
        {
          "name": "Revoke a subscription",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{token}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/ofctx/{{orgId}}/webhooks/:id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "ofctx",
                "{{orgId}}",
                "webhooks",
                ":id"
              ]
            }
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://medflo-pcc-vendor-api-eez5kqwsxa-uw.a.run.app"
    },
    {
      "key": "clientId",
      "value": ""
    },
    {
      "key": "clientSecret",
      "value": ""
    },
    {
      "key": "orgId",
      "value": "sandbox-org-0001"
    },
    {
      "key": "facilityId",
      "value": "sandbox-fac-0001"
    },
    {
      "key": "token",
      "value": ""
    }
  ]
}