A Django application which assist on integration of your web application with NHIF System with easy step.
- Python 3.6+
- Pip or Pipenv
- Generate Access Token to initiate call
- Enable easy generation of access token for any nhif service claim
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
- username = 'integrationuser'
- password = 'nhif@2018'
- 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)
{"$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
If you found this repository useful, give it a star so as the whole community of Tanzania developers can get to know it.
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).
If you have something to add I welcome pull requests on improvement , you're helpful contribution will be merged as soon as possible