For AI agents: the documentation index is at /docs/aidbox/llms.txt. A Markdown version of this page is available at /docs/aidbox/notebooks.md or by requesting it with the Accept: text/markdown header.
Aidbox Docs
All notebooks

FHIR Connectathon 41

Scripts for Testing the IG

18 cells · updated Jan 13, 2026

This is a read-only view. Responses shown were saved when the notebook was published — open it in your own Aidbox to run the cells against live data.

Instructions

  • You will need the following:
    • A Patient ID
    • A ResearchStudy ID

Get the ResearchStudy

  • Take the id for the study
REST Send Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
GET /ResearchStudy
Response: Body
Status: 200
{
  "resourceType": "Bundle",
  "type": "searchset",
  "meta": {
    "versionId": "0"
  },
  "total": 3,
  "link": [
    {
      "relation": "first",
      "url": "https://xfztpxesfy.edge.aidbox.app/ResearchStudy?page=1"
    },
    {
      "relation": "self",
      "url": "https://xfztpxesfy.edge.aidbox.app/ResearchStudy?page=1"
    }
  ],
  "entry": [
    {
      "resource": {
        "meta": {
          "lastUpdated": "2026-01-08T16:44:48.788144Z",
          "createdAt": "2026-01-08T16:44:48.788144Z",
          "versionId": "521"
        },
        "protocol": [
          {
            "id": "dynamic-visit-schedule-exit-example-PlanDefinition",
            "type": "PlanDefinition",
            "display": "dynamic-visit-schedule-exit-example-PlanDefinition",
            "resourceType": "PlanDefinition"
          }
        ],
        "resourceType": "ResearchStudy",
        "title": "Dynamic Schedule Exit Example",
        "descriptionSummary": "Connectathon-41 SoA: Dynamic Schedule Exit Example",
        "status": "active",
        "id": "Dynamic-Schedule-Exit-Example",
        "identifier": [
          {
            "value": "Dynamic-Schedule-Exit-Example",
            "system": "http://example.org/studies"
          }
        ],
        "primaryPurposeType": {
          "coding": [
            {
              "code": "treatment",
              "system": "http://terminology.hl7.org/CodeSystem/research-study-prim-purp-type"
            }
          ]
        }
      },
      "search": {
        "mode": "match"
      },
      "fullUrl": "https://xfztpxesfy.edge.aidbox.app/ResearchStudy/Dynamic-Schedule-Exit-Example",
      "link": [
        {
          "relation": "self",
          "url": "https://xfztpxesfy.edge.aidbox.app/ResearchStudy/Dynamic-Schedule-Exit-Example"
        }
      ]
    },
    {
      "resource": {
        "meta": {
          "lastUpdated": "2026-01-09T20:00:12.705446Z",
          "createdAt": "2026-01-09T20:00:12.705446Z",
          "versionId": "700"
        },
        "protocol": [
          {
            "id": "dynamic-visit-schedule-multiple-paths",
            "type": "PlanDefinition",
            "display": "dynamic-visit-schedule-multiple-paths",
            "resourceType": "PlanDefinition"
          }
        ],
        "resourceType": "ResearchStudy",
        "title": "Dynamic Schedule Multiple Paths Example",
        "descriptionSummary": "Connectathon-41 SoA: Dynamic Schedule Multiple Paths Example",
        "status": "active",
        "id": "Dynamic-Schedule-Multiple-Paths-Example",
        "identifier": [
          {
            "value": "Dynamic-Schedule-Multiple-Paths-Example",
            "system": "http://example.org/studies"
          }
        ],
        "primaryPurposeType": {
          "coding": [
            {
              "code": "treatment",
              "system": "http://terminology.hl7.org/CodeSystem/research-study-prim-purp-type"
            }
          ]
        }
      },
      "search": {
        "mode": "match"
      },
      "fullUrl": "https://xfztpxesfy.edge.aidbox.app/ResearchStudy/Dynamic-Schedule-Multiple-Paths-Example",
      "link": [
        {
          "relation": "self",
          "url": "https://xfztpxesfy.edge.aidbox.app/ResearchStudy/Dynamic-Schedule-Multiple-Paths-Example"
        }
      ]
    },
    {
      "resource": {
        "meta": {
          "lastUpdated": "2026-01-12T16:16:26.812040Z",
          "createdAt": "2026-01-12T16:16:26.812040Z",
          "versionId": "991"
        },
        "protocol": [
          {
            "id": "dynamic-visit-schedules-cycles-scheduled-interactions",
            "type": "PlanDefinition",
            "display": "dynamic-visit-schedules-cycles-scheduled-interactions",
            "resourceType": "PlanDefinition"
          }
        ],
        "resourceType": "ResearchStudy",
        "title": "Dynamic Schedule Cycles Example",
        "descriptionSummary": "Connectathon-41 SoA: Dynamic Schedule Cycles Example",
        "status": "active",
        "id": "Dynamic-Schedule-Cycles-Example",
        "identifier": [
          {
            "value": "Dynamic-Schedule-Cycles-Example",
            "system": "http://example.org/studies"
          }
        ],
        "primaryPurposeType": {
          "coding": [
            {
              "code": "treatment",
              "system": "http://terminology.hl7.org/CodeSystem/research-study-prim-purp-type"
            }
          ]
        }
      },
      "search": {
        "mode": "match"
      },
      "fullUrl": "https://xfztpxesfy.edge.aidbox.app/ResearchStudy/Dynamic-Schedule-Cycles-Example",
      "link": [
        {
          "relation": "self",
          "url": "https://xfztpxesfy.edge.aidbox.app/ResearchStudy/Dynamic-Schedule-Cycles-Example"
        }
      ]
    }
  ],
  "query-timeout": 60000,
  "query-time": 3
}

