Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

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.


Example

From the model:

Mapped on the following database scheme:


The django model for Claim is:

claims/models.py
class Claim(ExtendableModel):
  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:
claims/serialiers.py
class ClaimSerializer(DynamicModelSerializer):
  insuree = DynamicRelationField(InsureeSerializer, embed=True)
  class Meta:
    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:
class Claims(DynamicModelViewSet):
   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:
  • No labels