Search FHIR resources from natural language

POST/tools/lang2fhir-and-search

Converts natural language to FHIR search parameters and executes search in FHIR server

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Body parameters

textstringrequired

Natural language text to convert to FHIR search parameters

patient_idstringoptional

Patient ID to filter results

countintegeroptional

Maximum number of results to return

providerstring (uuid)optional

FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)

Returns  

Successfully generated search and retrieved results

Response fields

resource_typestringoptional

The FHIR resource type identified for the search

search_paramsstringoptional

FHIR search parameters in standard format

fhir_resultsobject[]optional

Array of FHIR resources returned from the search

successbooleanoptional
messagestringoptional

Status message

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/tools/lang2fhir-and-search' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "Find all appointments for patient John Doe next week",
  "patient_id": "patient-123",
  "count": 10,
  "provider": "550e8400-e29b-41d4-a716-446655440000"
}'
200 OKResponse
{
  "resource_type": "Appointment",
  "search_params": "patient=Patient/patient-123&date=ge2024-01-15&date=le2024-01-22",
  "fhir_results": [
    {
      "resourceType": "Appointment",
      "id": "appointment-123",
      "status": "booked",
      "start": "2024-01-16T10:00:00Z",
      "end": "2024-01-16T11:00:00Z",
      "participant": [
        {
          "actor": {
            "reference": "Patient/patient-123",
            "display": "John Doe"
          }
        }
      ]
    }
  ],
  "success": true,
  "message": "Successfully generated search and retrieved results"
}