# Medication name normalization and resolution

Integrate POST /v1/resolve and handle resolved and unresolved safely without assuming every name identifies a unique variant.

Canonical: https://iabula.com/docs/en/resolve

## Resolve an identity when evidence is sufficient

POST /v1/resolve accepts a required query string of 1–512 characters. It identifies a canonical MedicationVariant; it does not select medication for a patient. The response preserves the original query.

```bash
curl --fail-with-body "$IABULA_API_BASE/v1/resolve" \
  --header "X-API-Key: $IABULA_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"query":"NATULAXE CAPSULA"}'
```

## Verified positive example

NATULAXE CAPSULA was confirmed as resolved in the RapidAPI Hub. Confirmed facts are product_name = NATULAXE, entity_type = medication_variant and dosage_form = cápsula. These facts are documented without inventing a UUID or additional response values.

When status is resolved, resolved contains id, entity_type, product_name, brand_name, dosage_form and active_ingredient_text. brand_name and active_ingredient_text may be null. Ingredient text does not guarantee a canonical link to an ingredient entity.

## Abstention is a valid outcome

When evidence is insufficient for a safe identity, status is unresolved and resolved is null. Both outcomes use HTTP 200. Short, ambiguous or misspelled queries are not guaranteed to resolve. In default mode, candidates and internal gate diagnostics are not public fields. Scores are never public.

```javascript
const response = await fetch(`${process.env.IABULA_API_BASE}/v1/resolve`, {
  method: "POST",
  headers: {
    "X-API-Key": process.env.IABULA_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ query: "NATULAXE CAPSULA" }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.code}`);
