\usepackage[headsep=3cm,top=4cm, bottom=4cm]{geometry}
      \textbf{Date of birth}\newline\mydate&%
\fancyhead[LO]{{\Large \scshape d} \\ My degree\\My reg no}
    \fancyhead[RO]{{\Large \scshape other dr }\\ MBBS,  \\reg no }
\fancyfoot[CO]{{\scshape my  clinics}\\ My road,\\ city  \\ Phone: 000000000}


\newcommand{\mydate}{December 26, 1997}
\newcommand{\myaddress}{26 Washington Ave., Manhattan, New York.\newline United States of America}
\subsection*{Follow up/History}


This is the template I use to generate my patient's medical record using lyx. There are few problems. If you help me solve, I would be obliged.

  1. When I use \date{\today} , today's date is generated. I can use \date {ddMMYYYY} to have fixed date. When I use \today, can the date of printing the document be fixed; so that next time when I follow up a patient, the previous visit date is not changed.

  2. As you can see, I create single file per patient. So that when follow up occurs, I can continue on the same file and print only the recent observations. Is there a possibility of exporting a pdf file which has "name-datetime stamp" pattern, so that 1 pdf is generated every visit. This will help me save visit vise, but incremental notes (First pdf file will have first vist note, but subsequent files will have current visits notes in addition to previous visit). As I use lyx, I would like to change the preamble only.

  3. How can I vertically center every page generated? Most visits are short, and require 1 (max 2) page documentation only (majority).

  • What you need is a specialized application with a database back end that (if you like) would populate latex template and call latex programs to produce PDF. This is just too much for latex alone and not what it was designed for. Say a PHP web site with MySQL back end for example. Or just a text editor and a bunch of perl scripts. But still too much for latex. – ajeh Jan 16 '14 at 20:12
  • About #3: Why would you want to vertically center every page? It seems much more preferable to have the documentation starting always at the same height. You maybe want to start each personal documentation with a different title page (containing most important informations) but aside of this I would prefer consistent page structure... Do you agree? – strpeter Jan 17 '14 at 9:07
  • @ajeh: Some time ago, I initialized a project (for writing flashcards) similar to what you are stating but using Symfony provided on github. – strpeter Jan 17 '14 at 9:11
  • Related: tex.stackexchange.com/questions/154733/… – Ethan Bolker Jan 18 '14 at 16:04

This is a partial response - really more a discussion, and too long for a comment.

For #1, the answers here may help: What are \immediate & \write18 and how does one use them?

For #2, consider generating a separate one page pdf for each visit. When you want the full history, combine them using pdftk or pdfpages. (That would automatically solve #1 with \today for each visit.)

I'm sure someone can help with #3.

But ... are you sure this is the workflow you want? TeX will make nicely typeset visit reports, but may not be the best way to organize all the data you are collecting. Some day you may well want to search or select from or otherwise parse your medical records other than in the one-TeX-source-file-per-patient format you are committing to. Years ago I supervised a student software project for a doc at the then forefront of electronic medical records - what he wanted was a front end that would generate Word documents from a template. I thought it a bad idea even at the time. TeX is better than Word, but neither is a good format for storing data.

So I end up with the same kind of recommendation as @ILiketoCode - consider a database, or flat files with an easy to parse format. Generate your patient reports (pdf from TeX) with a script. (And remember to consider HIPAA compliance.)

Edits in response to OP's comments:

I see why you want free form input rather than tabbing through fields for database entry - I've watched my docs sometimes looking more at their computers than at me. Here's a possible design. You fill in a template that you can then both compile into a pdf and (if you wish) relatively easily parse with a script to populate a database, tag with XML markup, ... . You have one source file per visit, not per patient. Make sure you establish good naming and folder conventions. You can glue these together as outlined above.

I suggest environments for the parts of the visit report. That separates formatting from semantic content, and there are TeX packages and scripting tools (awk, python, ...) that can easily extract environments from these simple source files.

Some of this is just pseudoTeX - not compilable yet. It's based on an answer to Trying to create simple template for novice users.

The template:

% template for documenting an office visit

% specify date here rather than use \today so this file is self-documenting
\date{January 17, 2014}








The preamble:

% officevisitpreamble.tex

  % get last and first names
  % use the date as specified in the template
  % call some version of maketitle
% and the other new environments
   % whatever happens last
  • How do you know the questioner is in the US? Couldn't agree more re. database, though. – cfr Jan 16 '14 at 1:15
  • database is a good idea. but all emr's take longer than expected duration than when done on a one single file, as you end up clicking this and that button. Patient's deserve more time than the emr. HIPAA does not matter to me. – Vaibhav Jan 16 '14 at 10:08
  • @cfr There's a Manhattan address in the OP's sample document. Of course that might be fictional ... and he has asked another question about Sanskrit. – Ethan Bolker Jan 16 '14 at 16:02
  • @EthanBolker Not sure how I missed that. – cfr Jan 16 '14 at 16:40
  • If it weren't for the Lyx bit, I'd definitely think this made more sense as a merge but I've no idea how that'd work with Lyx. It would be more flexible, though as it could be imported into a database or spreadsheet later, for example. (Or exported to create the documentation if the OP goes that route.) I do this with output from Calc into CSV, for example, to produce assessment feedback per student, grade reports covering the whole class etc. But it would be easy to adapt here. But I've no idea about Lyx. – cfr Jan 17 '14 at 0:42

This is how I would go about it if I were you. Unfortunately I don't know Lyx thought I know LaTeX.

To answer 2., I would create a new .tex file per patient per visit. For example, if Roger Federer visited on 2014/01/01, I would create a .tex file federer-roger-20140101.tex. If Roger Federer again visited on 2014/01/13, I would copy the file federer-roger-20140101.tex into the new file federer-roger-20140113.tex, and edit the new file to add in any new information in the current visit.

To answer 1., I would manually add in the date for each visit using \date{2014/01/01} for example. I don't believe that you can just convert the old \today into a date in LaTeX, because LaTeX is not able to access the date a document was last modified (e.g. see link).

I don't have an answer to 3. unfortunately.

Finally, it sounds like you are entering patient notes into a database, and you want to automatically generate patient reports based on the contents of the database. One way to do this is to save all the files for a patient in a folder, say the folder federer-roger. You could then save the notes for each patient into a text file with a certain format, for example:

DATE 2014/01/01
HISTORY Likes to play tennis
EXAMINATION Measured his resting heart rate

And using some sort of script say written in Python, you could generate the LaTeX file by putting the preamble, and formatting each visit file 20140101.txt and 20140113.txt according to the format you desire.

  • This is actually funny to me, because I know someone who had Roger Federer as a patient. – Mark Richman Jan 14 '14 at 19:37
  • Or forget python and use tex with merge to merge in a data file. That way the template is fixed and you just add to the template each time, producing a new pdf. – cfr Jan 16 '14 at 1:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.