SELECT DISTINCT
       person_id,
       visit_occurrence_id,
       condition_concept_id,
       c_condition.concept_name,
       condition_start_datetime,
       condition_status_concept_id,
       c_status.concept_name
FROM condition_occurrence c_o
LEFT JOIN concept c_condition ON
    c_condition.concept_id = c_o.condition_concept_id
LEFT JOIN concept c_status ON
    c_status.concept_id = c_o.condition_status_concept_id
WHERE
    condition_status_concept_id IN (
        32901, --Primary admission diagnosis
        32907 --Secondary admission diagnosis
    )
ORDER BY person_id, visit_occurrence_id
