Module health.fhir.r4

ballerinax/health.fhir.r4 Ballerina library

4.3.0
FHIR R4 Base module

Sample Usage

This section focuses on samples depicting how to use this package to implement FHIR related integrations

Prerequisites

  1. Install Ballerina 2201.5.0 or later

Creating FHIR Resource models and serializing to JSON wire formats

Sample below is using the Patient resource in health.fhir.r4.internationa401 package.

Copy
import ballerina/log;
import ballerina/time;
import ballerinax/health.fhir.r4;
import ballerinax/health.fhir.r4.internationa401;


function createSamplePatient() returns json {
    internationa401:Patient patient = {
        meta: {
            lastUpdated: time:utcToString(time:utcNow()),
            profile: [internationa401:PROFILE_BASE_PATIENT]
        },
        active: true,
        name: [{
            family: "Doe",
            given: ["Jhon"],
            use: internationa401:official,
            prefix: ["Mr"]
        }],
        address: [{
            line: ["652 S. Lantern Dr."],
            city: "New York",
            country: "United States",
            postalCode: "10022",
            'type: internationa401:physical,
            use: internationa401:home
        }]
    };
    r4:FHIRResourceEntity fhirEntity = new(patient);
    // Serialize FHIR resource record to Json payload
    json|r4:FHIRSerializerError jsonResult = fhirEntity.toJson();
    if jsonResult is json {
        log:printInfo(string `Patient resource JSON payload : ${jsonResult.toString()}`);
        return jsonResult;
    } else {
        log:printError(string `Error occurred while serializing to JSON payload : ${jsonResult.message()}`, jsonResult);
    }
}

Import

import ballerinax/health.fhir.r4;Copy

Metadata

Released date: 4 months ago

Version: 4.3.0


Compatibility

Platform: any

Ballerina version: 2201.8.1

GraalVM compatible: Yes


Pull count

Total: 3949

Current verison: 240


Weekly downloads


Source repository


Keywords

Healthcare

FHIR

R4


Contributors

Other versions

See more...