Skip to content
This repository was archived by the owner on Mar 12, 2018. It is now read-only.

rahulsom/fhir-protobuf

Repository files navigation

FHIR Protobuf

Experimental FHIR parser that serializes to Protobuf. See this to see motivation.

Warning
This is not an official FHIR format. This was written before google open sourced their implementation of fhir protocol buffers. Based on what we’ve seen on the mailing lists, it appears that the google implementation will be adopted as an official standard.

Features

  • ✓ Parse and Create Protobufs using Protobuf DSL

  • ✓ Parse and Create Protobuf’s JSON using Protobuf DSL

  • ✓ Convert Standard JSON to Protobuf JSON

  • ✓ Convert Protobuf JSON to Standard JSON

Usage

Download the library you need from Maven

Types

badge

Contains types for parsing Protobuf binary and JSON formats.

Translate

badge

Supports translation of FHIR JSON to Protobuf JSON and back. Depends on Types.

Once released, the artifact will ba available on Maven Central. Until then, snapshots can be downloaded from Sonatype OSS.

To create a practitioner

Practitioner practitioner = Practitioner.newBuilder().
        setId("Practitioner_1").
        addName(HumanName.newBuilder().
                addGiven("Bob").
                setFamily("Kelso")).
        setGender(Practitioner_gender.Practitioner_gender_male).
        addIdentifier(Identifier.newBuilder().
                setSystem("https://stmarys.com/practitioners").
                setValue("BK001")).
        build();

To serialize to Protobuf Binary Format

byte[] protobufByteArray = practitioner.toByteArray();

To parse from Protobuf Binary Format

Practitioner practitionerFromBinary = Practitioner.parseFrom(protobufByteArray);

To serialize to Protobuf Json Format

String protobufJson = JsonFormat.printer().print(practitioner);

To parseFrom Protobuf Json Format

Practitioner.Builder jsonPractitionerBuilder = Practitioner.newBuilder();
JsonFormat.parser().merge(protobufJson, jsonPractitionerBuilder);
Practitioner practitionerFromJson = jsonPractitionerBuilder.build();

To translate FHIR Json to Protobuf Json

String protoJson = Converter.fromFhirJson(fhirJsonAsString);

To translate Protobuf Json to FHIR Json

String fhirJson = Converter.toFhirJson(protoJson);

About

Unofficial FHIR Protobuf Parser

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors