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.

...

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

...