Skip to content

Commit

Permalink
[feat] pre-visit summarization feature - closes #218
Browse files Browse the repository at this point in the history
  • Loading branch information
pkarw committed Nov 19, 2024
1 parent ed0ab35 commit f4e621a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src-distro/data/ai/prompt-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export const promptTemplates = {
template: (context: PromptTemplateContext) => {
return "What should be my best next diagnostic step for {select:regarding my overal results|" + promptOptions.join('|') + "}? Provide information sources and links."
},
},
preVisitSummary: {
label: "Prepare a summary for my next doctor's visit",
template: (context: PromptTemplateContext) => {
return "Prepare a summary report for my next doctor's visit. Format it as a report with proper headings, tables with results etc so it could be printed. Summarize results, mark all exceptions of the norms. Include the following: {select:my full test results|all test results - but just a quick summary|last year full test results|last year summary}. Provide information about the result sources (which examination, date)."
},
},

}
28 changes: 26 additions & 2 deletions src/components/chat-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from './
import Markdown from 'react-markdown'
import styles from './chat-message.module.css';
import { useTheme } from 'next-themes';
import dynamic from 'next/dynamic';
import showdown from 'showdown'

import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { Button } from '@/components/ui/button';
import { SaveIcon } from 'lucide-react';
import { DownloadIcon, SaveIcon } from 'lucide-react';
import { RecordContext } from '@/contexts/record-context';

interface ChatMessageProps {
Expand Down Expand Up @@ -100,6 +100,30 @@ const ChatMessage: React.FC<ChatMessageProps> = ({ message, ref }) => {
<Button title="Save message as new record" variant="ghost" size="icon" onClick={() => {
recordContext?.updateRecordFromText(message.content, message.recordRef ?? null, true);
}}><SaveIcon /></Button>
<Button title="Save message as new record" variant="ghost" size="icon" onClick={() => {

const converter = new showdown.Converter({ tables: true, completeHTMLDocument: true, openLinksInNewWindow: true });
converter.setFlavor('github');
const htmlContent = converter.makeHtml(message.content);

const mdElement = document.createElement('a');
const file = new Blob([message.content], { type: 'text/markdown' });
mdElement.href = URL.createObjectURL(file);
mdElement.download = `report-${message.id}.md`;
document.body.appendChild(mdElement);
mdElement.click();
document.body.removeChild(mdElement);

const htmlElement = document.createElement('a');
const fileHtml = new Blob([htmlContent], { type: 'text/html' });
htmlElement.href = URL.createObjectURL(fileHtml);
htmlElement.download = `report-${message.id}.html`;
document.body.appendChild(htmlElement);
htmlElement.click();
document.body.removeChild(htmlElement);

}}><DownloadIcon /></Button>

</div>
): null }
<div className="flex-wrap flex items-center justify-left min-h-100">
Expand Down

0 comments on commit f4e621a

Please sign in to comment.