openimis/openimis-be-api_fhir_py

View on GitHub

Showing 49 of 117 total issues

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

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

        @classmethod
        def __build_effective_date(cls, fhir_coverage, imis_coverage):
            enroll_date = cls.__build_date_extension(imis_coverage.effective_date,
                                                     Stu3CoverageConfig.get_effective_date_code())
            fhir_coverage.extension.append(enroll_date)
    Severity: Major
    Found in api_fhir/converters/coverageConventer.py and 1 other location - About 1 hr to fix
    api_fhir/converters/coverageConventer.py on lines 110..114

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

    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 4 locations. Consider refactoring.
    Open

    class FHIRApiHFPermissions(FHIRApiPermissions):
        permissions_get = LocationConfig.gql_query_health_facilities_perms
        permissions_post = LocationConfig.gql_mutation_create_health_facilities_perms
        permissions_put = LocationConfig.gql_mutation_create_health_facilities_perms
        permissions_patch = LocationConfig.gql_mutation_create_health_facilities_perms
    Severity: Major
    Found in api_fhir/permissions.py and 3 other locations - About 1 hr to fix
    api_fhir/permissions.py on lines 30..35
    api_fhir/permissions.py on lines 38..43
    api_fhir/permissions.py on lines 46..51

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

    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 4 locations. Consider refactoring.
    Open

    class FHIRApiClaimPermissions(FHIRApiPermissions):
        permissions_get = ClaimConfig.gql_query_claims_perms
        permissions_post = ClaimConfig.gql_mutation_create_claims_perms
        permissions_put = ClaimConfig.gql_mutation_update_claims_perms
        permissions_patch = ClaimConfig.gql_mutation_update_claims_perms
    Severity: Major
    Found in api_fhir/permissions.py and 3 other locations - About 1 hr to fix
    api_fhir/permissions.py on lines 38..43
    api_fhir/permissions.py on lines 46..51
    api_fhir/permissions.py on lines 70..75

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

    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

        @classmethod
        def __build_enroll_date(cls, fhir_coverage, imis_coverage):
            enroll_date = cls.__build_date_extension(imis_coverage.enroll_date,
                                                     Stu3CoverageConfig.get_enroll_date_code())
            fhir_coverage.extension.append(enroll_date)
    Severity: Major
    Found in api_fhir/converters/coverageConventer.py and 1 other location - About 1 hr to fix
    api_fhir/converters/coverageConventer.py on lines 104..108

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

    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

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

        @classmethod
        def build_imis_uuid(cls, fhir_eligibility_request):
            uuid = None
            patient_reference = fhir_eligibility_request.patient
            if patient_reference:
    Severity: Major
    Found in api_fhir/converters/policyEligibilityRequestConverter.py and 1 other location - About 1 hr to fix
    api_fhir/converters/eligibilityRequestConverter.py on lines 94..100

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

    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 4 locations. Consider refactoring.
    Open

    class FHIRApiPractitionerPermissions(FHIRApiPermissions):
        permissions_get = ClaimConfig.gql_query_claim_admins_perms
        permissions_post = ClaimConfig.gql_query_claim_admins_perms
        permissions_put = ClaimConfig.gql_query_claim_admins_perms
        permissions_patch = ClaimConfig.gql_query_claim_admins_perms
    Severity: Major
    Found in api_fhir/permissions.py and 3 other locations - About 1 hr to fix
    api_fhir/permissions.py on lines 30..35
    api_fhir/permissions.py on lines 38..43
    api_fhir/permissions.py on lines 70..75

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

    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 4 locations. Consider refactoring.
    Open

    class FHIRApiCommunicationRequestPermissions(FHIRApiPermissions):
        permissions_get = ClaimConfig.gql_mutation_select_claim_feedback_perms
        permissions_post = ClaimConfig.gql_mutation_deliver_claim_feedback_perms
        permissions_put = ClaimConfig.gql_mutation_deliver_claim_feedback_perms
        permissions_patch = ClaimConfig.gql_mutation_deliver_claim_feedback_perms
    Severity: Major
    Found in api_fhir/permissions.py and 3 other locations - About 1 hr to fix
    api_fhir/permissions.py on lines 30..35
    api_fhir/permissions.py on lines 46..51
    api_fhir/permissions.py on lines 70..75

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

    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

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

        @classmethod
        def build_imis_uuid(cls, fhir_eligibility_request):
            uuid = None
            patient_reference = fhir_eligibility_request.patient
            if patient_reference:
    Severity: Major
    Found in api_fhir/converters/eligibilityRequestConverter.py and 1 other location - About 1 hr to fix
    api_fhir/converters/policyEligibilityRequestConverter.py on lines 70..77

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

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

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

        @classmethod
        def build_fhir_generic_benefit_balance_financial(cls):
            financial = InsuranceBenefitBalanceFinancial()
            financial.type = cls.build_simple_codeable_concept(
                Config.get_fhir_financial_code())
    Severity: Minor
    Found in api_fhir/converters/policyEligibilityRequestConverter.py and 1 other location - About 45 mins to fix
    api_fhir/converters/eligibilityRequestConverter.py on lines 88..92

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

    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

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

        @classmethod
        def build_fhir_generic_benefit_balance_financial(cls):
            financial = InsuranceBenefitBalanceFinancial()
            financial.type = cls.build_simple_codeable_concept(Config.get_fhir_financial_code())
            return financial
    Severity: Minor
    Found in api_fhir/converters/eligibilityRequestConverter.py and 1 other location - About 45 mins to fix
    api_fhir/converters/policyEligibilityRequestConverter.py on lines 63..68

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

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

    Severity
    Category
    Status
    Source
    Language