dsi-icl/optimise

View on GitHub
packages/optimise-core/src/controllers/demographicDataController.js

Summary

Maintainability
F
1 mo
Test Coverage

File demographicDataController.js has 627 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import ErrorHelper from '../utils/error_helper';
import message from '../utils/message-utils';
import formatToJSON from '../utils/format-response';
import moment from 'moment';
import { DemographicCore, MedicalHistoryCore, ImmunisationCore, PregnancyCore } from '../core/demographic';
Severity: Major
Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 day to fix

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

        static createPregnancy({ body, user }, res) {
            if (body.hasOwnProperty('patient') && typeof body.patient === 'number') {
    
                if (body.hasOwnProperty('meddra') && body.meddra !== null && isNaN(parseInt(body.meddra))) {
                    res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
    Severity: Minor
    Found in packages/optimise-core/src/controllers/demographicDataController.js - 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

    Consider simplifying this complex logical expression.
    Open

            if (body.hasOwnProperty('patient') && body.hasOwnProperty('startDate') && body.hasOwnProperty('outcome') && body.hasOwnProperty('relation') && body.hasOwnProperty('conditionName') &&
                ((body.hasOwnProperty('resolvedYear') && typeof body.resolvedYear === 'number') || !body.hasOwnProperty('resolvedYear')) &&
                typeof body.patient === 'number' && typeof body.startDate === 'string' && typeof body.outcome === 'string' && typeof body.relation === 'number' && typeof body.conditionName === 'number') {
                const momentStart = moment(body.startDate, moment.ISO_8601);
                if (!momentStart.isValid() && body.startDate !== null) {
    Severity: Critical
    Found in packages/optimise-core/src/controllers/demographicDataController.js - About 3 hrs to fix

      DemographicDataController has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class DemographicDataController {
      
          static createDemographic({ body, user }, res) {
              if ((!body.hasOwnProperty('patient') || !body.hasOwnProperty('DOB') || !body.hasOwnProperty('gender') || !body.hasOwnProperty('dominant_hand')
                  || !body.hasOwnProperty('ethnicity') || !body.hasOwnProperty('country_of_origin'))) {
      Severity: Minor
      Found in packages/optimise-core/src/controllers/demographicDataController.js - About 2 hrs to fix

        Function editPregnancy has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            static editPregnancy({ body, user }, res) {
                if (body.hasOwnProperty('id') && typeof body.id === 'number') {
        
                    const entryObj = Object.assign({}, body);
                    const momentStart = moment(body.startDate, moment.ISO_8601);
        Severity: Minor
        Found in packages/optimise-core/src/controllers/demographicDataController.js - 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 createPregnancy has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static createPregnancy({ body, user }, res) {
                if (body.hasOwnProperty('patient') && typeof body.patient === 'number') {
        
                    if (body.hasOwnProperty('meddra') && body.meddra !== null && isNaN(parseInt(body.meddra))) {
                        res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
        Severity: Minor
        Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

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

              static createMedicalCondition({ body, user }, res) {
                  if (body.hasOwnProperty('patient') && body.hasOwnProperty('startDate') && body.hasOwnProperty('outcome') && body.hasOwnProperty('relation') && body.hasOwnProperty('conditionName') &&
                      ((body.hasOwnProperty('resolvedYear') && typeof body.resolvedYear === 'number') || !body.hasOwnProperty('resolvedYear')) &&
                      typeof body.patient === 'number' && typeof body.startDate === 'string' && typeof body.outcome === 'string' && typeof body.relation === 'number' && typeof body.conditionName === 'number') {
                      const momentStart = moment(body.startDate, moment.ISO_8601);
          Severity: Minor
          Found in packages/optimise-core/src/controllers/demographicDataController.js - 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 editPregnancyImage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              static editPregnancyImage({ body, user }, res) {
                  //
                  if (body.hasOwnProperty('id') && typeof body.id === 'number') {
          
                      const entryObj = Object.assign({}, body);
          Severity: Minor
          Found in packages/optimise-core/src/controllers/demographicDataController.js - 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 getDemographicFields has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static getDemographicFields({ query }, res) {
                  const action = {
                      gender: DemographicCore.getGenderFields,
                      dominant_hand: DemographicCore.getDominantHandsFields,
                      ethnicity: DemographicCore.getEthnicityFields,
          Severity: Minor
          Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

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

                static editDemographic({ body, user }, res) {
                    if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                        if (body.DOB) {
                            const momentDOB = moment(body.DOB, moment.ISO_8601);
                            if (!momentDOB.isValid()) {
            Severity: Minor
            Found in packages/optimise-core/src/controllers/demographicDataController.js - 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 editImmunisation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                static editImmunisation({ body, user }, res) {
                    if (body.hasOwnProperty('id') && typeof body.id === 'number' &&
                        ((body.hasOwnProperty('immunisationDate') && typeof body.immunisationDate === 'string') || !body.hasOwnProperty('immunisationDate'))) {
                        const momentImmun = moment(body.immunisationDate, moment.ISO_8601);
                        if (body.hasOwnProperty('immunisationDate') && body.immunisationDate !== null && !momentImmun.isValid()) {
            Severity: Minor
            Found in packages/optimise-core/src/controllers/demographicDataController.js - 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 getMedicalConditionFields has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                static getMedicalConditionFields({ query }, res) {
                    const action = {
                        relations: MedicalHistoryCore.getRelations,
                        conditions: MedicalHistoryCore.getConditions
                    };
            Severity: Minor
            Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

              Function createMedicalCondition has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  static createMedicalCondition({ body, user }, res) {
                      if (body.hasOwnProperty('patient') && body.hasOwnProperty('startDate') && body.hasOwnProperty('outcome') && body.hasOwnProperty('relation') && body.hasOwnProperty('conditionName') &&
                          ((body.hasOwnProperty('resolvedYear') && typeof body.resolvedYear === 'number') || !body.hasOwnProperty('resolvedYear')) &&
                          typeof body.patient === 'number' && typeof body.startDate === 'string' && typeof body.outcome === 'string' && typeof body.relation === 'number' && typeof body.conditionName === 'number') {
                          const momentStart = moment(body.startDate, moment.ISO_8601);
              Severity: Minor
              Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                        if (body.hasOwnProperty('id') && typeof body.id === 'number' &&
                            ((body.hasOwnProperty('outcome') && typeof body.outcome === 'string') || !body.hasOwnProperty('outcome')) &&
                            ((body.hasOwnProperty('resolvedYear') && typeof body.resolvedYear === 'number') || !body.hasOwnProperty('resolvedYear'))) {
                            MedicalHistoryCore.editMedicalHistory(user, body).then((result) => {
                                res.status(200).json(formatToJSON(result));
                Severity: Critical
                Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

                  Function createDemographic has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      static createDemographic({ body, user }, res) {
                          if ((!body.hasOwnProperty('patient') || !body.hasOwnProperty('DOB') || !body.hasOwnProperty('gender') || !body.hasOwnProperty('dominant_hand')
                              || !body.hasOwnProperty('ethnicity') || !body.hasOwnProperty('country_of_origin'))) {
                              res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                              return;
                  Severity: Minor
                  Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

                    Function editPregnancy has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        static editPregnancy({ body, user }, res) {
                            if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                    
                                const entryObj = Object.assign({}, body);
                                const momentStart = moment(body.startDate, moment.ISO_8601);
                    Severity: Minor
                    Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

                      Function editPregnancyImage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          static editPregnancyImage({ body, user }, res) {
                              //
                              if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                      
                                  const entryObj = Object.assign({}, body);
                      Severity: Minor
                      Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

                        Function createImmunisation has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            static createImmunisation({ body, user }, res) {
                                if (body.hasOwnProperty('patient') && body.hasOwnProperty('immunisationDate') && body.hasOwnProperty('vaccineName') &&
                                    typeof body.patient === 'number' && typeof body.immunisationDate === 'string' && typeof body.vaccineName === 'string') {
                                    const momentImmun = moment(body.immunisationDate, moment.ISO_8601);
                                    if (!momentImmun.isValid() && body.immunisationDate !== null) {
                        Severity: Minor
                        Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

                          Function createPregnancyImage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              static createPregnancyImage({ body, user }, res) {
                          
                                  if (!body.hasOwnProperty('visitId') || !body.hasOwnProperty('date') || !body.hasOwnProperty('mode') || !body.hasOwnProperty('result')) {
                                      res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                                      return;
                          Severity: Minor
                          Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

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

                                static createImmunisation({ body, user }, res) {
                                    if (body.hasOwnProperty('patient') && body.hasOwnProperty('immunisationDate') && body.hasOwnProperty('vaccineName') &&
                                        typeof body.patient === 'number' && typeof body.immunisationDate === 'string' && typeof body.vaccineName === 'string') {
                                        const momentImmun = moment(body.immunisationDate, moment.ISO_8601);
                                        if (!momentImmun.isValid() && body.immunisationDate !== null) {
                            Severity: Minor
                            Found in packages/optimise-core/src/controllers/demographicDataController.js - 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 createDemographic has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                static createDemographic({ body, user }, res) {
                                    if ((!body.hasOwnProperty('patient') || !body.hasOwnProperty('DOB') || !body.hasOwnProperty('gender') || !body.hasOwnProperty('dominant_hand')
                                        || !body.hasOwnProperty('ethnicity') || !body.hasOwnProperty('country_of_origin'))) {
                                        res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                                        return;
                            Severity: Minor
                            Found in packages/optimise-core/src/controllers/demographicDataController.js - About 55 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 getDemographicFields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                static getDemographicFields({ query }, res) {
                                    const action = {
                                        gender: DemographicCore.getGenderFields,
                                        dominant_hand: DemographicCore.getDominantHandsFields,
                                        ethnicity: DemographicCore.getEthnicityFields,
                            Severity: Minor
                            Found in packages/optimise-core/src/controllers/demographicDataController.js - 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

                            Consider simplifying this complex logical expression.
                            Open

                                    if ((!body.hasOwnProperty('patient') || !body.hasOwnProperty('DOB') || !body.hasOwnProperty('gender') || !body.hasOwnProperty('dominant_hand')
                                        || !body.hasOwnProperty('ethnicity') || !body.hasOwnProperty('country_of_origin'))) {
                                        res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                                        return;
                                    }
                            Severity: Major
                            Found in packages/optimise-core/src/controllers/demographicDataController.js - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      if (body.hasOwnProperty('patient') && body.hasOwnProperty('immunisationDate') && body.hasOwnProperty('vaccineName') &&
                                          typeof body.patient === 'number' && typeof body.immunisationDate === 'string' && typeof body.vaccineName === 'string') {
                                          const momentImmun = moment(body.immunisationDate, moment.ISO_8601);
                                          if (!momentImmun.isValid() && body.immunisationDate !== null) {
                                              const msg = message.dateError[momentImmun.invalidAt()] !== undefined ? message.dateError[momentImmun.invalidAt()] : message.userError.INVALIDDATE;
                              Severity: Major
                              Found in packages/optimise-core/src/controllers/demographicDataController.js - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                        if (typeof body.patient !== 'number' || typeof body.DOB !== 'string' || typeof body.gender !== 'number' || typeof body.dominant_hand !== 'number'
                                            || typeof body.ethnicity !== 'number' || typeof body.country_of_origin !== 'number') {
                                            res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
                                            return;
                                        }
                                Severity: Major
                                Found in packages/optimise-core/src/controllers/demographicDataController.js - About 40 mins to fix

                                  Function createPregnancyImage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      static createPregnancyImage({ body, user }, res) {
                                  
                                          if (!body.hasOwnProperty('visitId') || !body.hasOwnProperty('date') || !body.hasOwnProperty('mode') || !body.hasOwnProperty('result')) {
                                              res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                                              return;
                                  Severity: Minor
                                  Found in packages/optimise-core/src/controllers/demographicDataController.js - 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 getMedicalConditionFields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      static getMedicalConditionFields({ query }, res) {
                                          const action = {
                                              relations: MedicalHistoryCore.getRelations,
                                              conditions: MedicalHistoryCore.getConditions
                                          };
                                  Severity: Minor
                                  Found in packages/optimise-core/src/controllers/demographicDataController.js - 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

                                  Avoid too many return statements within this function.
                                  Open

                                              return;
                                  Severity: Major
                                  Found in packages/optimise-core/src/controllers/demographicDataController.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                return;
                                    Severity: Major
                                    Found in packages/optimise-core/src/controllers/demographicDataController.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                      return;
                                      Severity: Major
                                      Found in packages/optimise-core/src/controllers/demographicDataController.js - About 30 mins to fix

                                        Function editMedicalCondition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            static editMedicalCondition({ body, user }, res) {
                                                if (body.hasOwnProperty('id') && typeof body.id === 'number' &&
                                                    ((body.hasOwnProperty('outcome') && typeof body.outcome === 'string') || !body.hasOwnProperty('outcome')) &&
                                                    ((body.hasOwnProperty('resolvedYear') && typeof body.resolvedYear === 'number') || !body.hasOwnProperty('resolvedYear'))) {
                                                    MedicalHistoryCore.editMedicalHistory(user, body).then((result) => {
                                        Severity: Minor
                                        Found in packages/optimise-core/src/controllers/demographicDataController.js - 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

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

                                                if (Object.keys(query).length !== 0 && query.hasOwnProperty('fieldName')) {
                                                    if (action.hasOwnProperty(query.fieldName)) {
                                                        action[query.fieldName]().then((result) => {
                                                            res.status(200).json(formatToJSON(result));
                                                            return true;
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 343..373

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

                                        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

                                                if (Object.keys(query).length !== 0 && query.hasOwnProperty('fieldName')) {
                                                    if (action.hasOwnProperty(query.fieldName)) {
                                                        action[query.fieldName]().then((result) => {
                                                            res.status(200).json(formatToJSON(result));
                                                            return true;
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 304..334

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

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

                                            static deleteMedicalCondition({ body, user }, res) {
                                                if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                                                    MedicalHistoryCore.deleteMedicalHistory(user, { id: body.id }).then((result) => {
                                                        res.status(200).json(formatToJSON(result));
                                                        return true;
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 123..139
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 141..157
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 645..662
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88
                                        packages/optimise-core/src/controllers/testController.js on lines 79..96

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

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

                                            static deleteDemographic({ body, user }, res) {
                                                if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                                                    DemographicCore.deleteDemographic(user, { id: body.id }).then((result) => {
                                                        res.status(200).json(formatToJSON(result));
                                                        return true;
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 141..157
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 159..175
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 645..662
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88
                                        packages/optimise-core/src/controllers/testController.js on lines 79..96

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

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

                                            static deleteImmunisation({ body, user }, res) {
                                                if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                                                    ImmunisationCore.deleteImmunisation(user, { id: body.id }).then((result) => {
                                                        res.status(200).json(formatToJSON(result));
                                                        return true;
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 123..139
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 159..175
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 645..662
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88
                                        packages/optimise-core/src/controllers/testController.js on lines 79..96

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

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

                                            static deletePregnancyEntry({ body, user }, res) {
                                                if (body.hasOwnProperty('pregnancyEntryId') && typeof body.pregnancyEntryId === 'number') {
                                                    PregnancyCore.deletePregnancyEntry(user, { id: body.pregnancyEntryId }).then((result) => {
                                                        res.status(200).json(formatToJSON(result));
                                                        return true;
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 123..139
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 141..157
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 159..175
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88
                                        packages/optimise-core/src/controllers/testController.js on lines 79..96

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

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

                                                    if (body.hasOwnProperty('date') && body.date !== null && !momentDate.isValid()) {
                                                        const msg = message.dateError[momentDate.invalidAt()] !== undefined ? message.dateError[momentDate.invalidAt()] : message.userError.INVALIDDATE;
                                                        res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                        return;
                                                    } else if (body.hasOwnProperty('date') && body.date !== null) {
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 448..454
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 455..461
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 63..69
                                        packages/optimise-core/src/controllers/testController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js 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 178.

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

                                                    if (body.hasOwnProperty('outcomeDate') && body.outcomeDate !== null && !momentOutcome.isValid()) {
                                                        const msg = message.dateError[momentOutcome.invalidAt()] !== undefined ? message.dateError[momentOutcome.invalidAt()] : message.userError.INVALIDDATE;
                                                        res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                        return;
                                                    } else if (body.hasOwnProperty('outcomeDate') && body.outcomeDate !== null) {
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 448..454
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 541..547
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 63..69
                                        packages/optimise-core/src/controllers/testController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js 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 178.

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

                                                    if (body.hasOwnProperty('startDate') && body.startDate !== null && !momentStart.isValid()) {
                                                        const msg = message.dateError[momentStart.invalidAt()] !== undefined ? message.dateError[momentStart.invalidAt()] : message.userError.INVALIDDATE;
                                                        res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                        return;
                                                    } else if (body.hasOwnProperty('startDate') && body.startDate !== null) {
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 455..461
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 541..547
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 63..69
                                        packages/optimise-core/src/controllers/testController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js 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 178.

                                        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 (body.hasOwnProperty('patient') && body.hasOwnProperty('startDate') && body.hasOwnProperty('outcome') && body.hasOwnProperty('relation') && body.hasOwnProperty('conditionName') &&
                                                    ((body.hasOwnProperty('resolvedYear') && typeof body.resolvedYear === 'number') || !body.hasOwnProperty('resolvedYear')) &&
                                                    typeof body.patient === 'number' && typeof body.startDate === 'string' && typeof body.outcome === 'string' && typeof body.relation === 'number' && typeof body.conditionName === 'number') {
                                                    const momentStart = moment(body.startDate, moment.ISO_8601);
                                                    if (!momentStart.isValid() && body.startDate !== null) {
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 32..49

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

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

                                                    if (body.hasOwnProperty('outcomeDate') && body.outcomeDate !== null && !momentOutcome.isValid()) {
                                                        const msg = message.dateError[momentOutcome.invalidAt()] !== undefined ? message.dateError[momentOutcome.invalidAt()] : message.userError.INVALIDDATE;
                                                        res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                        return;
                                                    }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 208..212
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 403..407
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 511..515
                                        packages/optimise-core/src/controllers/testController.js on lines 25..29
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 165..169
                                        packages/optimise-core/src/controllers/visitController.js on lines 67..71

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

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

                                                if (body.hasOwnProperty('date') && body.date !== null && !momentDate.isValid()) {
                                                    let msg = message.dateError[momentDate.invalidAt()] !== undefined ? message.dateError[momentDate.invalidAt()] : message.userError.INVALIDDATE;
                                                    res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                    return;
                                                }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 208..212
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 403..407
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 408..412
                                        packages/optimise-core/src/controllers/testController.js on lines 25..29
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 165..169
                                        packages/optimise-core/src/controllers/visitController.js on lines 67..71

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

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

                                                    if (body.hasOwnProperty('immunisationDate') && body.immunisationDate !== null && !momentImmun.isValid()) {
                                                        const msg = message.dateError[momentImmun.invalidAt()] !== undefined ? message.dateError[momentImmun.invalidAt()] : message.userError.INVALIDDATE;
                                                        res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                        return;
                                                    }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 403..407
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 408..412
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 511..515
                                        packages/optimise-core/src/controllers/testController.js on lines 25..29
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 165..169
                                        packages/optimise-core/src/controllers/visitController.js on lines 67..71

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

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

                                                    if (body.hasOwnProperty('startDate') && body.startDate !== null && !momentStart.isValid()) {
                                                        const msg = message.dateError[momentStart.invalidAt()] !== undefined ? message.dateError[momentStart.invalidAt()] : message.userError.INVALIDDATE;
                                                        res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                        return;
                                                    }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 208..212
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 408..412
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 511..515
                                        packages/optimise-core/src/controllers/testController.js on lines 25..29
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 165..169
                                        packages/optimise-core/src/controllers/visitController.js on lines 67..71

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

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

                                                    if (!momentStart.isValid() && body.startDate !== null) {
                                                        const msg = message.dateError[momentStart.invalidAt()] !== undefined ? message.dateError[momentStart.invalidAt()] : message.userError.INVALIDDATE;
                                                        res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                        return;
                                                    }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 57..61
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 34..38
                                        packages/optimise-core/src/controllers/testController.js on lines 19..23
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 160..164
                                        packages/optimise-core/src/controllers/visitController.js on lines 38..42

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

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

                                                    if (!momentImmun.isValid() && body.immunisationDate !== null) {
                                                        const msg = message.dateError[momentImmun.invalidAt()] !== undefined ? message.dateError[momentImmun.invalidAt()] : message.userError.INVALIDDATE;
                                                        res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                        return;
                                                    }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 90..94
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 34..38
                                        packages/optimise-core/src/controllers/testController.js on lines 19..23
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 160..164
                                        packages/optimise-core/src/controllers/visitController.js on lines 38..42

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

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

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

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

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

                                        Refactorings

                                        Further Reading

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

                                            static getPregnancyAllFields(__unused__req, res) {
                                                PregnancyCore.getPregnancyAllFields().then((result) => {
                                                    res.status(200).json(formatToJSON(result));
                                                    return true;
                                                }).catch((error) => {
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 664..672
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 105..113

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

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

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

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

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

                                        Refactorings

                                        Further Reading

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

                                            static getPregnancyFields(__unused__req, res) {
                                                PregnancyCore.getPregnancyOutcomes().then((result) => {
                                                    res.status(200).json(formatToJSON(result));
                                                    return true;
                                                }).catch((error) => {
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 674..682
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 105..113

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

                                        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

                                                        if (!momentDOB.isValid()) {
                                                            const msg = message.dateError[momentDOB.invalidAt()] !== undefined ? message.dateError[momentDOB.invalidAt()] : message.userError.INVALIDDATE;
                                                            res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                            return;
                                                        }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 29..33

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

                                        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

                                                if (!momentDOB.isValid()) {
                                                    const msg = message.dateError[momentDOB.invalidAt()] !== undefined ? message.dateError[momentDOB.invalidAt()] : message.userError.INVALIDDATE;
                                                    res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                                                    return;
                                                }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 181..185

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

                                        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 (body.hasOwnProperty('id') && typeof body.id === 'number' &&
                                                    ((body.hasOwnProperty('outcome') && typeof body.outcome === 'string') || !body.hasOwnProperty('outcome')) &&
                                                    ((body.hasOwnProperty('resolvedYear') && typeof body.resolvedYear === 'number') || !body.hasOwnProperty('resolvedYear'))) {
                                                    MedicalHistoryCore.editMedicalHistory(user, body).then((result) => {
                                                        res.status(200).json(formatToJSON(result));
                                        packages/optimise-core/src/controllers/visitController.js on lines 158..172

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

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

                                                DemographicCore.createDemographic(entryObj).then((result) => {
                                                    res.status(200).json(formatToJSON(result));
                                                    return true;
                                                }).catch((error) => {
                                                    res.status(400).json(ErrorHelper(message.errorMessages.CREATIONFAIL, error));
                                        packages/optimise-core/src/controllers/actionController.js on lines 18..24
                                        packages/optimise-core/src/controllers/ceController.js on lines 39..45
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 20..26
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 43..49
                                        packages/optimise-core/src/controllers/concomitantMedController.js on lines 39..45
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 69..75
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 107..113
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 380..386
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 426..432
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 525..531
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 614..620
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 44..50
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 36..42
                                        packages/optimise-core/src/controllers/syncController.js on lines 31..37
                                        packages/optimise-core/src/controllers/syncController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js on lines 39..45
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 64..70
                                        packages/optimise-core/src/controllers/userController.js on lines 58..64
                                        packages/optimise-core/src/controllers/userController.js on lines 110..116
                                        packages/optimise-core/src/controllers/userController.js on lines 147..153
                                        packages/optimise-core/src/controllers/visitController.js on lines 50..56
                                        packages/optimise-core/src/controllers/visitController.js on lines 112..118
                                        packages/optimise-core/src/controllers/visitController.js on lines 134..140

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

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

                                                    PregnancyCore.createPregnancy(entryObj).then((result) => {
                                                        res.status(200).json(formatToJSON(result));
                                                        return true;
                                                    }).catch((error) => {
                                                        res.status(400).json(ErrorHelper(message.errorMessages.CREATIONFAIL, error));
                                        packages/optimise-core/src/controllers/actionController.js on lines 18..24
                                        packages/optimise-core/src/controllers/ceController.js on lines 39..45
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 20..26
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 43..49
                                        packages/optimise-core/src/controllers/concomitantMedController.js on lines 39..45
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 44..50
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 69..75
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 107..113
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 380..386
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 525..531
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 614..620
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 44..50
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 36..42
                                        packages/optimise-core/src/controllers/syncController.js on lines 31..37
                                        packages/optimise-core/src/controllers/syncController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js on lines 39..45
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 64..70
                                        packages/optimise-core/src/controllers/userController.js on lines 58..64
                                        packages/optimise-core/src/controllers/userController.js on lines 110..116
                                        packages/optimise-core/src/controllers/userController.js on lines 147..153
                                        packages/optimise-core/src/controllers/visitController.js on lines 50..56
                                        packages/optimise-core/src/controllers/visitController.js on lines 112..118
                                        packages/optimise-core/src/controllers/visitController.js on lines 134..140

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

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

                                                PregnancyCore.createPregnancyImage(entryObj).then((result) => {
                                                    res.status(200).json(formatToJSON(result));
                                                    return true;
                                                }).catch((error) => {
                                                    res.status(400).json(ErrorHelper(message.errorMessages.CREATIONFAIL, error));
                                        packages/optimise-core/src/controllers/actionController.js on lines 18..24
                                        packages/optimise-core/src/controllers/ceController.js on lines 39..45
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 20..26
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 43..49
                                        packages/optimise-core/src/controllers/concomitantMedController.js on lines 39..45
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 44..50
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 69..75
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 107..113
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 380..386
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 426..432
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 614..620
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 44..50
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 36..42
                                        packages/optimise-core/src/controllers/syncController.js on lines 31..37
                                        packages/optimise-core/src/controllers/syncController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js on lines 39..45
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 64..70
                                        packages/optimise-core/src/controllers/userController.js on lines 58..64
                                        packages/optimise-core/src/controllers/userController.js on lines 110..116
                                        packages/optimise-core/src/controllers/userController.js on lines 147..153
                                        packages/optimise-core/src/controllers/visitController.js on lines 50..56
                                        packages/optimise-core/src/controllers/visitController.js on lines 112..118
                                        packages/optimise-core/src/controllers/visitController.js on lines 134..140

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

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

                                                    MedicalHistoryCore.createMedicalHistory(entryObj).then((result) => {
                                                        res.status(200).json(formatToJSON(result));
                                                        return true;
                                                    }).catch((error) => {
                                                        res.status(400).json(ErrorHelper(message.errorMessages.CREATIONFAIL, error));
                                        packages/optimise-core/src/controllers/actionController.js on lines 18..24
                                        packages/optimise-core/src/controllers/ceController.js on lines 39..45
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 20..26
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 43..49
                                        packages/optimise-core/src/controllers/concomitantMedController.js on lines 39..45
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 44..50
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 69..75
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 380..386
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 426..432
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 525..531
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 614..620
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 44..50
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 36..42
                                        packages/optimise-core/src/controllers/syncController.js on lines 31..37
                                        packages/optimise-core/src/controllers/syncController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js on lines 39..45
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 64..70
                                        packages/optimise-core/src/controllers/userController.js on lines 58..64
                                        packages/optimise-core/src/controllers/userController.js on lines 110..116
                                        packages/optimise-core/src/controllers/userController.js on lines 147..153
                                        packages/optimise-core/src/controllers/visitController.js on lines 50..56
                                        packages/optimise-core/src/controllers/visitController.js on lines 112..118
                                        packages/optimise-core/src/controllers/visitController.js on lines 134..140

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

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

                                                PregnancyCore.getPregnancy(whereObj).then((result) => {
                                                    res.status(200).json(formatToJSON(result));
                                                    return true;
                                                }).catch((error) => {
                                                    res.status(400).json(ErrorHelper(message.errorMessages.GETFAIL, error));
                                        packages/optimise-core/src/controllers/actionController.js on lines 18..24
                                        packages/optimise-core/src/controllers/ceController.js on lines 39..45
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 20..26
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 43..49
                                        packages/optimise-core/src/controllers/concomitantMedController.js on lines 39..45
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 44..50
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 69..75
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 107..113
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 426..432
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 525..531
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 614..620
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 44..50
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 36..42
                                        packages/optimise-core/src/controllers/syncController.js on lines 31..37
                                        packages/optimise-core/src/controllers/syncController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js on lines 39..45
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 64..70
                                        packages/optimise-core/src/controllers/userController.js on lines 58..64
                                        packages/optimise-core/src/controllers/userController.js on lines 110..116
                                        packages/optimise-core/src/controllers/userController.js on lines 147..153
                                        packages/optimise-core/src/controllers/visitController.js on lines 50..56
                                        packages/optimise-core/src/controllers/visitController.js on lines 112..118
                                        packages/optimise-core/src/controllers/visitController.js on lines 134..140

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

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

                                                PregnancyCore.createPregnancyEntry(entryObj).then((result) => {
                                                    res.status(200).json(formatToJSON(result));
                                                    return true;
                                                }).catch((error) => {
                                                    res.status(400).json(ErrorHelper(message.errorMessages.CREATIONFAIL, error));
                                        packages/optimise-core/src/controllers/actionController.js on lines 18..24
                                        packages/optimise-core/src/controllers/ceController.js on lines 39..45
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 20..26
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 43..49
                                        packages/optimise-core/src/controllers/concomitantMedController.js on lines 39..45
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 44..50
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 69..75
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 107..113
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 380..386
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 426..432
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 525..531
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 44..50
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 36..42
                                        packages/optimise-core/src/controllers/syncController.js on lines 31..37
                                        packages/optimise-core/src/controllers/syncController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js on lines 39..45
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 64..70
                                        packages/optimise-core/src/controllers/userController.js on lines 58..64
                                        packages/optimise-core/src/controllers/userController.js on lines 110..116
                                        packages/optimise-core/src/controllers/userController.js on lines 147..153
                                        packages/optimise-core/src/controllers/visitController.js on lines 50..56
                                        packages/optimise-core/src/controllers/visitController.js on lines 112..118
                                        packages/optimise-core/src/controllers/visitController.js on lines 134..140

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

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

                                                    ImmunisationCore.createImmunisation(entryObj).then((result) => {
                                                        res.status(200).json(formatToJSON(result));
                                                        return true;
                                                    }).catch((error) => {
                                                        res.status(400).json(ErrorHelper(message.errorMessages.CREATIONFAIL, error));
                                        packages/optimise-core/src/controllers/actionController.js on lines 18..24
                                        packages/optimise-core/src/controllers/ceController.js on lines 39..45
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 20..26
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 43..49
                                        packages/optimise-core/src/controllers/concomitantMedController.js on lines 39..45
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 44..50
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 107..113
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 380..386
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 426..432
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 525..531
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 614..620
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 44..50
                                        packages/optimise-core/src/controllers/patientPiiController.js on lines 36..42
                                        packages/optimise-core/src/controllers/syncController.js on lines 31..37
                                        packages/optimise-core/src/controllers/syncController.js on lines 55..61
                                        packages/optimise-core/src/controllers/testController.js on lines 39..45
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 64..70
                                        packages/optimise-core/src/controllers/userController.js on lines 58..64
                                        packages/optimise-core/src/controllers/userController.js on lines 110..116
                                        packages/optimise-core/src/controllers/userController.js on lines 147..153
                                        packages/optimise-core/src/controllers/visitController.js on lines 50..56
                                        packages/optimise-core/src/controllers/visitController.js on lines 112..118
                                        packages/optimise-core/src/controllers/visitController.js on lines 134..140

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

                                        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

                                                if (body.hasOwnProperty('patient') && typeof body.patient === 'number') {
                                        
                                                    if (body.hasOwnProperty('meddra') && body.meddra !== null && isNaN(parseInt(body.meddra))) {
                                                        res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
                                                        return;
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 156..195
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 199..237
                                        packages/optimise-core/src/controllers/visitController.js on lines 128..148

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

                                        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 (!body.hasOwnProperty('visitId') || !body.hasOwnProperty('type') || !body.hasOwnProperty('pregnancyId')) {
                                                    res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                                                    return;
                                                }
                                        packages/optimise-core/src/controllers/testController.js on lines 10..13

                                        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 (typeof body.visitId !== 'number' || typeof body.type !== 'number' || typeof body.pregnancyId !== 'number') {
                                                    res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
                                                    return;
                                                }
                                        packages/optimise-core/src/controllers/testController.js on lines 14..17

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

                                                if (body.hasOwnProperty('patient') && body.hasOwnProperty('immunisationDate') && body.hasOwnProperty('vaccineName') &&
                                                    typeof body.patient === 'number' && typeof body.immunisationDate === 'string' && typeof body.vaccineName === 'string') {
                                                    const momentImmun = moment(body.immunisationDate, moment.ISO_8601);
                                                    if (!momentImmun.isValid() && body.immunisationDate !== null) {
                                                        const msg = message.dateError[momentImmun.invalidAt()] !== undefined ? message.dateError[momentImmun.invalidAt()] : message.userError.INVALIDDATE;
                                        packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 31..56
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 74..95

                                        Duplicated Code

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

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

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

                                        Tuning

                                        This issue has a mass of 76.

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

                                                    if (body.hasOwnProperty('meddra') && body.meddra !== null && isNaN(parseInt(body.meddra))) {
                                                        res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
                                                        return;
                                                    }
                                        packages/optimise-core/src/controllers/ceController.js on lines 24..27
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 170..173
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 213..216

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

                                        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 (typeof body.patient !== 'number' || typeof body.DOB !== 'string' || typeof body.gender !== 'number' || typeof body.dominant_hand !== 'number'
                                                    || typeof body.ethnicity !== 'number' || typeof body.country_of_origin !== 'number') {
                                        packages/optimise-core/src/controllers/userController.js on lines 76..76

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

                                        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 ((!body.hasOwnProperty('patient') || !body.hasOwnProperty('DOB') || !body.hasOwnProperty('gender') || !body.hasOwnProperty('dominant_hand')
                                                    || !body.hasOwnProperty('ethnicity') || !body.hasOwnProperty('country_of_origin'))) {
                                        packages/optimise-core/src/controllers/userController.js on lines 72..72

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

                                        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 (body.hasOwnProperty('id') && typeof body.id === 'number' &&
                                                    ((body.hasOwnProperty('immunisationDate') && typeof body.immunisationDate === 'string') || !body.hasOwnProperty('immunisationDate'))) {
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 233..234

                                        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 (body.hasOwnProperty('visitId') && typeof body.visitId !== 'number') {
                                                    res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                                                    return;
                                                }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 396..399

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

                                        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 ((body.hasOwnProperty('outcome') && typeof body.outcome !== 'number')) {
                                                        res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
                                                        return;
                                                    }
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 505..508

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

                                        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

                                                const entryObj = {
                                                    recordedDuringVisit: body.visitId,
                                                    offsprings: body.offsprings,
                                                    type: body.type,
                                                    pregnancyId: body.pregnancyId,
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 95..101

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

                                                    const entryObj = {
                                                        patient: body.patient,
                                                        relation: body.relation,
                                                        outcome: body.outcome,
                                                        conditionName: body.conditionName,
                                        packages/optimise-core/src/controllers/demographicDataController.js on lines 606..612

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

                                                if (!body.hasOwnProperty('id')) {
                                                    res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                                                    return;
                                                }
                                        packages/optimise-core/src/controllers/ceController.js on lines 56..59
                                        packages/optimise-core/src/controllers/comorbidityController.js on lines 8..11
                                        packages/optimise-core/src/controllers/testController.js on lines 49..52
                                        packages/optimise-core/src/controllers/treatmentController.js on lines 133..136
                                        packages/optimise-core/src/controllers/userController.js on lines 158..161
                                        packages/optimise-core/src/controllers/visitController.js on lines 19..22
                                        packages/optimise-core/src/controllers/visitController.js on lines 62..65
                                        packages/optimise-core/src/controllers/visitController.js on lines 88..91

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

                                        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