Resolva uma identidade, quando houver evidência#
POST /v1/resolve recebe query como string obrigatória de 1 a 512 caracteres. O objetivo é identificar uma MedicationVariant canônica, não escolher um medicamento para um paciente. A API preserva a consulta original no campo query.
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"}'Exemplo positivo verificado#
NATULAXE CAPSULA foi confirmado como resolved no Hub RapidAPI. Os fatos confirmados são product_name = NATULAXE, entity_type = medication_variant e dosage_form = cápsula. Esta documentação mostra esses fatos sem inventar um UUID ou outros valores de resposta.
Quando status é resolved, resolved contém id, entity_type, product_name, brand_name, dosage_form e active_ingredient_text. brand_name e active_ingredient_text podem ser nulos. O texto de ingrediente não garante vínculo canônico com a tabela de ingredientes.
Abstenção é um resultado válido#
Quando não há evidência suficiente para uma identidade segura, status é unresolved e resolved é null. Ambos os resultados usam HTTP 200. Consultas curtas, ambíguas ou com erros de digitação não têm resolução positiva garantida. No modo padrão, candidatos e motivos internos do gate não são campos públicos. Scores nunca são públicos.
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);
}Identificação comercial assistida#
Envie {"query":"ANADOR 500MG 24CPR","mode":"assisted"} para optar pelo contrato assistido. Uma apresentação textual exige nome exato, concentração, forma e quantidade comprovados e correspondência única. EAN ou GGREM válidos usam lookup exato. Sem mode, o contrato V1 continua intacto.
ANADOR 500MG pode retornar ambiguous, resolved:null e até cinco candidatos com fatos do catálogo. AMOXILINA retorna nomes semelhantes, sem escolher uma apresentação. Confira reason, missing_fields e candidates_truncated. A lista limitada nunca prova unicidade; não selecione automaticamente o primeiro candidato.
Sugestão de grafia e identidade#
AMOXILINA pode sugerir AMOXICILINA; ANADRO 500MG 24CPR pode recuperar uma embalagem compatível. suggested_query e name_suggestions são pistas, não uma identificação confirmada. Confira o nome, a concentração, a forma e a embalagem. A API não converte unidades nem ignora atributos incompatíveis.
Separe ausência de correspondência e falha#
Um HTTP 503 representa indisponibilidade temporária, não unresolved. Não transforme erros de autenticação, quota ou serviço em ausência de identidade. Uma aplicação deve oferecer revisão manual ou pedir informações adicionais quando houver abstenção.
POST /v1/resolve#
| Campo JSON | Tipo e limites | Obrigatório |
|---|---|---|
| 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 |
Campos do contrato OpenAPI#
| Schema.campo | Tipo e limites | Obrigatório |
|---|---|---|
| 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 |