Fhir Protobuf Translate

null

License

License

Categories

Categories

Protobuf Data Data Structures
GroupId

GroupId

com.github.rahulsom
ArtifactId

ArtifactId

fhir-protobuf-translate
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Fhir Protobuf Translate
null
Project URL

Project URL

https://github.com/rahulsom/fhir-protobuf
Source Code Management

Source Code Management

https://github.com/rahulsom/fhir-protobuf

Download fhir-protobuf-translate

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.rahulsom/fhir-protobuf-translate/ -->
<dependency>
    <groupId>com.github.rahulsom</groupId>
    <artifactId>fhir-protobuf-translate</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.rahulsom/fhir-protobuf-translate/
implementation 'com.github.rahulsom:fhir-protobuf-translate:0.1.0'
// https://jarcasting.com/artifacts/com.github.rahulsom/fhir-protobuf-translate/
implementation ("com.github.rahulsom:fhir-protobuf-translate:0.1.0")
'com.github.rahulsom:fhir-protobuf-translate:jar:0.1.0'
<dependency org="com.github.rahulsom" name="fhir-protobuf-translate" rev="0.1.0">
  <artifact name="fhir-protobuf-translate" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.rahulsom', module='fhir-protobuf-translate', version='0.1.0')
)
libraryDependencies += "com.github.rahulsom" % "fhir-protobuf-translate" % "0.1.0"
[com.github.rahulsom/fhir-protobuf-translate "0.1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
com.github.rahulsom : fhir-protobuf-types jar 0.1.0

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
ca.uhn.hapi.fhir : hapi-fhir-structures-dstu3 jar 3.1.0

Project Modules

There are no modules declared in this project.

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);

Versions

Version
0.1.0