Look at ResearchSubject

  • There's no reason why a Patient can't be involved in multiple studies, but lets check
REST Send Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
GET /ResearchSubject?_count=1&page=1
Response: Body
Status: 200
{
  "query-time": 2,
  "meta": {
    "versionId": "0"
  },
  "type": "searchset",
  "resourceType": "Bundle",
  "total": 3,
  "link": [
    {
      "relation": "first",
      "url": "https://xfztpxesfy.edge.aidbox.app/ResearchSubject?_count=1&page=1"
    },
    {
      "relation": "self",
      "url": "https://xfztpxesfy.edge.aidbox.app/ResearchSubject?_count=1&page=1"
    },
    {
      "relation": "next",
      "url": "https://xfztpxesfy.edge.aidbox.app/ResearchSubject?_count=1&page=2"
    },
    {
      "relation": "last",
      "url": "https://xfztpxesfy.edge.aidbox.app/ResearchSubject?_count=1&page=3"
    }
  ],
  "query-timeout": 60000,
  "total-time": 1,
  "entry": [
    {
      "resource": {
        "study": {
          "id": "Dynamic-Schedule-Exit-Example",
          "resourceType": "ResearchStudy"
        },
        "status": "active",
        "subject": {
          "id": "1b521aa1-cafa-4813-aef8-8604529d1797",
          "resourceType": "Patient"
        },
        "identifier": [
          {
            "value": "c2d96544-e7b2-4e6c-95fb-451d8090bc39",
            "system": "http://www.fhir4pharma.com/requestorchestration"
          }
        ],
        "subjectState": [
          {
            "code": {
              "coding": [
                {
                  "code": "on-study",
                  "system": "http://terminology.hl7.org/CodeSystem/research-subject-state"
                }
              ]
            },
            "startDate": "2026-01-10"
          }
        ],
        "id": "Dynamic-Schedule-Exit-Example_001",
        "resourceType": "ResearchSubject",
        "meta": {
          "lastUpdated": "2026-01-10T22:12:12.160618Z",
          "createdAt": "2026-01-10T22:12:12.160618Z",
          "versionId": "861"
        }
      },
      "search": {
        "mode": "match"
      },
      "fullUrl": "https://xfztpxesfy.edge.aidbox.app/ResearchSubject/Dynamic-Schedule-Exit-Example_001",
      "link": [
        {
          "relation": "self",
          "url": "https://xfztpxesfy.edge.aidbox.app/ResearchSubject/Dynamic-Schedule-Exit-Example_001"
        }
      ]
    }
  ]
}

Find a Patient

Search the list of patients

