{
  "info": {
    "_postman_id": "6d37c7bf-9ca6-452a-a819-0d1b1d8d4f42",
    "name": "MedDossier Handoff Integration Kit",
    "description": "Generated starter collection for MedDossier workspace authentication, account recovery, public intake, reviewer operations, order sharing, hospital webhook dispatch, and FHIR export.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "http://127.0.0.1:8000"
    },
    {
      "key": "accessToken",
      "value": ""
    },
    {
      "key": "refreshToken",
      "value": ""
    },
    {
      "key": "reviewerEmail",
      "value": "review@meddossier.local"
    },
    {
      "key": "reviewerPassword",
      "value": "MedDossier123!"
    },
    {
      "key": "resetToken",
      "value": ""
    },
    {
      "key": "previewResetUrl",
      "value": ""
    },
    {
      "key": "orderId",
      "value": "ord_demo_001"
    },
    {
      "key": "orderAccessToken",
      "value": ""
    },
    {
      "key": "deliveryId",
      "value": "wh_demo_001"
    },
    {
      "key": "hospitalCode",
      "value": "demo-hospital"
    },
    {
      "key": "hospitalApiKey",
      "value": "hospital-demo-key"
    }
  ],
  "item": [
    {
      "name": "Auth and Account",
      "item": [
        {
          "name": "Demo Login Reviewer",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/auth/demo",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "auth",
                "demo"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"role\": \"reviewer\"\n}"
            },
            "description": "Use seeded demo credentials to obtain a reviewer token and populate collection variables."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const payload = pm.response.json();",
                  "if (payload.access_token) pm.collectionVariables.set('accessToken', payload.access_token);",
                  "if (payload.refresh_token) pm.collectionVariables.set('refreshToken', payload.refresh_token);",
                  "if (payload.user_email) pm.collectionVariables.set('reviewerEmail', payload.user_email);"
                ]
              }
            }
          ]
        },
        {
          "name": "Workspace Login",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/auth/login",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "auth",
                "login"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"{{reviewerEmail}}\",\n  \"password\": \"{{reviewerPassword}}\"\n}"
            },
            "description": "Authenticate against the real email/password login route and save the returned token pair."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const payload = pm.response.json();",
                  "if (payload.access_token) pm.collectionVariables.set('accessToken', payload.access_token);",
                  "if (payload.refresh_token) pm.collectionVariables.set('refreshToken', payload.refresh_token);",
                  "if (payload.user_email) pm.collectionVariables.set('reviewerEmail', payload.user_email);"
                ]
              }
            }
          ]
        },
        {
          "name": "Refresh Session",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/auth/refresh",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "auth",
                "refresh"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"refresh_token\": \"{{refreshToken}}\"\n}"
            },
            "description": "Exchange the current refresh token for a fresh access token pair."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const payload = pm.response.json();",
                  "if (payload.access_token) pm.collectionVariables.set('accessToken', payload.access_token);",
                  "if (payload.refresh_token) pm.collectionVariables.set('refreshToken', payload.refresh_token);",
                  "if (payload.user_email) pm.collectionVariables.set('reviewerEmail', payload.user_email);"
                ]
              }
            }
          ]
        },
        {
          "name": "Current User",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/api/v1/auth/me",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "auth",
                "me"
              ]
            },
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{accessToken}}"
              }
            ],
            "description": "Inspect the current role context after login."
          }
        },
        {
          "name": "Request Password Reset",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/auth/password-reset/request",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "auth",
                "password-reset",
                "request"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"{{reviewerEmail}}\"\n}"
            },
            "description": "Request a password reset email. In demo or local mode, the preview URL is captured into collection variables so the token can be validated immediately."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const payload = pm.response.json();",
                  "if (payload.preview_url) {",
                  "  pm.collectionVariables.set('previewResetUrl', payload.preview_url);",
                  "  const tokenMatch = payload.preview_url.match(/[?&]token=([^&]+)/);",
                  "  if (tokenMatch && tokenMatch[1]) {",
                  "    pm.collectionVariables.set('resetToken', decodeURIComponent(tokenMatch[1]));",
                  "  }",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "Validate Password Reset Token",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/api/v1/auth/password-reset/validate",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "auth",
                "password-reset",
                "validate"
              ],
              "query": [
                {
                  "key": "token",
                  "value": "{{resetToken}}"
                }
              ]
            },
            "description": "Check whether the reset token is still active before submitting a new password."
          }
        },
        {
          "name": "Confirm Password Reset",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/auth/password-reset/confirm",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "auth",
                "password-reset",
                "confirm"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"token\": \"{{resetToken}}\",\n  \"new_password\": \"ResetReady123!\"\n}"
            },
            "description": "Consume the reset token and set a new password for the selected account."
          }
        }
      ]
    },
    {
      "name": "Public Intake",
      "item": [
        {
          "name": "Create Partner Lead",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/public/partner-leads",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "public",
                "partner-leads"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"organization_name\": \"Global Care Center\",\n  \"contact_name\": \"Alice Wong\",\n  \"contact_email\": \"alice@example.com\",\n  \"contact_phone\": \"+61 400 000 000\",\n  \"organization_type\": \"International patient program\",\n  \"monthly_case_volume\": \"10-30 per month\",\n  \"lead_source\": \"Website demo request\",\n  \"decision_timeline\": \"Within this quarter\",\n  \"intent_level\": \"active\",\n  \"primary_use_case\": \"Need structured bilingual oncology intake packets before second opinion review.\",\n  \"notes\": \"Pilot starts with one service line and one coordinator team.\"\n}"
            }
          }
        },
        {
          "name": "Create Compliance Request",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/public/compliance-requests",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "public",
                "compliance-requests"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"request_type\": \"privacy\",\n  \"requester_name\": \"Jamie Lee\",\n  \"requester_email\": \"jamie@example.com\",\n  \"relationship_to_patient\": \"Patient\",\n  \"patient_name\": \"Jamie Lee\",\n  \"details\": \"Please confirm how long my uploaded records are retained in the demo environment.\",\n  \"preferred_resolution\": \"Email response\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Review Operations",
      "item": [
        {
          "name": "Review Queue",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/api/v1/review/queue",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "review",
                "queue"
              ]
            },
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{accessToken}}"
              }
            ]
          }
        },
        {
          "name": "Update IPS Draft",
          "request": {
            "method": "PATCH",
            "url": {
              "raw": "{{baseUrl}}/api/v1/review/{{orderId}}/ips",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "review",
                "{{orderId}}",
                "ips"
              ]
            },
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{accessToken}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"allergies\": [\n    {\n      \"substance\": \"Penicillin\",\n      \"reaction\": \"Rash\"\n    }\n  ],\n  \"medications\": [\n    {\n      \"cn_name\": \"Metformin\",\n      \"generic\": \"500mg BID\"\n    }\n  ],\n  \"reviewer_edits\": {\n    \"review_notes\": \"Source medications and allergies verified against uploaded discharge summary.\",\n    \"risk_summary\": \"Missing one pathology appendix; current packet still usable for first-pass intake.\",\n    \"release_checklist\": {\n      \"authorization_confirmed\": true,\n      \"source_documents_checked\": true,\n      \"ai_extraction_checked\": true,\n      \"alerts_assessed\": true,\n      \"ready_for_handoff\": false\n    }\n  }\n}"
            }
          }
        },
        {
          "name": "Approve Review",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/review/{{orderId}}/approve",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "review",
                "{{orderId}}",
                "approve"
              ]
            },
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{accessToken}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"notes\": \"Reviewer approved for packet generation.\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Orders and Sharing",
      "item": [
        {
          "name": "Create Order",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/orders",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "orders"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"patient_name\": \"Jamie Lee\",\n  \"contact_email\": \"jamie@example.com\",\n  \"contact_phone\": \"+61 400 111 111\",\n  \"nationality\": \"Australia\",\n  \"purpose\": \"Second opinion preparation\",\n  \"target_hospital\": \"Demo International Center\",\n  \"target_department\": \"Oncology\",\n  \"appointment_date\": \"2026-05-01\",\n  \"authorization_scope\": \"records_and_hospital_contact\",\n  \"authorization_confirmed\": true,\n  \"package_type\": \"standard\",\n  \"payment_method\": \"stripe\"\n}"
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const payload = pm.response.json();",
                  "if (payload.id) pm.collectionVariables.set('orderId', payload.id);",
                  "if (payload.order_access_token) pm.collectionVariables.set('orderAccessToken', payload.order_access_token);"
                ]
              }
            }
          ]
        },
        {
          "name": "Get Patient Order",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/api/v1/orders/{{orderId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "orders",
                "{{orderId}}"
              ]
            },
            "header": [
              {
                "key": "X-Order-Access-Token",
                "value": "{{orderAccessToken}}"
              }
            ],
            "description": "Resolve the patient-facing order view using the signed order access token returned at order creation time."
          }
        },
        {
          "name": "Share Packet",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/orders/{{orderId}}/share",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "orders",
                "{{orderId}}",
                "share"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Order-Access-Token",
                "value": "{{orderAccessToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"hours\": 72\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Hospital Handoff",
      "item": [
        {
          "name": "Trigger Upload Invitation",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/hospital/trigger-upload",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "hospital",
                "trigger-upload"
              ]
            },
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-hospital-api-key",
                "value": "{{hospitalApiKey}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"hospital_code\": \"{{hospitalCode}}\",\n  \"patient_name\": \"Jamie Lee\",\n  \"appointment_date\": \"2026-05-01\",\n  \"department\": \"Oncology\",\n  \"contact_email\": \"jamie@example.com\",\n  \"contact_phone\": \"+61 400 111 111\"\n}"
            }
          }
        },
        {
          "name": "Dispatch Packet Webhook",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/hospital/orders/{{orderId}}/dispatch-webhook",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "hospital",
                "orders",
                "{{orderId}}",
                "dispatch-webhook"
              ],
              "query": [
                {
                  "key": "force",
                  "value": "true"
                }
              ]
            },
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{accessToken}}"
              }
            ]
          }
        },
        {
          "name": "FHIR Bundle Export",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/api/v1/hospital/orders/{{orderId}}/fhir-bundle",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "hospital",
                "orders",
                "{{orderId}}",
                "fhir-bundle"
              ]
            },
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{accessToken}}"
              }
            ]
          }
        },
        {
          "name": "Retry Webhook Delivery",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{baseUrl}}/api/v1/hospital/webhooks/{{deliveryId}}/retry",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "hospital",
                "webhooks",
                "{{deliveryId}}",
                "retry"
              ],
              "query": [
                {
                  "key": "force",
                  "value": "true"
                }
              ]
            },
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{accessToken}}"
              }
            ]
          }
        }
      ]
    }
  ]
}