• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1syntax = "proto3";
2
3package com.android.server.healthconnect.proto;
4
5option java_multiple_files=true;
6
7// FHIR spec details required for Health Connect PHR validation of medical data (FHIR resources
8// received as JSON strings).
9message FhirResourceSpec {
10    // A map of the FHIR resource type int to the FHIR spec config.
11    // The resource type int has to match one of the resource types in FhirResource.java
12    map<int32, FhirComplexTypeConfig> resource_type_to_config = 1;
13
14    // The fhir data type configs for types required by resource_type_to_config above.
15    // This list will also contain any child types that are defined within a resource or complex
16    // type definition. The naming for child types is derived from the path - For example, the
17    // child type at Immunization.performer field has type R4_FHIR_TYPE_IMMUNIZATION_PERFORMER.
18    repeated FhirDataType fhir_data_type_configs = 2;
19}
20
21// Contains the type and kind for each data type and complex type config for complex types.
22message FhirDataType {
23    optional R4FhirType fhir_type = 1;
24
25    // The kind of FHIR data type.
26    Kind kind = 2;
27
28    // The complex type config, if the type is a complex-type. For primitive types this will not be
29    // set.
30    optional FhirComplexTypeConfig fhir_complex_type_config = 3;
31}
32
33// The FHIR spec config of a resource or complex type.
34message FhirComplexTypeConfig {
35    // A map of all field names to field config for this data type. The keys of this map is the list
36    // of fields that are allowed to be populated.
37    map<string, FhirFieldConfig> allowed_field_names_to_config = 1;
38
39    // The list of fields that are required to be present for this data type.
40    // Note that this does not include required multi type fields. Whether or not these are required
41    // will be contained in the multi_type_fields configs (see next field).
42    repeated string required_fields = 2;
43
44    // The list of fields where one of several data type fields can be set.
45    // This is used to validate only one of each field is set and that exactly one is set if the
46    // field is required.
47    // Note that this config needs to be used to determine whether a multi type field is required
48    // or not, as these fields will not be included in the required_fields list above.
49    repeated MultiTypeFieldConfig multi_type_fields = 3;
50
51}
52
53// Represents the config of a FHIR field where a choice of data types can be set.
54// See https://build.fhir.org/formats.html#choice for more background.
55message MultiTypeFieldConfig {
56    // The name of the field without type suffix
57    optional string name = 1;
58
59    // The possible fields of a specific type that can be set in the json resource, e.g.
60    // "occurrenceDataTime", "occurrenceString". Only one of these fields is allowed to be present.
61    repeated string typed_field_names = 2;
62
63    // Whether or not the field is a required field.
64    // If true, exactly one of the fields in type_field_names is expected to be present.
65    optional bool is_required = 3;
66}
67
68// The FHIR spec config of a FHIR field.
69message FhirFieldConfig {
70    // Whether or not the field is an array.
71    optional bool is_array = 1;
72
73    // The data type of this field.
74    R4FhirType r4_type = 2;
75}
76
77// Represents the kind of fhir data type, as found in the StructureDefinition.kind field
78// (https://hl7.org/fhir/R4/valueset-structure-definition-kind.html). See
79// https://hl7.org/fhir/R4/valueset-structure-definition-kind.html for a description of the
80// different values.
81enum Kind {
82    KIND_UNSPECIFIED = 0;
83    // The data type is a resource type.
84    KIND_RESOURCE = 1;
85    // The data type is a primitive type.
86    KIND_PRIMITIVE_TYPE = 2;
87    // The data type is a complex type. For our use case this applies to any type that is not a
88    // resource or a primitive type.
89    KIND_COMPLEX_TYPE = 3;
90}
91
92// The R4 Fhir type used to indicate the type of a field extracted from the fhir spec.
93// Next ID: 57
94enum R4FhirType {
95    R4_FHIR_TYPE_UNSPECIFIED = 0;
96    R4_FHIR_TYPE_ADDRESS = 1;
97    R4_FHIR_TYPE_AGE = 2;
98    R4_FHIR_TYPE_ALLERGYINTOLERANCE_REACTION = 3;
99    R4_FHIR_TYPE_ANNOTATION = 4;
100    R4_FHIR_TYPE_ATTACHMENT = 5;
101    R4_FHIR_TYPE_BASE64_BINARY = 6;
102    R4_FHIR_TYPE_BOOLEAN = 7;
103    R4_FHIR_TYPE_CANONICAL = 8;
104    R4_FHIR_TYPE_CODE = 9;
105    R4_FHIR_TYPE_CODEABLE_CONCEPT = 10;
106    R4_FHIR_TYPE_CODING = 11;
107    R4_FHIR_TYPE_CONDITION_EVIDENCE = 12;
108    R4_FHIR_TYPE_CONDITION_STAGE = 13;
109    R4_FHIR_TYPE_CONTACT_DETAIL = 14;
110    R4_FHIR_TYPE_CONTACT_POINT = 15;
111    R4_FHIR_TYPE_CONTRIBUTOR = 16;
112    R4_FHIR_TYPE_COUNT = 17;
113    R4_FHIR_TYPE_DATA_REQUIREMENT = 18;
114    R4_FHIR_TYPE_DATAREQUIREMENT_CODEFILTER = 19;
115    R4_FHIR_TYPE_DATAREQUIREMENT_DATEFILTER = 20;
116    R4_FHIR_TYPE_DATAREQUIREMENT_SORT = 21;
117    R4_FHIR_TYPE_DATE = 22;
118    R4_FHIR_TYPE_DATE_TIME = 23;
119    R4_FHIR_TYPE_DECIMAL = 24;
120    R4_FHIR_TYPE_DISTANCE = 25;
121    R4_FHIR_TYPE_DOSAGE = 26;
122    R4_FHIR_TYPE_DOSAGE_DOSEANDRATE = 27;
123    R4_FHIR_TYPE_DURATION = 28;
124    R4_FHIR_TYPE_ELEMENT = 29;
125    R4_FHIR_TYPE_ENCOUNTER_CLASSHISTORY = 30;
126    R4_FHIR_TYPE_ENCOUNTER_DIAGNOSIS = 31;
127    R4_FHIR_TYPE_ENCOUNTER_HOSPITALIZATION = 32;
128    R4_FHIR_TYPE_ENCOUNTER_LOCATION = 33;
129    R4_FHIR_TYPE_ENCOUNTER_PARTICIPANT = 34;
130    R4_FHIR_TYPE_ENCOUNTER_STATUSHISTORY = 35;
131    R4_FHIR_TYPE_EXPRESSION = 36;
132    R4_FHIR_TYPE_EXTENSION = 37;
133    R4_FHIR_TYPE_HUMAN_NAME = 38;
134    R4_FHIR_TYPE_ID = 39;
135    R4_FHIR_TYPE_IDENTIFIER = 40;
136    R4_FHIR_TYPE_IMMUNIZATION_EDUCATION = 41;
137    R4_FHIR_TYPE_IMMUNIZATION_PERFORMER = 42;
138    R4_FHIR_TYPE_IMMUNIZATION_PROTOCOLAPPLIED = 43;
139    R4_FHIR_TYPE_IMMUNIZATION_REACTION = 44;
140    R4_FHIR_TYPE_INSTANT = 45;
141    R4_FHIR_TYPE_INTEGER = 46;
142    R4_FHIR_TYPE_LOCATION_HOURSOFOPERATION = 47;
143    R4_FHIR_TYPE_LOCATION_POSITION = 48;
144    R4_FHIR_TYPE_MARKDOWN = 49;
145    R4_FHIR_TYPE_MEDICATION_BATCH = 50;
146    R4_FHIR_TYPE_MEDICATION_INGREDIENT = 51;
147    R4_FHIR_TYPE_MEDICATIONREQUEST_DISPENSEREQUEST = 52;
148    R4_FHIR_TYPE_MEDICATIONREQUEST_DISPENSEREQUEST_INITIALFILL = 53;
149    R4_FHIR_TYPE_MEDICATIONREQUEST_SUBSTITUTION = 54;
150    R4_FHIR_TYPE_META = 55;
151    R4_FHIR_TYPE_MONEY = 56;
152    R4_FHIR_TYPE_NARRATIVE = 57;
153    R4_FHIR_TYPE_OBSERVATION_COMPONENT = 58;
154    R4_FHIR_TYPE_OBSERVATION_REFERENCERANGE = 59;
155    R4_FHIR_TYPE_OID = 60;
156    R4_FHIR_TYPE_ORGANIZATION_CONTACT = 61;
157    R4_FHIR_TYPE_PARAMETER_DEFINITION = 62;
158    R4_FHIR_TYPE_PATIENT_COMMUNICATION = 63;
159    R4_FHIR_TYPE_PATIENT_CONTACT = 64;
160    R4_FHIR_TYPE_PATIENT_LINK = 65;
161    R4_FHIR_TYPE_PERIOD = 66;
162    R4_FHIR_TYPE_POSITIVE_INT = 67;
163    R4_FHIR_TYPE_PRACTITIONER_QUALIFICATION = 68;
164    R4_FHIR_TYPE_PRACTITIONERROLE_AVAILABLETIME = 69;
165    R4_FHIR_TYPE_PRACTITIONERROLE_NOTAVAILABLE = 70;
166    R4_FHIR_TYPE_PROCEDURE_FOCALDEVICE = 71;
167    R4_FHIR_TYPE_PROCEDURE_PERFORMER = 72;
168    R4_FHIR_TYPE_QUANTITY = 73;
169    R4_FHIR_TYPE_RANGE = 74;
170    R4_FHIR_TYPE_RATIO = 75;
171    R4_FHIR_TYPE_REFERENCE = 76;
172    R4_FHIR_TYPE_RELATED_ARTIFACT = 77;
173    R4_FHIR_TYPE_RESOURCE = 78;
174    R4_FHIR_TYPE_SAMPLED_DATA = 79;
175    R4_FHIR_TYPE_SIGNATURE = 80;
176    R4_FHIR_TYPE_STRING = 81;
177    R4_FHIR_TYPE_TIME = 82;
178    R4_FHIR_TYPE_TIMING = 83;
179    R4_FHIR_TYPE_TIMING_REPEAT = 84;
180    R4_FHIR_TYPE_TRIGGER_DEFINITION = 85;
181    R4_FHIR_TYPE_UNSIGNED_INT = 86;
182    R4_FHIR_TYPE_URI = 87;
183    R4_FHIR_TYPE_URL = 88;
184    R4_FHIR_TYPE_USAGE_CONTEXT = 89;
185    R4_FHIR_TYPE_UUID = 90;
186    R4_FHIR_TYPE_XHTML = 91;
187    // These two types are added manually to handle two additional types present in R4B.
188    R4_FHIR_TYPE_CODEABLE_REFERENCE = 92;
189    R4_FHIR_TYPE_RATIO_RANGE = 93;
190}