REST Send Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
GET /Patient?page=6&_count=1
Response: Body
Status: 200
{
  "query-time": 2,
  "meta": {
    "versionId": "0"
  },
  "type": "searchset",
  "resourceType": "Bundle",
  "total": 100,
  "link": [
    {
      "relation": "first",
      "url": "https://xfztpxesfy.edge.aidbox.app/Patient?page=1&_count=1"
    },
    {
      "relation": "self",
      "url": "https://xfztpxesfy.edge.aidbox.app/Patient?page=6&_count=1"
    },
    {
      "relation": "next",
      "url": "https://xfztpxesfy.edge.aidbox.app/Patient?page=7&_count=1"
    },
    {
      "relation": "previous",
      "url": "https://xfztpxesfy.edge.aidbox.app/Patient?page=5&_count=1"
    },
    {
      "relation": "last",
      "url": "https://xfztpxesfy.edge.aidbox.app/Patient?page=100&_count=1"
    }
  ],
  "query-timeout": 60000,
  "total-time": 1,
  "entry": [
    {
      "resource": {
        "address": [
          {
            "city": "Dublin",
            "line": [
              "44 Pine St"
            ],
            "country": "FRA",
            "postalCode": "577 20"
          }
        ],
        "meta": {
          "profile": [
            "http://hl7.org/fhir/StructureDefinition/Patient"
          ],
          "lastUpdated": "2025-12-17T09:29:48.627621Z",
          "createdAt": "2025-12-17T09:29:48.627621Z",
          "versionId": "134"
        },
        "name": [
          {
            "use": "official",
            "given": [
              "Maria"
            ],
            "family": "Smith"
          }
        ],
        "birthDate": "1974-11-25",
        "resourceType": "Patient",
        "multipleBirth": {
          "boolean": false
        },
        "active": true,
        "id": "0dde494d-aa30-4141-8a8f-30311cd0bbaf",
        "identifier": [
          {
            "use": "usual",
            "value": "268909475",
            "system": "urn:oid:2.16.840.1.113883.4.1"
          }
        ],
        "telecom": [
          {
            "use": "mobile",
            "value": "+11577407245",
            "system": "phone"
          },
          {
            "use": "home",
            "value": "maria.smith@example.org",
            "system": "email"
          }
        ],
        "gender": "female",
        "maritalStatus": {
          "text": "Married",
          "coding": [
            {
              "code": "M",
              "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus",
              "display": "Married"
            }
          ]
        },
        "contact": [
          {
            "name": {
              "use": "usual",
              "given": [
                "Emily"
              ],
              "family": "Smith"
            },
            "telecom": [
              {
                "use": "mobile",
                "value": "+17448246676",
                "system": "phone"
              }
            ],
            "relationship": [
              {
                "coding": [
                  {
                    "code": "C",
                    "system": "http://terminology.hl7.org/CodeSystem/v2-0131",
                    "display": "Emergency Contact"
                  }
                ]
              }
            ]
          }
        ]
      },
      "search": {
        "mode": "match"
      },
      "fullUrl": "https://xfztpxesfy.edge.aidbox.app/Patient/0dde494d-aa30-4141-8a8f-30311cd0bbaf",
      "link": [
        {
          "relation": "self",
          "url": "https://xfztpxesfy.edge.aidbox.app/Patient/0dde494d-aa30-4141-8a8f-30311cd0bbaf"
        }
      ]
    }
  ]
}

Enrol the patient

  • using the ids from above (Research Study and Patient) create the ResearchSubject
REST Send Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/ResearchSubject?_pretty=true
Content-Type: text/yaml
Accept: text/yaml

resourceType: ResearchSubject
identifier:
- system: https://example.com/patient-identifier
  value: "0dde494d-aa30-4141-8a8f-30311cd0bbaf"
subject: 
  reference: "Patient/0dde494d-aa30-4141-8a8f-30311cd0bbaf"
study: 
  reference: "ResearchStudy/Dynamic-Schedule-Exit-Example"
status: active

Response: Body
Status: 201
study: {reference: ResearchStudy/Dynamic-Schedule-Exit-Example}
status: active
subject: {reference: Patient/0dde494d-aa30-4141-8a8f-30311cd0bbaf}
identifier:
- {value: 0dde494d-aa30-4141-8a8f-30311cd0bbaf, system: 'https://example.com/patient-identifier'}
id: 01813c91-e570-4f81-a475-68f1845b2c6e
resourceType: ResearchSubject
meta:
  lastUpdated: '2026-01-13T16:00:10.052596Z'
  versionId: '1517'
  extension:
  - {url: 'https://fhir.aidbox.app/fhir/StructureDefinition/created-at', valueInstant: '2026-01-13T16:00:10.052596Z'}

Add an encounter

(all of these use the Patient reference for the subject edge)

  • Get the PlanDefinition for the planned encounter (specifically the id)
  • Create a RequestOrchestration with the instatiatesCanonical matching the PlanDefinition id
  • Create a CarePlan with the basedOn matching the RequestOrchestration id
    • Create with status active
  • Create a ServiceRequest with the basedOn using the CarePlan
  • Initiate the Planned Encounter
    • Create an Encounter (using the as an identifier if available)
    • Create one or more tasks for activities as expected
  • Complete the encounter
    • Update the Encounter to 'completed'
    • Update the ServiceRequest to 'completed'
    • Update the CarePlan to 'ended'
REST Send Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /Bundle
Content-Type: text/yaml
Accept: text/yaml

