dsi-icl/optimise

View on GitHub

Showing 380 of 1,390 total issues

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

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

          static async createSync({ body: { data, uuid, agent, key }, headers, connection }, res) {
      
              if (data === undefined || uuid === undefined) {
                  res.status(401).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                  return;
      Severity: Minor
      Found in packages/optimise-sync/src/controllers/syncController.js - About 1 hr to fix

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

            _handleSubmit(ev) {
        
                ev.preventDefault();
                if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
                    return;

          Function changeRights has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static changeRights(wsEndpoint) {
                  return async function ({ user, body }, res) {
                      if (user.adminPriv !== 1) {
                          const remoteControlOpened = await new Promise((resolve) => {
                              const ws = new WebSocket(wsEndpoint, {
          Severity: Minor
          Found in packages/optimise-core/src/controllers/userController.js - About 1 hr to fix

            Function _findDateRange has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _findDateRange(date, entryType) {
            
                    let pregnancies = Array.from(this.props.data.pregnancy);
            
                    let currentPregnancy;

              Function render has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  render() {
                      const { match: { params }, patientProfile: { visits } } = this.props;
                      if (visits === undefined)
                          return null;
                      const visitFiltered = visits.filter(el => parseInt(params.visitId) === el.id);

                Function render has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    render() {
                        const { editing } = this.state;
                        const { data, typedict } = this.props;
                        return (
                            <div className={style.interruption} style={{

                  Consider simplifying this complex logical expression.
                  Open

                          if (body.hasOwnProperty('treatmentInterId') && typeof body.treatmentInterId === 'number' &&
                              body.hasOwnProperty('start_date') && typeof body.start_date === 'string') {
                              const momentStart = body.hasOwnProperty('start_date') && body.start_date !== null ? moment(body.start_date, moment.ISO_8601) : null;
                              const momentEnd = body.hasOwnProperty('end_date') && body.end_date !== null ? moment(body.end_date, moment.ISO_8601) : null;
                              if (momentStart !== null && !momentStart.isValid()) {
                  Severity: Critical
                  Found in packages/optimise-core/src/controllers/treatmentController.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

                      Consider simplifying this complex logical expression.
                      Open

                                  if ((this.props.filter.visits && this.props.visitType === 1) ||
                                      (this.props.filter.tests && visitHasTests) ||
                                      (this.props.filter.treatments && visitHasMedications) ||
                                      (this.props.filter.events && visitHasClinicalEvents))
                                      shouldRender = true;
                      Severity: Critical
                      Found in packages/optimise-ui/src/components/patientProfile/patientChart.jsx - 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 render has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              render() {
                          
                                  if (this.props.data.demographicData) {
                                      if (this.props.data.demographicData.gender === 1)
                                          return null;

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

                                render() {
                                    const { data, searchString } = this.props;
                                    const ind = data.aliasId.toLowerCase().indexOf(searchString.toLowerCase());
                                    const styledName = (
                                        <span>
                            Severity: Minor
                            Found in packages/optimise-ui/src/components/searchPatient/searchPatient.jsx - 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 migrate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export async function migrate() {
                                
                                    const db = await dbcon().then(client => client.db());
                                
                                    // // Verify the OPT_KV configuration table exists
                                Severity: Minor
                                Found in packages/optimise-sync/src/utils/db-handler.js - About 1 hr to fix

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

                                  export async function migrate() {
                                  
                                      const db = await dbcon().then(client => client.db());
                                  
                                      // // Verify the OPT_KV configuration table exists
                                  Severity: Minor
                                  Found in packages/optimise-remote-control/src/utils/db-handler.js - About 1 hr to fix

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

                                    export const alterPregnancyItemsCall = (body, callback) => async (dispatch) => {
                                        try {
                                            //if pregnancy entry needs to be created and entry type is 1 (baseline) then new pregnancy needs to be created
                                    
                                            const pregnancyMethod = body.pregnancyEntry?.type === 1 && !body.pregnancy.id ? 'POST' : 'PUT';
                                    Severity: Minor
                                    Found in packages/optimise-ui/src/redux/actions/demographicData.js - About 1 hr to fix

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

                                          render() {
                                              const { data } = this.props;
                                              const { userId } = this.props.match.params;
                                              if (!data.fetching) {
                                                  const usersFiltered = data.result.filter(el => el.id === parseInt(userId, 10));
                                      Severity: Minor
                                      Found in packages/optimise-ui/src/components/admin/userDetailPage.jsx - About 1 hr to fix

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

                                        const filterEmptyRenders = (allFields, inputType, typedict) => allFields.map(data => {
                                        
                                            const toTitleCase = (str) => str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
                                        
                                            let value;
                                        Severity: Minor
                                        Found in packages/optimise-ui/src/components/patientProfile/patientChart.jsx - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language