Metadata-Version: 2.1
Name: django-npi-field
Version: 0.1.2
Summary: Creates a Django field for U.S. National Provider Identifier numbers
License: MIT
Keywords: django
Author: Kyle Jensen
Author-email: kyle@nullandvoid.digital
Requires-Python: >=3.12,<4.0
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Dist: django (>=5.0.6,<6.0.0)
Description-Content-Type: text/x-rst

================
django-npi-field
================

Description
===========
A Django library which validates and stores 10-digit U.S. `National Provider Identifier (NPI)`_ numbers.

.. _`National Provider Identifier (NPI)`: \
   https://www.cms.gov/Regulations-and-Guidance/Administrative-Simplification/NationalProvIdentStand

Installation
============
From PyPI
---------
Using pip:

.. code-block:: zsh

   pip install django-npi-field

Using poetry:

.. code-block:: zsh

   poetry add django-npi-field

From GitHub
-----------
Using poetry:

.. code-block:: zsh

   poetry add git+https://github.com/PhoenixStorm1015/django-npi-field.git

Usage
=====
Add the app to ``INSTALLED_APPS`` in your ``settings.py`` file.

.. code-block:: python

   INSTALLED_APPS = [
       # Other apps...
       "npi_field",
   ]

Add the field to your ``models.py``.

.. code-block:: python

   from django.db import models
   from npi_field.modelfields import NPIField

   class HealthcareProvider(models.Model):
       npi = NPIField()

If you prefer, you can also call the validator directly and bypass the model field. If you want the length restriction,
make sure to also set the ``max_length`` argument.

.. code-block:: python

   from django.db import models
   from npi_field.validators import npi_validator

   class HealthcareProvider(models.Model):
       npi = models.CharField(max_length=10, validators = [npi_validator])

Implementation
==============
The NPI number is validated by a Luhn algorithm [1]_ implementation and stored in a standard CharField. This
CharField is automatically restricted to a ``max_length`` of 10 characters to maintain consistency with the NPI
specification.

Currently, this validation is the only thing restricting the input. In the future, this library will have special
integration with PostgreSQL's Custom Domains to do validation in-database, though the plan is for checks to keep the
library database agnostic.

.. [1] **NOTE:** This is a Luhn algorithm specially implemented for NPI numbers due to it's shorter length. This \
       validator **WILL NOT WORK** for other numbers validated by a Luhn algorithm, such as credit/debit card \
       numbers, ISBN numbers, or IMEI numbers.
