HAPI FHIR Server

create-type: Create a new AllergyIntolerance instance

Create AllergyIntolerance Record

The Create AllergyIntolerance method allows you to add a new allergy or intolerance record for a patient. This is useful for logging new allergies during patient intake, updating a medical history, or ensuring known allergies are properly recorded in an EHR system.

Endpoint

POST /fhir/R4/AllergyIntolerance

Required Headers

Authorization: Bearer {access_token}  
Accept: application/fhir+json  
Content-Type: application/fhir+json

Request Body Parameters

Parameter Type Required Description
clinicalStatus CodeableConcept Yes Indicates whether the allergy is active, inactive, or resolved.
verificationStatus CodeableConcept Yes Whether the allergy is confirmed or refuted.
type string No Defines if the reaction is an allergy or intolerance.
category array No Category of the allergen (e.g., medication, food, environment).
code CodeableConcept Yes The substance that triggers the reaction.
patient Reference Yes Reference to the patient associated with the allergy.
reaction array No Details about symptoms and severity.
recordedDate dateTime No The date the allergy was recorded.
recorder Reference No Who documented the allergy.

Example Request (Java)

import java.net.HttpURLConnection;
import java.net.URL;
import java.io.OutputStream;

public class AllergyIntoleranceCreate {
    public static void main(String[] args) throws Exception {
        String apiUrl = "https://api.healthgorilla.com/fhir/R4/AllergyIntolerance";
        URL url = new URL(apiUrl);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Authorization", "Bearer your_access_token");
        conn.setRequestProperty("Content-Type", "application/fhir+json");
        conn.setDoOutput(true);

        String jsonInputString = "{\"resourceType\": \"AllergyIntolerance\", \"clinicalStatus\": {\"coding\": [{\"system\": \"http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical\", \"code\": \"active\"}]}, \"code\": {\"coding\": [{\"system\": \"http://www.nlm.nih.gov/research/umls/rxnorm\", \"code\": \"2670\", \"display\": \"Penicillin\"}]}, \"patient\": {\"reference\": \"Patient/67890\"}}";

        try (OutputStream os = conn.getOutputStream()) {
            byte[] input = jsonInputString.getBytes("utf-8");
            os.write(input, 0, input.length);
        }

        int responseCode = conn.getResponseCode();
        System.out.println("Response Code: " + responseCode);
    }
}

Example Response

{
  "resourceType": "AllergyIntolerance",
  "id": "98765",
  "clinicalStatus": {
    "coding": [{
      "system": "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical",
      "code": "active",
      "display": "Active"
    }]
  },
  "code": {
    "coding": [{
      "system": "http://www.nlm.nih.gov/research/umls/rxnorm",
      "code": "2670",
      "display": "Penicillin"
    }]
  },
  "patient": {
    "reference": "Patient/67890"
  },
  "recordedDate": "2024-02-18T12:00:00Z"
}

Additional Resources

FHIR AllergyIntolerance Resource
Health Gorilla API Reference

post
http://localhost:8080/fhir/R4/AllergyIntolerance

Body

FHIR-JSON-RESOURCE

FHIR-JSON-RESOURCEobject

A FHIR resource

Response

200

Success

FHIR-JSON-RESOURCE

FHIR-JSON-RESOURCEobject

A FHIR resource

post/AllergyIntolerance

Body

{
  "resourceType": "AllergyIntolerance"
}
{ "resourceType": "AllergyIntolerance" }
 
curl --request POST \
  --url http://localhost:8080/fhir/R4/AllergyIntolerance \
  --header 'Accept: application/fhir+json, application/fhir+xml' \
  --header 'Authorization: Bearer ' \
  --header 'Content-Type: application/fhir+json' \
  --data '{
  "resourceType": "AllergyIntolerance"
}'
200
{}