openimis/openimis-be-api_fhir_py

View on GitHub
api_fhir/converters/patientConverter.py

Summary

Maintainability
D
2 days
Test Coverage

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

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

    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_gender has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_imis_gender(cls, imis_insuree, fhir_patient):
            gender = fhir_patient.gender
            if gender is not None:
                imis_gender_code = None
                if gender == AdministrativeGender.MALE.value:
    Severity: Minor
    Found in api_fhir/converters/patientConverter.py - About 35 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_fhir_marital_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_fhir_marital_status(cls, fhir_patient, imis_insuree):
            if imis_insuree.marital is not None:
                if imis_insuree.marital == ImisMaritalStatus.MARRIED.value:
                    fhir_patient.maritalStatus = \
                        cls.build_codeable_concept(Stu3MaritalConfig.get_fhir_married_code(),
    Severity: Minor
    Found in api_fhir/converters/patientConverter.py - About 35 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_addresses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_imis_addresses(cls, imis_insuree, fhir_patient):
            addresses = fhir_patient.address
            if addresses is not None:
                for address in addresses:
                    if address.type == AddressType.PHYSICAL.value:
    Severity: Minor
    Found in api_fhir/converters/patientConverter.py - About 35 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_fhir_gender has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_fhir_gender(cls, fhir_patient, imis_insuree):
            if hasattr(imis_insuree, "gender") and imis_insuree.gender is not None:
                code = imis_insuree.gender.code
                if code == GeneralConfiguration.get_male_gender_code():
                    fhir_patient.gender = AdministrativeGender.MALE.value
    Severity: Minor
    Found in api_fhir/converters/patientConverter.py - About 25 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

                if code == GeneralConfiguration.get_male_gender_code():
                    fhir_patient.gender = AdministrativeGender.MALE.value
                elif code == GeneralConfiguration.get_female_gender_code():
                    fhir_patient.gender = AdministrativeGender.FEMALE.value
                elif code == GeneralConfiguration.get_other_gender_code():
    Severity: Major
    Found in api_fhir/converters/patientConverter.py and 2 other locations - About 4 hrs to fix
    api_fhir/converters/locationConverter.py on lines 116..121
    api_fhir/converters/patientConverter.py on lines 186..193

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

    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

                        elif code == Stu3MaritalConfig.get_fhir_never_married_code():
                            imis_insuree.marital = ImisMaritalStatus.SINGLE.value
                        elif code == Stu3MaritalConfig.get_fhir_divorced_code():
                            imis_insuree.marital = ImisMaritalStatus.DIVORCED.value
                        elif code == Stu3MaritalConfig.get_fhir_widowed_code():
    Severity: Major
    Found in api_fhir/converters/patientConverter.py and 2 other locations - About 4 hrs to fix
    api_fhir/converters/locationConverter.py on lines 116..121
    api_fhir/converters/patientConverter.py on lines 130..135

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

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

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

        @classmethod
        def createDefaultInsuree(cls, audit_user_id):
            imis_insuree = Insuree()
            imis_insuree.head = GeneralConfiguration.get_default_value_of_patient_head_attribute()
            imis_insuree.card_issued = GeneralConfiguration.get_default_value_of_patient_card_issued_attribute()
    Severity: Major
    Found in api_fhir/converters/patientConverter.py and 1 other location - About 2 hrs to fix
    api_fhir/converters/locationConverter.py on lines 50..59

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

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

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

                for address in addresses:
                    if address.type == AddressType.PHYSICAL.value:
                        imis_insuree.current_address = address.text
                    elif address.type == AddressType.BOTH.value:
                        imis_insuree.geolocation = address.text
    Severity: Major
    Found in api_fhir/converters/patientConverter.py and 1 other location - About 2 hrs to fix
    api_fhir/converters/locationConverter.py on lines 159..164

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

    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

            if imis_insuree.current_address is not None:
                current_address = cls.build_fhir_address(imis_insuree.current_address, AddressUse.HOME.value,
                                                         AddressType.PHYSICAL.value)
                addresses.append(current_address)
    Severity: Major
    Found in api_fhir/converters/patientConverter.py and 4 other locations - About 1 hr to fix
    api_fhir/converters/locationConverter.py on lines 140..143
    api_fhir/converters/locationConverter.py on lines 144..147
    api_fhir/converters/locationConverter.py on lines 148..151
    api_fhir/converters/patientConverter.py on lines 210..213

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

    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

            if imis_insuree.geolocation is not None:
                geolocation = cls.build_fhir_address(imis_insuree.geolocation, AddressUse.HOME.value,
                                                     AddressType.BOTH.value)
                addresses.append(geolocation)
    Severity: Major
    Found in api_fhir/converters/patientConverter.py and 4 other locations - About 1 hr to fix
    api_fhir/converters/locationConverter.py on lines 140..143
    api_fhir/converters/locationConverter.py on lines 144..147
    api_fhir/converters/locationConverter.py on lines 148..151
    api_fhir/converters/patientConverter.py on lines 206..209

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

    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_insuree_uuid = cls.get_resource_id_from_reference(reference)
            return DbManagerUtils.get_object_or_none(Insuree, uuid=imis_insuree_uuid)
    Severity: Major
    Found in api_fhir/converters/patientConverter.py and 4 other locations - About 50 mins to fix
    api_fhir/converters/claimConverter.py on lines 59..62
    api_fhir/converters/communicationRequestConverter.py on lines 29..32
    api_fhir/converters/locationConverter.py on lines 45..48
    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 2 locations. Consider refactoring.
    Wontfix

        @classmethod
        def build_fhir_telecom(cls, fhir_patient, imis_insuree):
            fhir_patient.telecom = cls.build_fhir_telecom_for_person(phone=imis_insuree.phone, email=imis_insuree.email)
    Severity: Minor
    Found in api_fhir/converters/patientConverter.py and 1 other location - About 30 mins to fix
    api_fhir/converters/practitionerConverter.py on lines 96..99

    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