The various modules/plugins of openIMIS are delivered as interchangeable applications of a global Django project.
The modules/plugins expose a REST API, using the django-rest-framework.org and one of its plugin: the dynamic-rest extension.
Combined together, these frameworks/libraries allow decoupled/modularised implementation of a search.
From the model:
Mapped on the following database scheme:
The django model for Claim is:
declaration_date = models.DateField()
insuree = models.ForeignKey(Insuree, on_delete=models.CASCADE)
... there is an explicite ForeignKey to Insuree (but the Claim class makes no assumption on the actual content of Insuree)
The django serializer for Claim is:
insuree = DynamicRelationField(InsureeSerializer, embed=True)
model = Claim
fields = ExtendableModelSerializer.Meta.fields + ('declaration_date','insuree',)
... here again, the DynamicRelationField points to whatever implementation of Insuree serializer is provided by the Insuree plugin.
Finally the django view for the ClaimList is:
queryset = Claim.objects.all()
serializer_class = ClaimSerializer
By extending DynamicModelViewSet out of dynamic-rest extension of django REST framework, the exposed claims API can (dynamically) filter on insuree name
... while the claims django plugin has no direct reference to the "name" attribute of the insuree class: