openimis/openimis-be-api_fhir_py

View on GitHub

Showing 49 of 117 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

class HFViewSet(BaseFHIRView, viewsets.ModelViewSet):
    lookup_field = 'uuid'
    serializer_class = LocationSerializer
    permission_classes = (FHIRApiHFPermissions,)

Severity: Major
Found in api_fhir/views.py and 1 other location - About 1 day to fix
api_fhir/views.py on lines 116..134

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 141.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

class PractitionerViewSet(BaseFHIRView, viewsets.ModelViewSet):
    lookup_field = 'uuid'
    serializer_class = PractitionerSerializer
    permission_classes = (FHIRApiPractitionerPermissions,)

Severity: Major
Found in api_fhir/views.py and 1 other location - About 1 day to fix
api_fhir/views.py on lines 77..95

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 141.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function build_fhir_extentions has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    def build_fhir_extentions(cls, fhir_patient, imis_insuree):
        fhir_patient.extension = []

        def build_extension(fhir_patient, imis_insuree,value):
            extension = Extension()
Severity: Minor
Found in api_fhir/converters/patientConverter.py - About 5 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

ClaimConverter has 40 functions (exceeds 20 allowed). Consider refactoring.
Open

class ClaimConverter(BaseFHIRConverter, ReferenceConverterMixin):

    @classmethod
    def to_fhir_obj(cls, imis_claim):
        fhir_claim = FHIRClaim()
