MAGENT

Neonatal · LIVE

Pregnancy due date from LMP

Return ACOG Committee Opinion 700 Naegele estimated due date in days from a certain last menstrual period, adjusting the 280-day interval when cycle length is not 28 days.

LIVE $0.005 USDC GET /api/calc/pregnancy_due_dates

Markdown: /docs/pregnancy-due-dates.md · Canonical: https://magentlab.com/docs/pregnancy-due-dates

Not a medical device. Not a diagnosis, dose, or listing recommendation.

What it computes

Return ACOG Committee Opinion 700 Naegele estimated due date in days from a certain last menstrual period, adjusting the 280-day interval when cycle length is not 28 days.

When to use

When an agent already has numeric days since LMP and cycle length and must not treat the result as a dating ultrasound, imaging interpretation, or a delivery date order.

When not to use

  • Not a medical device. Not a dating ultrasound. magent does not interpret imaging. Not a delivery date order.
  • Inputs are numeric days_since_lmp (0-294 inclusive) and cycle_length_days (21-35 inclusive). Those ranges are magent clamps; ACOG 700 publishes the 280-day Naegele interval and cycle-length adjustment, not those input bands. No calendar dates or names.
  • For a certain LMP and a 28-day cycle, EDD is 280 days from the first day of the LMP (Naegele as used by ACOG 700). When cycle_length_days is not 28, edd_days_from_lmp = 280 + (cycle_length_days - 28). gestational_age_days = days_since_lmp. days_until_edd may be negative if past EDD.
  • ACOG 700 Table 1 ultrasound redating discrepancies are not applied. magent implements LMP and cycle-length conversion only and does not redate from imaging.
  • Caller supplies days since LMP and cycle length. magent does not take a menstrual history or assign a delivery date.

Formula

edd_days_from_lmp = 280 + (cycle_length_days - 28); gestational_age_days = days_since_lmp; days_until_edd = edd_days_from_lmp - days_since_lmp

Citation

Title
Methods for Estimating the Due Date
Authors
Committee on Obstetric Practice; American Institute of Ultrasound in Medicine; Society for Maternal-Fetal Medicine
Source
Obstet Gynecol. 2017;129(5):e150-e154
DOI
10.1097/AOG.0000000000002046

Worked example

Certain LMP, day 0, 28-day cycle

Given: cycle_length_days=28days_since_lmp=0

  1. edd_days_from_lmp = 280 + (28 - 28) = 280
  2. gestational_age_days = 0
  3. days_until_edd = 280 - 0 = 280

35-day cycle

Given: cycle_length_days=35days_since_lmp=0

  1. edd_days_from_lmp = 280 + (35 - 28) = 287
  2. gestational_age_days = 0
  3. days_until_edd = 287 - 0 = 287

21-day cycle

Given: cycle_length_days=21days_since_lmp=0

  1. edd_days_from_lmp = 280 + (21 - 28) = 273
  2. gestational_age_days = 0
  3. days_until_edd = 273 - 0 = 273

Past EDD on a 28-day cycle

Given: cycle_length_days=28days_since_lmp=281

  1. edd_days_from_lmp = 280 + (28 - 28) = 280
  2. gestational_age_days = 281
  3. days_until_edd = 280 - 281 = -1

Also searched as

  • pregnancy due date
  • estimated due date
  • EDD from LMP
  • Naegele rule
  • ACOG 700 due date
  • days until EDD
  • gestational age from LMP
  • LMP due date

Try

Opens the live endpoint. Unpaid browser requests show the paywall; agents should send Accept: application/json.

/api/calc/pregnancy_due_dates?days_since_lmp=0&cycle_length_days=28

Full URL: https://api.magentlab.com/api/calc/pregnancy_due_dates?days_since_lmp=0&cycle_length_days=28

Call

Expect HTTP 402 until you retry with PAYMENT-SIGNATURE. Incomplete query params return HTTP 400 before any quote or charge.

