API developed as challenge for a backend job position at iClinic.
- Python
- Django with Django REST Framework
- Docker
- PostgreSQL
- Redis
SECRET_KEY=******
DJANGO_SETTINGS_MODULE=iclinic.settings
APP_PORT=8000
DB_NAME=postgres
DB_USER=postgres
DB_PASSWD=******
DB_HOST=db
DB_PORT=5432
REDIS_LOCATION=redis://redis_dev:6379/1
PHYSICIANS_API_URL=https://5f71da6964a3720016e60ff8.mockapi.io/v1
PHYSICIANS_API_PATH=/physicians/{id}
PHYSICIANS_API_TOKEN=******
PHYSICIANS_API_TIMEOUT=4
PHYSICIANS_API_RETRY=2
PHYSICIANS_API_CACHE_TTL_HOURS=48
CLINICS_API_URL=https://5f71da6964a3720016e60ff8.mockapi.io/v1
CLINICS_API_PATH=/clinics/{id}
CLINICS_API_TOKEN=******
CLINICS_API_TIMEOUT=5
CLINICS_API_RETRY=3
CLINICS_API_CACHE_TTL_HOURS=72
PATIENTS_API_URL=https://5f71da6964a3720016e60ff8.mockapi.io/v1
PATIENTS_API_PATH=/patients/{id}
PATIENTS_API_TOKEN=******
PATIENTS_API_TIMEOUT=3
PATIENTS_API_RETRY=2
PATIENTS_API_CACHE_TTL_HOURS=12
METRICS_API_URL=https://5f71da6964a3720016e60ff8.mockapi.io/v1
METRICS_API_PATH=/metrics
METRICS_API_TOKEN=******
METRICS_API_TIMEOUT=6
METRICS_API_RETRY=5
$ git clone https://github.com/flribeiro/iclinic_prescriptions_api
- To have the
.env
file (sent by e-mail) present at the project's root directory; - To have
docker
anddocker-compose
installed.
$ make build
The endpoint to post prescriptions will be available at
http://localhost:8000/prescriptions/
# unit tests
$ make test
After run the tests, coverage report will be available at htmlcov/index.html
(open in browser).
curl --location --request POST 'http://localhost:8000/prescriptions/' \
--header 'Content-Type: application/json' \
--data-raw '{
"clinic": {
"id": 1
},
"physician": {
"id": 1
},
"patient": {
"id": 1
},
"text": "Medication"
}'
Output body sample:
{
"data": {
"id": 1,
"clinic": {
"id": 1
},
"physician": {
"id": 1
},
"patient": {
"id": 1
},
"text": "Dipirona 1x ao dia"
}
}