openimis/openimis-be-api_fhir_py

View on GitHub
api_fhir/converters/claimConverter.py

Summary

Maintainability
C
1 day
Test Coverage

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 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 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_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

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

          @classmethod
          def build_imis_health_facility(cls, errors, fhir_claim, imis_claim):
              if fhir_claim.facility:
                  health_facility = LocationConverter.get_imis_obj_by_fhir_reference(fhir_claim.facility)
                  if health_facility:
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 2 other locations - About 3 hrs to fix
      api_fhir/converters/claimConverter.py on lines 87..94
      api_fhir/converters/claimConverter.py on lines 223..230

      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 73.

      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.
      Wontfix

          @classmethod
          def build_imis_claim_admin(cls, imis_claim, fhir_claim, errors):
              if fhir_claim.enterer:
                  admin = PractitionerConverter.get_imis_obj_by_fhir_reference(fhir_claim.enterer)
                  if admin:
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 2 other locations - About 3 hrs to fix
      api_fhir/converters/claimConverter.py on lines 87..94
      api_fhir/converters/claimConverter.py on lines 96..103

      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 73.

      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.
      Wontfix

          @classmethod
          def build_imis_patient(cls, imis_claim, fhir_claim, errors):
              if fhir_claim.patient:
                  insuree = PatientConverter.get_imis_obj_by_fhir_reference(fhir_claim.patient)
                  if insuree:
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 2 other locations - About 3 hrs to fix
      api_fhir/converters/claimConverter.py on lines 96..103
      api_fhir/converters/claimConverter.py on lines 223..230

      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 73.

      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.
      Wontfix

          @classmethod
          def build_imis_identifier(cls, imis_claim, fhir_claim, errors):
              value = cls.get_fhir_identifier_by_code(fhir_claim.identifier, Stu3IdentifierConfig.get_fhir_claim_code_type())
              if value:
                  imis_claim.code = value
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 2 other locations - About 3 hrs to fix
      api_fhir/converters/locationConverter.py on lines 76..82
      api_fhir/converters/practitionerConverter.py on lines 68..74

      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.
      Wontfix

          @classmethod
          def build_imis_submit_service(cls, imis_services, fhir_item):
              price_asked = cls.get_fhir_item_price_asked(fhir_item)
              qty_provided = cls.get_fhir_item_qty_provided(fhir_item)
              service_code = cls.get_fhir_item_code(fhir_item)
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 1 other location - About 2 hrs to fix
      api_fhir/converters/claimConverter.py on lines 337..342

      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 58.

      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.
      Wontfix

          @classmethod
          def build_imis_submit_item(cls, imis_items, fhir_item):
              price_asked = cls.get_fhir_item_price_asked(fhir_item)
              qty_provided = cls.get_fhir_item_qty_provided(fhir_item)
              item_code = cls.get_fhir_item_code(fhir_item)
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 1 other location - About 2 hrs to fix
      api_fhir/converters/claimConverter.py on lines 344..349

      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 58.

      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.
      Wontfix

          @classmethod
          def build_items_for_imis_item(cls, fhir_claim, imis_claim):
              for item in cls.get_imis_items_for_claim(imis_claim):
                  if item.item:
                      type = Stu3ClaimConfig.get_fhir_claim_item_code()
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 1 other location - About 2 hrs to fix
      api_fhir/converters/claimConverter.py on lines 283..288

      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 53.

      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.
      Wontfix

          @classmethod
          def build_items_for_imis_services(cls, fhir_claim, imis_claim):
              for service in cls.get_imis_services_for_claim(imis_claim):
                  if service.service:
                      type = Stu3ClaimConfig.get_fhir_claim_service_code()
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 1 other location - About 2 hrs to fix
      api_fhir/converters/claimConverter.py on lines 276..281

      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 53.

      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.
      Wontfix

          @classmethod
          def get_imis_items_for_claim(cls, imis_claim):
              items = []
              if imis_claim and imis_claim.id:
                  items = ClaimItem.objects.filter(claim_id=imis_claim.id)
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 1 other location - About 1 hr to fix
      api_fhir/converters/claimConverter.py on lines 315..320

      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 45.

      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.
      Wontfix

          @classmethod
          def get_imis_services_for_claim(cls, imis_claim):
              services = []
              if imis_claim and imis_claim.id:
                  services = ClaimService.objects.filter(claim_id=imis_claim.id)
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 1 other location - About 1 hr to fix
      api_fhir/converters/claimConverter.py on lines 308..313

      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 45.

      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 5 locations. Consider refactoring.
      Wontfix

          @classmethod
          def get_imis_obj_by_fhir_reference(cls, reference, errors=None):
              imis_claim_code = cls.get_resource_id_from_reference(reference)
              return DbManagerUtils.get_object_or_none(Claim, code=imis_claim_code)
      Severity: Major
      Found in api_fhir/converters/claimConverter.py and 4 other locations - About 50 mins to fix
      api_fhir/converters/communicationRequestConverter.py on lines 29..32
      api_fhir/converters/locationConverter.py on lines 45..48
      api_fhir/converters/patientConverter.py on lines 52..55
      api_fhir/converters/practitionerConverter.py on lines 41..44

      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 36.

      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.
      Wontfix

          @classmethod
          def get_fhir_item_qty_provided(cls, fhir_item):
              qty_provided = None
              if fhir_item.quantity:
                  qty_provided = fhir_item.quantity.value
      Severity: Minor
      Found in api_fhir/converters/claimConverter.py and 2 other locations - About 30 mins to fix
      api_fhir/converters/claimConverter.py on lines 351..356
      api_fhir/converters/claimConverter.py on lines 365..370

      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 32.

      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.
      Wontfix

          @classmethod
          def get_fhir_item_price_asked(cls, fhir_item):
              price_asked = None
              if fhir_item.unitPrice:
                  price_asked = fhir_item.unitPrice.value
      Severity: Minor
      Found in api_fhir/converters/claimConverter.py and 2 other locations - About 30 mins to fix
      api_fhir/converters/claimConverter.py on lines 351..356
      api_fhir/converters/claimConverter.py on lines 358..363

      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 32.

      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.
      Wontfix

          @classmethod
          def get_fhir_item_code(cls, fhir_item):
              item_code = None
              if fhir_item.service:
                  item_code = fhir_item.service.text
      Severity: Minor
      Found in api_fhir/converters/claimConverter.py and 2 other locations - About 30 mins to fix
      api_fhir/converters/claimConverter.py on lines 358..363
      api_fhir/converters/claimConverter.py on lines 365..370

      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 32.

      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

      There are no issues that match your filters.

      Category
      Status