File size: 6,891 Bytes
4d4468d 453396e 4d4468d 453396e 4d4468d 453396e 4d4468d 453396e 4d4468d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | """
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)
|