4 MedScript is a medical prescription writing software. It is primarily for
5 medical practitioners for writing prescriptions.
7 The purpose of the program is to enable medical practitioners to prepare
8 computerized prescriptions. The program has been designed after the commonly
9 used prescription format among the medical practitioners in India.
14 The program uses a custom file format mpaz (Medical Prescription Archive -
15 Zipped). It is a zip file in a specific format which includes:
17 1. A meta.json file containing file type and mpaz version.
18 2. A prescription.zip file containing the actual prescription.
19 3. An attachment folder containing attached files.
20 4. A template folder containing the bundled prescription template.
22 Optionally the mpaz archive may also include an S/MIME signature and
23 certificate for authentication.
25 The structure of the mpaz file is as follows:
27 <filename>.mpaz (zipped file)
28 |-- meta.json (e.g. {"type": "MedScript", "version": "<mpaz version>"})
29 |-- prescription.json (Prescription object in JSON format)
30 |-- template (included template for rendering)
31 | |-- index.html (Jinja2 template)
32 | |-- <other template files e.g. CSS>
33 |-- attachment (directory containing attachments)
34 | |-- <attached files>
35 |-- signature (optional: S/MIME signature)
36 |-- certificate.pem (optional: full certificate chain including end-user, intermediates and root certificate)
41 MedScript uses a directory structure to store user files. It is highly
42 configurable. An example directory structure is given below:
44 <medscript data directory> (configurable)
45 |-- document (for storing prescription files)
46 | |-- <document files>
47 |-- form (for custom input form files)
48 | |-- <custom forms in JSON format)
49 |-- log (for storing log files)
50 | |-- <log files written by the program>
51 |-- plugin (for installing plugins)
52 | |-- <installed plugins>
53 |-- prescriber (for storing prescriber information)
54 | |-- <prescriber files in JSON format>
55 |-- preset (for storing preset files)
59 | |-- investigation.csv
64 | |-- <installed templates>
65 |-- config.json (the configuration file)
70 MedScript can be used by simply downloading it from the repository and running
71 it with the Python 3 interpreter. The necessary python libraries need to
72 be installed. Alternatively the release versions can be
73 downloaded and used directly.
75 The required Python libraries are as follows:
90 When starting the program, the main window of is shown.The menu bar at the top
91 can be used to access most of the functions. The toolbar below it contains the
92 most commonly used functions for quick access.
94 ### Creating a prescription
96 A new prescription can be created right from the starting window.
97 Alternatively the "New File" menu option can be used to create a new
100 There are eight tabs in the tab bar containing important parts of a
103 1. Patient tab: It contains the demographical data of the patient, diagnosis
104 and a few extra parameters of the prescription. The diagnosis can be entered
105 here. To enter multiple diagnosis semicolon (;) may be used to separate them.
106 Please note that date of birth and age cannot be used simultaneously. There
107 are radio buttons to select which field to use in the prescription.
109 2. Clinical tab: It contains the clinical note regarding the patient. The
110 presets can be selected from the preset box at the top and inserted into the
111 note by clicking the insert button.
113 3. Report tab: It contains the reports shown by the patient. It also has the
116 4. Advice tab: It contains the primary advices given to the patient. It is
117 usually printed at the top of the advice section of the prescription. It also
118 has the preset option.
120 5. Investigation tab: It contains the investigations suggested to the
121 patient. It also has the preset option.
123 6. Medication tab: It contains the medications advised to the patient. It has
124 the preset option. It can contain both the generic and brand names of a
125 medicine. To insert an alternative name (generic/brand) write it on the same
126 line and surround it with square brackets i.e []. It also has the preset
129 7. Additional tab: It contains additional advice given to the patient. It is
130 commonly printed at the bottom of the prescription.
132 8. Certificate tab: It can be used to write a medical certificate. Rendering a
133 medical certificate requires use of a different template. The "medcert"
134 template included with MedScript can be used for this purpose.
136 9. Attachment tab: Files e.g. PDF, images may be attached to the prescription
137 file from the attachment tab. These attachments can be viewed later when
138 opening the prescription file with the program. However, this attachments are
139 not printed with the prescription.
141 ### Viewing the prescription
143 The prescription can be quickly viewed by using the "Quick Display" option
144 under the "Process" menu. Viewing the prescriptions this way only shows the
145 prescription data without considering the formatting. To display the
146 prescription in a printable format, use the rendering option instead.
148 ### Saving a prescription
150 The "Save File" or the "Save As" option from the "File" menu can be used to
151 save a file created or edited in the program.
153 While saving the template can be selected from the "Template" combo box in the
154 toolbar. The template will be saved in the mpaz file. When opening an existing
155 file the "Template" combo box has the option to change the template or to keep
158 ### Opening a prescription
160 The prescriptions are saved in mpaz files and can be shared easily. To open a
161 prescription file, the "Open File" option from the file menu can be used.
162 Alternatively the file name can be supplied to the program as command line
163 argument when starting from the command line.
166 ### Rendering a prescription
168 The prescriptions can be rendered and subsequently printed from the "Process"
169 menu by selecting the "Render Prescription" option. Note that the files must
170 be saved before rendering. The rendered prescription is opened in a separate
171 window. It can be saved as PDF or printed directly.
175 The prescription files in the default document folder are incorporated into an
176 index which can be used to quickly find a particular prescription. To use this
177 feature, select the "Show Index" option in the "File" menu. Any changes to the
178 directory including creation, modification or deletion of files is monitored
179 by the index and reflected accordingly.
181 The index can be filtered by using patient id, prescription id or patient's
182 name. The entries can be viewed directly, opened in the program for
183 editing/rendering or copied into a new prescription. This can be useful while
184 consulting follow up patients.
188 The program uses Jinja2 template for rendering the prescription. A default
189 template is provided with the program. However, other templates (see default
190 template for reference) can be created and placed in the template folder to be
191 used for rendering the prescriptions. The drop down option in the toolbar can
192 be used to switch between available templates.
194 Note that the templates are packaged with the mpaz file which can be used for
195 rendering. However, modifying/saving the file overwrites it.
197 It is easy to develop templates for the program. How to develop templates is
202 This program supports markdown formatting. Markdown can be used to format the
203 prescriptions and certificates. It can be turned on from the
204 "Edit Configuration" dialog under the "Settings" menu.
209 The program is primarily targeted towards individual practitioners. However,
210 it can be easily adapted for multiple practitioners.
212 The "Current Prescriber" option under the "Settings" menu can be used to
213 view/edit the current prescriber. The "Select Prescriber" option can be used
214 to open the prescriber selector dialog. All the prescribers are listed here. A
215 prescriber can be selected from here. Prescribers can also be edited, deleted
216 or new prescribers can be created from this dialog.
218 The data of the practitioner is stored in JSON files in the prescriber
219 directory. The default file to be loaded is configured in the config file. A
220 command line option can be used to specify which alternative prescriber file
221 to load in the program, e.g. `<program> --prescriber <prescriber file>`.
226 The program uses a preset system to insert repeatedly used text without the
227 need to type them. To use this feature the text must be entered beforehand to
228 the respective files. These files are in the CSV format and can be edited
229 with any spreadsheet editing software.
231 There is a preset editor included with this software as well. This editor can
232 be accessed by going to the "Settings" menu and selecting the "Edit Presets"
235 The preset editor contains a drop down input at the top which can be used to
236 select the respective file to edit. There is also a "Save" button at the top
237 which can be used to save the changes to the selected file.
239 The data is presented in an editable table which can be used to edit the data
240 in the selected file. While editing, the KEY/VALUE format is to be used as
241 shown in the top row. The "Add Row" button at the bottom can be used to add a
242 new row for entry of new data.
244 The preset files are kept in the preset directory. The files associated with
245 medical certificate, clinical note, report, advice, investigation, medication
246 and additional are certificate.csv, note.csv, report.csv, advice.csv,
247 investigation.csv, medication.csv and additional.csv. Each file contains a top
248 row indicating the variables in the columns. The data is entered in two
249 columns with each row containing a KEY and a TEXT. The TEXT can be entered in
250 the edit area by selecting the KEY from the preset input. Blank files with
251 only the top row are included with the program.
256 The default configuration file contains sane defaults and the program can be
257 used without editing it. However, the json formatted configuration file can be
258 edited to further tune the program to the users preference.
260 The default configuration is the config.json located in the config directory.
261 However, a different config file may be provided by using the
262 `<program> --config <filename>` command line argument.
264 It is recommended to use the default config file as base while creating
265 another customized config file.
267 A graphical configuration editor is also included with the program. It can be
268 accessed by going to the "Settings" menu and selecting the "Edit Configuration"
269 option. The configurable options are as follows:
271 1. Data directory: where the user data of the program is stored.
273 2. Prescriber: the default prescriber which is loaded when the program
276 3. Preset newline: whether a newline / line break to be inserted after a preset
279 4. Preset delimiter: CSV files may have different delimiters. By default
280 this program uses "," as delimiter, however this can be changed to ";" from
283 5. Age/DOB: Checking this box makes new documents use age instead of date of
286 6. Markdown: The markdown formatting can be enabled from here.
288 7. Check update: Whether updates are available can be checked at program start
289 up by enabling this option.
291 8. Form: The custom input form system can be enabled from here.
293 9. Plugin: The plugin system can be enabled from here.
295 10. S/MIME: This is an experimental feature and is disabled by default. To use
296 it, it has to be enabled first from the settings. The Private key, X509
297 certificate and Root bundle can be selected from the options that follow this.
302 The program uses a Prescription object to store the prescription data. The
303 structure of the Prescription object is as follows:
305 prescription (Prescription object)
306 |-- date (string: date-time in the %Y-%m-%d %H:%M:%S format)
307 |-- id (string: the id of the prescription)
308 |-- pid (string: the patient's id)
309 |-- name (string: the name of the patient)
310 |-- dob (string: the date of birth)
311 |-- age (string: the age of the patient, may contain unit)
312 |-- sex (string: sex of the patient)
313 |-- address (string: address of the patient)
314 |-- contact (string: contact number / email of the patient)
315 |-- extra (string: extra data related to the prescription)
316 |-- mode (string: the mode of consultation e.g. tele-consultation)
317 |-- daw (boolean: dispense as written)
318 |-- diagnosis (string: diagnosis of the patient's condition)
319 |-- note (string: clinical note e.g. history, physical examination)
320 |-- report (string: available reports)
321 |-- advice (string: advice given to the patient, not the medications)
322 |-- investigation (string: investigations suggested for the patient)
323 |-- medication (string: the list of medications prescribed)
324 |-- additional (string: any additional advice/instructions)
325 |-- certificate (string: content of a medical certificate)
326 |-- custom (list: contents of custom input forms)
327 |-- properties (dictionary: plugin data, each plugin in separate key)
328 |-- prescriber (Prescriber object)
329 | |-- name (string: the name of the prescriber)
330 | |-- qualification (string: the qualification of the prescriber)
331 | |-- registration (string: the registration number of the prescriber)
332 | |-- address (string: the address of the prescriber)
333 | |-- contact (string: contact number / email of the prescriber)
334 | |-- extra (string: any extra data about the prescriber)
335 | |-- properties (dictionary: plugin data, each plugin in separate key)
337 Best practice for assigning plugin data to properties is to use a separate
338 key for each plugin and store the data as the value associated with that key.
343 MedScript has a plugin system which can be used to incorporate customized
344 plugins written in python. To use the plugins, the plugins must be saved in
345 the configured plugin directory and plugin must be enabled in the
348 Enabling arbitrary plugin is dangerous and may cause catastrophic damage. Only
349 install plugins from trusted sources and review the code.
354 Developing MedScript plugin is very simple. All you need is to create a python
355 file and implement a few functions.
357 The plugin is kept in its own directory. The name of the directory is the name
358 of the plugin. A plugin directory must contain a file called main.py which
359 contains the functions needed by MedScript plugin system. The directory tree
362 <medscript data directory (e.g. ~/MedScript)>
364 | |-- <plugin directory (e.g. the name of the plugin)
366 | | |-- <other files needed by the plugin>
368 The main.py file may implement the following functions which will be called by
369 the program as needed:
371 def new(prescription)
372 Called when creating a new document. It is also called during program startup.
373 def open(prescription)
374 Called when opening a document.
375 def save(prescription)
376 Called when saving a document.
377 def refresh(prescription)
378 Called when the refresh interface option is selected.
379 def run(prescription)
380 Called when the option associated with the plugin is selected from the plugin menu.
382 The `prescription` parameter passed to the functions is a Prescription object.
383 The structure of this object is mentioned above. The `prescription` object can
384 be modified directly by the plugins.
386 Please note that an option associated with the plugin is added to the "Plugin"
387 menu if the plugin implements a `run` function. By default the name of the
388 option is the name of the plugin. However, this can be overridden by setting a
389 global variable called `name` with the desired name.
391 Plugins may ask for user confirmation before executing the `run` function by
392 setting a global variable called `confirm` containing the confirmation prompt.
394 Each function mentioned above may return a string which will be displayed to
395 the user by the program.
397 Plugins may get input from the user by implementing one or more of the
400 def input(string text)
401 Get text input from the user.
402 def fileopen(string path)
403 Get file to open. Only called before "run" function.
404 def filesave(string path)
405 Get file to save. Only called before "run" function.
407 Plugin may run in the background by defining a global variable `background`
408 with the value `True`. This may be useful for long running tasks without
409 freezing the program. This is only available for the "run" function. However,
410 plugins running in the background can not modify the prescription object.
412 The plugin may implement one or more functions mentioned above, it is not
413 necessary to implement all.
415 An example plugin, that modifies the name of the patient, may be as follows:
421 def run(prescription):
423 prescription.name=text
424 return("Name change")
430 Plugins may also contain a web app written in HTML/JavaScript. To use it the
431 plugin must contain a function called `web` which takes the prescription object
432 and returns a tuple containing the URL of the web app and a json string
433 containing any data to be passed on to the web app. The `run` function of such
434 a plugin must take two arguments, the prescription and the data returned from
437 The web app itself must include the `qtwebchannel.js` from PyQt6
438 (qrc:///qtwebchannel/qwebchannel.js). The webchannel exposes an object named
439 `js` to the web app. The web app may access the data from the plugin by using
440 the `js.get()` function. The web app may return data to the plugin by calling
441 the `run` function of the exposed `js` object with the return data as the
442 argument. The web app window may be closed by calling the `close` function of
448 Templates are used to render the prescriptions to HTML. A template contains a
449 directory with the name of the template. This directory contains a file called
450 index.html and any other additional files needed.
452 <medscript data directory (e.g. ~/MedScript)>
454 | |-- <template directory e.g. the name of the template>
455 | | |-- index.html (the Jinja2 template)
456 | | |-- <additional files e.g. CSS>
458 The index.html file is the Jinja2 template. The attributes of the Prescription
459 object is available to the template. For example the name of the patient can
460 be accessed by `{{name}}` while the name of the prescriber can be accessed by
461 `{{prescriber.name}}`.
466 Custom input forms can be used to create customized input fields which can be
467 accessed from the "Custom" tab. For this, the custom input form files must be
468 stored in the configured form directory and the form option must be enabled in
471 A custom form file is a JSON file with contains the following:
473 1. **title**: the title of the form.
474 2. **form**: a list containing the inputs. Each input has the following:
475 1. **name**: name of the input field, can be accessed from
477 2. **type**: valid input types are line (single line), text (multiple line),
478 date (date time), check (checkbox).
479 3. **description**: this is shown to the user and should briefly describe
482 An example form is provided below:
485 "title": "Example Form",
490 "description": "Example Input"
498 MedScript has a package installer for convenient installation and
499 uninstallation of presets, templates, custom forms and plugins. It can be
500 accessed from the "Package Installer" option under the "Settings" menu.
502 The installed components are listed there. The installed components can be
503 uninstalled by selecting it and clicking the "Uninstall" button. New packages
504 can be installed by clicking the "Install" button and selecting the package
505 file. MedScript will ask for user's confirmation before installing each
506 component of the package.
511 MedScript installable packages are zip files containing preset, template,
512 form and plugin in respective folders. More than one of each component is
513 allowed in each package. The package structure is as follows:
515 <package as a zip file>
517 | |-- <preset files in CSV format>
519 | |-- <template directories each containing index.html and other files>
521 | |-- <custom input forms in JSON format>
523 | |-- <plugin directories each containing main.py and other files>
525 The following names are not allowed as component names:
542 <https://code.agnibho.com/medscript/>
549 Copyright (C) 2023 Dr. Agnibho Mondal
551 MedScript is free software: you can redistribute it and/or modify it under the
552 terms of the GNU General Public License as published by the Free Software
553 Foundation, either version 3 of the License, or (at your option) any later
556 MedScript is distributed in the hope that it will be useful, but WITHOUT ANY
557 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
558 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
560 You should have received a copy of the GNU General Public License along with
561 MedScript. If not, see <https://www.gnu.org/licenses/>.