curl -i -H "Accept: application/json" "https://api.magentlab.com/api/calc/pregnancy_due_dates?days_since_lmp=0&cycle_length_days=28"

Parameters

Name Type Required Description
days_since_lmp integer required Completed days since the first day of a certain last menstrual period (integer 0-294 inclusive). magent clamp; ACOG 700 publishes the 280-day Naegele interval, not this input band. Numeric days only. Not a calendar date.
cycle_length_days integer required Usual cycle length in days (integer 21-35 inclusive). magent clamp; ACOG 700 adjusts the 280-day interval by (cycle_length_days - 28) and does not publish this input band. 28 is the Naegele reference cycle.

Bulk (POST)

POST the same path with a JSON items array. The first item is the GET unit; each additional item is $0.002. Invalid items return HTTP 400 before settlement.

POST /api/calc/pregnancy_due_dates Max 25 unit_amount + extra_item_amount * (n - 1) extra $0.002 PREVIEW

  • 1 to 25 items. Each item uses the same keys as the GET query parameters.
  • POST of 1 item costs the same as GET. Lists longer than 25: chunk into multiple POSTs. Extra items still execute; do not pad dummy rows.
  • The first invalid item fails the whole request (index in the 400 JSON). You are not charged.
  • HTTP 200 is {count, path, items}. Each items[i] is the GET 200 body for that row.
  • Catalog misses (empty matches, found=false) stay paid 200s inside that slot.
  • x402 resource URL is this path plus n and body_sha256. Browsers that prefer text/html get the same paywall as GET; Pay retries POST with the same items.

Example request (fixture)

{
  "items": [
    {
      "cycle_length_days": "28",
      "days_since_lmp": "0"
    },
    {
      "cycle_length_days": "28",
      "days_since_lmp": "0"
    }
  ]
}

Open bulk paywall →

Opens a two-item fixture on the API host. Unpaid browsers get the same MetaMask paywall as GET; Pay retries POST with those items.

Example 200 (fixture)

{
  "count": 2,
  "path": "/api/calc/pregnancy_due_dates",
  "items": [
    {
      "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
      "citation": {
        "authors": "Committee on Obstetric Practice; American Institute of Ultrasound in Medicine; Society for Maternal-Fetal Medicine",
        "doi": "10.1097/AOG.0000000000002046",
        "id": "acog-2017-700",
        "pmid": "28426617",
        "source": "Obstet Gynecol. 2017;129(5):e150-e154",
        "title": "Methods for Estimating the Due Date"
      },
      "formula": "pregnancy_due_dates",
      "formula_expression": "edd_days_from_lmp = 280 + (cycle_length_days - 28); gestational_age_days = days_since_lmp; days_until_edd = edd_days_from_lmp - days_since_lmp",
      "cycle_length_days": 28,
      "days_since_lmp": 0,
      "days_until_edd": 280,
      "edd_days_from_lmp": 280,
      "gestational_age_days": 0
    },
    {
      "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
      "citation": {
        "authors": "Committee on Obstetric Practice; American Institute of Ultrasound in Medicine; Society for Maternal-Fetal Medicine",
        "doi": "10.1097/AOG.0000000000002046",
        "id": "acog-2017-700",
        "pmid": "28426617",
        "source": "Obstet Gynecol. 2017;129(5):e150-e154",
        "title": "Methods for Estimating the Due Date"
      },
      "formula": "pregnancy_due_dates",
      "formula_expression": "edd_days_from_lmp = 280 + (cycle_length_days - 28); gestational_age_days = days_since_lmp; days_until_edd = edd_days_from_lmp - days_since_lmp",
      "cycle_length_days": 28,
      "days_since_lmp": 0,
      "days_until_edd": 280,
      "edd_days_from_lmp": 280,
      "gestational_age_days": 0
    }
  ]
}

Response

