print('Hello world!')import openpyxl
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side

# Création du classeur
wb = openpyxl.Workbook()
ws = wb.active
ws.title = "Fiche_FAAM"

# Couleurs et Styles
NAVY_HEADER = "1E293B"
fill_header = PatternFill(start_color=NAVY_HEADER, end_color=NAVY_HEADER, fill_type="solid")
fill_section = PatternFill(start_color="E2E8F0", end_color="E2E8F0", fill_type="solid")
fill_table_hdr = PatternFill(start_color="3B82F6", end_color="3B82F6", fill_type="solid")

font_title = Font(name="Calibri", size=16, bold=True, color="FFFFFF")
font_section = Font(name="Calibri", size=12, bold=True, color="1E293B")
font_bold = Font(name="Calibri", size=11, bold=True, color="0F172A")
font_regular = Font(name="Calibri", size=11, color="334155")

thin_border_side = Side(border_style="thin", color="CBD5E1")
border_all = Border(left=thin_border_side, right=thin_border_side, top=thin_border_side, bottom=thin_border_side)

ws.views.sheetView[0].showGridLines = True

# Titre
ws.merge_cells("A1:G2")
ws["A1"] = "FICHE D'AFFECTATION ANALYTIQUE MÉDICALE (FAAM)"
ws["A1"].font = font_title
ws["A1"].fill = fill_header
ws["A1"].alignment = Alignment(horizontal="center", vertical="center")

# Section 1 : Identification
ws.merge_cells("A5:G5")
ws["A5"] = "1. IDENTIFICATION DU PRATICIEN"
ws["A5"].font = font_section
ws["A5"].fill = fill_section

labels_sec1 = [
    ("A6", "Nom / Prénom :", "C6", "M BAREK Mona Mouna"),
    ("E6", "Matricule RH :", "F6", "012345"),
    ("A7", "Statut / Grade :", "C7", "Prat.hosp TPA CS"),
    ("E7", "Discipline / Spé :", "F7", "Médecine Générale / Addictologie"),
    ("A8", "Quotité Contrat (ETP) :", "C8", 0.8),
    ("E8", "Date d'effet :", "F8", "01/09/2026")
]
for pos_l, val_l, pos_v, val_v in labels_sec1:
    ws[pos_l] = val_l
    ws[pos_l].font = font_bold
    ws[pos_v] = val_v
    ws[pos_v].font = font_regular

# Section 3 : Tableau de ventilation ETP
ws.merge_cells("A14:G14")
ws["A14"] = "3. VENTILATION PAR UNITÉ FONCTIONNELLE (UF)"
ws["A14"].font = font_section
ws["A14"].fill = fill_section

headers = ["Code UF", "Libellé de l'UF", "Type d'Activité", "Quotité ETP", "MIG / Cahier des charges", "Tuteur", "Commentaires"]
for col_idx, h in enumerate(headers, start=1):
    cell = ws.cell(row=15, column=col_idx, value=h)
    cell.font = Font(name="Calibri", size=10, bold=True, color="FFFFFF")
    cell.fill = fill_table_hdr
    cell.alignment = Alignment(horizontal="center", vertical="center")

table_data = [
    (3325, "HYGIENE ALIMENTAIRE - ADDICTOLOGIE", "Hospitalisation Conv.", 0.50, "Non", "-", "13 Lits sevrage"),
    (3326, "EQUIPE DE LIAISON EN ADDICTOLOGIE", "Liaison / Transversale", 0.10, "Oui (MIG Addicto)", "Dr M BAREK", "Respect cahier des charges MIG"),
    (3429, "CONSULT HYGIENE ALIMENTAIRE - ADDICTOLOG", "Consultations Externes", 0.20, "Non", "-", "Activité CCAM externe"),
    ("", "Hôpital de Jour Addictologie", "HDJ", 0.00, "Oui (HDJ)", "-", "Nécessite temps médical dédié")
]

for i, row in enumerate(table_data, start=16):
    for j, val in enumerate(row, start=1):
        c = ws.cell(row=i, column=j, value=val)
        c.font = font_regular
        c.border = border_all

# Totaux et Formule de contrôle
tot_row = 20
ws.cell(row=tot_row, column=1, value="TOTAL ETP AFFECTÉ").font = font_bold
ws.cell(row=tot_row, column=4, value=f"=SUM(D16:D19)").font = font_bold
ws.cell(row=tot_row, column=5, value="CONTRÔLE :").font = font_bold
ws.cell(row=tot_row, column=6, value=f'=IF(ABS(D{tot_row}-C8)<0.001, "CONFORME (100%)", "ÉCART DETECTÉ !")').font = Font(bold=True, color="16A34A")

# Largeur des colonnes
widths = {'A': 12, 'B': 42, 'C': 25, 'D': 14, 'E': 24, 'F': 22, 'G': 30}
for col, w in widths.items():
    ws.column_dimensions[col].width = w

wb.save("FAAM_Fiche_Affectation_Analytique_Medicale.xlsx")

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: