Main Tables Materialized Views Indexes Constraints DDL scrips
Description Columns Query Constraints Triggers

MIMIC2V26.DEMOGRAPHIC_DETAIL

ContainerUpdatable
DEMOGRAPHIC_DETAIL N
DDL script

Columns

NameTypeNullableInsertableUpdatableDeletableComment
SUBJECT_IDNUMBER(7)NYESYESYESThe subject identifier.
HADM_IDNUMBER(7)NYESYESYESThe hospital admission.
MARITAL_STATUS_ITEMIDNUMBER(7)YYESYESYESThe itemid for the marital-status component of the demographic.
MARITAL_STATUS_DESCRVARCHAR2(50)YYESYESYESThe description of the marital-status component of the demographic.
ETHNICITY_ITEMIDNUMBER(7)YYESYESYESThe itemid for the ethnicity component of the demographic.
ETHNICITY_DESCRVARCHAR2(50)YYESYESYESThe description of the ethnicity component of the demographic.
OVERALL_PAYOR_GROUP_ITEMIDNUMBER(7)YYESYESYESThe itemid for the overall-payor-group component of the demographic.
OVERALL_PAYOR_GROUP_DESCRVARCHAR2(50)YYESYESYESThe description of the overall-payor-group component of the demographic.
RELIGION_ITEMIDNUMBER(7)YYESYESYESThe itemid for the religion component of the demographic.
RELIGION_DESCRVARCHAR2(50)YYESYESYESThe description of the religion component of the demographic.
ADMISSION_TYPE_ITEMIDNUMBER(7)YYESYESYESThe itemid for the admission type of the demographic.
ADMISSION_TYPE_DESCRVARCHAR2(50)YYESYESYESThe description of the admission type of the demographic.
ADMISSION_SOURCE_ITEMIDNUMBER(7)YYESYESYESThe itemid for the admission source of the demographic.
ADMISSION_SOURCE_DESCRVARCHAR2(50)YYESYESYESThe description of the admission source of the demographic.

Query:

Note: Syntax highlighting off
select distinct
  subject_id,
  hadm_id,
  cast(max(marital_status_itemid) over (partition by subject_id, hadm_id) as number(7.0)) as marital_status_itemid,
  max(marital_status_descr) over (partition by subject_id, hadm_id) as marital_status_descr,
  cast(max(ethnicity_itemid) over (partition by subject_id, hadm_id) as number(7.0)) as ethnicity_itemid,
  max(ethnicity_descr) over (partition by subject_id, hadm_id) as ethnicity_descr,
  cast(max(overall_payor_group_itemid) over (partition by subject_id, hadm_id) as number(7.0)) as overall_payor_group_itemid,
  max(overall_payor_group_descr) over (partition by subject_id, hadm_id) as overall_payor_group_descr,
  cast(max(religion_itemid) over (partition by subject_id, hadm_id) as number(7.0)) as religion_itemid,
  max(religion_descr) over (partition by subject_id, hadm_id) as religion_descr,
  cast(max(admission_type_itemid) over (partition by subject_id, hadm_id) as number(7.0)) as admission_type_itemid,
  max(admission_type_descr) over (partition by subject_id, hadm_id) as admission_type_descr,
  cast(max(admission_source_itemid) over (partition by subject_id, hadm_id) as number(7.0)) as admission_source_itemid,
  max(admission_source_descr) over (partition by subject_id, hadm_id) as admission_source_descr
from
  (select
    de.subject_id,
    de.hadm_id,
    (case when di.category = 'MARITAL STATUS' then di.itemid else null end) as marital_status_itemid,
    (case when di.category = 'MARITAL STATUS' then di.label else null end) as marital_status_descr,
    (case when di.category = 'ETHNICITY' then di.itemid else null end) as ethnicity_itemid,
    (case when di.category = 'ETHNICITY' then di.label else null end) as ethnicity_descr,
    (case when di.category = 'OVERALL PAYOR GROUP' then di.itemid else null end) as overall_payor_group_itemid,
    (case when di.category = 'OVERALL PAYOR GROUP' then di.label else null end) as overall_payor_group_descr,
    (case when di.category = 'RELIGION' then di.itemid else null end) as religion_itemid,
    (case when di.category = 'RELIGION' then di.label else null end) as religion_descr,
    (case when di.category = 'ADMISSION TYPE' then di.itemid else null end) as admission_type_itemid,
    (case when di.category = 'ADMISSION TYPE' then di.label else null end) as admission_type_descr,
    (case when di.category = 'ADMISSION SOURCE' then di.itemid else null end) as admission_source_itemid,
    (case when di.category = 'ADMISSION SOURCE' then di.label else null end) as admission_source_descr
  from
    mimic2v26.demographicevents de,
    mimic2v26.d_demographicitems di
  where
    de.itemid = di.itemid)