Field Type Description
formula string pregnancy_due_dates
formula_expression string Exact expression used
days_since_lmp integer Completed days since the first day of the certain LMP
cycle_length_days integer Usual cycle length in days used for the Naegele adjustment
edd_days_from_lmp integer Estimated due date as days from the first day of the LMP
gestational_age_days integer Gestational age in days, equal to days_since_lmp
days_until_edd integer Days from today-in-LMP-days to the EDD; negative if past EDD
citation object ACOG Committee Opinion 700 citation
disclaimer string Not-a-device notice

Example JSON

Machine form of the same example. Frozen fixture. Not a live lookup.

{
  "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
  "citation": {
    "authors": "Committee on Obstetric Practice; American Institute of Ultrasound in Medicine; Society for Maternal-Fetal Medicine",
    "doi": "10.1097/AOG.0000000000002046",
    "id": "acog-2017-700",
    "pmid": "28426617",
    "source": "Obstet Gynecol. 2017;129(5):e150-e154",
    "title": "Methods for Estimating the Due Date"
  },
  "formula": "pregnancy_due_dates",
  "formula_expression": "edd_days_from_lmp = 280 + (cycle_length_days - 28); gestational_age_days = days_since_lmp; days_until_edd = edd_days_from_lmp - days_since_lmp",
  "cycle_length_days": 28,
  "days_since_lmp": 0,
  "days_until_edd": 280,
  "edd_days_from_lmp": 280,
  "gestational_age_days": 0
}

Client errors (HTTP 400)

Invalid params return 400 without charge. Shared HTTP 402 and 503 meanings: Payments.

HTTP Code When
400 invalid_due_date Due-date inputs must match ACOG Committee Opinion 700 cycle length and days since LMP from that opinion. Returned before settlement; you are not charged.
400 invalid_items POST body must be a JSON object with only an items array Returned before settlement; you are not charged.
400 invalid_item_count items must be an array of 1 to 25 objects Returned before settlement; you are not charged.
400 invalid_item each items entry must be a JSON object Returned before settlement; you are not charged.

Related tools

  • Bishop score — Return the Bishop 1964 pelvic score as the sum of five caller-assigned integer components (dilation, effacement, station, consistency, position).
  • Flamm VBAC score — Sum the Flamm 1997 admission VBAC points (max 10) from caller-assigned age, vaginal-birth history, first-cesarean indication, and admission cervical factors, and return the published 49% or 95% success rates only for scores 0–2 and 8–10.
  • PUQE — Sum three caller-assigned Koren 2002 12-hour PUQE items (nausea_duration, vomiting_episodes, retching_episodes; each integer 1-5) and return the published 3-15 total. Does not apply later 24-hour, trimester-long, or 3-6 / 7-12 / ≥13 cuts.

Payment

Unpaid requests return HTTP 402 even if query parameters or POST items are missing or invalid, so CDP and agents can index the path. After a PAYMENT-SIGNATURE, invalid params return HTTP 400 JSON before settlement. magent does not charge. Fix the params, then request a new 402 quote for that complete URL. Catalog misses (empty matches, found=false) are valid paid 200s. Unpaid valid requests return HTTP 402 with a base64 PAYMENT-REQUIRED header. HTTP 503 is not a new quote: retry the same PAYMENT-SIGNATURE. Full handshake and shared payment errors: Payments. Stdio MCP: /docs/mcp.

Guarantees

  • HTTP 402 is unpaid, including a missing query. After PAYMENT-SIGNATURE, invalid parameters return HTTP 400 before settlement. You are not charged. HTTP 402 never includes the tool JSON.
  • exact: settlement finishes before the tool (paymentFlow upfront). batch-settlement: verify/deposit before the tool; chargedCumulativeAmount commits after HTTP 2xx. Uncertain or failed settlement fails closed (HTTP 503). Retry the same PAYMENT-SIGNATURE.
  • HTTP 402 is unpaid only. Do not sign a second authorization because of a 503.
  • Execution is timeout-bounded and concurrency-capped.
  • Calculator inputs are stored encrypted for allowlisted operators (Magent Console). They are not in public logs, SSH lookups, catalog, or rollups. Request logs store path without query.