Severity: Minor
Found in api_fhir/converters/claimConverter.py - About 5 hrs to fix

    File claimConverter.py has 326 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from claim import ClaimItemSubmit, ClaimServiceSubmit
    from claim.models import Claim, ClaimItem, ClaimService
    from medical.models import Diagnosis
    from django.utils.translation import gettext
    
    
    Severity: Minor
    Found in api_fhir/converters/claimConverter.py - About 3 hrs to fix

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      class CoverageRequestQuerySet(BaseFHIRView, mixins.RetrieveModelMixin, mixins.ListModelMixin, GenericViewSet):
          lookup_field = 'uuid'
          serializer_class = CoverageSerializer
          permission_classes = (FHIRApiCoverageRequestPermissions,)
      
      
      Severity: Major
      Found in api_fhir/views.py and 2 other locations - About 3 hrs to fix
      api_fhir/views.py on lines 152..161
      api_fhir/views.py on lines 165..174

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 69.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      class ClaimResponseViewSet(BaseFHIRView, mixins.RetrieveModelMixin, mixins.ListModelMixin, GenericViewSet):
          lookup_field = 'uuid'
          serializer_class = ClaimResponseSerializer
          permission_classes = (FHIRApiClaimPermissions,)
      
      
      Severity: Major
      Found in api_fhir/views.py and 2 other locations - About 3 hrs to fix
      api_fhir/views.py on lines 165..174
      api_fhir/views.py on lines 191..200

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 69.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

      class CommunicationRequestViewSet(BaseFHIRView, mixins.RetrieveModelMixin, mixins.ListModelMixin, GenericViewSet):
          lookup_field = 'uuid'
          serializer_class = CommunicationRequestSerializer
          permission_classes = (FHIRApiCommunicationRequestPermissions,)
      
      
      Severity: Major
      Found in api_fhir/views.py and 2 other locations - About 3 hrs to fix
      api_fhir/views.py on lines 152..161
      api_fhir/views.py on lines 191..200

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 69.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function toDict has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def toDict(self):
              retval = dict()
      
              if isinstance(self, Resource):
                  retval['resourceType'] = self.__class__.__name__
      Severity: Minor
      Found in api_fhir/models/__init__.py - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      File __init__.py has 300 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import sys
      
      
      class BaseConfiguration(object):  # pragma: no cover
      
      
      Severity: Minor
      Found in api_fhir/configurations/__init__.py - About 3 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        if hasattr(imis_insuree, "profession") and imis_insuree.profession is not None:
                            if imis_insuree.profession.profession is not None:
                                extension.valueString = imis_insuree.profession.profession
                            else :
                                extension.valueString = ""
        Severity: Major
        Found in api_fhir/converters/patientConverter.py and 1 other location - About 3 hrs to fix
        api_fhir/converters/patientConverter.py on lines 253..259

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 63.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        if hasattr(imis_insuree, "education") and imis_insuree.education is not None:
                            if imis_insuree.education.education is not None:
                                extension.valueString = imis_insuree.education.education
                            else :
                                extension.valueString = ""
        Severity: Major
        Found in api_fhir/converters/patientConverter.py and 1 other location - About 3 hrs to fix
        api_fhir/converters/patientConverter.py on lines 262..268

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 63.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function _fromDict has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            def _fromDict(self, object_dict):
                for attr, obj in object_dict.items():
        
                    prop, prop_type = self._get_property_details_for_name(attr)
                    value = None
        Severity: Minor
        Found in api_fhir/models/__init__.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                try:
                    response = EligibilityService(request.user).request(eligibility_request)
                except TypeError:
                    self.logger.warning('The insuree with chfid `{}` is not connected with policy. '
                                        'The default eligibility response will be used.'
        Severity: Major
        Found in api_fhir/serializers/eligibilityRequestSerializer.py and 1 other location - About 2 hrs to fix
        api_fhir/serializers/policyEligibilityRequestSerializer.py on lines 17..23

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 56.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        PatientConverter has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class PatientConverter(BaseFHIRConverter, PersonConverterMixin, ReferenceConverterMixin):
        
            @classmethod
            def to_fhir_obj(cls, imis_insuree):
                fhir_patient = Patient()
        Severity: Minor
        Found in api_fhir/converters/patientConverter.py - About 2 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  try:
                      response = ByInsureeService(request.user).request(eligibility_request)
                  except TypeError:
                      self.logger.warning('The insuree with chfid `{}` is not connected with policy. '
                                          'The default eligibility response will be used.'
          Severity: Major
          Found in api_fhir/serializers/policyEligibilityRequestSerializer.py and 1 other location - About 2 hrs to fix
          api_fhir/serializers/eligibilityRequestSerializer.py on lines 19..25

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 56.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Stu3EligibilityConfiguration has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Stu3EligibilityConfiguration(EligibilityConfiguration):
          
              @classmethod
              def build_configuration(cls, cfg):
                  cls.get_config().stu3_fhir_eligibility_config = cfg['stu3_fhir_eligibility_config']
          Severity: Minor
          Found in api_fhir/configurations/stu3EligibilityConfiguration.py - About 2 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                @classmethod
                def build_fhir_chfid_identifier(cls, identifiers, imis_insuree):
                    if imis_insuree.chf_id is not None:
                        identifier = cls.build_fhir_identifier(imis_insuree.chf_id,
                                                               Stu3IdentifierConfig.get_fhir_identifier_type_system(),
            Severity: Major
            Found in api_fhir/converters/patientConverter.py and 1 other location - About 2 hrs to fix
            api_fhir/converters/__init__.py on lines 63..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 54.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            EligibilityConfiguration has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class EligibilityConfiguration(BaseConfiguration):  # pragma: no cover
            
                @classmethod
                def build_configuration(cls, cfg):
                    raise NotImplementedError('`build_configuration()` must be implemented.')
            Severity: Minor
            Found in api_fhir/configurations/__init__.py - About 2 hrs to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  @classmethod
                  def build_fhir_uuid_identifier(cls, identifiers, imis_object):
                      if imis_object.uuid is not None:
                          identifier = cls.build_fhir_identifier(imis_object.uuid,
                                                                 Stu3IdentifierConfig.get_fhir_identifier_type_system(),
              Severity: Major
              Found in api_fhir/converters/__init__.py and 1 other location - About 2 hrs to fix
              api_fhir/converters/patientConverter.py on lines 98..104

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 54.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language