Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:Image Removed

...

Mapped on the following database scheme:Image Removed

...


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

classClaimSerializer(DynamicModelSerializer):

  insuree = DynamicRelationField(InsureeSerializer, embed=True)

  classMeta:

    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:

classClaims(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:

...