From c12e382fc3284744dc2a0170a9cfe516c629cb97 Mon Sep 17 00:00:00 2001 From: Agnibho Mondal Date: Sun, 23 May 2021 16:55:53 +0530 Subject: [PATCH] Removed LaTeX PDF generator --- discharge.tex | 53 -------------------------------- www/discharge.php | 11 +++++-- www/print-discharge.php | 67 ----------------------------------------- 3 files changed, 8 insertions(+), 123 deletions(-) delete mode 100644 discharge.tex delete mode 100644 www/print-discharge.php diff --git a/discharge.tex b/discharge.tex deleted file mode 100644 index 89ddf62..0000000 --- a/discharge.tex +++ /dev/null @@ -1,53 +0,0 @@ -\documentclass{article} -\usepackage[a4paper]{geometry} -\usepackage{tabularx} -\usepackage{fancyhdr} - -\begin{document} -\pagenumbering{gobble} -\begin{center} -School of Tropical Medicine \\ -{\small 108, Chittaranjan Avenue, Kolkata-700073} -\rule{\textwidth}{0.4pt} -Discharge Certificate\\ -\rule{\textwidth}{0.4pt} -\end{center} -\flushright -%[vp]% \\ -\vspace{3em} -\begin{tabular}{r r} -Date of admission & %[doa]% \\ -Date of discharge & %[dod]% \\ -\end{tabular} -\flushleft -\vspace{-5em} -\begin{tabularx}{\textwidth}{l X} - Name & %[name]%\\ - Age & %[age]% \\ - Sex & %[sex]% \\ - Admission ID & %[pid]% \\ - Diagnosis & %[diagnosis]%\\ -\end{tabularx} -\rule{\textwidth}{0.4pt} -\paragraph{Summary} -%[summary]% -\rule{\textwidth}{0.4pt} -\paragraph{Advice on Discharge} -%[advice]% -\paragraph{} -%[advice]% -\vspace{2em} -%[note]% -\vfill -\flushright -\rule{10em}{0.4pt}\\ -Signature of Physician - -\newpage -\fancyhead[R]{%[name]%} -\fancyhead[C]{%[pid]%} -\fancyhead[L]{Investigations} -\setlength{\topmargin}{-5em} -\pagestyle{fancy} -%[reports]% -\end{document} diff --git a/www/discharge.php b/www/discharge.php index 2c06977..aaec721 100644 --- a/www/discharge.php +++ b/www/discharge.php @@ -2,6 +2,11 @@ require(dirname(__DIR__)."/require.php"); if(!empty($_GET["pid"])){ $pid=$_GET["pid"]; + if(!empty($_POST["discharge"]) && $_POST["discharge"]=="discharge"){ + $db->setDischarged($pid); + header("Location: view.php?pid=".$_GET["pid"]); + exit(); + } if(!empty($_POST["delete"])){ $db->deleteAdvice($_POST["delete"]); } @@ -37,9 +42,9 @@ if(!empty($_GET["pid"])){
>
-
> - - + > + +
diff --git a/www/print-discharge.php b/www/print-discharge.php deleted file mode 100644 index 4b0e4bc..0000000 --- a/www/print-discharge.php +++ /dev/null @@ -1,67 +0,0 @@ -form)){ - $schema=json_decode(file_get_contents("forms/".$data->form.".schema.json")); - } - unset($data->cat); - $view="\begin{tabularx}{\\textwidth}{l X}\n"; - foreach($data as $field=>$value){ - if($field!="form" && !empty($value)){ - if(!empty($schema->properties->$field)){ - $view=$view.$schema->properties->$field->description." & ".$value."\\\\\n"; - } - else{ - $view=$view.$field." & ".$value."\n"; - } - } - } - $view=$view."\\end{tabularx}\n"; - return $view; -} -if(!empty($_GET["pid"])){ - $pid=$_GET["pid"]; - $template=file_get_contents(CONFIG_ROOT."discharge.tex"); - if(!empty($_POST["discharge-note"])){ - $template=str_replace("%[note]%", $_POST["discharge-note"], $template); - } - $template=str_replace("%[name]%", $db->getName($pid)->fetcharray()["name"], $template); - $template=str_replace("%[age]%", $db->getAge($pid)->fetcharray()["age"], $template); - $template=str_replace("%[sex]%", $db->getSex($pid)->fetcharray()["sex"], $template); - $template=str_replace("%[pid]%", $pid, $template); - $template=str_replace("%[diagnosis]%", $db->getDiagnosis($pid)->fetcharray()["diagnosis"], $template); - $template=str_replace("%[doa]%", $db->getAdmission($pid)->fetcharray()["admission"], $template); - $template=str_replace("%[dod]%", $db->getDeparture($pid)->fetcharray()["departure"], $template); - $template=str_replace("%[summary]%", $db->getSummary($pid)->fetcharray()["summary"], $template); - $list=$db->getAdvice($pid); - $view=""; - while($drug=$list->fetchArray()){ - $view=$view."\item ".$drug["drug"]." ".$drug["dose"]." ".$drug["route"]." ".$drug["frequency"]." ".$drug["duration"]." ".$drug["addl"]."\n"; - } - if($view){ - $template=str_replace("%[advice]%", "\begin{enumerate}\n".$view."\\end{enumerate}", $template); - } - $reports=[]; - $reportsArray=$db->getAllData($pid, "reports"); - while($r=$reportsArray->fetchArray()){ - $template=str_replace("%[reports]%", json2tex($r["data"]), $template); - } - //echo $template; - $f=str_replace("/", "", $pid)."-".time()."-".rand(); - file_put_contents("data/discharge/".$f.".tex", $template); - exec("pdflatex --output-directory data/discharge/ data/discharge/".$f.".tex", $out, $ret); - //var_dump($out); - //var_dump($ret); - if($ret!=0){ - header("Content-Type: text/plain"); - echo "Failed to generate discharge certificate. Please check whether patient information, summary, reports, discharge advices are properly filled up."; - } - else{ - $db->setDischarged($pid); - header("Content-Type: application/pdf"); - readFile("data/discharge/".$f.".pdf"); - exec(" rm data/discharge/".$f."*"); - } -} -?> -- 2.39.5