Custom filters / Advanced filters
This module provides the ability to define custom filters and their construction. It includes the following classes:
CustomFilterRegistryPoint: This class is responsible for registering filters from a specific module.CustomFilterWizardInterface: This interface defines the implementation details of a custom filtering wizard. It should be called in the apps.py file of the respective module (see example below) to enable filter construction for specific objects.CustomFilterWizardStorage: This class provides a service that connects to the registered filter hub, allowing retrieval of the filter construction definition for specific objects.
To integrate this mechanism into an openIMIS module, follow these steps:
Implement the CustomFilterWizardInterface from the core module to output the filter construction definition for the chosen object.
In the apps.py file of the module, add the following import statement:
from core.custom_filters import CustomFilterRegistryPoint.Invoke such example code somewhere in ready() method in apps.py file:
# register custom filter
from social_protection.custom_filters import BenefitPlanCustomFilterWizard, BeneficiaryCustomFilterWizard
CustomFilterRegistryPoint.register_custom_filters(
module_name=cls.name,
custom_filter_class_list=[BenefitPlanCustomFilterWizard, BeneficiaryCustomFilterWizard]
)
After completing the above steps, the filter will be registered in the filter hub/storage and can be accessed by invoking the wizard hub service. Here's an example using the Django shell:
from core.custom_filters.custom_filter_wizard_storage import CustomFilterWizardStorage
CustomFilterWizardStorage.build_output_how_to_build_filter('social_protection', 'Beneficiary')
Additional Field Definition
Individual model comes with a minimal set of fields: first_name, last_name, dob. To add additional fields, define them in the backend admin interface by adding a Module configuration for individual:
In the web app, visit URL path
/api/admin/core/moduleconfigurationin browserClick on ADD MODULE CONFIGURATION
Fill in the form with the following values:
Module: individual
Layer: backend
Version: 1
Config:
{"individual_schema": "{\"$id\": \"https://example.com/beneficiares.schema.json\", \"type\": \"object\", \"title\": \"Record of beneficiares\", \"$schema\": \"http://json-schema.org/draft-04/schema#\", \"properties\": {\"email\": {\"type\": \"string\", \"description\": \"email address to contact with beneficiary\", \"validationCalculation\": {\"name\": \"EmailValidationStrategy\"}}, \"able_bodied\": {\"type\": \"boolean\", \"description\": \"Flag determining whether someone is able bodied or not\"}, \"national_id\": {\"type\": \"string\", \"description\": \"national id\"}, \"educated_level\": {\"type\": \"string\", \"description\": \"The level of person when it comes to the school/education/studies\"}, \"chronic_illness\": {\"type\": \"boolean\", \"description\": \"Flag determining whether someone has such kind of illness or not\"}, \"national_id_type\": {\"type\": \"string\", \"description\": \"A type of national id\"}, \"number_of_elderly\": {\"type\": \"integer\", \"description\": \"Number of elderly\"}, \"number_of_children\": {\"type\": \"integer\", \"description\": \"Number of children\"}, \"beneficiary_data_source\": {\"type\": \"string\", \"description\": \"The source from where such beneficiary comes\"}}, \"description\": \"This document records the details beneficiares\"}"}Modify theConfigvalue accordingly with your individual additional field definitions.
Click on SAVE
Did you encounter a problem or do you have a suggestion?
Please contact our Service Desk
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/