resourceType: Bundle
entry:
- request:
    method: POST
    url: RequestOrchestration
  resource:
    resourceType: RequestOrchestration
    id: request-orchestration-id
    instantiatesCanonical:
    - PlanDefinition/<plan-definition-id>
    intent: plan
    status: active
    subject:
      reference: Patient/<patient-id>
      type: Patient
- request:
    method: POST
    url: CarePlan
  resource:
    resourceType: CarePlan
    id: careplan-id
    basedOn:
    - reference: RequestOrchestration/request-orchestration-id
      type: RequestOrchestration
    intent: plan
    status: active
    subject:
      reference: Patient/<patient-id>
      type: Patient
- request:
    method: POST
    url: ServiceRequest
  resource:
    resourceType: ServiceRequest
    id: service-request-id
    basedOn:
    - reference: CarePlan/careplan-id
      type: CarePlan
    intent: order
    status: active
    subject:
      reference: Patient/<patient-id>
      type: Patient
- request:
    method: POST
    url: Encounter
  resource:
    resourceType: Encounter
    id: encounter-id
    basedOn:
    - reference: ServiceRequest/service-request-id
      type: ServiceRequest
    identifier:
    - system: http://example.com/encounters/oids
      use: secondary
      value: SCREEN
    status: in-progress
    subject:
      reference: Patient/<patient-id>
      type: Patient
type: transaction

Complete the Activities

Look at the output and get the ids for the RequestOrchestration, CarePlan, ServiceRequest, Encounter; you will need these to update the statuses to complete the activities

REST Send Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /Bundle
Content-Type: text/yaml
Accept: text/yaml

resourceType: Bundle
entry:
- request:
    method: PUT
    url: RequestOrchestration/<request-orchestration-id>
  resource:
    resourceType: RequestOrchestration
    status: complete
- request:
    method: PUT
    url: CarePlan/<careplan-id>
  resource:
    resourceType: CarePlan
    status: complete
- request:
    method: PUT
    url: ServiceRequest/<service-request-d>
  resource:
    resourceType: ServiceRequest
    status: complete
- request:
    method: PUT
    url: Encounter
  resource:
    status: complete
type: transaction

Evaluate the Next Step

  • Get the ResearchSubject (and therefore Patient) (see above)
  • Get the ResearchStudy
  • Get the Study Plan (PlanDefinition)
  • Review the Study Plan to find available Exits
  • List the CarePlans for the Patient
  • For each CarePlan
    • Check the status
    • Get the RequestOrchestration and retrieve the referenced PlanDefinition id
