A Django application which assist on integration of your web application with NHIF System with easy step
Project description
django-nhif
A Django application which assist on integration of your web application with NHIF System with easy step.
Prerequisites
- Python 3.6+
- Pip or Pipenv
It will Cover
- Generate Access Token to initiate call
- Enable easy generation of access token for any nhif service claim
Installation
This package is available in Python Package Index and can be installed using pip
or pipenv
- Run
pip install django-nhif
- Add
nhif
toINSTALLED_APPS
Usage
Contact with NHIF office near your to get username and password, for testing use bellow credentials
- username = 'integrationuser'
- password = 'nhif@2018'
Open "settings.py" on your project, set the following variables
- USERNAME = "your username"
- PASSWORD = "your api password"
After setting above,Then on your views.py file, This show an example on how to generate access token and verify patient before offer any service.
import json
import requests
from django.shortcuts import render
from django.http import JsonResponse
from django.conf import settings
from nhif.token import generateToken
def client_verification(request):
username = settings.USERNAME
password = settings.PASSWORD
#Specify the url for token generation according to requested service
address = 'http://196.13.105.15/nhifservice/Token'
results = generateToken(username, password, address)
access_token = results['access_token']
# Client Verification Start
url = 'http://196.13.105.15/nhifservice/breeze/verification/AuthorizeCard'
# Define your parameters
card_no = '01-nhif241'
visit_type_id = '1'
referral_no = ''
remarks = ''
payload = {
'CardNo': card_no,
'VisitTypeID': visit_type_id,
'ReferralNo': referral_no,
'Remarks': remarks,
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {}'.format(access_token)
}
output = requests.get(url=url, params=payload, headers=headers)
output = json.loads(output.text)
print(output)
return JsonResponse(data=output, safe=False)
sample response
{"$id": "1", "$type": "Dapper.SqlMapper+DapperRow, Dapper", "AuthorizationID": "0aaf0dcd-eb40-4df5-8ed0-56bb62cdbf37", "CardNo": "01-nhif241", "MembershipNo": "900035308", "EmployerNo": null, "EmployerName": null, "HasSupplementary": "No", "SchemeID": 1001, "SchemeName": "Standard NHIF Benefit Scheme", "CardExistence": "EXISTING", "CardStatusID": 4, "CardStatus": "Inactive", "IsValidCard": false, "IsActive": false, "StatusDescription": "Revoked", "FirstName": "Amour", "MiddleName": "R", "LastName": "Hamad", "FullName": "Amour R Hamad", "Gender": "Male", "PFNumber": "NHIF241", "DateOfBirth": "1974-03-18", "YearOfBirth": 1974, "Age": "47", "ExpiryDate": null, "CHNationalID": null, "LatestContribution": "Not Available", "AuthorizationStatus": "REJECTED", "AuthorizationNo": null, "LatestAuthorization": "UPANGA EYE SPECIALIZED CLINIC on July 26,2021", "Remarks": "The card is In Active,If the beneficiary thinks this is is a mistake he should visit the nearby NHIF office for verification", "FacilityCode": "06697", "ProductName": "STANDARD", "ProductCode": "NH011", "CreatedBy": "integrationuser", "AuthorizationDate": "2021-07-31T18:33:32.050", "DateCreated": "2021-07-31T18:33:32.050", "LastModifiedBy": "integrationuser", "LastModified": "2021-07-31T18:33:32.050", "AuthorizationDateSerial": 20210731}
For full example on how to integrate please visit the github repo on example folder you will find all source codes here
Give it a star
If you found this repository useful, give it a star so as the whole community of Tanzania developers can get to know it.
Bug bounty?
If you encounter issue with the usage of the package, feel free raise an issue so as we can fix it as soon as possible(ASAP).
Pull Requests
If you have something to add I welcome pull requests on improvement , you're helpful contribution will be merged as soon as possible
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-nhif-0.0.1.tar.gz
.
File metadata
- Download URL: django-nhif-0.0.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2a3d6cd1dd4f6c8bec7c7d14db443324077ba0c5413670c2d69266831d05475 |
|
MD5 | af46b136f8836b5b7b6ffeaac5c11cd2 |
|
BLAKE2b-256 | fbff1f59efddcd95adf15e30e91d411abd4e2730dfadd012208ccbfddead28f8 |
File details
Details for the file django_nhif-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: django_nhif-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60631f15ea244aaca854297044a4dae9150f61f2639b192fe12df7f1bbf32bd5 |
|
MD5 | 174302b299977912ca48cd555e50d481 |
|
BLAKE2b-256 | 8afe41930f2427504b64efcb9fc3a856faac6f40d61770d54d1646c8c1f1eddc |