{"action":"created","comment":{"url":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/comments/197653685","pull_request_review_id":131437328,"id":197653685,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzY1MzY4NQ==","diff_hunk":"@@ -1,55 +1,59 @@\n-const {isEmptyObject, validateAndFormatDate} = require('../utils/basic-utils');\n-const {createEntry, deleteEntry, updateEntry} = require('../utils/controller-utils');\n+const { isEmptyObject, validateAndFormatDate } = require('../utils/basic-utils');\n+const { createEntry, deleteEntry } = require('../utils/controller-utils');\n const knex = require('../utils/db-connection');\n \n class VisitController {\n     static getVisitsOfPatient(req, res){\n-        if (!isEmptyObject(req.query) && Object.keys(req.query).length === 1 && typeof(req.query.patientId) === 'string') {\n-            knex('patients')\n-                .select({patientId:'patients.id'}, 'patients.alias_id', {visitId: 'visits.id'}, 'visits.visit_date')\n-                .leftOuterJoin('visits', 'patients.id', 'visits.patient')\n-                .where({'patients.alias_id': req.query.patientId, 'visits.deleted': 0})\n-                .then(result => res.status(200).json(result))\n+        if (!isEmptyObject(req.query) && Object.keys(req.query).length === 1 && typeof (req.query.patientId) === 'string') {\n+            knex('PATIENTS')\n+                .select({ patientId: 'PATIENTS.id' }, 'PATIENTS.aliasId', { visitId: 'VISITS.id' }, 'VISITS.visitDate')\n+                .leftOuterJoin('VISITS', 'PATIENTS.id', 'VISITS.patient')\n+                .where({ 'PATIENTS.aliasId': req.query.patientId, 'VISITS.deleted': '-' })\n+                .then(result => res.status(200).json(result));\n         } else {\n             res.status(400).send('The query string must have one and only one parameter \"patientId\"');\n         }\n     }\n \n     static createVisit(req, res){\n         if (req.body.patientId && req.body.visitDate && validateAndFormatDate(req.body.visitDate)){\n-            knex('patients')\n+            knex('PATIENTS')\n                 .select('id')\n-                .where({'alias_id': req.body.patientId, 'deleted': 0})\n+                .where({ 'aliasId': req.body.patientId, 'deleted': '-' })\n                 .then(result => {\n                     if (result.length === 0) {\n-                        res.status(404).send(\"Can't seem to find your patient!\");\n+                        res.status(404).send('Can\\'t seem to find your patient!');\n                     } else if (result.length === 1) {\n-                        const entryObj = {'patient': result[0]['id'], 'visit_date': validateAndFormatDate(req.body.visitDate)};\n-                        createEntry(req, res, 'visits', entryObj, 'Error. Visit might already exists.')\n+                        const entryObj = { 'patient': result[0]['id'], 'visitDate': validateAndFormatDate(req.body.visitDate) };\n+                        if (req.body.type && typeof (req.body.type) === 'number')\n+                            entryObj.type = req.body.type;\n+                        createEntry(req, res, 'VISITS', entryObj, 'Error. Visit might already exists.');\n                     } else {\n                         res.status(500).send('Database error');\n                     }\n-                })\n+                });\n         } else {\n             res.status(400).send('Error. Please provide the suitable parameters.');\n         }\n     }\n \n     static deleteVisit(req, res){\n-        if (req.requester.priv === 1 && req.body.patientId && req.body.visitDate && validateAndFormatDate(req.body.visitDate)) {\n-            knex('patients')\n+        if (req.requester.priv !== 1)\n+            console.log('BAD PRIVILEDGES');","path":"src/controllers/visitController.js","position":58,"original_position":58,"commit_id":"e2718b4fefad18c7f9f92cfafd65088717ba313c","original_commit_id":"e2718b4fefad18c7f9f92cfafd65088717ba313c","user":{"login":"codacy-bot","id":19940114,"node_id":"MDQ6VXNlcjE5OTQwMTE0","avatar_url":"https://avatars1.githubusercontent.com/u/19940114?v=4","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://app.codacy.com/assets/images/favicon.png) Issue found: [Unexpected console statement. (no-console)](https://app.codacy.com/app/dsi-icl/optimise-core/pullRequest?prid=1818280)","created_at":"2018-06-24T21:37:19Z","updated_at":"2018-06-24T21:37:20Z","html_url":"https://github.com/dsi-icl/optimise-core/pull/27#discussion_r197653685","pull_request_url":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/27","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/comments/197653685"},"html":{"href":"https://github.com/dsi-icl/optimise-core/pull/27#discussion_r197653685"},"pull_request":{"href":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/27","id":196906540,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2OTA2NTQw","html_url":"https://github.com/dsi-icl/optimise-core/pull/27","diff_url":"https://github.com/dsi-icl/optimise-core/pull/27.diff","patch_url":"https://github.com/dsi-icl/optimise-core/pull/27.patch","issue_url":"https://api.github.com/repos/dsi-icl/optimise-core/issues/27","number":27,"state":"open","locked":false,"title":"automatic db creation and seeding, and testing (WIP)","user":{"login":"sou-c","id":35537528,"node_id":"MDQ6VXNlcjM1NTM3NTI4","avatar_url":"https://avatars3.githubusercontent.com/u/35537528?v=4","gravatar_id":"","url":"https://api.github.com/users/sou-c","html_url":"https://github.com/sou-c","followers_url":"https://api.github.com/users/sou-c/followers","following_url":"https://api.github.com/users/sou-c/following{/other_user}","gists_url":"https://api.github.com/users/sou-c/gists{/gist_id}","starred_url":"https://api.github.com/users/sou-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sou-c/subscriptions","organizations_url":"https://api.github.com/users/sou-c/orgs","repos_url":"https://api.github.com/users/sou-c/repos","events_url":"https://api.github.com/users/sou-c/events{/privacy}","received_events_url":"https://api.github.com/users/sou-c/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-23T15:10:50Z","updated_at":"2018-06-24T21:37:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"678cc7e6541984af3bbc71dde847a3d4bace75a8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/27/commits","review_comments_url":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/27/comments","review_comment_url":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dsi-icl/optimise-core/issues/27/comments","statuses_url":"https://api.github.com/repos/dsi-icl/optimise-core/statuses/e2718b4fefad18c7f9f92cfafd65088717ba313c","head":{"label":"dsi-icl:rebase-controller","ref":"rebase-controller","sha":"e2718b4fefad18c7f9f92cfafd65088717ba313c","user":{"login":"dsi-icl","id":22317045,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzE3MDQ1","avatar_url":"https://avatars1.githubusercontent.com/u/22317045?v=4","gravatar_id":"","url":"https://api.github.com/users/dsi-icl","html_url":"https://github.com/dsi-icl","followers_url":"https://api.github.com/users/dsi-icl/followers","following_url":"https://api.github.com/users/dsi-icl/following{/other_user}","gists_url":"https://api.github.com/users/dsi-icl/gists{/gist_id}","starred_url":"https://api.github.com/users/dsi-icl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsi-icl/subscriptions","organizations_url":"https://api.github.com/users/dsi-icl/orgs","repos_url":"https://api.github.com/users/dsi-icl/repos","events_url":"https://api.github.com/users/dsi-icl/events{/privacy}","received_events_url":"https://api.github.com/users/dsi-icl/received_events","type":"Organization","site_admin":false},"repo":{"id":134406398,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQ0MDYzOTg=","name":"optimise-core","full_name":"dsi-icl/optimise-core","owner":{"login":"dsi-icl","id":22317045,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzE3MDQ1","avatar_url":"https://avatars1.githubusercontent.com/u/22317045?v=4","gravatar_id":"","url":"https://api.github.com/users/dsi-icl","html_url":"https://github.com/dsi-icl","followers_url":"https://api.github.com/users/dsi-icl/followers","following_url":"https://api.github.com/users/dsi-icl/following{/other_user}","gists_url":"https://api.github.com/users/dsi-icl/gists{/gist_id}","starred_url":"https://api.github.com/users/dsi-icl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsi-icl/subscriptions","organizations_url":"https://api.github.com/users/dsi-icl/orgs","repos_url":"https://api.github.com/users/dsi-icl/repos","events_url":"https://api.github.com/users/dsi-icl/events{/privacy}","received_events_url":"https://api.github.com/users/dsi-icl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dsi-icl/optimise-core","description":"Backend for OptimiseMS","fork":false,"url":"https://api.github.com/repos/dsi-icl/optimise-core","forks_url":"https://api.github.com/repos/dsi-icl/optimise-core/forks","keys_url":"https://api.github.com/repos/dsi-icl/optimise-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dsi-icl/optimise-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dsi-icl/optimise-core/teams","hooks_url":"https://api.github.com/repos/dsi-icl/optimise-core/hooks","issue_events_url":"https://api.github.com/repos/dsi-icl/optimise-core/issues/events{/number}","events_url":"https://api.github.com/repos/dsi-icl/optimise-core/events","assignees_url":"https://api.github.com/repos/dsi-icl/optimise-core/assignees{/user}","branches_url":"https://api.github.com/repos/dsi-icl/optimise-core/branches{/branch}","tags_url":"https://api.github.com/repos/dsi-icl/optimise-core/tags","blobs_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dsi-icl/optimise-core/statuses/{sha}","languages_url":"https://api.github.com/repos/dsi-icl/optimise-core/languages","stargazers_url":"https://api.github.com/repos/dsi-icl/optimise-core/stargazers","contributors_url":"https://api.github.com/repos/dsi-icl/optimise-core/contributors","subscribers_url":"https://api.github.com/repos/dsi-icl/optimise-core/subscribers","subscription_url":"https://api.github.com/repos/dsi-icl/optimise-core/subscription","commits_url":"https://api.github.com/repos/dsi-icl/optimise-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/dsi-icl/optimise-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/dsi-icl/optimise-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/dsi-icl/optimise-core/contents/{+path}","compare_url":"https://api.github.com/repos/dsi-icl/optimise-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dsi-icl/optimise-core/merges","archive_url":"https://api.github.com/repos/dsi-icl/optimise-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dsi-icl/optimise-core/downloads","issues_url":"https://api.github.com/repos/dsi-icl/optimise-core/issues{/number}","pulls_url":"https://api.github.com/repos/dsi-icl/optimise-core/pulls{/number}","milestones_url":"https://api.github.com/repos/dsi-icl/optimise-core/milestones{/number}","notifications_url":"https://api.github.com/repos/dsi-icl/optimise-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dsi-icl/optimise-core/labels{/name}","releases_url":"https://api.github.com/repos/dsi-icl/optimise-core/releases{/id}","deployments_url":"https://api.github.com/repos/dsi-icl/optimise-core/deployments","created_at":"2018-05-22T11:38:07Z","updated_at":"2018-06-05T11:01:48Z","pushed_at":"2018-06-24T21:35:54Z","git_url":"git://github.com/dsi-icl/optimise-core.git","ssh_url":"git@github.com:dsi-icl/optimise-core.git","clone_url":"https://github.com/dsi-icl/optimise-core.git","svn_url":"https://github.com/dsi-icl/optimise-core","homepage":"https://optimise.dsi.ic.ac.uk","size":542,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"dsi-icl:master","ref":"master","sha":"fbe9977c15ce7e41306eacf353bd67b1086b3bba","user":{"login":"dsi-icl","id":22317045,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzE3MDQ1","avatar_url":"https://avatars1.githubusercontent.com/u/22317045?v=4","gravatar_id":"","url":"https://api.github.com/users/dsi-icl","html_url":"https://github.com/dsi-icl","followers_url":"https://api.github.com/users/dsi-icl/followers","following_url":"https://api.github.com/users/dsi-icl/following{/other_user}","gists_url":"https://api.github.com/users/dsi-icl/gists{/gist_id}","starred_url":"https://api.github.com/users/dsi-icl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsi-icl/subscriptions","organizations_url":"https://api.github.com/users/dsi-icl/orgs","repos_url":"https://api.github.com/users/dsi-icl/repos","events_url":"https://api.github.com/users/dsi-icl/events{/privacy}","received_events_url":"https://api.github.com/users/dsi-icl/received_events","type":"Organization","site_admin":false},"repo":{"id":134406398,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQ0MDYzOTg=","name":"optimise-core","full_name":"dsi-icl/optimise-core","owner":{"login":"dsi-icl","id":22317045,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzE3MDQ1","avatar_url":"https://avatars1.githubusercontent.com/u/22317045?v=4","gravatar_id":"","url":"https://api.github.com/users/dsi-icl","html_url":"https://github.com/dsi-icl","followers_url":"https://api.github.com/users/dsi-icl/followers","following_url":"https://api.github.com/users/dsi-icl/following{/other_user}","gists_url":"https://api.github.com/users/dsi-icl/gists{/gist_id}","starred_url":"https://api.github.com/users/dsi-icl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsi-icl/subscriptions","organizations_url":"https://api.github.com/users/dsi-icl/orgs","repos_url":"https://api.github.com/users/dsi-icl/repos","events_url":"https://api.github.com/users/dsi-icl/events{/privacy}","received_events_url":"https://api.github.com/users/dsi-icl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dsi-icl/optimise-core","description":"Backend for OptimiseMS","fork":false,"url":"https://api.github.com/repos/dsi-icl/optimise-core","forks_url":"https://api.github.com/repos/dsi-icl/optimise-core/forks","keys_url":"https://api.github.com/repos/dsi-icl/optimise-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dsi-icl/optimise-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dsi-icl/optimise-core/teams","hooks_url":"https://api.github.com/repos/dsi-icl/optimise-core/hooks","issue_events_url":"https://api.github.com/repos/dsi-icl/optimise-core/issues/events{/number}","events_url":"https://api.github.com/repos/dsi-icl/optimise-core/events","assignees_url":"https://api.github.com/repos/dsi-icl/optimise-core/assignees{/user}","branches_url":"https://api.github.com/repos/dsi-icl/optimise-core/branches{/branch}","tags_url":"https://api.github.com/repos/dsi-icl/optimise-core/tags","blobs_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dsi-icl/optimise-core/statuses/{sha}","languages_url":"https://api.github.com/repos/dsi-icl/optimise-core/languages","stargazers_url":"https://api.github.com/repos/dsi-icl/optimise-core/stargazers","contributors_url":"https://api.github.com/repos/dsi-icl/optimise-core/contributors","subscribers_url":"https://api.github.com/repos/dsi-icl/optimise-core/subscribers","subscription_url":"https://api.github.com/repos/dsi-icl/optimise-core/subscription","commits_url":"https://api.github.com/repos/dsi-icl/optimise-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/dsi-icl/optimise-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/dsi-icl/optimise-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/dsi-icl/optimise-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/dsi-icl/optimise-core/contents/{+path}","compare_url":"https://api.github.com/repos/dsi-icl/optimise-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dsi-icl/optimise-core/merges","archive_url":"https://api.github.com/repos/dsi-icl/optimise-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dsi-icl/optimise-core/downloads","issues_url":"https://api.github.com/repos/dsi-icl/optimise-core/issues{/number}","pulls_url":"https://api.github.com/repos/dsi-icl/optimise-core/pulls{/number}","milestones_url":"https://api.github.com/repos/dsi-icl/optimise-core/milestones{/number}","notifications_url":"https://api.github.com/repos/dsi-icl/optimise-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dsi-icl/optimise-core/labels{/name}","releases_url":"https://api.github.com/repos/dsi-icl/optimise-core/releases{/id}","deployments_url":"https://api.github.com/repos/dsi-icl/optimise-core/deployments","created_at":"2018-05-22T11:38:07Z","updated_at":"2018-06-05T11:01:48Z","pushed_at":"2018-06-24T21:35:54Z","git_url":"git://github.com/dsi-icl/optimise-core.git","ssh_url":"git@github.com:dsi-icl/optimise-core.git","clone_url":"https://github.com/dsi-icl/optimise-core.git","svn_url":"https://github.com/dsi-icl/optimise-core","homepage":"https://optimise.dsi.ic.ac.uk","size":542,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/27"},"html":{"href":"https://github.com/dsi-icl/optimise-core/pull/27"},"issue":{"href":"https://api.github.com/repos/dsi-icl/optimise-core/issues/27"},"comments":{"href":"https://api.github.com/repos/dsi-icl/optimise-core/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dsi-icl/optimise-core/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/dsi-icl/optimise-core/statuses/e2718b4fefad18c7f9f92cfafd65088717ba313c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"codacy-bot"}}