# ispy2_mri

[![PyPI - Version](https://img.shields.io/pypi/v/ispy2-mri.svg)](https://pypi.org/project/ispy2-mri)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ispy2-mri.svg)](https://pypi.org/project/ispy2-mri)
[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)

-----

**Table of Contents**

- [ispy2\_mri](#ispy2_mri)
  - [Purpose](#purpose)
  - [Installation](#installation)
    - [Prerequisites](#prerequisites)
    - [Program Setup](#program-setup)
  - [License](#license)
  - [Developer Notes](#developer-notes)

## Purpose
If you are not in UCSF Radiology, it is very unlikely this package is of interest.

This package provide a graphical application to enter information about batches of MRI's as they come in from sites.  The information is saved in the ispy2 database, named `breastdb` on the server.  Some of that information is available electronically, and can be pulled from a plain text file of the user's choice instead of entered manually.

This is a replacement for *one* of the functions currently accessible through a web interface.  That web application can still be used for other things, like generating reports, or even for entering the same information.  However, the web application does not use the information in the plain text files.

## Installation

### Prerequisites
   * Only tested on MS-Windows, might work elsewhere if ODBC does
   * Python 3.10 or greater installed.  To test, start a terminal (hit the Windows button, type "command prompt", and select that application), and enter `py --version` in the terminal.
   * 64-bit ODBC installed with a recent MS SQL Server driver, e.g., 18.
   * An ODBC data source ("DSN") named `breastdb-new` pointing to the breastdb database.
   * You have permission to write to that database.
   * The machine you are using can contact the database (may require firewall changes)
   * You have access to the directory in which the text files summarizing key scan info are available.

### Program Setup
The main issue is exactly how you get access to the Python Package that uses the program.

```console
py -m pip install ispy2_mri  # MS-Windows
```

This will create a program that can be launched from a terminal with `ispy2-mri`.  You may want to create a desktop shortcut that will do the same thing.

## License

`ispy2-mri` is distributed under the terms of the [GPL-3](https://www.gnu.org/licenses/gpl-3.0.en.html) license.


## Developer Notes
The application that ships is under `src`, but it is generated by the scripts under `build`.  Make any changes to the code in `build`, and then run `pre_fields.py` to regenerate `src/ispy2_mri/ispy2_gui.py`.  The `pre` is for pre-processor: the code turns the "specification" in tomcat web application's original `ispy2.jsp` (which came from the `insert` directory of the `bdb` project) into a Python-based Qt application.

There is probably a way to automate that into the regular build process, which uses `hatch`.  But its documentation doesn't spell out how.

See [Notes.md](Notes.md) for the main developer notes, as well as comments in the code and the version control history.  In time, the issues for the project might have something as well.

I do not recommend studying the code in `ispy2_gui.py` directly as it has a lot of repetitive, automatically generated code.  And it does not have a lot of the notes and To Do list in the comments for `pre_fields.py`.
