From 4ba950e5350b35f8a5fad00f84c15a144d216f4a Mon Sep 17 00:00:00 2001 From: BogdanScherban Date: Tue, 23 Jul 2019 15:32:07 +0300 Subject: [PATCH 1/3] changes 2019-07-23 --- .../ResourseTemplates/CreateTemplate.js | 6 +- .../common/ResourseTemplates/ListTemplate.js | 15 +++- .../fragments/CustomDatagridRow.js | 22 ++++- .../fragments/TableContent.js | 14 --- src/core/common/Toolbars/CreateFormToolbar.js | 17 +++- .../AdvancedSearchDialog.js | 13 +-- src/core/dataProviders/patientsProvider.js | 85 +++++++++++++++++-- .../fragments/EventsTimeline.js | 6 -- src/core/pages/PatientsList/PatientShow.js | 12 ++- .../PatientsList/fragments/DatagridRow.js | 2 - .../templates/PatientListTemplate.js | 18 ++-- 11 files changed, 144 insertions(+), 66 deletions(-) diff --git a/src/core/common/ResourseTemplates/CreateTemplate.js b/src/core/common/ResourseTemplates/CreateTemplate.js index 84e88b16..b3e330bb 100644 --- a/src/core/common/ResourseTemplates/CreateTemplate.js +++ b/src/core/common/ResourseTemplates/CreateTemplate.js @@ -54,13 +54,15 @@ const styles = theme => ({ * @author Bogdan Shcherban * @param {shape} classes * @param {boolean} isCustom + * @param {string} resourceUrl + * @param {shape} history * @param {boolean} isListOpened * @param {func} toggleListBlock * @param {string} blockTitle * @param {shape} children * @param {shape} rest */ -const CreateTemplate = ({ classes, isCustom, isListOpened, toggleListBlock, blockTitle, children, ...rest }) => ( +const CreateTemplate = ({ classes, isCustom, resourceUrl, history, isListOpened, toggleListBlock, blockTitle, children, ...rest }) => (
{blockTitle} @@ -74,7 +76,7 @@ const CreateTemplate = ({ classes, isCustom, isListOpened, toggleListBlock, bloc { !isCustom ? - }> + }> {children} diff --git a/src/core/common/ResourseTemplates/ListTemplate.js b/src/core/common/ResourseTemplates/ListTemplate.js index 9d5d9062..17bed527 100644 --- a/src/core/common/ResourseTemplates/ListTemplate.js +++ b/src/core/common/ResourseTemplates/ListTemplate.js @@ -138,7 +138,14 @@ class ListTemplate extends Component { * @return {string} */ getCreateUrl = () => { - return "/" + this.props.resourceUrl + "/create"; + let currentPage = null; + const search = get(this.props, 'location.search', null); + if (search) { + const params = new URLSearchParams(search); + currentPage = params.get('page'); + } + let createPage = "/" + this.props.resourceUrl + "/create"; + return currentPage ? (createPage + "?page=" + currentPage + "&perPage=10") : createPage; }; /** @@ -158,7 +165,8 @@ class ListTemplate extends Component { * @return {string} */ isCreatePage = () => { - return (this.props.location.pathname === this.getCreateUrl()); + const defaultCreateUrl = "/" + this.props.resourceUrl + "/create"; + return (this.props.location.pathname === defaultCreateUrl); }; /** @@ -327,6 +335,7 @@ class ListTemplate extends Component { ]; const CreateBlock = create; const createUrl = this.getCreateUrl(); + const defaultCreateUrl = "/" + this.props.resourceUrl + "/create"; let titleTable = title; @@ -418,7 +427,7 @@ class ListTemplate extends Component { /> : } /> } diff --git a/src/core/common/ResourseTemplates/fragments/CustomDatagridRow.js b/src/core/common/ResourseTemplates/fragments/CustomDatagridRow.js index 00165c0c..a33f1ef2 100644 --- a/src/core/common/ResourseTemplates/fragments/CustomDatagridRow.js +++ b/src/core/common/ResourseTemplates/fragments/CustomDatagridRow.js @@ -1,5 +1,6 @@ import React, { Component } from "react"; import get from "lodash/get"; +import {Datagrid, DatagridRow} from 'react-admin'; import { withStyles } from "@material-ui/core/styles"; import TableRow from '@material-ui/core/TableRow'; @@ -32,12 +33,29 @@ class CustomDatagridRow extends Component { return id === sourceId; }; + getCurrentPage = () => { + const { location } = this.props; + let result = 1; + const search = get(location, 'search', null); + if (search) { + const params = new URLSearchParams(search); + result = params.get('page'); + } + return result; + }; + + getUrl = () => { + const { id, basePath } = this.props; + const currentPage = this.getCurrentPage(); + return (currentPage > 1) ? (basePath + '/' + id + '?page=' + currentPage + '&perPage=10') : (basePath + '/' + id); + }; + render() { - const { classes, record, id, history, basePath, children } = this.props; + const { classes, record, history, children } = this.props; if (!record) { return null; } - const detailsPath = basePath + '/' + id; + const detailsPath = this.getUrl(); const isActiveRow = this.isActiveRow(); return ( history.push(detailsPath)}> diff --git a/src/core/common/ResourseTemplates/fragments/TableContent.js b/src/core/common/ResourseTemplates/fragments/TableContent.js index 2feb04a8..324811fa 100644 --- a/src/core/common/ResourseTemplates/fragments/TableContent.js +++ b/src/core/common/ResourseTemplates/fragments/TableContent.js @@ -48,18 +48,6 @@ const styles = theme => ({ } }); - -function getPath(id, basePath, record) { - - console.log('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') - console.log('id', id); - console.log('basePath', basePath); - console.log('record', record); - - return 'show' - -} - const CustomDatagridBody = ({ CustomRow, location, hiddenColumns, history, ...rest }) => { return ( { return ( getPath(id, basePath, record)} body={ getPath(id, basePath, record)} {...rest} > {children} diff --git a/src/core/common/Toolbars/CreateFormToolbar.js b/src/core/common/Toolbars/CreateFormToolbar.js index d4dc443b..c122581e 100644 --- a/src/core/common/Toolbars/CreateFormToolbar.js +++ b/src/core/common/Toolbars/CreateFormToolbar.js @@ -5,6 +5,8 @@ import { withStyles } from '@material-ui/core/styles'; import BlockIcon from '@material-ui/icons/Block'; import CustomSaveButton from "../../common/Buttons/CustomSaveButton"; +import Tooltip from "@material-ui/core/Tooltip"; +import IconButton from "@material-ui/core/IconButton"; const styles = theme => ({ listButton: { @@ -43,13 +45,20 @@ const styles = theme => ({ * This component returns toolbar without delete button for create forms * * @author Bogdan Shcherban - * @param {shape} classes - * @param {shape} props + * @param {shape} classes + * @param {string} resourceUrl + * @param {shape} history + * @param {shape} props */ -const CreateFormToolbar = ({ classes, ...props}) => { +const CreateFormToolbar = ({ classes, resourceUrl, history, ...props}) => { return ( - } className={classes.listButton} /> + + history.push('/' + resourceUrl)}> + + Cancel + + ); diff --git a/src/core/common/Topbar/fragments/AdvancedUserSearch/AdvancedSearchDialog.js b/src/core/common/Topbar/fragments/AdvancedUserSearch/AdvancedSearchDialog.js index 5a7ee6a3..db2733c7 100644 --- a/src/core/common/Topbar/fragments/AdvancedUserSearch/AdvancedSearchDialog.js +++ b/src/core/common/Topbar/fragments/AdvancedUserSearch/AdvancedSearchDialog.js @@ -126,18 +126,7 @@ class AdvancedSearchDialog extends Component { this.props.removeUserSearch(); this.props.removeClinicalQuery(); this.props.setAdvancedSearch(advancedSearchData); - - if (nhsNumber) { - this.props.setUserId(nhsNumber); - } else if (lastName) { - this.props.setUserSearch(lastName.toLowerCase()); - } else if (searchDateOfBirth) { - this.props.setSearchType('by_birthdate', searchDateOfBirth); - } else if (gender) { - this.props.setSearchType('by_gender', gender); - } else if (age) { - this.props.setSearchType('by_age', age); - } + this.props.setSearchType('advanced', advancedSearchData); window.location.replace('/#/patients'); this.props.onClose(); diff --git a/src/core/dataProviders/patientsProvider.js b/src/core/dataProviders/patientsProvider.js index 8b86fa98..078bc475 100644 --- a/src/core/dataProviders/patientsProvider.js +++ b/src/core/dataProviders/patientsProvider.js @@ -49,12 +49,12 @@ function getRequestUrl(params) { let result = null; if (searchType === 'id') { result = `${domainName}/mpi/Patient/${search}`; + } else if (searchType === 'by_city' && search) { + result = `${domainName}/mpi/Patient/search/searchByCity`; } else if (searchType === 'clinicalQuery' && clinicalSearchType) { result = `${domainName}/api/patient/clinicalSearch/${clinicalSearchType}`; - } else if (searchType === 'by_age' && search) { - result = `${domainName}/mpi/Patient/search/advanced?type=by_age&from=${search[0]}&to=${search[1]}`; - } else if (searchType !== 'name' && search) { - result = `${domainName}/mpi/Patient/search/advanced?type=${searchType}&value=${search.toLowerCase()}`; + } else if ((searchType === 'by_age' || searchType !== 'name') && search) { + result = `${domainName}/mpi/Patient/search/advanced`; } else if (search) { result = `${domainName}/mpi/Patient?name=${search}`; } @@ -63,14 +63,45 @@ function getRequestUrl(params) { function getRequestMethod(params) { const isClinicalQuery = get(params, 'filter.clinicalQuery', null); - return isClinicalQuery ? 'POST' : 'GET'; + const searchType = get(params, 'filter.filterType', null); + const isSearchByCity = (searchType === 'by_city'); + const isSearchByAge = (searchType === 'by_age'); + const isAdvancedSearch = (searchType === 'advanced'); + return (isClinicalQuery || isSearchByCity || isSearchByAge || isAdvancedSearch) ? 'POST' : 'GET'; } -function getRequestBody(params) { - const isClinicalQuery = get(params, 'filter.clinicalQuery', null); - if (!isClinicalQuery) { - return null; +function getAdvancedSearchBody(params) { + const searchParams = get(params, 'filter.filterText', null); + const nhsNumber = get(searchParams, 'nhsNumber', null); + const firstName = get(searchParams, 'firstName', null); + const lastName = get(searchParams, 'lastName', null); + const gender = get(searchParams, 'gender', null); + const birthDate = get(searchParams, 'dateOfBirth', null); + const from = get(searchParams, 'minAge', 0); + const to = get(searchParams, 'maxAge', 100); + let requestBody = {}; + if (birthDate) { + requestBody = { + nhsNumber: nhsNumber, + firstName: firstName, + lastName : lastName, + gender: gender, + birthDate: birthDate + } + } else { + requestBody = { + from: from, + to: to, + nhsNumber: nhsNumber, + firstName: firstName, + lastName : lastName, + gender: gender, + } } + return requestBody; +} + +function getClinicalQueryBody(params) { let requestBody = { query: get(params, 'filter.clinicalQuery.searchValue', null), gender: get(params, 'filter.clinicalQuery.gender', null), @@ -84,6 +115,38 @@ function getRequestBody(params) { requestBody.from = from; requestBody.to = to; } + return requestBody; +} + +function getRequestBody(params) { + + const isClinicalQuery = get(params, 'filter.clinicalQuery', null); + const searchType = get(params, 'filter.filterType', null); + const isSearchByCity = (searchType === 'by_city'); + const isSearchByAge = (searchType === 'by_age'); + const isAdvancedSearch = (searchType === 'advanced'); + + if (!isClinicalQuery && !isSearchByCity && !isSearchByAge && !isAdvancedSearch) { + return null; + } + + let requestBody = {}; + if (isClinicalQuery) { + requestBody = getClinicalQueryBody(params); + } else if (isSearchByCity) { + requestBody = { + city: get(params, 'filter.filterText', null), + } + } else if (isAdvancedSearch) { + requestBody = getAdvancedSearchBody(params); + } else if (isSearchByAge) { + const ageRange = get(params, 'filter.filterText', [0, 100]); + requestBody = { + from: ageRange[0], + to: ageRange[1], + }; + } + return JSON.stringify(requestBody); } @@ -405,6 +468,10 @@ function getSortedResults(results, params) { export default (type, resource, params) => { let { url, options } = convertPatientsDataRequestToHTTP(type, resource, params); + if (!url) { + return null; + } + let responseInfo = {}; return fetch(url, options).then(response => { responseInfo.status = get(response, 'status', null); diff --git a/src/core/pages/PatientSummary/fragments/EventsTimeline.js b/src/core/pages/PatientSummary/fragments/EventsTimeline.js index be58048e..8c54de03 100644 --- a/src/core/pages/PatientSummary/fragments/EventsTimeline.js +++ b/src/core/pages/PatientSummary/fragments/EventsTimeline.js @@ -79,13 +79,8 @@ const CustomHeader = ({ classes, items }) => { const dateAndTime = items[0]; const events = items[1]; - - console.log('dateAndTime', dateAndTime) - const dateForPoint = moment.unix(dateAndTime).format('Do MMM') - console.log('dateForPoint', dateForPoint) - // Use your own CSS return ( @@ -165,7 +160,6 @@ const EventsTimeline = ({ classes }) => { const eventsGroupByDateArray = Object.entries(eventsGroupByDate); - console.log('eventsGroupByDate', eventsGroupByDate) return (
diff --git a/src/core/pages/PatientsList/PatientShow.js b/src/core/pages/PatientsList/PatientShow.js index 057ee8b3..1051afc3 100644 --- a/src/core/pages/PatientsList/PatientShow.js +++ b/src/core/pages/PatientsList/PatientShow.js @@ -20,10 +20,16 @@ const styles = { */ const PatientShow = ({ classes, ...rest }) => ( - - + + + - + + + + + + ); diff --git a/src/core/pages/PatientsList/fragments/DatagridRow.js b/src/core/pages/PatientsList/fragments/DatagridRow.js index 0d077c6d..a86ffcf1 100644 --- a/src/core/pages/PatientsList/fragments/DatagridRow.js +++ b/src/core/pages/PatientsList/fragments/DatagridRow.js @@ -100,8 +100,6 @@ class PatientDatagridRow extends Component { const isPermissionRequired = get(themeCommonElements, 'patientSummaryPermission', false); const open = Boolean(anchorEl); - console.log('record', record) - return ( diff --git a/src/core/pages/PatientsList/templates/PatientListTemplate.js b/src/core/pages/PatientsList/templates/PatientListTemplate.js index 8c096183..623cd535 100644 --- a/src/core/pages/PatientsList/templates/PatientListTemplate.js +++ b/src/core/pages/PatientsList/templates/PatientListTemplate.js @@ -281,6 +281,8 @@ class ListTemplate extends Component { if (defaultHiddenColumns) { this.props.updateTableHead(); } + + } componentWillReceiveProps(nextProps, nextContext) { @@ -361,18 +363,16 @@ class ListTemplate extends Component { }; getTitleForAdvancedSearh = (userSearchType, userSearchValue) => { + + console.log('userSearchType', userSearchType) + console.log('userSearchValue', userSearchValue) + let result = ''; - if (userSearchType === 'by_gender') { - result = `Patients search by Gender: ${userSearchValue}`; - } - if (userSearchType === 'by_birthdate') { - result = `Patients search by Birthdate: ${userSearchValue}`; - } if (userSearchType === 'by_city') { result = `Patients search by City: ${userSearchValue}`; } - if (userSearchType === 'by_age') { - result = `Patients search by Age: ${userSearchValue[0]}-${userSearchValue[1]}`; + if (userSearchType === 'advanced') { + result = userSearchValue.title; } return result; }; @@ -546,4 +546,4 @@ const mapDispatchToProps = dispatch => { } }; -export default connect(mapStateToProps, mapDispatchToProps)(withStyles(listStyles)(ListTemplate)); \ No newline at end of file +export default connect(mapStateToProps, mapDispatchToProps)(withStyles(listStyles)(ListTemplate)); From be34246b54c273edccfaeb3cc7d8a33c64a14cef Mon Sep 17 00:00:00 2001 From: BogdanScherban Date: Tue, 23 Jul 2019 15:40:41 +0300 Subject: [PATCH 2/3] changes 2019-07-23 --- .../pages/PatientsList/templates/PatientListTemplate.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/core/pages/PatientsList/templates/PatientListTemplate.js b/src/core/pages/PatientsList/templates/PatientListTemplate.js index 623cd535..b6943309 100644 --- a/src/core/pages/PatientsList/templates/PatientListTemplate.js +++ b/src/core/pages/PatientsList/templates/PatientListTemplate.js @@ -281,8 +281,6 @@ class ListTemplate extends Component { if (defaultHiddenColumns) { this.props.updateTableHead(); } - - } componentWillReceiveProps(nextProps, nextContext) { @@ -363,10 +361,6 @@ class ListTemplate extends Component { }; getTitleForAdvancedSearh = (userSearchType, userSearchValue) => { - - console.log('userSearchType', userSearchType) - console.log('userSearchValue', userSearchValue) - let result = ''; if (userSearchType === 'by_city') { result = `Patients search by City: ${userSearchValue}`; From fe2b4fc3af84f563056b5607f842c03426a5bee6 Mon Sep 17 00:00:00 2001 From: BogdanScherban Date: Wed, 24 Jul 2019 11:13:03 +0300 Subject: [PATCH 3/3] fix --- src/core/pages/PatientsList/templates/PatientListTemplate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/pages/PatientsList/templates/PatientListTemplate.js b/src/core/pages/PatientsList/templates/PatientListTemplate.js index b6943309..f5f68c77 100644 --- a/src/core/pages/PatientsList/templates/PatientListTemplate.js +++ b/src/core/pages/PatientsList/templates/PatientListTemplate.js @@ -33,7 +33,7 @@ import ColumnsTogglingIcon from "../../../common/ResourseTemplates/icons/Columns const listStyles = theme => ({ container: { - width: '100vw', + width: '100%', height: '100%', background: theme.patientSummaryPanel.container.background, backgroundSize: "cover",