Generate a summary from FHIR resources

POST/fhir2summary/create

Creates a summary from FHIR resources using one of three modes:

  • narrative: Uses a template to substitute FHIR data into placeholders (requires template_id)
  • flatten: Flattens FHIR resources into a searchable format for RAG/search (no template needed)
  • ips: Generates an International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG. Requires a Bundle with exactly one Patient resource (returns 400 error if no Patient or multiple Patients are present). Automatically filters resources to those referencing the patient and generates sections for allergies, medications, problems, immunizations, procedures, and vital signs.
RequiresBearerauthentication

Body parameters

modestringoptionaldefault narrative

Summary generation mode:

  • narrative: Substitute FHIR data into a template (requires template_id)
  • flatten: Flatten FHIR resources for RAG/search (no template needed)
  • ips: Generate International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG
narrativeflattenips
template_idstring (uuid)optional

ID of the template to use (required for narrative mode)

fhir_resourcesobjectrequired

FHIR resources (single resource or Bundle). For IPS mode, must be a Bundle containing exactly one Patient resource with at least one identifier (id, fullUrl, or identifier field). Returns an error if no Patient is found, if multiple Patients are present, or if the Patient has no identifiers. Resources are automatically filtered to only include those referencing the patient.

Returns  

Summary generated successfully

Response fields

successbooleanoptional
messagestringoptional
summarystringoptional

Generated summary text

warningsstring[]optional

Unresolved placeholders or issues (narrative mode only)

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/fhir2summary/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "mode": "narrative",
  "template_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "fhir_resources": {
    "resourceType": "Bundle",
    "type": "collection",
    "entry": [
      {
        "resource": {
          "resourceType": "Patient",
          "name": [
            {
              "given": [
                "John"
              ],
              "family": "Doe"
            }
          ],
          "gender": "male",
          "birthDate": "1979-03-15"
        }
      },
      {
        "resource": {
          "resourceType": "Condition",
          "code": {
            "text": "Type 2 Diabetes Mellitus"
          },
          "onsetDateTime": "2024-01-15"
        }
      }
    ]
  }
}'
200 OKResponse
{
  "success": true,
  "summary": "Patient John Doe is a 45-year-old male diagnosed with Type 2 Diabetes Mellitus on January 15, 2024. Current treatment plan includes lifestyle modifications and medication management.",
  "warnings": []
}