src: |
  SELECT p_bloc_occupation.finess_id,
      p_bloc_occupation.code_original,
      p_bloc_occupation.date,
      to_char(p_bloc_occupation.date::timestamp with time zone, 'YYYYMMDD'::text)::bigint AS date_id,
      p_bloc_occupation.date::text AS date_code,
      p_calendrier.texte AS date_texte,
      p_calendrier.mois AS mois_id,
      p_calendrier.mois::text AS mois_code,
      (p_calendrier.mois_texte || ' '::text) || p_calendrier.iso_annee::text AS mois_texte,
      p_bloc_occupation.date_programmation,
      p_bloc_occupation.heure_debut_occupation,
      p_bloc_occupation.heure_debut_remise_en_etat,
      p_bloc_occupation.heure_entree_salle,
      p_bloc_occupation.heure_fin_occupation,
      p_bloc_occupation.heure_fin_remise_en_etat,
      p_bloc_occupation.heure_sortie_salle,
      p_bloc_occupation.medecin_chirurgien_id,
      t_medecins_administratifs_c.adm_code AS medecin_chirurgien_adm_intervention_code,
      t_medecins_administratifs_c.adm_nom AS medecin_chirurgien_adm_intervention_nom,
      t_medecins_administratifs_c.adm_prenom AS medecin_chirurgien_adm_intervention_prenom,
      t_medecins_administratifs_c.adm_nom_prenom AS medecin_chirurgien_adm_intervention_texte,
      t_medecins_administratifs_c.section_id AS medecin_chirurgien_adm_intervention_section_id,
      t_medecins_administratifs_c.section_code AS medecin_chirurgien_adm_intervention_section_code,
      t_medecins_administratifs_c.section_texte AS medecin_chirurgien_adm_intervention_section_texte,
      t_medecins_administratifs_c.medecin_id AS medecin_chirurgien_intervention_id,
      t_medecins_administratifs_c.medecin_code AS medecin_chirurgien_intervention_code,
      t_medecins_administratifs_c.nom AS medecin_chirurgien_intervention_nom,
      t_medecins_administratifs_c.prenom AS medecin_chirurgien_intervention_prenom,
      t_medecins_administratifs_c.nom_prenom AS medecin_chirurgien_intervention_texte,
      t_medecins_administratifs_c.specialite_id AS medecin_chirurgien_intervention_specialite_id,
      t_medecins_administratifs_c.specialite_code AS medecin_chirurgien_intervention_specialite_code,
      t_medecins_administratifs_c.specialite_texte AS medecin_chirurgien_intervention_specialite_texte,
      p_bloc_occupation.motif_intervention_id,
      t_bloc_motif_intervention.code AS motif_intervention_code,
      t_bloc_motif_intervention.texte_court AS motif_intervention_texte,
      t_bloc_motif_intervention.section_id AS motif_intervention_section_id,
      t_bloc_motif_intervention.section_code AS motif_intervention_section_code,
      t_bloc_motif_intervention.section_texte AS motif_intervention_section_texte,
      p_bloc_occupation.no_sejour,
      p_bloc_occupation.salle_id,
      t_bloc_salle.code AS salle_code,
      t_bloc_salle.texte_court AS salle_texte,
      t_bloc_salle.section_id AS salle_section_id,
      t_bloc_salle.section_code AS salle_section_code,
      t_bloc_salle.section_texte AS salle_section_texte,
      t_bloc_salle.bloc_id,
      t_bloc.code AS bloc_code,
      t_bloc.texte_court AS bloc_texte,
      p_bloc_occupation.sejour_id,
      p_bloc_occupation.type_programmation,
      p_bloc_occupation.valide,
      1::numeric AS nb_intervention,
      p_bloc_occupation.duree_disponible,
      p_bloc_occupation.type_mouvement,
      p_bloc_occupation.duree_debordement,
      p_bloc_occupation.duree_occupation,
      p_bloc_occupation.duree_remise_en_etat,
      p_bloc_occupation.duree_salle,
      p_bloc_occupation.duree_total
     FROM activite.p_bloc_occupation
       JOIN activite.t_bloc_salle ON p_bloc_occupation.salle_id = t_bloc_salle.oid
       JOIN activite.t_bloc ON t_bloc_salle.bloc_id = t_bloc.oid
       JOIN activite.t_bloc_motif_intervention ON p_bloc_occupation.motif_intervention_id = t_bloc_motif_intervention.oid
       JOIN activite.t_medecins_administratifs_c ON p_bloc_occupation.medecin_chirurgien_id = t_medecins_administratifs_c.oid
       JOIN base.p_calendrier ON p_bloc_occupation.date = p_calendrier.date;