Extract Medical Record

Extract patient details, diagnoses, and medications from a medical record into structured JSON for healthcare workflows.

Who this is for

Healthcare providers and clinical software platforms use this recipe to digitize a patient record. Upload a medical document and receive structured JSON with patient details, diagnosis codes, and medication list — ready for integration with your EHR or clinical database.

Request
curl -X POST https://api.iterationlayer.com/document-extraction/v1/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "files": [
      {
        "type": "url",
        "name": "medical-record.pdf",
        "url": "https://example.com/records/medical-record.pdf"
      }
    ],
    "schema": {
      "fields": [
        {
          "name": "patient_name",
          "type": "TEXT",
          "description": "Full name of the patient"
        },
        {
          "name": "date_of_birth",
          "type": "DATE",
          "description": "Patient date of birth"
        },
        {
          "name": "diagnoses",
          "type": "ARRAY",
          "description": "List of diagnoses",
          "fields": [
            {
              "name": "code",
              "type": "TEXT",
              "description": "Diagnosis or ICD code"
            },
            {
              "name": "description",
              "type": "TEXT",
              "description": "Diagnosis description"
            }
          ]
        },
        {
          "name": "medications",
          "type": "ARRAY",
          "description": "List of prescribed medications",
          "fields": [
            {
              "name": "name",
              "type": "TEXT",
              "description": "Medication name"
            },
            {
              "name": "dosage",
              "type": "TEXT",
              "description": "Prescribed dosage"
            }
          ]
        }
      ]
    }
  }'
Response
{
  "success": true,
  "data": {
    "patient_name": {
      "value": "James R. Patterson",
      "confidence": 0.99,
      "citations": ["Patient: James R. Patterson"]
    },
    "date_of_birth": {
      "value": "1978-03-22",
      "confidence": 0.98,
      "citations": ["DOB: 03/22/1978"]
    },
    "diagnoses": {
      "value": [
        {
          "code": {
            "value": "E11.9",
            "confidence": 0.97,
            "citations": ["E11.9"]
          },
          "description": {
            "value": "Type 2 diabetes mellitus without complications",
            "confidence": 0.96,
            "citations": [
              "Type 2 diabetes mellitus without complications"
            ]
          }
        },
        {
          "code": {
            "value": "I10",
            "confidence": 0.98,
            "citations": ["I10"]
          },
          "description": {
            "value": "Essential hypertension",
            "confidence": 0.97,
            "citations": [
              "Essential (primary) hypertension"
            ]
          }
        }
      ],
      "confidence": 0.96,
      "citations": []
    },
    "medications": {
      "value": [
        {
          "name": {
            "value": "Metformin",
            "confidence": 0.98,
            "citations": ["Metformin HCl"]
          },
          "dosage": {
            "value": "500mg twice daily",
            "confidence": 0.95,
            "citations": ["500mg BID"]
          }
        },
        {
          "name": {
            "value": "Lisinopril",
            "confidence": 0.97,
            "citations": ["Lisinopril"]
          },
          "dosage": {
            "value": "10mg once daily",
            "confidence": 0.96,
            "citations": ["10mg QD"]
          }
        }
      ],
      "confidence": 0.96,
      "citations": []
    }
  }
}
Request
import { IterationLayer } from "iterationlayer";
const client = new IterationLayer({ apiKey: "YOUR_API_KEY" });

const result = await client.extract({
  files: [
    {
      type: "url",
      name: "medical-record.pdf",
      url: "https://example.com/records/medical-record.pdf",
    },
  ],
  schema: {
    fields: [
      {
        name: "patient_name",
        type: "TEXT",
        description: "Full name of the patient",
      },
      {
        name: "date_of_birth",
        type: "DATE",
        description: "Patient date of birth",
      },
      {
        name: "diagnoses",
        type: "ARRAY",
        description: "List of diagnoses",
        fields: [
          {
            name: "code",
            type: "TEXT",
            description: "Diagnosis or ICD code",
          },
          {
            name: "description",
            type: "TEXT",
            description: "Diagnosis description",
          },
        ],
      },
      {
        name: "medications",
        type: "ARRAY",
        description: "List of prescribed medications",
        fields: [
          {
            name: "name",
            type: "TEXT",
            description: "Medication name",
          },
          {
            name: "dosage",
            type: "TEXT",
            description: "Prescribed dosage",
          },
        ],
      },
    ],
  },
});

