-- DBMS: bigquery
CREATE TABLE `bigquery-public-data.fhir_synthea.encounter`
(
  account ARRAY<STRUCT<accountId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, display STRING>>,
  appointment STRUCT<appointmentId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, display STRING>,
  classHistory ARRAY<STRUCT<class STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>, period STRUCT<start STRING, `end` STRING>>>,
  diagnosis ARRAY<STRUCT<condition STRUCT<conditionId STRING, procedureId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, display STRING>, role STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, rank INT64>>,
  episodeOfCare ARRAY<STRUCT<episodeOfCareId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, display STRING>>,
  identifier ARRAY<STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>>,
  implicitRules STRING,
  incomingReferral ARRAY<STRUCT<referralRequestId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, display STRING>>,
  language STRING,
  length STRUCT<value FLOAT64, comparator STRING, unit STRING, system STRING, code STRING>,
  location ARRAY<STRUCT<location STRUCT<locationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, display STRING>, status STRING, period STRUCT<start STRING, `end` STRING>>>,
  partOf STRUCT<encounterId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, display STRING>,
  priority STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>,
  statusHistory ARRAY<STRUCT<status STRING, period STRUCT<start STRING, `end` STRING>>>,
  text STRUCT<status STRING, div STRING>,
  shr_action_PerformedContext_extension STRUCT<shr_action_Status_extension STRUCT<value STRUCT<code STRING>>>,
  class STRUCT<display STRING, userSelected BOOL, version STRING, code STRING, system STRING>,
  hospitalization STRUCT<admitSource STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, destination STRUCT<locationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, display STRING>, dietPreference ARRAY<STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>>, origin STRUCT<locationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, display STRING>, preAdmissionIdentifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>>, display STRING>>, display STRING>>, reAdmission STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, specialArrangement ARRAY<STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>>, specialCourtesy ARRAY<STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>>, dischargeDisposition STRUCT<coding ARRAY<STRUCT<userSelected BOOL, version STRING, code STRING, display STRING, system STRING>>, text STRING>>,
  id STRING,
  meta STRUCT<lastUpdated TIMESTAMP, security ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, tag ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, versionId STRING, profile ARRAY<STRING>>,
  participant ARRAY<STRUCT<period STRUCT<start STRING, `end` STRING>, type ARRAY<STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>>, individual STRUCT<display STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, reference STRING, relatedPersonId STRING, practitionerId STRING>>>,
  period STRUCT<`end` STRING, start STRING>,
  reason ARRAY<STRUCT<text STRING, coding ARRAY<STRUCT<userSelected BOOL, version STRING, code STRING, display STRING, system STRING>>>>,
  serviceProvider STRUCT<display STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, reference STRING, organizationId STRING>,
  status STRING,
  subject STRUCT<display STRING, groupId STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, identifier STRUCT<use STRING, type STRUCT<coding ARRAY<STRUCT<system STRING, version STRING, code STRING, display STRING, userSelected BOOL>>, text STRING>, system STRING, value STRING, period STRUCT<start STRING, `end` STRING>, assigner STRUCT<organizationId STRING, reference STRING, display STRING>>, display STRING>>, reference STRING, patientId STRING>,
  type ARRAY<STRUCT<coding ARRAY<STRUCT<userSelected BOOL, version STRING, code STRING, display STRING, system STRING>>, text STRING>>
);

