 );
 
 drop sequence omop_seq; 
-/*
+
 declare
  ex number;
 begin

      else null
    end as v,
    case
      when nu.rxn_unit='%' then ' %' -- percent (gas in Rx)
      when eds.denominator_value is not null then nu.rxn_unit||'/'||de.rxn_unit -- concentration (liquid)
      when eds.numerator_value is not null then nu.rxn_unit||'/'||de.rxn_unit -- concentration (liquid)
      when eds.amount_value is not null then au.rxn_unit -- absolute (solid)

;
commit;

-- Temporary till q_to_r is stable. Currently, it misses alternative df/bn/mf

drop table namesmate purge;
create table namesmate as
select concept_name 
from (
  select concept_name, concept_code from extension_name where not exists (select 1 from q_to_r where q_dcode=concept_code)
)
join (
  select concept_name, concept_class_id from concept where concept.vocabulary_id like 'RxNorm%' and invalid_reason is null
) using(concept_name)
;

insert into q_to_r (q_dcode, r_did)
select cn.concept_code as q_dcode, c.concept_id as r_did
from namesmate
join extension_name cn using(concept_name)
join concept c using(concept_name)
where c.vocabulary_id in ('RxNorm', 'RxNorm Extension') and c.invalid_reason is null
;
commit;


-- Process Packs
-- create XXX type concept_codes for hte new ones
drop table pack_seq purge;
