text: 
  
  LOCK TABLE concept IN EXCLUSIVE MODE;
  SELECT setval('concept_concept_id_seq', COALESCE((SELECT MAX(concept_id)+1 FROM concept), 1), false)
  WHERE EXISTS (SELECT 1 FROM pg_class c WHERE c.relkind = 'S');
  COMMIT;
  
  INSERT INTO System (SYSTEM_ID,SYSTEM_URI,SYSTEM_NAME) VALUES (1002,'https://fhir.yorkhospitals.nhs.uk/Id/episode','York Hospitals Episodes');
  INSERT INTO System (SYSTEM_ID,SYSTEM_URI,SYSTEM_NAME) VALUES (1003,'https://fhir.yorkhospitals.nhs.uk/Id/locations','York Hospitals Locations');
  
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('1660001','Plant seeds',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('10097211000001102','Insulin glulisine 100units ml solution for injection 3ml pre-filled disposable devices (product)',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('1521000175104','After dinner',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('174184006','Diagnostic endoscopic examination on colon',9);
  
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('226017009','Bombay mix',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('281685003','Admission for care',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('25241000000106','Discharge from care',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('22220005','Genuine stress incontinence',9);
  
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('39579001','Anaphylaxis',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('308292007','Transfer of care',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('396429000','Measles, mumps and rubella vaccine',9);
  
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('441321000000103','Personal history of narcotic agent allergy ',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('414058001','Drug pseudoallergen by function',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('44054006','Type 2 diabetes mellitus',9);
  
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('91175000','Seizure',9);
  INSERT INTO Concept(CODE,DISPLAY,CODESYSTEM_ID) VALUES ('923461000000103','Lifestyle education for diabetes',9);
  
  INSERT INTO Location (LOCATION_ID,ENT_NAME,status,MANAGING_ORGANISATION_ID,physicalType,TYPE_CONCEPT_ID) VALUES (200000,'York Hospital',0,200001,479,352);
  INSERT INTO LocationIdentifier (LOCATION_IDENTIFIER_ID,identifierUse,listOrder,IDENTIFIER_VALUE,SYSTEM_ID,LOCATION_ID) VALUES (200000,0,NULL,'RC855',2,200000);
  
  INSERT INTO Location (LOCATION_ID,ENT_NAME,status,MANAGING_ORGANISATION_ID,physicalType,TYPE_CONCEPT_ID,PART_OF_LOCATION_ID) VALUES (200001,'Observation Ward',0,200001,480,329,200000);
  INSERT INTO LocationIdentifier (LOCATION_IDENTIFIER_ID,identifierUse,listOrder,IDENTIFIER_VALUE,SYSTEM_ID,LOCATION_ID) VALUES (200001,0,NULL,'OBS',1003,200001);
  
  INSERT INTO Location (LOCATION_ID,ENT_NAME,status,MANAGING_ORGANISATION_ID,physicalType,TYPE_CONCEPT_ID,PART_OF_LOCATION_ID) VALUES (200002,'Recovery Ward',0,200001,480,329,200000);
  INSERT INTO LocationIdentifier (LOCATION_IDENTIFIER_ID,identifierUse,listOrder,IDENTIFIER_VALUE,SYSTEM_ID,LOCATION_ID) VALUES (200002,0,NULL,'RCB55-RECOVERYWARD',1003,200002);
  
  INSERT INTO EpisodeOfCare (EPISODE_ID,ORGANISATION_ID,PATIENT_ID,PRACTITIONER_ID,TYPE_CONCEPT_ID,periodEndDate,periodStartDate,status)
  SELECT 1,200001,4,200001,CONCEPT_ID,'2010-10-21 17:06:00','2010-10-20 17:16:00',4 FROM Concept where CODE = '394802001';
  
  INSERT INTO EpisodeOfCareIdentifier (EPISODE_IDENTIFIER_ID,IDENTIFIER_VALUE,SYSTEM_ID,EPISODE_ID)
  VALUES (1,2139,1002,1);
  
  INSERT INTO Encounter (ENCOUNTER_ID,PATIENT_ID,periodEndDate,periodStartDate,status,CLASS_CONCEPT_ID,LOCATION_ID,ORGANISATION_ID,PARTICIPANT_PRACTITIONER_ID,PRIORITY_CONCEPT_ID,TYPE_CONCEPT_ID)
  SELECT 1,4,null,'2010-10-20 17:16:00',1,21069,200001,200001,200001,22052,CONCEPT_ID FROM Concept where CODE = '281685003' ;
  
  INSERT INTO Encounter (ENCOUNTER_ID,PATIENT_ID,periodEndDate,periodStartDate,status,CLASS_CONCEPT_ID,LOCATION_ID,ORGANISATION_ID,PARTICIPANT_PRACTITIONER_ID,PRIORITY_CONCEPT_ID,TYPE_CONCEPT_ID)
  SELECT 2,4,null,'2010-10-21 13:15:00',3,21069,200002,200001,200001,22052,CONCEPT_ID FROM Concept where CODE = '308292007' ;
  
  INSERT INTO Encounter (ENCOUNTER_ID,PATIENT_ID,periodEndDate,periodStartDate,status,CLASS_CONCEPT_ID,LOCATION_ID,ORGANISATION_ID,PARTICIPANT_PRACTITIONER_ID,PRIORITY_CONCEPT_ID,TYPE_CONCEPT_ID)
  SELECT 3,4,null,'2010-10-21 17:35:00',5,21069,200001,200001,200001,22052,CONCEPT_ID FROM Concept where CODE = '25241000000106';
  
  INSERT INTO EncounterEpisodeOfCare (ENCOUNTER_EPISODE_ID,ENCOUNTER_ID,EPISODE_ID)
  VALUES (1,1,1);
  INSERT INTO EncounterEpisodeOfCare (ENCOUNTER_EPISODE_ID,ENCOUNTER_ID,EPISODE_ID)
  VALUES (2,2,1);
  INSERT INTO EncounterEpisodeOfCare (ENCOUNTER_EPISODE_ID,ENCOUNTER_ID,EPISODE_ID)
  VALUES (3,3,1);
  
  