# Pregnancy due date from LMP

Pregnancy due date from LMP

Status: LIVE
Price: $0.005 USDC
`GET /api/calc/pregnancy_due_dates`
HTML: https://magentlab.com/docs/pregnancy-due-dates
Markdown: https://magentlab.com/docs/pregnancy-due-dates.md

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

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

## Worked example

### Certain LMP, day 0, 28-day cycle

Given: `cycle_length_days=28, days_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=35, days_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=21, days_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=28, days_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

## Parameters

- `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.

Method: `POST /api/calc/pregnancy_due_dates`
Max items: 25
Price: unit_amount + extra_item_amount * (n - 1) (unit 5000 atomic, extra 2000 atomic)
Status: 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:

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

Human paywall (two-item fixture): https://api.magentlab.com/paywall/bulk/pregnancy-due-dates

Example 200:

```json
{
  "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 fields

- `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

Frozen fixture. Not a live lookup.

```json
{
  "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
}
```

## Errors

- HTTP 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.
- HTTP 400 `invalid_items`: POST body must be a JSON object with only an items array Returned before settlement; you are not charged.
- HTTP 400 `invalid_item_count`: items must be an array of 1 to 25 objects Returned before settlement; you are not charged.
- HTTP 400 `invalid_item`: each items entry must be a JSON object Returned before settlement; you are not charged.

Shared HTTP 402 and 503: https://magentlab.com/docs/payments

## Related tools

- [Bishop score](https://magentlab.com/docs/bishop) — Return the Bishop 1964 pelvic score as the sum of five caller-assigned integer components (dilation, effacement, station, consistency, position).
- [Flamm VBAC score](https://magentlab.com/docs/flamm-vbac) — 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](https://magentlab.com/docs/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.

- GET the tool with Accept: application/json (do not send Accept: text/html unless you want the human paywall).
- HTTP 402 means you have not paid. Decode the base64 PAYMENT-REQUIRED header. HTTP 503 is not a new quote.
- Sign accepts[0] (exact, EIP-3009) with validBefore = now + maxTimeoutSeconds (600 seconds), or accepts[1] (batch-settlement deposit/voucher) on product GET. Ping and POST {items} stay exact. Magent retries transient facilitator 429/5xx before answering.
- Retry the same URL with PAYMENT-SIGNATURE (base64 JSON of accepted and payload). Magent attaches canonical extensions.bazaar on CDP verify/settle; echoing 402 bazaar is optional.
- Success is HTTP 200 JSON plus PAYMENT-RESPONSE. exact settles before the tool. batch-settlement verifies (and deposit-settles) before the tool and commits the charge after HTTP 2xx. HTTP 503: retry the same PAYMENT-SIGNATURE. Mint a new exact nonce only after a new HTTP 402.

- offered `exact` on eip155:8453: Fixed-price USDC on Base. The buyer authorizes the advertised amount (EIP-3009). magent settles before the tool runs (paymentFlow upfront). extra.assetTransferMethod=eip3009 extra.paymentFlow=upfront.
- offered `batch-settlement` on eip155:8453: Payment-channel vouchers claimed later in batches. Exact stays accepts[0]. Same-path POST {items} is still exact. extra.assetTransferMethod=eip3009 extra.paymentFlow=authorization.

- not offered `upto`: Not offered. Usage-based: buyer authorizes a ceiling, seller settles the actual amount after work. Reserved for a future metered tool. Not for current calculators or code search.

Same-path POST {items} is still scheme exact: one EIP-3009 authorization for GET unit plus $0.002 per extra item. That is not x402 batch-settlement (payment channels / vouchers).

Shared HTTP 402 and 503 table: https://magentlab.com/docs/payments

Stdio MCP (one process per host): https://magentlab.com/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.
