src: | SELECT t_ghm.oid, t_ghm.code AS ghm_code, t_ghm.texte AS ghm_texte, t_ghm5.oid AS ghm5_id, t_ghm5.code AS ghm5_code, t_ghm5.texte AS ghm5_texte, substr(t_ghm.code::text, 1, 5) AS ghm_prefixe, substr(t_ghm.code::text, 6, 1) AS ghm_suffixe, t_ghm.cas_id, t_cas.code AS cas_code, t_cas.texte AS cas_texte, t_ghm.mco, t_mco.texte AS mco_texte, t_ghm.severite AS severite_ghm_code, t_severites_ghm.texte AS severite_ghm_texte, t_ghm.cmd_id, t_cmd.code AS cmd_code, t_cmd.texte_court AS cmd_texte, CASE WHEN t_cmd.code::text = '24'::text THEN '1'::text ELSE '0'::text END AS cmd_24, CASE WHEN t_cmd.code::text = '28'::text THEN '1'::text ELSE '0'::text END AS cmd_28, CASE WHEN t_cmd.code::text <> '24'::text AND t_cmd.code::text <> '28'::text THEN '1'::text ELSE '0'::text END AS cmd_n24n28, t_ghm.groupe_activite_id, t_groupes_activite.code AS groupe_activite_code, t_groupes_activite.texte_court AS groupe_activite_texte, t_lignes_oap.pole_oap_id, t_poles_oap.code AS pole_oap_code, t_poles_oap.texte_court AS pole_oap_texte, t_ghm.ligne_oap_id, t_lignes_oap.code AS ligne_oap_code, t_lignes_oap.texte AS ligne_oap_texte, t_ghm.ht_fg11 FROM pmsi.t_ghm JOIN pmsi.t_mco ON t_ghm.mco = t_mco.code::bpchar JOIN pmsi.t_severites_ghm ON t_ghm.severite = t_severites_ghm.code JOIN pmsi.t_cmd ON t_ghm.cmd_id = t_cmd.oid JOIN pmsi.t_groupes_activite ON t_ghm.groupe_activite_id = t_groupes_activite.oid JOIN pmsi.t_lignes_oap ON t_ghm.ligne_oap_id = t_lignes_oap.oid JOIN pmsi.t_poles_oap ON t_lignes_oap.pole_oap_id = t_poles_oap.oid JOIN pmsi.t_ghm5 ON t_ghm.ghm5_id = t_ghm5.oid JOIN base.t_cas ON t_ghm.cas_id = t_cas.oid;