// Copyright (C) 2024 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // This file contains the proto libraries, python script and genrule required for FHIR structural // validation of PHR medical data. // The python script generate_fhir_spec.py reads in the FHIR spec json files published by FHIR // (located in the android external folder). The official spec is then used to generate a fhirspec // proto message that is written to "fhirspec-r4.binarypb". This file is then added to // java_resources of the HC service to be used for the validation of incoming FHIR resources, // specifically in the FhirSpecProvider class. package { default_applicable_licenses: ["Android-Apache-2.0"], default_team: "trendy_team_android_health", } filegroup { name: "fhirspec-proto", srcs: [ "*.proto", ], } // Generate the java fhirspec proto library, used for capturing FHIR spec details for validation java_library { name: "fhirspec-java-proto-lite", sdk_version: "core_current", proto: { type: "lite", include_dirs: [ "external/protobuf/src", "external/protobuf/java", ], }, srcs: [ ":fhirspec-proto", ":libprotobuf-internal-protos", ], static_libs: ["libprotobuf-java-lite"], apex_available: ["com.android.healthfitness"], } // Generate the python fhirspec proto library, used for capturing FHIR spec details for validation python_library_host { name: "fhirspec-py-proto", srcs: [ "fhirspec.proto", ], proto: { canonical_path_from_root: false, }, } python_library_host { name: "fhir-spec-extractor", srcs: [ "fhir_spec_extractor.py", ], libs: [ "fhirspec-py-proto", ], } python_test_host { name: "fhir-spec-extractor-test", main: "fhir_spec_extractor_test.py", srcs: [ "fhir_spec_extractor_test.py", ], libs: [ "fhirspec-py-proto", "fhir-spec-extractor", ], test_options: { unit_test: true, }, version: { py3: { embedded_launcher: true, }, }, } // Python script for generating a FhirResourceSpec proto message based on fhir spec json files python_binary_host { name: "generate-fhir-spec", main: "generate_fhir_spec.py", srcs: [ "generate_fhir_spec.py", ], libs: [ "fhirspec-py-proto", "fhir-spec-extractor", ], } // Genrule that runs generate_fhir_spec.py to generate a FhirResourceSpec proto binary file genrule { name: "generate-fhir-spec-r4-binarypb", srcs: [ "//external/fhir/spec/r4:resource-definitions", ], tools: ["generate-fhir-spec"], cmd: "$(location generate-fhir-spec) $(out) $(in)", out: ["fhirspec-r4.binarypb"], }