Skip to content

Commit

Permalink
Separates "google" extensions into two extension files: google.fhir.$…
Browse files Browse the repository at this point in the history
…version.fhirproto for extensions that are inherent to the FHIR proto format and do not appear in JSON, and

google.fhir.$version.ml for machine-learning related extensions.

In addition to being more descriptive and tighter in scope, these names eliminate the problem vector that occurs from having the token "google" twice in the same namespace

PiperOrigin-RevId: 324271177
  • Loading branch information
nickgeorge committed Aug 14, 2020
1 parent 2824b7e commit 184d5aa
Show file tree
Hide file tree
Showing 74 changed files with 355 additions and 269 deletions.
1 change: 1 addition & 0 deletions cc/google/fhir/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ cc_test(
"//proto/r4/core/resources:bundle_and_contained_resource_cc_proto",
"//proto/stu3:datatypes_cc_proto",
"//proto/stu3:extensions_cc_proto",
"//proto/stu3:ml_extensions_cc_proto",
"//proto/stu3:resources_cc_proto",
"//testdata/r4/profiles:test_cc_proto",
"//testdata/stu3/profiles:test_cc_proto",
Expand Down
7 changes: 4 additions & 3 deletions cc/google/fhir/r4/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ cc_test(
":extensions",
"//cc/google/fhir:test_helper",
"//cc/google/fhir/testutil:proto_matchers",
"//proto/r4:google_extensions_cc_proto",
"//proto/r4:fhirproto_extensions_cc_proto",
"//proto/r4:ml_extensions_cc_proto",
"//proto/r4/core:datatypes_cc_proto",
"//proto/r4/core:extensions_cc_proto",
"//proto/r4/core/resources:composition_cc_proto",
Expand Down Expand Up @@ -136,7 +137,7 @@ cc_library(
"//cc/google/fhir:util",
"//cc/google/fhir/status",
"//cc/google/fhir/status:statusor",
"//proto/r4:google_extensions_cc_proto",
"//proto/r4:fhirproto_extensions_cc_proto",
"//proto/r4/core:datatypes_cc_proto",
"//proto/r4/core/resources:bundle_and_contained_resource_cc_proto",
"@com_google_absl//absl/memory",
Expand All @@ -160,7 +161,7 @@ cc_test(
"//cc/google/fhir:json_format",
"//cc/google/fhir:test_helper",
"//cc/google/fhir/testutil:proto_matchers",
"//proto/r4:google_extensions_cc_proto",
"//proto/r4:fhirproto_extensions_cc_proto",
"//proto/r4/core:datatypes_cc_proto",
"//proto/r4/core/resources:binary_cc_proto",
"//proto/r4/core/resources:observation_cc_proto",
Expand Down
11 changes: 6 additions & 5 deletions cc/google/fhir/r4/extensions_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
#include "proto/r4/core/datatypes.pb.h"
#include "proto/r4/core/extensions.pb.h"
#include "proto/r4/core/resources/composition.pb.h"
#include "proto/r4/google_extensions.pb.h"
#include "proto/r4/fhirproto_extensions.pb.h"
#include "proto/r4/ml_extensions.pb.h"
#include "testdata/r4/profiles/test_extensions.pb.h"

namespace google {
Expand All @@ -37,11 +38,11 @@ namespace {
using core::CapabilityStatementSearchParameterCombination;
using core::Composition;
using core::Extension;
using google::Base64BinarySeparatorStride;
using google::EventLabel;
using google::EventTrigger;
using google::PrimitiveHasNoValue;
using fhirproto::Base64BinarySeparatorStride;
using fhirproto::PrimitiveHasNoValue;
using ::google::fhir::testutil::EqualsProto;
using ml::EventLabel;
using ml::EventTrigger;
using testing::DigitalMediaType;

template <class T>
Expand Down
4 changes: 2 additions & 2 deletions cc/google/fhir/r4/primitive_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "google/fhir/status/statusor.h"
#include "google/fhir/util.h"
#include "proto/r4/core/datatypes.pb.h"
#include "proto/r4/google_extensions.pb.h"
#include "proto/r4/fhirproto_extensions.pb.h"
#include "include/json/json.h"

namespace google {
Expand All @@ -50,7 +50,7 @@ StatusOr<std::unique_ptr<PrimitiveWrapper>> R4PrimitiveHandler::GetWrapper(
const Descriptor* target_descriptor) const {
absl::optional<std::unique_ptr<PrimitiveWrapper>> wrapper =
primitives_internal::GetWrapperForR4Types<
core::Extension, core::Xhtml, google::Base64BinarySeparatorStride>(
core::Extension, core::Xhtml, fhirproto::Base64BinarySeparatorStride>(
target_descriptor);

if (wrapper.has_value()) {
Expand Down
8 changes: 4 additions & 4 deletions cc/google/fhir/r4/primitive_handler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
#include "google/fhir/json_format.h"
#include "google/fhir/r4/json_format.h"
#include "google/fhir/test_helper.h"
#include "google/fhir/testutil/proto_matchers.h"
#include "proto/r4/core/datatypes.pb.h"
#include "proto/r4/core/resources/binary.pb.h"
#include "proto/r4/core/resources/observation.pb.h"
#include "proto/r4/core/resources/patient.pb.h"
#include "proto/r4/google_extensions.pb.h"
#include "google/fhir/testutil/proto_matchers.h"
#include "proto/r4/fhirproto_extensions.pb.h"

namespace google {
namespace fhir {
Expand Down Expand Up @@ -107,8 +107,8 @@ void TestJsonValidation() {
template <class W>
void AddPrimitiveHasNoValue(W* primitive) {
Extension* e = primitive->add_extension();
e->mutable_url()->set_value(
GetStructureDefinitionUrl(r4::google::PrimitiveHasNoValue::descriptor()));
e->mutable_url()->set_value(GetStructureDefinitionUrl(
r4::fhirproto::PrimitiveHasNoValue::descriptor()));
e->mutable_value()->mutable_boolean()->set_value(true);
}

Expand Down
5 changes: 3 additions & 2 deletions cc/google/fhir/seqex/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ cc_library(
":resource_to_example",
":text_tokenizer",
"//cc/google/fhir/stu3:primitive_handler",
"//proto/stu3:extensions_cc_proto",
"//proto/stu3:fhirproto_extensions_cc_proto",
"//proto/stu3:ml_extensions_cc_proto",
"//proto/stu3:resources_cc_proto",
"@com_google_absl//absl/status",
],
Expand All @@ -224,7 +225,7 @@ cc_library(
":resource_to_example",
":text_tokenizer",
"//cc/google/fhir/r4:primitive_handler",
"//proto/r4:google_extensions_cc_proto",
"//proto/r4:ml_extensions_cc_proto",
"//proto/r4/core/resources:bundle_and_contained_resource_cc_proto",
"//proto/r4/core/resources:claim_cc_proto",
"//proto/r4/core/resources:composition_cc_proto",
Expand Down
6 changes: 3 additions & 3 deletions cc/google/fhir/seqex/r4.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "proto/r4/core/resources/patient.pb.h"
#include "proto/r4/core/resources/procedure.pb.h"
#include "proto/r4/core/resources/service_request.pb.h"
#include "proto/r4/google_extensions.pb.h"
#include "proto/r4/ml_extensions.pb.h"

namespace google {
namespace fhir {
Expand All @@ -51,8 +51,8 @@ inline void ResourceToExample(const google::protobuf::Message& message,
::google::fhir::r4::R4PrimitiveHandler::GetInstance());
}

typedef seqex::ConverterTypes<google::fhir::r4::google::EventTrigger,
google::fhir::r4::google::EventLabel,
typedef seqex::ConverterTypes<google::fhir::r4::ml::EventTrigger,
google::fhir::r4::ml::EventLabel,
r4::R4PrimitiveHandler>
ConverterTypes;

Expand Down
7 changes: 4 additions & 3 deletions cc/google/fhir/seqex/stu3.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#include "google/fhir/seqex/resource_to_example.h"
#include "google/fhir/seqex/text_tokenizer.h"
#include "google/fhir/stu3/primitive_handler.h"
#include "proto/stu3/google_extensions.pb.h"
#include "proto/stu3/fhirproto_extensions.pb.h"
#include "proto/stu3/ml_extensions.pb.h"
#include "proto/stu3/resources.pb.h"

namespace google {
Expand All @@ -41,8 +42,8 @@ inline void ResourceToExample(const google::protobuf::Message& message,
::google::fhir::stu3::Stu3PrimitiveHandler::GetInstance());
}

typedef seqex::ConverterTypes<google::fhir::stu3::google::EventTrigger,
google::fhir::stu3::google::EventLabel,
typedef seqex::ConverterTypes<google::fhir::stu3::ml::EventTrigger,
google::fhir::stu3::ml::EventLabel,
stu3::Stu3PrimitiveHandler>
ConverterTypes;

Expand Down
6 changes: 4 additions & 2 deletions cc/google/fhir/stu3/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ cc_test(
"//cc/google/fhir/testutil:proto_matchers",
"//proto/stu3:datatypes_cc_proto",
"//proto/stu3:extensions_cc_proto",
"//proto/stu3:fhirproto_extensions_cc_proto",
"//proto/stu3:ml_extensions_cc_proto",
"//proto/stu3:resources_cc_proto",
"//testdata/stu3/profiles:test_cc_proto",
"@com_google_absl//absl/status",
Expand All @@ -129,7 +131,7 @@ cc_library(
"//cc/google/fhir/status",
"//cc/google/fhir/status:statusor",
"//proto/stu3:datatypes_cc_proto",
"//proto/stu3:extensions_cc_proto",
"//proto/stu3:fhirproto_extensions_cc_proto",
"//proto/stu3:resources_cc_proto",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
Expand Down Expand Up @@ -222,7 +224,7 @@ cc_test(
"//cc/google/fhir/testutil:proto_matchers",
"//proto/stu3:codes_cc_proto",
"//proto/stu3:datatypes_cc_proto",
"//proto/stu3:extensions_cc_proto",
"//proto/stu3:fhirproto_extensions_cc_proto",
"//proto/stu3:resources_cc_proto",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
Expand Down
11 changes: 6 additions & 5 deletions cc/google/fhir/stu3/extensions_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#include "google/fhir/testutil/proto_matchers.h"
#include "proto/stu3/datatypes.pb.h"
#include "proto/stu3/extensions.pb.h"
#include "proto/stu3/google_extensions.pb.h"
#include "proto/stu3/fhirproto_extensions.pb.h"
#include "proto/stu3/ml_extensions.pb.h"
#include "proto/stu3/resources.pb.h"
#include "testdata/stu3/profiles/test_extensions.pb.h"

Expand All @@ -34,11 +35,11 @@ namespace stu3 {

namespace {

using google::Base64BinarySeparatorStride;
using google::EventLabel;
using google::EventTrigger;
using google::PrimitiveHasNoValue;
using fhirproto::Base64BinarySeparatorStride;
using fhirproto::PrimitiveHasNoValue;
using ::google::fhir::testutil::EqualsProto;
using ml::EventLabel;
using ml::EventTrigger;
using proto::CapabilityStatementSearchParameterCombination;
using proto::Composition;
using testing::DigitalMediaType;
Expand Down
6 changes: 3 additions & 3 deletions cc/google/fhir/stu3/primitive_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "google/fhir/status/statusor.h"
#include "google/fhir/util.h"
#include "proto/stu3/datatypes.pb.h"
#include "proto/stu3/google_extensions.pb.h"
#include "proto/stu3/fhirproto_extensions.pb.h"
#include "include/json/json.h"

namespace google {
Expand All @@ -50,8 +50,8 @@ StatusOr<std::unique_ptr<PrimitiveWrapper>> Stu3PrimitiveHandler::GetWrapper(
const Descriptor* target_descriptor) const {
absl::optional<std::unique_ptr<PrimitiveWrapper>> wrapper =
primitives_internal::GetWrapperForStu3Types<
proto::Extension, proto::Xhtml, google::Base64BinarySeparatorStride>(
target_descriptor);
proto::Extension, proto::Xhtml,
fhirproto::Base64BinarySeparatorStride>(target_descriptor);

if (wrapper.has_value()) {
return std::move(wrapper.value());
Expand Down
6 changes: 3 additions & 3 deletions cc/google/fhir/stu3/primitive_handler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#include "google/fhir/json_format.h"
#include "google/fhir/stu3/json_format.h"
#include "google/fhir/test_helper.h"
#include "google/fhir/testutil/proto_matchers.h"
#include "proto/stu3/codes.pb.h"
#include "proto/stu3/datatypes.pb.h"
#include "proto/stu3/google_extensions.pb.h"
#include "proto/stu3/fhirproto_extensions.pb.h"
#include "proto/stu3/resources.pb.h"
#include "google/fhir/testutil/proto_matchers.h"

namespace google {
namespace fhir {
Expand Down Expand Up @@ -110,7 +110,7 @@ template <class W>
void AddPrimitiveHasNoValue(W* primitive) {
Extension* e = primitive->add_extension();
e->mutable_url()->set_value(GetStructureDefinitionUrl(
stu3::google::PrimitiveHasNoValue::descriptor()));
stu3::fhirproto::PrimitiveHasNoValue::descriptor()));
e->mutable_value()->mutable_boolean()->set_value(true);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/gcp_datalab/02-gen-fhirdependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mkdir out-bin
cp -fr bazel-bin/py ./out-bin/.
cp -fr bazel-bin/proto ./out-bin/.

#Importing google_extensions_pb2
#Importing fhirproto_extensions_pb2
touch ./out-genfiles/proto/__init__.py
touch ./out-genfiles/proto/stu3/__init__.py

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"import time\n",
"\n",
"from proto import version_config_pb2\n",
"from proto.stu3 import google_extensions_pb2\n",
"from proto.stu3 import fhirproto_extensions_pb2\n",
"from proto.stu3 import resources_pb2\n",
"\n",
"from google.protobuf import text_format\n",
Expand Down Expand Up @@ -251,7 +251,7 @@
"\n",
"_ = labels | beam.io.WriteToTFRecord(\n",
" LABELS_PATH,\n",
" coder=beam.coders.ProtoCoder(google_extensions_pb2.EventLabel),\n",
" coder=beam.coders.ProtoCoder(fhirproto_extensions_pb2.EventLabel),\n",
" file_name_suffix='.tfrecords')"
]
},
Expand Down Expand Up @@ -486,7 +486,7 @@
"event_labels = ( \n",
" p1 | 'readEventLabels' >> beam.io.ReadFromTFRecord(\n",
" TF_RECORD_LABELS,\n",
" coder=beam.coders.ProtoCoder(google_extensions_pb2.EventLabel)))\n",
" coder=beam.coders.ProtoCoder(fhirproto_extensions_pb2.EventLabel)))\n",
"\n",
"keyed_event_labels = bundle_to_seqex.CreateTriggerLabelsPairLists(\n",
" event_labels)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"import time\n",
"\n",
"from proto import version_config_pb2\n",
"from proto.stu3 import google_extensions_pb2\n",
"from proto.stu3 import fhirproto_extensions_pb2\n",
"from proto.stu3 import resources_pb2\n",
"\n",
"from google.protobuf import text_format\n",
Expand Down
20 changes: 10 additions & 10 deletions go/google/fhir/jsonformat/BUILD → go/jsonformat/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ go_library(
"unmarshaller.go",
"version_config.go",
],
importpath = "google/fhir/jsonformat/jsonformat",
importpath = "github.com/google/fhir/go/jsonformat",
deps = [
"//go/google/fhir/jsonformat/internal/accessor",
"//go/google/fhir/jsonformat/internal/jsonpbhelper",
"//go/jsonformat/internal/accessor",
"//go/jsonformat/internal/jsonpbhelper",
"//proto:annotations_go_proto",
"//proto/r4:google_extensions_go_proto",
"//proto/r4:fhirproto_extensions_go_proto",
"//proto/r4/core:datatypes_go_proto",
"//proto/r4/core/resources:bundle_and_contained_resource_go_proto",
"//proto/stu3:datatypes_go_proto",
"//proto/stu3:extensions_go_proto",
"//proto/stu3:fhirproto_extensions_go_proto",
"//proto/stu3:resources_go_proto",
"@com_bitbucket_creachadair_stringset//:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
Expand All @@ -48,13 +48,13 @@ go_test(
],
embed = [":jsonformat"],
deps = [
"//go/google/fhir/jsonformat/internal/accessor",
"//go/google/fhir/jsonformat/internal/jsonpbhelper",
"//go/jsonformat/internal/accessor",
"//go/jsonformat/internal/jsonpbhelper",
"//proto:annotations_go_proto",
"//proto/r4:google_extensions_go_proto",
"//proto/r4:fhirproto_extensions_go_proto",
"//proto/r4/core:datatypes_go_proto",
"//proto/stu3:datatypes_go_proto",
"//proto/stu3:extensions_go_proto",
"//proto/stu3:fhirproto_extensions_go_proto",
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_google_go_cmp//cmp:go_default_library",
"@org_golang_google_protobuf//reflect/protoreflect:go_default_library",
Expand All @@ -71,7 +71,7 @@ go_test(
],
embed = [":jsonformat"],
deps = [
"//go/google/fhir/jsonformat/internal/jsonpbhelper",
"//go/jsonformat/internal/jsonpbhelper",
"//proto/dstu2:codes_go_proto",
"//proto/dstu2:datatypes_go_proto",
"//proto/dstu2:metadatatypes_go_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"fmt"
"time"

"google/fhir/jsonformat/internal/accessor/accessor"
"google/fhir/jsonformat/internal/jsonpbhelper/jsonpbhelper"
"github.com/google/fhir/go/jsonformat/internal/accessor"
"github.com/google/fhir/go/jsonformat/internal/jsonpbhelper"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"
"time"

"google/fhir/jsonformat/internal/accessor/accessor"
"github.com/google/fhir/go/jsonformat/internal/accessor"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
go_library(
name = "accessor",
srcs = ["getter_setter.go"],
importpath = "google/fhir/jsonformat/internal/accessor/accessor",
importpath = "github.com/google/fhir/go/jsonformat/internal/accessor",
deps = [
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_pkg_errors//:go_default_library",
Expand Down Expand Up @@ -38,6 +38,6 @@ proto_library(

go_proto_library(
name = "accessor_test_go_proto",
importpath = "google/fhir/jsonformat/internal/accessor/accessor_test_go_proto",
importpath = "jsonformat/internal/accessor/accessor_test_go_proto",
proto = ":accessor_test_proto",
)
Loading

0 comments on commit 184d5aa

Please sign in to comment.