""" docs_export.py — La Suite Docs integration for CQAI Nursing Case Studies Tool Converts care plans and case study responses to Markdown for La Suite Docs. No API credentials needed. """ from __future__ import annotations from datetime import date import streamlit as st DOCS_PUBLIC_INSTANCE = "https://notes.liiib.re" DOCS_SIGNUP_URL = "https://notes.liiib.re" DOCS_IMPORT_GUIDE = """ **How to use La Suite Docs (free, no credit card):** 1. **Sign up** → go to [notes.liiib.re ↗](https://notes.liiib.re) and click **Start Writing** 2. Click **Créer un nouveau compte** (Create a new account) — enter username, email, password 3. Once logged in, click **+ New document** 4. Click the **⋯ menu → Import** → select your downloaded `.md` file 5. Your document is live — share, annotate, collaborate in real time > 💡 Accounts are free. Content resets monthly on this public demo instance. > For a permanent instance, consider self-hosting on Railway (see CQAI docs). """.format() def render_save_to_docs( title: str, markdown_content: str, filename: str, description: str = "", instance_url: str = DOCS_PUBLIC_INSTANCE, ) -> None: """Render a 'Save to Docs' panel with .md download + Open Docs link.""" st.markdown("---") st.markdown("#### 📄 Save to La Suite Docs") if description: st.caption(description) col_dl, col_open = st.columns(2) with col_dl: st.download_button( label="⬇️ Download as .md", data=markdown_content, file_name=f"{filename}.md", mime="text/markdown", use_container_width=True, key=f"docs_dl_{filename}", ) with col_open: st.link_button( "🌐 Sign up / Open Docs", url="https://notes.liiib.re", use_container_width=True, ) with st.expander("📋 How to import into Docs", expanded=False): st.markdown(DOCS_IMPORT_GUIDE) st.info( "💡 La Suite Docs is an open-source, GDPR-compliant alternative to Notion " "and Google Docs — built by the French and German governments. Free to use.", icon="ℹ️", ) # --------------------------------------------------------------------------- # Case Studies — Markdown generators # --------------------------------------------------------------------------- def care_plan_to_markdown( case_title: str, patient_summary: str, adpie: dict, nanda_diagnoses: list, mcq_answers: dict | None = None, ) -> str: """ Convert a NANDA/ADPIE care plan to Docs-ready Markdown. Args: case_title: e.g. "STEMI — Mr Ahmed, 58" patient_summary: brief case overview adpie: dict with keys Assessment, Diagnosis, Planning, Implementation, Evaluation nanda_diagnoses: list of NANDA diagnosis strings mcq_answers: optional dict of {question: answer} for NCLEX questions """ lines = [ f"# Care Plan — {case_title}", "", f"> Generated: {date.today().strftime('%d %B %Y')} ", "> Tool: CQAI Nursing Case Studies ", "> Framework: NANDA / ADPIE ", "> *This document supports but does not replace clinical judgment.*", "", "---", "", ] if patient_summary: lines += [ "## Patient Summary", "", patient_summary.strip(), "", "---", "", ] if nanda_diagnoses: lines += [ "## NANDA Nursing Diagnoses", "", ] for dx in nanda_diagnoses: lines.append(f"- {dx}") lines.append("") lines.append("---") lines.append("") adpie_icons = { "Assessment": "🔍", "Diagnosis": "📋", "Planning": "🎯", "Implementation": "⚙️", "Evaluation": "✅", } if adpie: lines += [ "## ADPIE Nursing Process", "", ] for step in ["Assessment", "Diagnosis", "Planning", "Implementation", "Evaluation"]: content = adpie.get(step, "") if content: icon = adpie_icons.get(step, "") lines += [ f"### {icon} {step}", "", content.strip() if isinstance(content, str) else "\n".join(f"- {c}" for c in content), "", ] lines += ["---", ""] if mcq_answers: lines += [ "## NCLEX Practice Questions — My Answers", "", ] for q, a in mcq_answers.items(): lines.append(f"**Q:** {q}") lines.append(f"**A:** {a}") lines.append("") lines += ["---", ""] lines += [ "## Reflection", "", "*Use these prompts for NMC revalidation portfolio:*", "", "- What assessment findings were most significant and why?", "- How did you prioritise nursing diagnoses in this case?", "- What would you do differently in clinical practice?", "- Which NMC Standards of Proficiency did this case address?", "", "---", "", "## NMC Revalidation — CPD Record", "", "| Field | Value |", "|-------|-------|", f"| **Case** | {case_title} |", "| **Date** | [DATE] |", "| **CPD method** | Case-based learning |", "| **NMC Standards** | [e.g. Platform 3.4, 4.2] |", "| **Hours** | [X] |", "", "---", "", "*Generated by CQAI Nursing Case Studies. " "This tool supports but does not replace clinical judgment.*", ] return "\n".join(lines) def case_summary_to_markdown( case_title: str, presentation: str, key_learning: list, model_answers: dict, ) -> str: """Format a full case study summary for Docs.""" lines = [ f"# Case Study — {case_title}", "", f"> Generated: {date.today().strftime('%d %B %Y')}", "", "---", "", "## Clinical Presentation", "", presentation.strip(), "", "---", "", ] if model_answers: lines += ["## Model Answers (ADPIE)", ""] for step, answer in model_answers.items(): lines += [f"### {step}", "", answer.strip() if answer else "*See textbook.*", ""] lines += ["---", ""] if key_learning: lines += ["## Key Learning Points", ""] for point in key_learning: lines.append(f"- {point}") lines += ["", "---", ""] lines += [ "*Generated by CQAI Nursing Case Studies. " "This tool supports but does not replace clinical judgment.*", ] return "\n".join(lines)