 declare
  ex number;
 begin
-  select max(cast(substr(concept_code, 5) as integer))+1 into ex from devv5.concept where concept_code like 'OMOP%' and concept_code not like '% %'; -- Last valid value of the OMOP123-type codes
+  select max(cast(substr(concept_code, 5) as integer))+1 into ex from drug_concept_stage where concept_code like 'OMOP%' and concept_code not like '% %'; -- Last valid value of the OMOP123-type codes
   begin
     execute immediate 'create sequence new_vocab increment by 1 start with ' || ex || ' nocycle cache 20 noorder';
     exception

  c.concept_code concept_code_2,
  c.vocabulary_id as vocabulary_id_2,
  'Maps to' as relationship_id,
  (select latest_update from vocabulary v where v.vocabulary_id=(select vocabulary_id from drug_concept_stage where rownum=1)) as valid_start_date,
  '31-Dec-2099' as valid_end_date,
  null as invalid_reason

where q.concept_class_id = 'Dose Form' and q.domain_id='Drug'
;

-- Write maps from complete_concept_stage to RxNorm, both as Maps to as well as 'Drug eq to'
insert into concept_relationship_stage (concept_code_1, vocabulary_id_1, concept_code_2, vocabulary_id_2, relationship_id, valid_start_date, valid_end_date, invalid_reason)
select 
  qr.q_dcode as concept_code_1,
