Skip to main content
POST
/
medical
/
v1
/
cohort
/
{id}
/
patient
Add Patients to Cohort
curl --request POST \
  --url https://api.sandbox.metriport.com/medical/v1/cohort/{id}/patient \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "patientIds": [
    "<string>"
  ],
  "allPatients": true
}'
import { MetriportMedicalApi } from "@metriport/api-sdk";

const metriport = new MetriportMedicalApi("YOUR_API_KEY");

// Add specific patients to cohort
const cohortWithPatients = await metriport.addPatientsToCohort({
  cohortId: "00000000-0000-0000-0000-000000000000",
  patientIds: [
    "11111111-1111-1111-1111-111111111111",
    "22222222-2222-2222-2222-222222222222"
  ]
});

// Add all patients to cohort
const cohortWithAllPatients = await metriport.addPatientsToCohort({
  cohortId: "00000000-0000-0000-0000-000000000000",
  allPatients: true
});
For more information, see the guide about Cohorts

Path Params

id
string
required
The ID of the cohort to assign patients to.

Body

You must provide either patientIds or allPatients, but not both.
patientIds
string[]
Array of patient IDs to assign to the cohort. Mutually exclusive with the allPatients property.
allPatients
boolean
Property to confirm you want to assign all patients in your metriport instance to the cohort. Mutually exclusive with the patientIds array.

Response

message
string
required
Confirmation message indicating the operation was successful.
cohort
cohort
required
The cohort details.
import { MetriportMedicalApi } from "@metriport/api-sdk";

const metriport = new MetriportMedicalApi("YOUR_API_KEY");

// Add specific patients to cohort
const cohortWithPatients = await metriport.addPatientsToCohort({
  cohortId: "00000000-0000-0000-0000-000000000000",
  patientIds: [
    "11111111-1111-1111-1111-111111111111",
    "22222222-2222-2222-2222-222222222222"
  ]
});

// Add all patients to cohort
const cohortWithAllPatients = await metriport.addPatientsToCohort({
  cohortId: "00000000-0000-0000-0000-000000000000",
  allPatients: true
});
{
  "message": "Patient(s) successfully added to cohort",
  "cohort": {
    "id": "00000000-0000-0000-0000-000000000000",
    "eTag": "1",
    "name": "High Risk",
    "description": "Patients that need frequent and robust monitoring.",
    "color": "red",
    "settings": {
        "monitoring": {
          "hie": {
            "enabled": true,
            "frequency": "weekly"
          },
          "adt": {
            "enabled": true
          },
          "pharmacy": {
            "notifications": true,
            "schedule": {
              "enabled": false,
              "frequency": "monthly"
            }
          },
          "laboratory": {
            "notifications": true,
            "schedule": {
              "enabled": false,
              "frequency": "monthly"
            }
          }
        }
    },
    "size": 250
  }
}