console.log(result);
Response
{
  "success": true,
  "data": {
    "patient_name": {
      "value": "James R. Patterson",
      "confidence": 0.99,
      "citations": ["Patient: James R. Patterson"]
    },
    "date_of_birth": {
      "value": "1978-03-22",
      "confidence": 0.98,
      "citations": ["DOB: 03/22/1978"]
    },
    "diagnoses": {
      "value": [
        {
          "code": {
            "value": "E11.9",
            "confidence": 0.97,
            "citations": ["E11.9"]
          },
          "description": {
            "value": "Type 2 diabetes mellitus without complications",
            "confidence": 0.96,
            "citations": [
              "Type 2 diabetes mellitus without complications"
            ]
          }
        },
        {
          "code": {
            "value": "I10",
            "confidence": 0.98,
            "citations": ["I10"]
          },
          "description": {
            "value": "Essential hypertension",
            "confidence": 0.97,
            "citations": [
              "Essential (primary) hypertension"
            ]
          }
        }
      ],
      "confidence": 0.96,
      "citations": []
    },
    "medications": {
      "value": [
        {
          "name": {
            "value": "Metformin",
            "confidence": 0.98,
            "citations": ["Metformin HCl"]
          },
          "dosage": {
            "value": "500mg twice daily",
            "confidence": 0.95,
            "citations": ["500mg BID"]
          }
        },
        {
          "name": {
            "value": "Lisinopril",
            "confidence": 0.97,
            "citations": ["Lisinopril"]
          },
          "dosage": {
            "value": "10mg once daily",
            "confidence": 0.96,
            "citations": ["10mg QD"]
          }
        }
      ],
      "confidence": 0.96,
      "citations": []
    }
  }
}
Request
from iterationlayer import IterationLayer
client = IterationLayer(api_key="YOUR_API_KEY")

result = client.extract(
    files=[
        {
            "type": "url",
            "name": "medical-record.pdf",
            "url": "https://example.com/records/medical-record.pdf",
        }
    ],
    schema={
        "fields": [
            {
                "name": "patient_name",
                "type": "TEXT",
                "description": "Full name of the patient",
            },
            {
                "name": "date_of_birth",
                "type": "DATE",
                "description": "Patient date of birth",
            },
            {
                "name": "diagnoses",
                "type": "ARRAY",
                "description": "List of diagnoses",
                "fields": [
                    {
                        "name": "code",
                        "type": "TEXT",
                        "description": "Diagnosis or ICD code",
                    },
                    {
                        "name": "description",
                        "type": "TEXT",
                        "description": "Diagnosis description",
                    },
                ],
            },
            {
                "name": "medications",
                "type": "ARRAY",
                "description": "List of prescribed medications",
                "fields": [
                    {
                        "name": "name",
                        "type": "TEXT",
                        "description": "Medication name",
                    },
                    {
                        "name": "dosage",
                        "type": "TEXT",
                        "description": "Prescribed dosage",
                    },
                ],
            },
        ]
    },
)

