-
Notifications
You must be signed in to change notification settings - Fork 61
Transactions
Jason Walonoski edited this page Apr 13, 2020
·
4 revisions
Batches and Transactions in FHIR allow a client to submit multiple requests (e.g. creates, searches, operations) bundled together in a single HTTP request.
In a batch, each request is handled independently. In a transaction, all requests must succeed.
In a batch, each request is handled independently. A batch can succeed even if one or more requests in the batch fail.
Batches contain a series of client.add_batch_request
calls bounded by client.begin_batch
and client.end_batch
.
client.begin_batch
client.add_transaction_request('POST', nil, patient)
client.add_transaction_request('POST', nil, observation)
reply = client.end_batch
In a transaction, all requests must succeed.
Transactions contain a series of client.add_transaction_request
calls bounded by client.begin_transaction
and client.end_transaction
.
# Create a patient
patient = FHIR::Patient.new
patient.id = 'temporary_id'
# Create an observation
observation = FHIR::Observation.new
observation.status = 'final'
coding = FHIR::Coding.new
coding.system = 'http://loinc.org'
coding.code='8302-2'
observation.code = FHIR::CodeableConcept.new
observation.code.coding = [ coding ]
quantity = FHIR::Quantity.new
quantity.value = 170
quantity.unit = 'cm'
quantity.system = 'http://unitsofmeasure.org'
observation.valueQuantity = quantity
reference = FHIR::Reference.new
reference.reference = "Patient/#{patient.id}"
observation.subject = reference
# Submit them both as a transaction
client.begin_transaction
client.add_transaction_request('POST', nil, patient)
client.add_transaction_request('POST', nil, observation)
reply = client.end_transaction
- Getting Started
- Configuration
-
Searching
- History
- CRUD
- Transactions
- Validation
-
Operations
$everything
$validate