 [comment]: <>  ( __version__ = '0.4.9'  )
 
# *pharmacy*
[![Package Status](https://img.shields.io/pypi/status/pharmacy.svg)](https://pypi.org/project/pharmacy/)
[![PyPI Latest Release](https://img.shields.io/pypi/v/pharmacy.svg)](https://pypi.org/project/pharmacy/)
[![License](https://img.shields.io/pypi/l/pharmacy.svg)](https://github.com/PyPharm/pypharm/LICENSE/blob/main/LICENSE)
[![Downloads](https://static.pepy.tech/badge/pharmacy/month)](https://pepy.tech/project/pharmacy)

A hospital and retail pharmacy-focused Python package by Danny Limoges, PharmD. 

## <span style="color:red">*This project is in the alpha/planning stage.*</span>

## Installation
Available on PyPI as an installable package:  https://pypi.org/project/pharmacy/
```
  pip install pharmacy
```
## What is it?
This is a collection of modular utilities that aid in processing pharmacy data.  Users must perform their
own data validation to ensure that results generated by pharmacy are accurate 
and that the correct data was inputted.

## What is it *not*?
*pharmacy* is not a pharmacy management system and does not replace Epic, Meditech, Pioneer or any other pharmacy software.
 
# Syntax
 
## find_best_matches
 Get a **fuzzy match** between two DataFrames and combine them where matched.
 
**Output:** pandas DataFrame.  All rows from df_orig are kept and their corresponding matches are tacked onto the end if they  meet the match threshold.
 
```python
import pharmacy as rx
import pandas as pd

df_out = rx.find_best_matches(
                  df_orig       # Original pandas DataFrame 
                  , df2         # DataFrame to match against
                  , match_col   # Which column to examine in original DataFrame
                  , match_col_comparator = None   # The column name to compare
                  , threshold=80    # Only accept matches above this fuzzy match threshold.
                  , scorer=fuzz.token_set_ratio # Which type of fuzzy match? 
                                                # options: ratio, partial_ratio, token_sort_ratio, token_set_ratio
                  )
```
For more information on fuzzy match types, check out this article:
 
[Understanding Fuzzy String Matching: Exploring Fuzz Ratio, Fuzz Partial Ratio, Token Set Ratio, and Token Sort Ratio: Machine Learning Concept 78, by 
Chandra Prakash Bathula](https://medium.com/@chandu.bathula16/understanding-fuzzy-string-matching-exploring-fuzz-ratio-fuzz-partial-ratio-token-set-ratio-and-d6892430f53c)

### Example
```python
>>> import pandas as pd
>>> import pharmacy as rx
>>> df = pd.DataFrame(
...     [('10000-1000-10','Acetaminophen 325mg',),
...     ('20000-2000-30','Lisinopril 10mg','7'),
...     ('30000-3000-30','Tylenol #3','c5'),
...      ], columns = ['ndc','description','schedule'])
```


## Potential Future Goals
Tools to work on data from...
- Drug data
  - Use fuzzy and exact-matching to align different drug data files. 
  - Pricing
  - Generic Equivalents
  - Usage
  - Shortages and availability
- Patient profiles
  - Demographics
  - Geolocation
- Prescription data
  - Fills
  - Claims
    - Loss analysis
    - Opportunity analysis
- **Modeling**
  - Integrate pharmacy data with TensorFlow
  - Generate large-scale insights
  - Predict the outcomes of new clinical services based on current data
- **Integration**
  - Incorporate data from ordering sites, etc.

  

[comment]: https://fontawesome.com/icons/hospital?s=thin