INSERT INTO `bigquery-public-data.fhir_synthea.encounter` (account, appointment, classHistory, diagnosis, episodeOfCare, identifier, implicitRules, incomingReferral, language, length, location, partOf, priority, statusHistory, text, shr_action_PerformedContext_extension, class, hospitalization, id, meta, participant, period, reason, serviceProvider, status, subject, type) VALUES ('[]', NULL, '[]', '[]', '[]', '[]', NULL, '[]', NULL, NULL, '[]', NULL, NULL, '[]', NULL, {'shr_action_Status_extension': {'value': {'code': 'finished'}}}, {'display': None, 'userSelected': None, 'version': None, 'code': 'AMB', 'system': 'http://terminology.hl7.org/CodeSystem/v3-ActCode'}, NULL, '8276f5d5-b6f8-4132-9c24-520fe17c4810', {'lastUpdated': None, 'security': '[]', 'tag': '[]', 'versionId': None, 'profile': "['http://standardhealthrecord.org/fhir/StructureDefinition/shr-encounter-EncounterPerformed']"}, '[]', {'end': '2001-10-11T06:09:21+00:00', 'start': '2001-10-11T05:54:21+00:00'}, '[]', {'display': None, 'identifier': None, 'reference': None, 'organizationId': '226098a2-6a40-3588-b5bb-db56c3a30a04'}, 'finished', {'display': None, 'groupId': None, 'identifier': None, 'reference': None, 'patientId': 'c4807d1b-c656-4fbb-a458-ca9a44ef52f6'}, '[{''coding'': array([{''userSelected'': None, ''version'': None, ''code'': ''308646001'', ''display'': ''Death Certification'', ''system'': ''http://snomed.info/sct''}],
       dtype=object), ''text'': ''Death Certification''}                                                                                                   ]'), ('[]', NULL, '[]', '[]', '[]', '[]', NULL, '[]', NULL, NULL, '[]', NULL, NULL, '[]', NULL, {'shr_action_Status_extension': {'value': {'code': 'finished'}}}, {'display': None, 'userSelected': None, 'version': None, 'code': 'AMB', 'system': 'http://terminology.hl7.org/CodeSystem/v3-ActCode'}, NULL, '827d4087-58c7-4c44-a877-4eaeafed55b4', {'lastUpdated': None, 'security': '[]', 'tag': '[]', 'versionId': None, 'profile': "['http://standardhealthrecord.org/fhir/StructureDefinition/shr-encounter-EncounterPerformed']"}, '[]', {'end': '1997-02-13T16:30:22+00:00', 'start': '1997-02-13T16:15:22+00:00'}, '[]', {'display': None, 'identifier': None, 'reference': None, 'organizationId': '24cb4eab-6166-3530-bddc-a5a8a14a4fc1'}, 'finished', {'display': None, 'groupId': None, 'identifier': None, 'reference': None, 'patientId': '1f630100-f66f-42d6-b170-fe3c2dd7f392'}, '[{''coding'': array([{''userSelected'': None, ''version'': None, ''code'': ''308646001'', ''display'': ''Death Certification'', ''system'': ''http://snomed.info/sct''}],
       dtype=object), ''text'': ''Death Certification''}                                                                                                   ]'), ('[]', NULL, '[]', '[]', '[]', '[]', NULL, '[]', NULL, NULL, '[]', NULL, NULL, '[]', NULL, {'shr_action_Status_extension': {'value': {'code': 'finished'}}}, {'display': None, 'userSelected': None, 'version': None, 'code': 'AMB', 'system': 'http://terminology.hl7.org/CodeSystem/v3-ActCode'}, NULL, '829af61e-df15-4946-81d6-9b0d78692bb8', {'lastUpdated': None, 'security': '[]', 'tag': '[]', 'versionId': None, 'profile': "['http://standardhealthrecord.org/fhir/StructureDefinition/shr-encounter-EncounterPerformed']"}, '[]', {'end': '1931-10-13T02:56:15+00:00', 'start': '1931-10-13T02:41:15+00:00'}, '[]', {'display': None, 'identifier': None, 'reference': None, 'organizationId': 'b0e04623-b02c-3f8b-92ea-943fc4db60da'}, 'finished', {'display': None, 'groupId': None, 'identifier': None, 'reference': None, 'patientId': 'f4be50bf-da56-4fb8-affa-3e8d34348900'}, '[{''coding'': array([{''userSelected'': None, ''version'': None, ''code'': ''308646001'', ''display'': ''Death Certification'', ''system'': ''http://snomed.info/sct''}],
       dtype=object), ''text'': ''Death Certification''}                                                                                                   ]'), ('[]', NULL, '[]', '[]', '[]', '[]', NULL, '[]', NULL, NULL, '[]', NULL, NULL, '[]', NULL, {'shr_action_Status_extension': {'value': {'code': 'finished'}}}, {'display': None, 'userSelected': None, 'version': None, 'code': 'AMB', 'system': 'http://terminology.hl7.org/CodeSystem/v3-ActCode'}, NULL, '386e6d10-4bd3-44b8-bfe6-7d027b6e8f89', {'lastUpdated': None, 'security': '[]', 'tag': '[]', 'versionId': None, 'profile': "['http://standardhealthrecord.org/fhir/StructureDefinition/shr-encounter-EncounterPerformed']"}, '[]', {'end': '1954-09-19T19:42:09+00:00', 'start': '1954-09-19T19:27:09+00:00'}, '[]', {'display': None, 'identifier': None, 'reference': None, 'organizationId': '7fb56531-86bd-3e4a-8619-4df9942da309'}, 'finished', {'display': None, 'groupId': None, 'identifier': None, 'reference': None, 'patientId': '6229e450-882d-45e8-87a7-5da84687c67e'}, '[{''coding'': array([{''userSelected'': None, ''version'': None, ''code'': ''308646001'', ''display'': ''Death Certification'', ''system'': ''http://snomed.info/sct''}],
       dtype=object), ''text'': ''Death Certification''}                                                                                                   ]'), ('[]', NULL, '[]', '[]', '[]', '[]', NULL, '[]', NULL, NULL, '[]', NULL, NULL, '[]', NULL, {'shr_action_Status_extension': {'value': {'code': 'finished'}}}, {'display': None, 'userSelected': None, 'version': None, 'code': 'AMB', 'system': 'http://terminology.hl7.org/CodeSystem/v3-ActCode'}, NULL, '387e6df9-913b-4781-b6b1-69d146b4efe4', {'lastUpdated': None, 'security': '[]', 'tag': '[]', 'versionId': None, 'profile': "['http://standardhealthrecord.org/fhir/StructureDefinition/shr-encounter-EncounterPerformed']"}, '[]', {'end': '1997-01-11T10:34:46+00:00', 'start': '1997-01-11T10:19:46+00:00'}, '[]', {'display': None, 'identifier': None, 'reference': None, 'organizationId': '8ad64ecf-c817-3753-bee7-006a8e662e06'}, 'finished', {'display': None, 'groupId': None, 'identifier': None, 'reference': None, 'patientId': '5940767c-1b4f-449d-9e25-edc12eb1ce68'}, '[{''coding'': array([{''userSelected'': None, ''version'': None, ''code'': ''308646001'', ''display'': ''Death Certification'', ''system'': ''http://snomed.info/sct''}],
       dtype=object), ''text'': ''Death Certification''}                                                                                                   ]');