Create FHIR resource from text and store it

POST/tools/lang2fhir-and-create

Converts natural language to FHIR resource and optionally stores it in a 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

resourcestringrequired

Type of FHIR resource to create. Use 'auto' for automatic resource type detection, or specify a supported US Core profile.

autoappointmentcondition-encounter-diagnosismedicationrequestcareplancondition-problems-health-concernscoverageencounterobservation-clinical-resultobservation-labpatientprocedurequestionnairequestionnaireresponseservicerequestsimple-observationvital-signs
textstringrequired

Natural language text to convert to FHIR resource

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 created FHIR resource

Response fields

fhir_resourceobjectoptional

The created FHIR resource

fhir_idstringoptional

ID of the resource in the FHIR server (if successfully stored)

successbooleanoptional
messagestringoptional

Status message

POSTRequest
# Get authentication token
PHENOML_TOKEN=$(curl -X POST "https://experiment.app.pheno.ml/v2/auth/token" \
  -u "$PHENOML_CLIENT_ID:$PHENOML_CLIENT_SECRET" \
  | jq -r '.access_token')

curl -X POST "https://experiment.app.pheno.ml/tools/lang2fhir-and-create" \
  -H "Authorization: Bearer $PHENOML_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "resource": "condition-encounter-diagnosis",
  "text": "Patient has severe persistent asthma with acute exacerbation",
  "provider": "550e8400-e29b-41d4-a716-446655440000"
}'
200 OKExample Response
{
  "success": true,
  "message": "FHIR resource created successfully",
  "fhir_id": "condition-123",
  "fhir_resource": {
    "resourceType": "Condition",
    "id": "condition-123",
    "clinicalStatus": {
      "coding": [
        {
          "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
          "code": "active"
        }
      ]
    },
    "verificationStatus": {
      "coding": [
        {
          "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status",
          "code": "confirmed"
        }
      ]
    },
    "category": [
      {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/condition-category",
            "code": "encounter-diagnosis"
          }
        ]
      }
    ],
    "code": {
      "coding": [
        {
          "system": "http://snomed.info/sct",
          "code": "195967001",
          "display": "Asthma"
        }
      ],
      "text": "Severe persistent asthma with acute exacerbation"
    },
    "subject": {
      "reference": "Patient/patient-123"
    }
  }
}