Upload custom FHIR profile

POST/lang2fhir/profile/upload

Upload a custom FHIR StructureDefinition profile for use with the lang2fhir service.

All metadata is derived from the StructureDefinition JSON itself. The lowercase id field from the StructureDefinition is used as the profile's unique identifier and lookup key. To use the uploaded profile with /lang2fhir/create, pass this id as the resource parameter.

Uploads will be rejected if:

  • A built-in US Core or R4 base profile already exists with the same id
  • A custom profile with the same id has already been uploaded
  • A custom profile with the same url has already been uploaded
RequiresBearerauthentication

Body parameters

profilestringrequired

Base64 encoded JSON string of a FHIR StructureDefinition. The profile must include id, url, type, and a snapshot with elements. All metadata (version, resource type, identifier) is derived from the StructureDefinition itself. The lowercase id from the StructureDefinition becomes the profile's lookup key.

implementation_guidestringoptional

Implementation Guide name to group this profile under. Defaults to "custom" if omitted. Cannot be "us_core" (reserved). Use this to organize custom profiles into named IGs that can be referenced when calling create/multi or document/multi endpoints.

profile_contextstringoptional

Natural language context that helps the LLM select the right profiles from this implementation guide during resource detection. For example, "When the text mentions phenotypic features or abnormalities, prefer the hpo-observation profile over Condition." This is stored as IG-level metadata and injected into the LLM prompt. Max 2000 characters. Providing this field on any upload will update the context for the entire IG (last write wins).

Returns  

Profile successfully uploaded

Response fields

messagestringoptional
idstringoptional

The lowercase StructureDefinition id, used as the profile's unique identifier and lookup key. Pass this value as the resource parameter to /lang2fhir/create or /lang2fhir/profile/json/:version/:resource to use this profile.

typestringoptional

The FHIR resource type from the StructureDefinition

urlstringoptional

The canonical URL from the StructureDefinition

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/lang2fhir/profile/upload' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "profile": "(base64 encoded FHIR StructureDefinition JSON)",
  "implementation_guide": "acme-cardiology",
  "profile_context": "When clinical text describes phenotypic features, abnormalities, or findings that map to HPO terms, use the hpo-phenotype-observation profile instead of Condition."
}'
201 CreatedResponse
{
  "message": "Profile successfully uploaded",
  "id": "custom-patient",
  "type": "Patient",
  "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient"
}