Library designed for interacting with the CIMA API (AEMPS)
Project description
AEMPSconn
Library designed for interacting with the CIMA REST API (AEMPS).
More information related to the official REST API can be found here.
Note: AEMPSconn is developed to make use of it with CIMA REST API v1.23.
Installation
Use the package manager pip to install foobar.
pip install aempsconn
Custom Logger
The use of the logger
in the library is not mandatory.
A custom logger has been created in order to offer the possibility to use it in an integrated way with the library and it allows you to set the logging level.
However, as the logger
argument requires a Logger type, it is fully customizable so that the programmer can set it according to his own preferences.
To not use any logger, simply leave it blank.
Building queries
It has developed a easy-use query builder for the most important endpoints: /medicamento
& /medicamentos
.
Each endpoint has its own custom filters so you can find and add them to the request by:
import aempsonn
aemps = aempsconn.Orchestrate(logger=aempsconn.CustomLogger(level=50))
filter_med = aemps.filter_medicamento.<FILTER_CONDITION_MED>.equals(value="")
filter_meds = aemps.filter_medicamento.<FILTER_CONDITION__MEDS>.equals(value="")
This query builder supports as many conditions/filters as you want.
Taking into account that the first endpoint will only make use of the last one indicated, since it only admits a single condition.
Usage
import aempsconn
# Initialize all the modules with the same configuration.
aemps = aempsconn.Orchestrate(logger=aempsconn.CustomLogger(level=50))
# Create a filter needed for the wanted request.
# This filter is custom for "/medicamento" endpoint.
filter1 = aemps.filter_medicamento.num_registro.equals("59494")
# Download the med that satisfies the previous custom filter.
med = aemps.medicamento.get(filter=filter1)
# If med is not null prints the name.
if med is not None:
print(med.nombre)
# Create a new filter needed for the wanted request.
# This filter is custom for "/medicamentos" endpoint.
filter2 = (
aemps.filter_medicamentos.nombre.equals("paraceta*")
.comercializado.equals(True)
.laboratorio.equals("cinfa")
.receta.equals(True)
)
# Download all the meds that satisfy the previous custom filter.
meds = aemps.medicamentos.get(filter=filter2)
# If meds are not null iterates and prints the names.
if meds is not None:
for med in meds:
print(med.nombre)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Disclaimer
The use of Spanish words or descriptions is intended to facilitate consistency between the official CIMA API and this library, so that the programmer does not hesitate with the name of each of the filters or data received.
This library is not official.
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
Hashes for aempsconn-0.1.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7773b8f5c50a80816a462bd30f54d4cd5f5f86a671cb9b292f7d0bcb26b6b935 |
|
MD5 | 60cb74827ab6333e4cc7969e297776d9 |
|
BLAKE2b-256 | e82ae50164ab1ea7ff2c8b2e61c9eac6c8e9c2892403d155575e72a3c1168736 |