REST Send Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
GET /PlanDefinition/dynamic-visit-schedule-exit-example-PlanDefinition
Response: Body
Status: 200
{
  "description": "dynamic-visit-schedule-exit-example-PlanDefinition",
  "meta": {
    "lastUpdated": "2026-01-09T20:46:14.391964Z",
    "createdAt": "2026-01-08T16:43:50.193978Z",
    "versionId": "711"
  },
  "publisher": "fhir4pharma [Richardson & Genyn, JMIR Med Inform 2025;13:e71430, DOI: 10.2196/71430]",
  "name": "dynamic-visit-schedule-exit-example-PlanDefinition",
  "type": {
    "coding": [
      {
        "code": "clinical-protocol",
        "system": "http://terminology.hl7.org/CodeSystem/plan-definition-type"
      }
    ]
  },
  "resourceType": "PlanDefinition",
  "title": "dynamic-visit-schedule-exit-example-PlanDefinition",
  "status": "active",
  "id": "dynamic-visit-schedule-exit-example-PlanDefinition",
  "identifier": [
    {
      "value": "12c63d44-415f-4834-bd6c-630790711d4b",
      "system": "http://www.fhir4pharma.com/plandefinition"
    }
  ],
  "action": [
    {
      "id": "349447c3-8ad4-4034-8c31-c3d96dcc5f9a",
      "title": "Day 7",
      "action": [
        {
          "condition": [
            {
              "kind": "start",
              "expression": {
                "language": "text/x-soa-expressionplain",
                "expression": "{'withdraw':True, 'operation': '=='}"
              }
            }
          ],
          "extension": [
            {
              "url": "http://fhir4pharma.com/StructureDefinition/soaTransition",
              "extension": [
                {
                  "url": "soaTargetId",
                  "value": {
                    "string": "dbc35dee-a5f2-473f-b9b1-bb14b2a1c9ef"
                  }
                },
                {
                  "url": "soaTransitionType",
                  "value": {
                    "string": "SS"
                  }
                },
                {
                  "url": "soaTransitionDelay",
                  "value": {
                    "Duration": {
                      "code": "h",
                      "value": 24,
                      "system": "http://unitsofmeasure.org"
                    }
                  }
                },
                {
                  "url": "soaTransitionRange",
                  "value": {
                    "Range": {
                      "low": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      },
                      "high": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      }
                    }
                  }
                }
              ]
            }
          ]
        },
        {
          "extension": [
            {
              "url": "http://fhir4pharma.com/StructureDefinition/soaTransition",
              "extension": [
                {
                  "url": "soaTargetId",
                  "value": {
                    "string": "d0dd287a-0a87-439d-95cc-8690e7abf0cb"
                  }
                },
                {
                  "url": "soaTransitionType",
                  "value": {
                    "string": "SS"
                  }
                },
                {
                  "url": "soaTransitionDelay",
                  "value": {
                    "Duration": {
                      "code": "d",
                      "value": 7,
                      "system": "http://unitsofmeasure.org"
                    }
                  }
                },
                {
                  "url": "soaTransitionRange",
                  "value": {
                    "Range": {
                      "low": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      },
                      "high": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      }
                    }
                  }
                }
              ]
            }
          ]
        }
      ],
      "extension": [
        {
          "url": "http://fhir4pharma.com/StructureDefinition/soaPlannedTimepoint",
          "extension": [
            {
              "url": "soaPlannedTimePoint",
              "value": {
                "Quantity": {
                  "code": "d",
                  "value": 7,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaReferenceTimePoint",
              "value": {
                "string": "Treatment Day 1"
              }
            },
            {
              "url": "soaRepeatAllowed",
              "value": {
                "boolean": false
              }
            },
            {
              "url": "soaPlannedDuration",
              "value": {
                "Duration": {
                  "code": "h",
                  "value": 24,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaTimePointType",
              "value": {
                "string": "Interaction"
              }
            },
            {
              "url": "soaPlannedRange",
              "value": {
                "Range": {
                  "low": {
                    "code": "s",
                    "value": 0,
                    "system": "http://unitsofmeasure.org"
                  },
                  "high": {
                    "code": "s",
                    "value": 0,
                    "system": "http://unitsofmeasure.org"
                  }
                }
              }
            },
            {
              "url": "soaRangeFromTimePoint",
              "value": {
                "string": "Treatment Day 1"
              }
            }
          ]
        }
      ],
      "definition": {
        "canonical": "PlanDefinition/dynamic-visit-schedule-exit-example-Day-7-PlanDefinition"
      },
      "description": "Day 7",
      "groupingBehavior": "visual-group",
      "selectionBehavior": "exactly-one"
    },
    {
      "id": "d0dd287a-0a87-439d-95cc-8690e7abf0cb",
      "title": "Day 15",
      "action": [
        {
          "extension": [
            {
              "url": "http://fhir4pharma.com/StructureDefinition/soaTransition",
              "extension": [
                {
                  "url": "soaTargetId",
                  "value": {
                    "string": "dbc35dee-a5f2-473f-b9b1-bb14b2a1c9ef"
                  }
                },
                {
                  "url": "soaTransitionType",
                  "value": {
                    "string": "SS"
                  }
                },
                {
                  "url": "soaTransitionDelay",
                  "value": {
                    "Duration": {
                      "code": "d",
                      "value": 7,
                      "system": "http://unitsofmeasure.org"
                    }
                  }
                },
                {
                  "url": "soaTransitionRange",
                  "value": {
                    "Range": {
                      "low": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      },
                      "high": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      }
                    }
                  }
                }
              ]
            }
          ]
        }
      ],
      "extension": [
        {
          "url": "http://fhir4pharma.com/StructureDefinition/soaPlannedTimepoint",
          "extension": [
            {
              "url": "soaPlannedTimePoint",
              "value": {
                "Quantity": {
                  "code": "d",
                  "value": 15,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaReferenceTimePoint",
              "value": {
                "string": "Treatment Day 1"
              }
            },
            {
              "url": "soaRepeatAllowed",
              "value": {
                "boolean": false
              }
            },
            {
              "url": "soaPlannedDuration",
              "value": {
                "Duration": {
                  "code": "h",
                  "value": 24,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaTimePointType",
              "value": {
                "string": "Interaction"
              }
            },
            {
              "url": "soaPlannedRange",
              "value": {
                "Range": {
                  "low": {
                    "code": "s",
                    "value": 0,
                    "system": "http://unitsofmeasure.org"
                  },
                  "high": {
                    "code": "s",
                    "value": 0,
                    "system": "http://unitsofmeasure.org"
                  }
                }
              }
            },
            {
              "url": "soaRangeFromTimePoint",
              "value": {
                "string": "Treatment Day 1"
              }
            }
          ]
        }
      ],
      "definition": {
        "canonical": "PlanDefinition/dynamic-visit-schedule-exit-example-Day-15-PlanDefinition"
      },
      "description": "Day 15",
      "groupingBehavior": "visual-group",
      "selectionBehavior": "exactly-one"
    },
    {
      "id": "a1806239-54f3-4762-af3f-edb9d80d29dc",
      "title": "Treatment Day 1",
      "action": [
        {
          "extension": [
            {
              "url": "http://fhir4pharma.com/StructureDefinition/soaTransition",
              "extension": [
                {
                  "url": "soaTargetId",
                  "value": {
                    "string": "349447c3-8ad4-4034-8c31-c3d96dcc5f9a"
                  }
                },
                {
                  "url": "soaTransitionType",
                  "value": {
                    "string": "SS"
                  }
                },
                {
                  "url": "soaTransitionDelay",
                  "value": {
                    "Duration": {
                      "code": "h",
                      "value": 24,
                      "system": "http://unitsofmeasure.org"
                    }
                  }
                },
                {
                  "url": "soaTransitionRange",
                  "value": {
                    "Range": {
                      "low": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      },
                      "high": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      }
                    }
                  }
                }
              ]
            }
          ]
        },
        {
          "extension": [
            {
              "url": "http://fhir4pharma.com/StructureDefinition/soaTransition",
              "extension": [
                {
                  "url": "soaTargetId",
                  "value": {
                    "string": "d0dd287a-0a87-439d-95cc-8690e7abf0cb"
                  }
                },
                {
                  "url": "soaTransitionType",
                  "value": {
                    "string": "SS"
                  }
                },
                {
                  "url": "soaTransitionDelay",
                  "value": {
                    "Duration": {
                      "code": "d",
                      "value": 28,
                      "system": "http://unitsofmeasure.org"
                    }
                  }
                },
                {
                  "url": "soaTransitionRange",
                  "value": {
                    "Range": {
                      "low": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      },
                      "high": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      }
                    }
                  }
                }
              ]
            }
          ]
        },
        {
          "condition": [
            {
              "kind": "start",
              "expression": {
                "language": "text/x-soa-expressionplain",
                "expression": "{'withdraw':True, 'operation': '=='}"
              }
            }
          ],
          "extension": [
            {
              "url": "http://fhir4pharma.com/StructureDefinition/soaTransition",
              "extension": [
                {
                  "url": "soaTargetId",
                  "value": {
                    "string": "dbc35dee-a5f2-473f-b9b1-bb14b2a1c9ef"
                  }
                },
                {
                  "url": "soaTransitionType",
                  "value": {
                    "string": "FS"
                  }
                },
                {
                  "url": "soaTransitionDelay",
                  "value": {
                    "Duration": {
                      "code": "s",
                      "value": 0,
                      "system": "http://unitsofmeasure.org"
                    }
                  }
                },
                {
                  "url": "soaTransitionRange",
                  "value": {
                    "Range": {
                      "low": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      },
                      "high": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      }
                    }
                  }
                }
              ]
            }
          ]
        }
      ],
      "extension": [
        {
          "url": "http://fhir4pharma.com/StructureDefinition/soaPlannedTimepoint",
          "extension": [
            {
              "url": "soaPlannedTimePoint",
              "value": {
                "Quantity": {
                  "code": "s",
                  "value": 0,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaReferenceTimePoint",
              "value": {
                "string": "Screening"
              }
            },
            {
              "url": "soaRepeatAllowed",
              "value": {
                "boolean": false
              }
            },
            {
              "url": "soaPlannedDuration",
              "value": {
                "Duration": {
                  "code": "h",
                  "value": 24,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaTimePointType",
              "value": {
                "string": "Interaction"
              }
            },
            {
              "url": "soaPlannedRange",
              "value": {
                "Range": {
                  "low": {
                    "code": "h",
                    "value": 24,
                    "system": "http://unitsofmeasure.org"
                  },
                  "high": {
                    "code": "h",
                    "value": 24,
                    "system": "http://unitsofmeasure.org"
                  }
                }
              }
            },
            {
              "url": "soaRangeFromTimePoint",
              "value": {
                "string": "Screening"
              }
            }
          ]
        }
      ],
      "definition": {
        "canonical": "PlanDefinition/dynamic-visit-schedule-exit-example-Treatment-Day-1-PlanDefinition"
      },
      "description": "Treatment Day 1",
      "groupingBehavior": "visual-group",
      "selectionBehavior": "exactly-one"
    },
    {
      "id": "dbc35dee-a5f2-473f-b9b1-bb14b2a1c9ef",
      "title": "End of Study",
      "action": [
        {
          "extension": [
            {
              "url": "http://fhir4pharma.com/StructureDefinition/soaTransition",
              "extension": [
                {
                  "url": "soaTargetId",
                  "value": {
                    "string": "76fb46ca-2a08-4421-8ce9-b8d412db2fb5"
                  }
                },
                {
                  "url": "soaTransitionType",
                  "value": {
                    "string": "SS"
                  }
                },
                {
                  "url": "soaTransitionDelay",
                  "value": {
                    "Duration": {
                      "code": "d",
                      "value": 28,
                      "system": "http://unitsofmeasure.org"
                    }
                  }
                },
                {
                  "url": "soaTransitionRange",
                  "value": {
                    "Range": {
                      "low": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      },
                      "high": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      }
                    }
                  }
                }
              ]
            }
          ]
        }
      ],
      "extension": [
        {
          "url": "http://fhir4pharma.com/StructureDefinition/soaPlannedTimepoint",
          "extension": [
            {
              "url": "soaPlannedTimePoint",
              "value": {
                "Quantity": {
                  "code": "d",
                  "value": 21,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaReferenceTimePoint",
              "value": {
                "string": "Treatment Day 1"
              }
            },
            {
              "url": "soaRepeatAllowed",
              "value": {
                "boolean": false
              }
            },
            {
              "url": "soaPlannedDuration",
              "value": {
                "Duration": {
                  "code": "h",
                  "value": 24,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaTimePointType",
              "value": {
                "string": "Interaction"
              }
            },
            {
              "url": "soaPlannedRange",
              "value": {
                "Range": {
                  "low": {
                    "code": "h",
                    "value": 24,
                    "system": "http://unitsofmeasure.org"
                  },
                  "high": {
                    "code": "h",
                    "value": 24,
                    "system": "http://unitsofmeasure.org"
                  }
                }
              }
            },
            {
              "url": "soaRangeFromTimePoint",
              "value": {
                "string": "Treatment Day 1"
              }
            }
          ]
        }
      ],
      "definition": {
        "canonical": "PlanDefinition/dynamic-visit-schedule-exit-example-End-of-Study-PlanDefinition"
      },
      "description": "End of Study",
      "groupingBehavior": "visual-group",
      "selectionBehavior": "exactly-one"
    },
    {
      "id": "0700e721-1f12-4998-89b8-6f4e649b62f7",
      "title": "Screening",
      "action": [
        {
          "extension": [
            {
              "url": "http://fhir4pharma.com/StructureDefinition/soaTransition",
              "extension": [
                {
                  "url": "soaTargetId",
                  "value": {
                    "string": "a1806239-54f3-4762-af3f-edb9d80d29dc"
                  }
                },
                {
                  "url": "soaTransitionType",
                  "value": {
                    "string": "SS"
                  }
                },
                {
                  "url": "soaTransitionDelay",
                  "value": {
                    "Duration": {
                      "code": "s",
                      "value": 0,
                      "system": "http://unitsofmeasure.org"
                    }
                  }
                },
                {
                  "url": "soaTransitionRange",
                  "value": {
                    "Range": {
                      "low": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      },
                      "high": {
                        "code": "s",
                        "value": 0,
                        "system": "http://unitsofmeasure.org"
                      }
                    }
                  }
                }
              ]
            }
          ]
        }
      ],
      "extension": [
        {
          "url": "http://fhir4pharma.com/StructureDefinition/soaPlannedTimepoint",
          "extension": [
            {
              "url": "soaPlannedTimePoint",
              "value": {
                "Quantity": {
                  "code": "s",
                  "value": 0,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaReferenceTimePoint",
              "value": {
                "string": "Screening"
              }
            },
            {
              "url": "soaRepeatAllowed",
              "value": {
                "boolean": false
              }
            },
            {
              "url": "soaPlannedDuration",
              "value": {
                "Duration": {
                  "code": "h",
                  "value": 24,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaTimePointType",
              "value": {
                "string": "Interaction"
              }
            },
            {
              "url": "soaPlannedRange",
              "value": {
                "Range": {
                  "low": {
                    "code": "h",
                    "value": 24,
                    "system": "http://unitsofmeasure.org"
                  },
                  "high": {
                    "code": "h",
                    "value": 24,
                    "system": "http://unitsofmeasure.org"
                  }
                }
              }
            },
            {
              "url": "soaRangeFromTimePoint",
              "value": {
                "string": "Screening"
              }
            }
          ]
        }
      ],
      "definition": {
        "canonical": "PlanDefinition/dynamic-visit-schedule-exit-example-Screening-PlanDefinition"
      },
      "description": "Screening",
      "groupingBehavior": "visual-group",
      "selectionBehavior": "exactly-one"
    },
    {
      "id": "76fb46ca-2a08-4421-8ce9-b8d412db2fb5",
      "title": "Follow Up",
      "extension": [
        {
          "url": "http://fhir4pharma.com/StructureDefinition/soaPlannedTimepoint",
          "extension": [
            {
              "url": "soaPlannedTimePoint",
              "value": {
                "Quantity": {
                  "code": "d",
                  "value": 28,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaReferenceTimePoint",
              "value": {
                "string": "End of Study"
              }
            },
            {
              "url": "soaRepeatAllowed",
              "value": {
                "boolean": false
              }
            },
            {
              "url": "soaPlannedDuration",
              "value": {
                "Duration": {
                  "code": "h",
                  "value": 24,
                  "system": "http://unitsofmeasure.org"
                }
              }
            },
            {
              "url": "soaTimePointType",
              "value": {
                "string": "Interaction"
              }
            },
            {
              "url": "soaPlannedRange",
              "value": {
                "Range": {
                  "low": {
                    "code": "h",
                    "value": 24,
                    "system": "http://unitsofmeasure.org"
                  },
                  "high": {
                    "code": "h",
                    "value": 24,
                    "system": "http://unitsofmeasure.org"
                  }
                }
              }
            },
            {
              "url": "soaRangeFromTimePoint",
              "value": {
                "string": "End of Study"
              }
            }
          ]
        }
      ],
      "definition": {
        "canonical": "PlanDefinition/dynamic-visit-schedule-exit-example-Follow-Up-PlanDefinition"
      },
      "description": "Follow Up"
    }
  ],
  "version": "V00"
}

Assign a patient to an Arm

  • We can update the patient assigned arm on Randomization
  • For a start, let's list the groups
REST Send Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
GET /fhir/Group
Response: Body
Status: 200
{
  "resourceType": "Bundle",
  "type": "searchset",
  "meta": {
    "versionId": "0"
  },
  "total": 2,
  "link": [
    {
      "relation": "first",
      "url": "https://xfztpxesfy.edge.aidbox.app/fhir/Group?page=1"
    },
    {
      "relation": "self",
      "url": "https://xfztpxesfy.edge.aidbox.app/fhir/Group?page=1"
    }
  ],
  "entry": [
    {
      "resource": {
        "name": "ArmA",
        "type": "person",
        "title": "Treatment Group Arm A",
        "identifier": [
          {
            "use": "official",
            "value": "ARMA"
          }
        ],
        "membership": "definitional",
        "id": "61667f6f-0de9-4cf3-8c52-b9729e6bbea5",
        "resourceType": "Group",
        "meta": {
          "lastUpdated": "2026-01-13T14:36:23.007084Z",
          "versionId": "1374",
          "extension": [
            {
              "url": "https://fhir.aidbox.app/fhir/StructureDefinition/created-at",
              "valueInstant": "2026-01-13T14:36:23.007084Z"
            }
          ]
        }
      },
      "search": {
        "mode": "match"
      },
      "fullUrl": "https://xfztpxesfy.edge.aidbox.app/Group/61667f6f-0de9-4cf3-8c52-b9729e6bbea5",
      "link": [
        {
          "relation": "self",
          "url": "https://xfztpxesfy.edge.aidbox.app/Group/61667f6f-0de9-4cf3-8c52-b9729e6bbea5"
        }
      ]
    },
    {
      "resource": {
        "name": "ArmB",
        "type": "person",
        "title": "Treatment Group Arm B",
        "identifier": [
          {
            "use": "official",
            "value": "ARMB"
          }
        ],
        "membership": "definitional",
        "id": "c8b72731-88f6-481b-93bf-f57a97bbf1e4",
        "resourceType": "Group",
        "meta": {
          "lastUpdated": "2026-01-13T14:36:42.500786Z",
          "versionId": "1375",
          "extension": [
            {
              "url": "https://fhir.aidbox.app/fhir/StructureDefinition/created-at",
              "valueInstant": "2026-01-13T14:36:42.500786Z"
            }
          ]
        }
      },
      "search": {
        "mode": "match"
      },
      "fullUrl": "https://xfztpxesfy.edge.aidbox.app/Group/c8b72731-88f6-481b-93bf-f57a97bbf1e4",
      "link": [
        {
          "relation": "self",
          "url": "https://xfztpxesfy.edge.aidbox.app/Group/c8b72731-88f6-481b-93bf-f57a97bbf1e4"
        }
      ]
    }
  ]
}

Then we can assign a patient to an Arm