MedScript is a medical prescription writing software. It is primarily for medical practitioners for writing prescriptions.
The purpose of the program is to enable medical practitioners to prepare computerized prescriptions. The program has been designed after the commonly used prescription format among the medical practitioners in India. Inclusion of prescription style of other regions will hopefully be implemented in future updates.
Please note that this is a beta version and is meant for testing. Bugs are to be expected. If you find them, report them to the developer.
Mandatory warning: always back up your data. A single copy of data is as good as none.
MedScript can be enhanced by isntalling additional packages such as the Basic Enhancement Package.
The program uses a custom file format .mpaz (Medical Prescription Archive - Zipped). It is a zip file in a specific format which includes:
Optionally the mpaz archive may also include an S/MIME signature and certificate for authentication.
The structure of the mpaz file is as follows:
<filename>.mpaz (zipped file) |-- meta.json (e.g. {"type": "MedScript", "version": "<mpaz version>"}) |-- prescription.json (Prescription object in JSON format) |-- template (included template for rendering) | |-- index.html (Jinja2 template) | |-- <other template files e.g. CSS> |-- attachment (directory containing attachments) | |-- <attached files> |-- signature (optional: S/MIME signature) |-- certificate.pem (optional: full certificate chain including end-user, intermediates and root certificate)
MedScript uses a directory structure to store user files. It is highly configurable. An example directory structure is given below:
<medscript data directory> (configurable) |-- document (for storing prescription files) | |-- <document files> |-- plugin (for installing plugins) | |-- <installed plugins> |-- prescriber (for storing prescriber information) | |-- <prescriber files in JSON format> |-- preset (for storing preset files) | |-- additional.csv | |-- advice.csv | |-- certificate.csv | |-- investigation.csv | |-- medication.csv | |-- note.csv | |-- report.csv |-- template | |-- <installed templates> |-- config.json (the configuration file)
MedScript can be used by simply downloading it from the repository and running it with the Python 3 interpreter. The necessary python libraries need to be installed. Alternatively the release versions can be downloaded and used directly.
The git repo can also be cloned by running git clone https://code.agnibho.com/repo/medscript.git
.
If you use flatpak, you can install MedScript by running the following commands:
> flatpak remote-add --user --if-not-exists MedScript https://code.agnibho.com/medscript/download/MedScript.flatpakrepo
> flatpak install com.agnibho.MedScript
If you are on Windows, you can download the Windows installation file of MedScript from the sidebar.
By default Medscript creates a MedScript folder in the user's home directory and uses it to save the necessary files.
The functionality of MedScript can be enhanced by installing extra packages. Packages are zip files containing one or more presets, templates, forms or plugins. The details of package development is mentioned later.
A basic enhancement package is available for download. It is recommended to install this package to further improve the user experience with MedScript.
For installation download the file from the above link. Then open MedScript and go to "Setting"→"Package Installer" to open the installer window. Now click on the "Install" button at the bottom and select the downloaded file. MedScript will ask for confirmation before installing each component. Restart MedScript after installation is complete.
The common functionalities of the program can be used within the graphical interface. Editing of some configuration files are needed only for the advanced features such as custom presets.
When starting the program, the main window of is shown.The menu bar at the top can be used to access most of the functions. The toolbar below it contains the most commonly used functions for quick access.
A new prescription can be created right from the starting window. Alternatively the "New" menu option can be used to create a new prescription.
There are eight tabs in the tab bar containing important parts of a prescription.
The prescription can be quickly viewed by using the "Quick Display" option under the "Process" menu. Viewing the prescriptions this way only shows the prescription data without considering the formatting. To display the prescription in a printable format, use the rendering option instead.
The "Save" or the "Save As" option from the "File" menu can be used to save a file created or edited in the program.
The prescriptions are saved in .mpaz files and can be shared easily. To open a prescription file, the "Open" option from the file menu can be used. Alternatively the file name can be supplied to the program as command line argument when starting from the command line.
The prescriptions can be rendered and subsequently printed from the "Process" menu by selecting the "Render" option. Note that the files must be saved before rendering. The rendered prescription is opened in a separate window. It can be saved as PDF or it can be opened in the system browser and printed from there.
The prescription files in the default document folder are incorporated into an index which can be used to quickly find a particular prescription. To use this feature, select the "Show Index" option in the "File" menu. Any changes to the directory including creation, modification or deletion of files is monitored by the index and reflected accordingly.
The index can be filtered by using patient id, prescription id or patient's name. The entries can be viewed directly, opened in the program for editing/rendering or copied into a new prescription. This can be useful while consulting follow up patients.
The program uses jinja2 template for rendering the prescription. A default template is provided with the program. However, other templates (see default template for reference) can be created and placed in the template folder to be used for rendering the prescriptions. The drop down option in the toolbar can be used to switch between available templates.
Note that the templates are packaged with the .mpaz file which can be used for rendering. However, modifying/saving the file overwrites it.
It is easy to develop templates for the program. How to develop templates is mentioned below.
This program supports markdown formatting. Markdown can be used to format the prescriptions and certificates. It can be turned on from the configuration dialog under the settings menu.
The "Certificate" tab can be used to write a medical prescription. Preset system is available for this as well. Certification requires different templates designed for it. A template named medcert is included with the program.
The program is primarily targeted towards individual practitioners. However, it can be easily adapted for multiple practitioners.
The "Current Prescriber" option under the "Settings" menu can be used to view/edit the current prescriber. The "Select Prescriber" option can be used to open the prescriber selector dialog. All the prescribers are listed here. A prescriber can be selected from here. Prescribers can also be edited, deleted or new prescribers can be created from this dialog.
The data of the practitioner is stored in json files in the prescriber directory. The default file to be loaded is configured in the config file. A command line option can be used to specify which alternative prescriber file to load in the program, e.g. <program> --prescriber <prescriber file>
.
The program uses a preset system to insert repeatedly used text without the need to type them. To use this feature the text must be entered beforehand to the respective files. These files are in the .csv format and can be edited with any spreadsheet editing software.
There is a preset editor included with this software as well. This editor can be accessed by going to the "Settings" menu and selecting the "Preset" option.
The preset editor contains a drop down input at the top which can be used to select the respective file to edit. There is also a "Save" button at the top which can be used to save the changes to the selected file.
The data is presented in an editable table which can be used to edit the data in the selected file. While editing, the KEY/VALUE format is to be used as shown in the top row. The "Add Row" button at the bottom can be used to add a new row for entry of new data.
The preset files are kept in the preset directory. The files associated with clinical note, report, advice, investigation, medication and additional are note.csv, report.csv, advice.csv, investigation.csv, medication.csv and additional.csv. Each file contains a top row indicating the variables in the columns. The data is entered in two columns with each row containing a KEY and a TEXT. The TEXT can be entered in to the edit area by selecting the KEY from the preset input. Blank files with only the top row are included with the program.
A sample set of preset files can be downloaded from here. To use them, unzip the downloaded file and place the included files into the preset folder of MedScript by replacing/merging the csv files already present there. These are for example only. The users are expected to create their own preset files as per their requirements.
The default configuration file contains sane defaults and the program can be used without editing it. However, the json formatted configuration file can be edited to further tune the program to the users preference.
The default configuration is the config.json located in the config directory. However, a different config file may be provided by using the <program> --config <config file>
command line argument.
It is recommended to use the default config file as base while creating another customized config file.
A graphical configuration editor is also included with the program. The options are as follows:
The program uses a Prescription object to store the prescription data. The structure of the Prescription object is as follows:
prescription (Prescription object) |-- date (string: date-time in the %Y-%m-%d %H:%M:%S format) |-- id (string: the id of the prescription) |-- name (string: the name of the patient) |-- dob (string: the date of birth) |-- age (string: the age of the patient, may contain unit) |-- sex (string: sex of the patient) |-- address (string: address of the patient) |-- contact (string: contact number / email of the patient) |-- extra (string: extra data related to the prescription, may also be used for writing certificates) |-- mode (string: the mode of consultation e.g. tele-consultation) |-- daw (boolean: dispense as written) |-- diagnosis (string: diagnosis of the patient's condition) |-- note (string: clinical note e.g. history, physical examination) |-- report (string: available reports) |-- advice (string: advice given to the patient, not the medications) |-- investigation (string: investigations suggested for the patient) |-- medication (string: the list of medications prescribed) |-- additional (string: any additional advice/instructions) |-- certificate (string: content of a medical certificate) |-- custom (list: contents of custom input forms) |-- properties (object: unused, included for future/plugin use) |-- prescriber (Prescriber object) | |-- name (string: the name of the prescriber) | |-- qualification (string: the qualification of the prescriber) | |-- registration (string: the registration number of the prescriber) | |-- address (string: the address of the prescriber) | |-- contact (string: contact number / email of the prescriber) | |-- extra (string: any extra data about the prescriber)
MedScript has a plugin system which can be used to incorporate customized plugins written in python. To use the plugins, the plugins must be saved in the configured plugin directory and plugin must be enabled in the configuration.
Enabling arbitrary plugin is dangerous and may cause catastrophic damage. Only install plugins from trusted sources and review the code.
Developing MedScript plugin is very simple. All you need is to create a python file and implement a few functions.
The plugin is kept in its own directory. The name of the directory is the name of the plugin. A plugin directory must contain a file called main.py which contains the functions needed by MedScript plugin system. The directory tree is as follows:
<medscript data directory (e.g. ~/MedScript)> |-- plugin | |-- <plugin directory (e.g. the name of the plugin)> | | |-- main.py | | |-- <other files needed by the plugin>
The main.py file may implement the following functions which will be called by the program as needed:
The prescription
parameter passed to the functions is a Prescription object. The structure of this object is mentioned above. The prescription
object can be modified directly by the plugins.
Please note that an option associated with the plugin is added to the "Plugin" menu if the plugin implements a run
function. By default the name of the option is the name of the plugin. However, this can be overridden by setting a global variable called name
with the desired name.
Each function mentioned above may return a string which will be displayed to the user by the program.
Plugins may get input from the user by implementing one or more of the following functions:
Plugin may run in the background by defining a global variable background
with the value True
. This may be useful for long running tasks without freezing the program. This is only available for the "run" function. However, plugins running in the background can not modify the prescription object.
The plugin may implement one or more functions mentioned above, it is not necessary to implement all.
An example plugin, that modifies the name of the patient, may be as follows:
name="Change Name"
background=False
text=""
def run(prescription):
global text
prescription.name=text
return("Name change")
def input(data):
global text
text=data.strip()
Plugins may also contain a web app written in HTML/JavaScript. To use it the plugin must contain a function called `web` which takes the prescription object and returns the URL of the web app. The run function of such a plugin must take two arguments, the prescription and the data returned from the web app.
The web app itself must include the qtwebchannel.js from PyQt6. The webchannel exposes an object named `js` to the web app. The web app may return data by calling the `run` function of the exposed `js` object.
Templates are used to render the prescriptions to HTML. A template contains a directory with the name of the template. This directory contains a file called index.html and any other additional files needed.
<medscript data directory (e.g. ~/MedScript)> |-- template | |-- <template directory e.g. the name of the template> | | |-- index.html (the Jinja2 template) | | |-- <additional files e.g. CSS>
The index.html file is the Jinja2 template. The attributes of the Prescription object is available to the template. For example the name of the patient can be accessed by {{name}}
while the name of the prescriber can be accessed by {{prescriber.name}}
.
Custom input forms can be used to create customized input fields which can be accessed from the "Custom" tab. For this, the custom input form files must be stored in the configured form directory and the form option must be enabled in the configuration.
A custom form file is a JSON file with contains the following:
An example form is provided below:
{ "title": "Example Form", "form": [ { "name": "example", "type": "line", "description": "Example Input" } ] }
MedScript has a package installer for convenient installation and uninstallation of presets, templates, custom forms and plugins. It can be accessed from the "Package Installer" option under the "Settings" menu.
The installed components are listed there. The installed components can be uninstalled by selecting it and clicking the "Uninstall" button. New packages can be installed by clicking the "Install" button and selecting the package file. MedScript will ask for user's confirmation before installing each component of the package.
MedScript installable packages are zip files containing preset, template, form and plugin in respective folders. More than one of each component is allowed in each package. The package structure is as follows:
<package as a zip file> |-- preset | |-- <preset files in CSV format> |-- template | |-- <template directories each containing index.html and other files> |-- form | |-- <custom input forms in JSON format> |-- plugin | |-- <plugin directories each containing main.py and other files>
The following names are not allowed as component names:
MedScript
Copyright © 2023 Dr. Agnibho Mondal
MedScript is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
MedScript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with MedScript. If not, see <https://www.gnu.org/licenses/>.
Dr. Agnibho Mondal
mondal@agnibho.com
www.agnibho.com
Copyright © 2023-2024 Dr. Agnibho Mondal
All rights reserved
MedScript is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Agnibho Mondal
mondal@agnibho.com
www.agnibho.com
Softwares of Agnibho
Copyright © 2013-2024 Dr. Agnibho Mondal
www.agnibho.com