-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
715 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<h1 class='text-2xl text-center bold'> | ||
{{settings.hospital}} | ||
</h1> | ||
<h2 class='text-lg pt-1 text-center'> | ||
{{settings.unit}} | ||
</h2> | ||
|
||
<div class='grid grid-cols-3 gap-2 mt-3 p-3'> | ||
<p> | ||
<span class='bold'> | ||
Name: | ||
</span> | ||
{{patient.name}} | ||
</p> | ||
<p> | ||
<span class='bold'> | ||
Age: | ||
</span> | ||
{{patient.age}} | ||
</p> | ||
<p> | ||
<span class='bold'> | ||
BHT: | ||
</span> | ||
{{surgery.bht}} | ||
</p> | ||
<p> | ||
<span class='bold'> | ||
Ward: | ||
</span> | ||
{{surgery.ward}} | ||
</p> | ||
<p> | ||
<span class='bold'> | ||
Date: | ||
</span> | ||
{{surgery.date}} | ||
</p> | ||
</div> | ||
|
||
<hr /> | ||
|
||
<h2 class='text-xl mt-3 text-center p-3'> | ||
{{surgery.title}} | ||
</h2> | ||
|
||
<div class='flex justify-end items-end flex-col'> | ||
<div> | ||
{{#if surgery.doneBy.length}} | ||
<div class='p-1'> | ||
<div class='bold m-1'> | ||
Done By: | ||
</div> | ||
<ul class='disc'> | ||
{{#each surgery.doneBy as |doctor|}} | ||
<li> | ||
{{doctor}} | ||
</li> | ||
{{/each}} | ||
</ul> | ||
</div> | ||
{{/if}} | ||
{{#if surgery.assistedBy.length}} | ||
<div class='p-1'> | ||
<div class='bold m-1'> | ||
Assisted By: | ||
</div> | ||
<ul class='disc'> | ||
{{#each surgery.assistedBy as |doctor|}} | ||
<li> | ||
{{doctor}} | ||
</li> | ||
{{/each}} | ||
</ul> | ||
</div> | ||
{{/if}} | ||
</div> | ||
</div> | ||
|
||
{{#if surgery.notes}} | ||
<div class='p-1'> | ||
<div class='prose'> | ||
{{{surgery.notes}}} | ||
</div> | ||
</div> | ||
{{/if}} | ||
|
||
{{#if surgery.post_op_notes}} | ||
<hr /> | ||
<div class='p-1'> | ||
<h2 class='text-lg mt-3 text-center p-3'> | ||
Post-Op Notes | ||
</h2> | ||
<div class='prose'> | ||
{{{surgery.post_op_notes}}} | ||
</div> | ||
</div> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface PrintDialogArgs { | ||
title?: string | ||
data?: object | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>OpNotes</title> | ||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> | ||
<meta http-equiv="Content-Security-Policy" | ||
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Print Preview</title> | ||
|
||
<link rel="stylesheet" href="/src/styles/reset.css" /> | ||
<link rel="stylesheet" href="/src/styles/screen.css" /> | ||
<link rel="stylesheet" href="/src/styles/print.css" media="print" /> | ||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" /> | ||
</head> | ||
|
||
<body class="overflow-hidden p-0 m-0"> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
<script type="module" src="/src/print.tsx"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { PatientModel } from '@shared/models/PatientModel' | ||
import { SurgeryModel } from '@shared/models/SurgeryModel' | ||
import { formatDate, isEmptyHtml } from './utils' | ||
|
||
export const surgeryPrintData = ( | ||
patient?: PatientModel, | ||
surgery?: SurgeryModel, | ||
settings?: Record<string, string | null> | ||
) => ({ | ||
patient: { | ||
...patient, | ||
age: patient?.age ? `${patient?.age} yrs` : `<1 yrs` | ||
}, | ||
surgery: { | ||
...surgery, | ||
doneBy: surgery?.doneBy | ||
? surgery?.doneBy.map((doctor) => `Dr. ${doctor.name} (${doctor.designation})`) | ||
: [], | ||
assistedBy: surgery?.assistedBy | ||
? surgery?.assistedBy.map((doctor) => `Dr. ${doctor.name} (${doctor.designation})`) | ||
: [], | ||
date: surgery?.date ? formatDate(surgery?.date) : null, | ||
notes: isEmptyHtml(surgery?.notes) ? null : surgery?.notes, | ||
post_op_notes: isEmptyHtml(surgery?.post_op_notes) ? null : surgery?.post_op_notes | ||
}, | ||
settings: { | ||
hospital: settings?.hospital || '', | ||
unit: settings?.unit || '' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
import React, { useEffect, useMemo } from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import handlebars from 'handlebars' | ||
import surgeryOpNoteTemplate from '../../../resources/templates/surgery-opnote.hbs?raw' | ||
import { Button } from './components/ui/button' | ||
|
||
const printTemplate = handlebars.compile(surgeryOpNoteTemplate) | ||
|
||
const Print = () => { | ||
const [printData, setPrintData] = React.useState<object | null>(null) | ||
useEffect(() => { | ||
const handlePrintData = (data) => { | ||
setPrintData(data) | ||
} | ||
|
||
window.electronApi.onPrintData(handlePrintData) | ||
}, []) | ||
|
||
const printHtml = useMemo(() => { | ||
if (!printData) { | ||
return '' | ||
} | ||
return printTemplate((printData as any).data) | ||
}, [printData]) | ||
|
||
const handlePrint = () => { | ||
window.print() | ||
} | ||
|
||
useEffect(() => { | ||
const keyboardListener = (e: KeyboardEvent) => { | ||
if (e.key === 'p' && e.ctrlKey) { | ||
handlePrint() | ||
} | ||
} | ||
|
||
window.addEventListener('keydown', keyboardListener) | ||
|
||
return () => { | ||
window.removeEventListener('keydown', keyboardListener) | ||
} | ||
}, []) | ||
|
||
return ( | ||
<div className="w-full"> | ||
<div className="flex justify-end print-hidden"> | ||
<Button onClick={handlePrint}>Print</Button> | ||
</div> | ||
{printData && <div dangerouslySetInnerHTML={{ __html: printHtml }}></div>} | ||
</div> | ||
) | ||
} | ||
|
||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( | ||
<React.StrictMode> | ||
<Print /> | ||
</React.StrictMode> | ||
) |
Oops, something went wrong.