print(result)
Response
{
  "success": true,
  "data": {
    "patient_name": {
      "value": "James R. Patterson",
      "confidence": 0.99,
      "citations": ["Patient: James R. Patterson"]
    },
    "date_of_birth": {
      "value": "1978-03-22",
      "confidence": 0.98,
      "citations": ["DOB: 03/22/1978"]
    },
    "diagnoses": {
      "value": [
        {
          "code": {
            "value": "E11.9",
            "confidence": 0.97,
            "citations": ["E11.9"]
          },
          "description": {
            "value": "Type 2 diabetes mellitus without complications",
            "confidence": 0.96,
            "citations": [
              "Type 2 diabetes mellitus without complications"
            ]
          }
        },
        {
          "code": {
            "value": "I10",
            "confidence": 0.98,
            "citations": ["I10"]
          },
          "description": {
            "value": "Essential hypertension",
            "confidence": 0.97,
            "citations": [
              "Essential (primary) hypertension"
            ]
          }
        }
      ],
      "confidence": 0.96,
      "citations": []
    },
    "medications": {
      "value": [
        {
          "name": {
            "value": "Metformin",
            "confidence": 0.98,
            "citations": ["Metformin HCl"]
          },
          "dosage": {
            "value": "500mg twice daily",
            "confidence": 0.95,
            "citations": ["500mg BID"]
          }
        },
        {
          "name": {
            "value": "Lisinopril",
            "confidence": 0.97,
            "citations": ["Lisinopril"]
          },
          "dosage": {
            "value": "10mg once daily",
            "confidence": 0.96,
            "citations": ["10mg QD"]
          }
        }
      ],
      "confidence": 0.96,
      "citations": []
    }
  }
}
Request
package main

import il "github.com/iterationlayer/sdk-go"

client := il.NewClient("YOUR_API_KEY")

result, err := client.Extract(il.ExtractRequest{
    Files: []il.FileInput{
        il.NewFileFromURL(
            "medical-record.pdf",
            "https://example.com/records/medical-record.pdf",
        ),
    },
    Schema: il.ExtractionSchema{
        "patient_name": il.NewTextFieldConfig(
            "patient_name", "Full name of the patient",
        ),
        "date_of_birth": il.NewDateFieldConfig(
            "date_of_birth", "Patient date of birth",
        ),
        "diagnoses": il.NewArrayFieldConfig(
            "diagnoses",
            "List of diagnoses",
            []il.FieldConfig{
                il.NewTextFieldConfig(
                    "code", "Diagnosis or ICD code",
                ),
                il.NewTextFieldConfig(
                    "description", "Diagnosis description",
                ),
            },
        ),
        "medications": il.NewArrayFieldConfig(
            "medications",
            "List of prescribed medications",
            []il.FieldConfig{
                il.NewTextFieldConfig(
                    "name", "Medication name",
                ),
                il.NewTextFieldConfig(
                    "dosage", "Prescribed dosage",
                ),
            },
        ),
    },
})
Response
{
  "success": true,
  "data": {
    "patient_name": {
      "value": "James R. Patterson",
      "confidence": 0.99,
      "citations": ["Patient: James R. Patterson"]
    },
    "date_of_birth": {
      "value": "1978-03-22",
      "confidence": 0.98,
      "citations": ["DOB: 03/22/1978"]
    },
    "diagnoses": {
      "value": [
        {
          "code": {
            "value": "E11.9",
            "confidence": 0.97,
            "citations": ["E11.9"]
          },
          "description": {
            "value": "Type 2 diabetes mellitus without complications",
            "confidence": 0.96,
            "citations": [
              "Type 2 diabetes mellitus without complications"
            ]
          }
        },
        {
          "code": {
            "value": "I10",
            "confidence": 0.98,
            "citations": ["I10"]
          },
          "description": {
            "value": "Essential hypertension",
            "confidence": 0.97,
            "citations": [
              "Essential (primary) hypertension"
            ]
          }
        }
      ],
      "confidence": 0.96,
      "citations": []
    },
    "medications": {
      "value": [
        {
          "name": {
            "value": "Metformin",
            "confidence": 0.98,
            "citations": ["Metformin HCl"]
          },
          "dosage": {
            "value": "500mg twice daily",
            "confidence": 0.95,
            "citations": ["500mg BID"]
          }
        },
        {
          "name": {
            "value": "Lisinopril",
            "confidence": 0.97,
            "citations": ["Lisinopril"]
          },
          "dosage": {
            "value": "10mg once daily",
            "confidence": 0.96,
            "citations": ["10mg QD"]
          }
        }
      ],
      "confidence": 0.96,
      "citations": []
    }
  }
}

Related Recipes

Start building in minutes

Free trial credits included. No credit card required.