if (result.status === "unresolved") {
  // Ask for more source information or route to manual review.
} else {
  console.log(result.resolved.product_name, result.resolved.dosage_form);
}
```

## Assisted commercial identification

Send {"query":"ANADOR 500MG 24CPR","mode":"assisted"} to opt into assisted matching. A textual presentation requires exact name, proven strength, form and count, and a unique match. Valid EAN or GGREM codes use exact lookup. Omitting mode preserves the V1 contract.

ANADOR 500MG may return ambiguous, resolved:null and up to five candidates with catalog facts. AMOXILINA returns similar names without selecting a presentation. Inspect reason, missing_fields and candidates_truncated. A limited list never proves uniqueness; never automatically select the first candidate.

## Spelling hints and identity

AMOXILINA may suggest AMOXICILINA; ANADRO 500MG 24CPR may retrieve a compatible package. suggested_query and name_suggestions are hints, not confirmed identity. Check name, strength, form and package. The API never converts units or ignores incompatible attributes.

## Distinguish no match from failure

HTTP 503 indicates temporary unavailability, not unresolved. Do not translate authentication, quota or service errors into absence of identity. Applications should allow manual review or request more source information after abstention.

- [API errors](https://iabula.com/docs/en/errors)
- [Normalization guide](https://iabula.com/docs/en/guides/normalizar-nome-de-medicamento)

## POST /v1/resolve

| JSON field | Type and bounds | Required |
| --- | --- | --- |
| query | string; minLength=1, maxLength=512 | yes |
| mode | string: legacy, assisted; default=legacy | no |

| HTTP | Content-Type | Schema |
| --- | --- | --- |
| 200 | application/json | AssistedResolveResponse \| ResolveSuccess \| ResolveUnresolved |
| 400 | application/problem+json | Problem |
| 401 | application/problem+json | Problem |
| 403 | application/problem+json | Problem |
| 500 | application/problem+json | Problem |
| 503 | application/problem+json | Problem |
| 429 | application/problem+json | Problem |
| 422 | application/json | HTTPValidationError |

## OpenAPI contract fields

| Schema.field | Type and bounds | Required |
| --- | --- | --- |
| AssistedResolveResponse.mode | string: assisted | yes |
| AssistedResolveResponse.status | string: resolved, ambiguous, unresolved | yes |
| AssistedResolveResponse.query | string | yes |
| AssistedResolveResponse.resolved | ResolvePresentation \| ResolvedMedicationVariant \| null | yes |
| AssistedResolveResponse.reason | string: unique_identifier, unique_presentation, variant_identified, multiple_matches, insufficient_information, similar_names, no_match, invalid_identifier, unsupported_description | yes |
| AssistedResolveResponse.candidates | array<ResolvePresentation> | yes |
| AssistedResolveResponse.candidates_truncated | boolean | yes |
| AssistedResolveResponse.missing_fields | array<string: dosage_form, strength, unit_count, laboratory_or_identifier> | yes |
| AssistedResolveResponse.suggested_query | string \| null | no |
| AssistedResolveResponse.name_suggestions | array<ResolveNameSuggestion> | no |
| Evidence.class | string | yes |
| Evidence.source | string \| null | no |
| Evidence.attribute | string \| null | no |
| HTTPValidationError.detail | array<ValidationError> | no |
| PackageContent.amount | string | yes |
| PackageContent.unit | string | yes |
| PackageContent.class | string: DERIVED | yes |
| Problem.type | string | yes |
| Problem.title | string | yes |
| Problem.status | integer | yes |
| Problem.code | string | yes |
| Problem.detail | string \| null | no |
| Problem.request_id | string | yes |
| ResolveNameSuggestion.name | string | yes |
| ResolveNameSuggestion.kind | string: product, substance | yes |
| ResolvePresentation.strength | string \| null | no |
| ResolvePresentation.package_description | string \| null | no |
| ResolvePresentation.structured_strength | StructuredStrength \| null | no |
| ResolvePresentation.package_content | PackageContent \| null | no |
| ResolvePresentation.id | string (uuid) | yes |
| ResolvePresentation.unit_count | integer \| null | no |
| ResolvePresentation.identifiers | array<SupportedSourceIdentifier> | yes |
| ResolvePresentation.evidence | array<Evidence> | yes |
| ResolvePresentation.entity_type | string: presentation | yes |
| ResolvePresentation.product_id | string (uuid) | yes |
| ResolvePresentation.product_name | string | yes |
| ResolvePresentation.variant_id | string (uuid) | yes |
| ResolvePresentation.dosage_form | string \| null | yes |
| ResolvePresentation.source_laboratories | array<SupportedSourceValue> | yes |
| ResolvePresentation.source_substances | array<SupportedSourceValue> | yes |
| ResolveRequest.query | string; minLength=1, maxLength=512 | yes |
| ResolveRequest.mode | string: legacy, assisted; default=legacy | no |
| ResolveSuccess.status | string: resolved | yes |
| ResolveSuccess.query | string | yes |
| ResolveSuccess.resolved | ResolvedMedicationVariant | yes |
| ResolveUnresolved.status | string: unresolved | yes |
| ResolveUnresolved.query | string | yes |
| ResolveUnresolved.resolved | null | yes |
| ResolvedMedicationVariant.id | string (uuid) | yes |
| ResolvedMedicationVariant.entity_type | string: medication_variant | yes |
| ResolvedMedicationVariant.product_name | string | yes |
| ResolvedMedicationVariant.brand_name | string \| null | yes |
| ResolvedMedicationVariant.dosage_form | string | yes |
| ResolvedMedicationVariant.active_ingredient_text | string \| null | yes |
| StrengthComponent.amount | string | yes |
| StrengthComponent.unit | string | yes |
| StrengthComponent.per_amount | string \| null | yes |
| StrengthComponent.per_unit | string \| null | yes |
| StructuredStrength.status | string: structured, missing, unparsed | yes |
| StructuredStrength.components | array<StrengthComponent> | yes |
| StructuredStrength.class | string: DERIVED | yes |
| SupportedSourceIdentifier.value | string | yes |
| SupportedSourceIdentifier.evidence | array<Evidence> | yes |
| SupportedSourceIdentifier.format_status | string: checksum_valid, checksum_invalid, invalid_format, not_checked; default=not_checked | no |
| SupportedSourceIdentifier.scheme | string: CMED_REGISTRO, CMED_CNPJ, CMED_GGREM, EAN | yes |
| SupportedSourceValue.value | string | yes |
| SupportedSourceValue.evidence | array<Evidence> | yes |
| ValidationError.loc | array<string \| integer> | yes |
| ValidationError.msg | string | yes |
| ValidationError.type | string | yes |
| ValidationError.input | object | no |
| ValidationError.ctx | object | no |

## Resources

- [OpenAPI JSON](https://iabula.com/openapi.json)
- [Swagger](https://iabula.com/docs/swagger)
- [Documentation index](https://iabula.com/llms.txt)
