openimis/openimis-be-api_fhir_py

View on GitHub

Showing 28 of 117 total issues

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

      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

        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

        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

          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

            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

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

              import inspect
              import json
              import sys
              
              import math
              Severity: Minor
              Found in api_fhir/models/__init__.py - About 2 hrs to fix

                Function build_imis_marital has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_imis_marital(cls, imis_insuree, fhir_patient):
                        marital_status = fhir_patient.maritalStatus
                        if marital_status is not None:
                            for maritialCoding in marital_status.coding:
                                if maritialCoding.system == Stu3MaritalConfig.get_fhir_marital_status_system():
                Severity: Minor
                Found in api_fhir/converters/patientConverter.py - About 1 hr 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

                Function build_imis_hf_level has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_imis_hf_level(cls, imis_hf, fhir_location, errors):
                        location_type = fhir_location.type
                        if not cls.valid_condition(location_type is None,
                                                   gettext('Missing patient `type` attribute'), errors):
                            for maritalCoding in location_type.coding:
                Severity: Minor
                Found in api_fhir/converters/locationConverter.py - About 1 hr 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

                Function build_imis_submit_items_and_services has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_imis_submit_items_and_services(cls, imis_claim, fhir_claim):
                        imis_items = []
                        imis_services = []
                        if fhir_claim.item:
                            for item in fhir_claim.item:
                Severity: Minor
                Found in api_fhir/converters/claimConverter.py - About 1 hr 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

                Function __set__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __set__(self, instance, value):
                        if self.definition.count_max > 1:
                            if isinstance(value, list):
                                instance._values.setdefault(self.definition.name, PropertyList(self.definition))
                                del instance._values[self.definition.name][:]
                Severity: Minor
                Found in api_fhir/models/__init__.py - About 1 hr 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

                Function build_imis_diagnoses has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_imis_diagnoses(cls, imis_claim, fhir_claim, errors):
                        diagnoses = fhir_claim.diagnosis
                        if diagnoses:
                            for diagnosis in diagnoses:
                                diagnosis_type = cls.get_diagnosis_type(diagnosis)
                Severity: Minor
                Found in api_fhir/converters/claimConverter.py - About 1 hr 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

                Function build_imis_last_and_other_name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_imis_last_and_other_name(cls, names):
                        last_name = None
                        other_names = None
                        if isinstance(names, list):
                            for name in names:
                Severity: Minor
                Found in api_fhir/converters/personConverterMixin.py - About 1 hr 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

                Function validate_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def validate_type(cls, value):
                        valid = False
                        if value and isinstance(value, str):
                            if re.search(cls._datetime_regex, value):
                                valid = True
                Severity: Minor
                Found in api_fhir/models/fhirdate.py - About 45 mins 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

                Function build_imis_hf_contacts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_imis_hf_contacts(cls, imis_hf, fhir_location):
                        telecom = fhir_location.telecom
                        if telecom is not None:
                            for contact_point in telecom:
                                if contact_point.system == ContactPointSystem.PHONE.value:
                Severity: Minor
                Found in api_fhir/converters/locationConverter.py - About 45 mins 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

                Function build_imis_information has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_imis_information(cls, imis_claim, fhir_claim):
                        if fhir_claim.information:
                            for information in fhir_claim.information:
                                category = information.category
                                if category and category.text == Stu3ClaimConfig.get_fhir_claim_information_guarantee_id_code():
                Severity: Minor
                Found in api_fhir/converters/claimConverter.py - About 45 mins 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

                Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(self, name, property_type, count_max=1, count_min=0, required=False):
                Severity: Minor
                Found in api_fhir/models/__init__.py - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language