diff --git a/packages/esm-commons-lib/src/index.ts b/packages/esm-commons-lib/src/index.ts index 29c2377a7..21be16992 100644 --- a/packages/esm-commons-lib/src/index.ts +++ b/packages/esm-commons-lib/src/index.ts @@ -53,6 +53,8 @@ export * from './hooks/useLastEncounter'; export * from './utils/encounter-list-config-builder'; export * from './utils/summary-card-config-builder'; export * from './utils/encounter-tile-config-builder'; +export * from './utils/cohort-list-config-builder'; +export * from './utils/patient-list-tabs-config-builder'; // Workspace registration moved to the index.ts and routes.json const options = { featureName: 'ohri-forms-workspace-item', diff --git a/packages/esm-commons-lib/src/utils/cohort-list-config-builder.ts b/packages/esm-commons-lib/src/utils/cohort-list-config-builder.ts new file mode 100644 index 000000000..504d8c360 --- /dev/null +++ b/packages/esm-commons-lib/src/utils/cohort-list-config-builder.ts @@ -0,0 +1,15 @@ +import { extractSchemaValues, replaceWithConfigDefaults } from './schema-manipulation'; + +export const getCohortListTabsData = (cohortTabsSchema, config) => { + const configDefaults = extractSchemaValues(config); + const transformedSchemaConfig = replaceWithConfigDefaults(cohortTabsSchema, configDefaults); + + const tabs = transformedSchemaConfig.tabDefinitions?.map((tab) => { + return { + name: tab.tabName, + cohortListData: tab.cohortContent, + }; + }); + + return tabs; +}; diff --git a/packages/esm-commons-lib/src/utils/createOHRIDashboardLink.tsx b/packages/esm-commons-lib/src/utils/createOHRIDashboardLink.tsx index d4af86fde..78ab83ce9 100644 --- a/packages/esm-commons-lib/src/utils/createOHRIDashboardLink.tsx +++ b/packages/esm-commons-lib/src/utils/createOHRIDashboardLink.tsx @@ -22,7 +22,7 @@ export const createOHRIDashboardLink = (meta) => { if (meta.isFolder) { return ( - + ); diff --git a/packages/esm-commons-lib/src/utils/patient-list-tabs-config-builder.ts b/packages/esm-commons-lib/src/utils/patient-list-tabs-config-builder.ts new file mode 100644 index 000000000..74fdd3e6d --- /dev/null +++ b/packages/esm-commons-lib/src/utils/patient-list-tabs-config-builder.ts @@ -0,0 +1,41 @@ +import { getObsFromEncounter } from './encounter-list-utils'; +import { extractSchemaValues, replaceWithConfigDefaults } from './schema-manipulation'; + +export const getPatientListTabsData = (patientListTabsSchema, config) => { + const configDefaults = extractSchemaValues(config); + const transformedSchemaConfig = replaceWithConfigDefaults(patientListTabsSchema, configDefaults); + + const tabs = transformedSchemaConfig.tabDefinitions?.map((tab) => { + const otherColumnsData = tab.otherColumns.map((column) => { + return { + key: column.id, + header: column.title, + index: column.index || null, + getValue: (row) => { + if (column.type === 'patientId') { + return row.id; + } + + if (column.type === 'lastDate') { + return '13/01/2021'; + } + + if (column.type === 'appointmentDate') { + return '03/03/2021'; + } + + const { encounter } = row; + return getObsFromEncounter(encounter, column.concept, column.isDate); + }, + }; + }); + return { + ...tab, + label: tab.tabName, + queryParams: tab.hasQueryParams ? [`value1=${new Date().toISOString().split('T')[0]}`] : null, + otherColumns: otherColumnsData, + }; + }); + + return tabs; +}; diff --git a/packages/esm-hiv-care-treatment-app/src/index.ts b/packages/esm-hiv-care-treatment-app/src/index.ts index cd60b113e..d204030da 100644 --- a/packages/esm-hiv-care-treatment-app/src/index.ts +++ b/packages/esm-hiv-care-treatment-app/src/index.ts @@ -1,9 +1,9 @@ import { defineConfigSchema, getSyncLifecycle } from '@openmrs/esm-framework'; -import ServiceSummaryOverviewList from './views/service-summary/encounter-list/service-summary-encounter-list.component'; -import ProgramManagementSummary from './views/program-management/program-management-summary.component'; -import VisitsSummary from './views/visits/visits-summary.component'; -import GeneralCounsellingSummary from './views/general-counselling/general-counselling-summary.component'; -import PartnerNotificationServices from './views/partner-notification-services/partner-notification-services.component'; +import ServiceSummaryOverviewList from './views/patient-chart/service-summary/service-summary-encounter-list.component'; +import ProgramManagementSummary from './views/patient-chart/program-management/program-management-summary.component'; +import VisitsSummary from './views/patient-chart/visits/visits-summary.component'; +import GeneralCounsellingSummary from './views/patient-chart/general-counselling/general-counselling-summary.component'; +import PartnerNotificationServices from './views/patient-chart/partner-notification-services/partner-notification-services.component'; import { createOHRIDashboardLink, PatientStatusBannerTag, diff --git a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-form-viewer.tsx b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-form-viewer.tsx deleted file mode 100644 index 006b19337..000000000 --- a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-form-viewer.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React, { useState } from 'react'; -import { launchFormWithCustomTitle } from '@ohri/openmrs-esm-ohri-commons-lib'; -import { getForm, applyFormIntent } from '@openmrs/openmrs-form-engine-lib'; -import styles from './tabs/patient-list.scss'; -import { OverflowMenu, OverflowMenuItem } from '@carbon/react'; -import { navigate, WorkspaceWindow } from '@openmrs/esm-framework'; -import { useTranslation } from 'react-i18next'; -import { moduleName } from '../../../index'; - -export interface LabresultsFormViewerProps { - patientUuid: string; - encounterUuid: string; - form?: { package: string; name: string; view?: string }; - patientUrl: string; -} - -export const LabresultsFormViewer: React.FC = ({ - patientUuid, - encounterUuid, - form, - patientUrl, -}) => { - const { t } = useTranslation(); - const [encounterForm, setEncounterForm] = useState(getForm(form.package, form.name)); - const [counter, setCounter] = useState(0); - - const forceComponentUpdate = () => setCounter(counter + 1); - const capitalize = (word) => word[0].toUpperCase() + word.substr(1); - - const launchEncounterForm = (form?: any, intent: string = '*', action: string = 'add', encounterUuid?: any) => { - const launcherTitle = `${capitalize(action)} ` + (form?.name || encounterForm?.name); - launchFormWithCustomTitle( - form || encounterForm, - moduleName, - launcherTitle, - 'view', - encounterUuid, - forceComponentUpdate, - ); - }; - return ( - <> - {encounterUuid ? ( - <> - - { - e.preventDefault(); - launchEncounterForm(applyFormIntent('*', getForm(form.package, form.name)), '*', 'view', encounterUuid); - navigate({ to: patientUrl }); - }} - /> - - - - ) : ( - <> - )} - - ); -}; diff --git a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary-tiles.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary-tiles.component.tsx deleted file mode 100644 index 1df0b10d4..000000000 --- a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary-tiles.component.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import React, { useEffect, useState, useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { OHRIProgrammeSummaryTiles, getReportingCohort } from '@ohri/openmrs-esm-ohri-commons-lib'; -import { useConfig } from '@openmrs/esm-framework'; - -function LabResultsSummaryTiles() { - const { t } = useTranslation(); - const [missingCd4Count, setMissingCd4Count] = useState(0); - const [dueForVlCount, setDueForVlCount] = useState(0); - const [highVlCount, setHighVlCount] = useState(0); - const { cohorts } = useConfig(); - - const memoizedCohorts = useMemo(() => cohorts, [cohorts]); - - useEffect(() => { - getReportingCohort(memoizedCohorts.missingCd4Cohort).then((data) => { - setMissingCd4Count(data.members.length); - }); - - getReportingCohort(memoizedCohorts.highVlCohort).then((results) => { - setHighVlCount(results.members.length); - }); - }, [memoizedCohorts.missingCd4Cohort, memoizedCohorts.highVlCohort]); - - const tiles = [ - { - title: t('missingCd4', 'Missing CD4'), - linkAddress: '#', - subTitle: t('noCd4Results', 'Patients with no CD4 result (count)'), - value: missingCd4Count, - }, - { - title: t('vlDue', 'Due for VL'), - linkAddress: '#', - subTitle: t('noVlResults', 'Patients with no VL in the last 12 months (count)'), - value: dueForVlCount, - }, - { - title: t('highVl', 'High VL'), - linkAddress: '#', - subTitle: t('highVlResults', 'Patients whose recent VL >1000 copies/ml (count)'), - value: highVlCount, - }, - ]; - - return ; -} - -export default LabResultsSummaryTiles; diff --git a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary.component.tsx deleted file mode 100644 index 61067aa41..000000000 --- a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary.component.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import React from 'react'; -import { Tabs, Tab, TabPanels, TabPanel, TabList } from '@carbon/react'; -import styles from '../lab-results/tabs/patient-list.scss'; -import CD4ResultsList from './tabs/cd4-results.component'; -import ViralLoadResultsList from './tabs/viral-load-results.component'; -import { useTranslation } from 'react-i18next'; - -interface OverviewListProps { - patientUuid: string; -} - -const LabResultsSummary: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - return ( - - - {t('cd4LabResults', 'CD4 Lab Results')} - {t('viralLoadResults', 'Viral Load Results')} - - - - - - - - - - - ); -}; - -export default LabResultsSummary; diff --git a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/tabs/cd4-results.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/tabs/cd4-results.component.tsx deleted file mode 100644 index 24f5b11c6..000000000 --- a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/tabs/cd4-results.component.tsx +++ /dev/null @@ -1,195 +0,0 @@ -import React, { useEffect, useState, useCallback } from 'react'; -import { useTranslation } from 'react-i18next'; -import { - EmptyState, - encounterRepresentation, - fetchPatientList, - getObsFromEncounter, - OTable, -} from '@ohri/openmrs-esm-ohri-commons-lib'; -import { age, navigate, openmrsFetch, useConfig } from '@openmrs/esm-framework'; -import { DataTableSkeleton, Pagination, Search } from '@carbon/react'; -import { capitalize } from 'lodash-es'; -import { Link, BrowserRouter as Router } from 'react-router-dom'; -import { LabresultsFormViewer } from '../lab-results-form-viewer'; - -import styles from './patient-list.scss'; - -interface CD4ResultsListProps { - patientUuid: string; -} - -export const filterPatientsByName = (searchTerm: string, patients: Array) => { - return patients.filter((patient) => patient.patientSearchName.toLowerCase().includes(searchTerm.toLowerCase())); -}; - -const CD4ResultsList: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - const [patients, setPatients] = useState([]); - const [patientToCd4Map, setPatientToCd4Map] = useState([]); - const [allRows, setAllRows] = useState([]); - const [filteredResults, setFilteredResults] = useState([]); - const [searchTerm, setSearchTerm] = useState(null); - const [isLoading, setIsLoading] = useState(true); - const rowCount = 5; - const [page, setPage] = useState(1); - const [pageSize, setPageSize] = useState(10); - const [totalPatientCount, setPatientCount] = useState(0); - const [nextOffSet, setNextOffSet] = useState(0); - const headerTitle = ''; - const { obsConcepts, encounterTypes } = useConfig(); - - const tableHeaders = [ - { key: 'name', header: t('patientName', 'Patient Name'), isSortable: true }, - { key: 'gender', header: t('sex', 'Sex') }, - { key: 'age', header: t('age', 'Age') }, - { key: 'cd4Result', header: t('recentCd4', 'Recent CD4') }, - { key: 'cd4ResultDate', header: t('recentCd4Date', 'Recent CD4 Date') }, - { key: 'actions', header: t('actions', 'Actions') }, - ]; - - useEffect(() => { - setIsLoading(true); - fetchPatientList(nextOffSet, pageSize).then(({ data }) => { - setPatients(data.entry); - setPatientCount(data.total); - setIsLoading(false); - }); - }, [nextOffSet, page, pageSize]); - - useEffect(() => { - let rows = []; - for (let patient of patients) { - const lastCd4Result = patientToCd4Map.find((entry) => entry.patientId === patient.resource.id)?.cd4Result; - const lastCd4ResultDate = patientToCd4Map.find((entry) => entry.patientId === patient.resource.id)?.cd4ResultDate; - const lastCd4EncounterUuid = patientToCd4Map.find((entry) => entry.patientId === patient.resource.id) - ?.cd4EncounterUuid; - const patientActions = ( - - ); - - rows.push({ - id: patient.resource.id, - name: ( - - - {`${patient.resource.name[0].given.join(' ')} ${patient.resource.name[0].family}`} - - - ), - gender: capitalize(patient.resource.gender), - age: age(patient.resource.birthDate), - cd4Result: lastCd4Result ? lastCd4Result : '--', - cd4ResultDate: lastCd4ResultDate ? lastCd4ResultDate : '--', - actions: patientActions, - patientSearchName: `${patient.resource.name[0].given.join(' ')} ${patient.resource.name[0].family}`, - }); - } - setAllRows(rows); - }, [patients, patientToCd4Map]); - - const fetchPatientLastCd4Encounters = useCallback( - async (patientUuid) => { - let latestCd4Encounter = { - result: '--', - date: '--', - encounterUuid: '', - }; - const query = `encounterType=${encounterTypes.CD4LabResultsEncounter_UUID}&patient=${patientUuid}`; - const viralResults = await openmrsFetch(`/ws/rest/v1/encounter?${query}&v=${encounterRepresentation}`); - if (viralResults.data.results?.length > 0) { - const sortedEncounters = viralResults.data.results.sort( - (firstEncounter, secondEncounter) => - new Date(secondEncounter.encounterDatetime).getTime() - - new Date(firstEncounter.encounterDatetime).getTime(), - ); - const lastEncounter = sortedEncounters[0]; - - latestCd4Encounter.result = getObsFromEncounter(lastEncounter, obsConcepts.hivCD4Count_UUID); - latestCd4Encounter.date = getObsFromEncounter(lastEncounter, obsConcepts.Cd4LabResultDate_UUID, true); - latestCd4Encounter.encounterUuid = lastEncounter.uuid; - } - return latestCd4Encounter; - }, - [encounterTypes.CD4LabResultsEncounter_UUID, obsConcepts.Cd4LabResultDate_UUID, obsConcepts.hivCD4Count_UUID], - ); - - useEffect(() => { - const patientToCd4ResultsPromises = patients.map((patient) => fetchPatientLastCd4Encounters(patient.resource.id)); - Promise.all(patientToCd4ResultsPromises).then((values) => { - setPatientToCd4Map( - values.map((value, index) => ({ - cd4Result: value.result, - cd4ResultDate: value.date, - patientId: patients[index].resource.id, - cd4EncounterUuid: value.encounterUuid, - })), - ); - }); - }, [fetchPatientLastCd4Encounters, patients]); - - const handleSearch = useCallback( - (searchTerm) => { - setSearchTerm(searchTerm); - const filtrate = filterPatientsByName(searchTerm, allRows); - setFilteredResults(filtrate); - return true; - }, - [allRows], - ); - - const addNewPatient = () => navigate({ to: '${openmrsSpaBase}/patient-registration' }); - const getPatientURL = (patientUuid) => `/openmrs/spa/patient/${patientUuid}/chart/hts-summary`; - const [latestCd4Encounter, setLatestCd4Encounter] = useState({ - result: '--', - date: '--', - encounterUuid: '', - }); - - return ( - <> - {isLoading ? ( - - ) : allRows.length > 0 ? ( - <> -
- handleSearch(target['value'])} - /> -
-
- -
- { - setSearchTerm(null); - setPage(page); - setNextOffSet((page - 1) * pageSize); - setPageSize(pageSize); - }} - /> -
-
- - ) : ( - - )} - - ); -}; - -export default CD4ResultsList; diff --git a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/tabs/patient-list.scss b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/tabs/patient-list.scss deleted file mode 100644 index 42ed8036f..000000000 --- a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/tabs/patient-list.scss +++ /dev/null @@ -1,56 +0,0 @@ -@use '@carbon/styles/scss/spacing'; -@import '../../../../root.scss'; - -.widgetContainer { - background-color: $ui-background; -} - -.widgetHeaderContainer { - display: flex; - justify-content: space-between; - align-items: center; - padding: spacing.$spacing-04 0 spacing.$spacing-04 spacing.$spacing-05; -} - -.widgetHeaderContainer > h4:after { - content: ''; - display: block; - width: 2rem; - padding-top: 0.188rem; - border-bottom: 0.375rem solid var(--brand-01); -} - -.toggleButtons { - width: fit-content; - margin: 0 spacing.$spacing-03; -} - -.searchField { - width: 100%; - max-width: 250px; - border: 0px !important; -} - -.searchBox { - width: 100%; - display: flex; - justify-content: right; -} - -.container { - margin-top: 16px; - margin-left: inherit; - width: 100%; - overflow-y: hidden; -} - -.tabContainer{ -margin-top: 16px; -padding-left: 1rem; -background-color: #ffffff; - -} - -.tabContainer li button{ -width: 100% !important; -} diff --git a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/tabs/viral-load-results.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/tabs/viral-load-results.component.tsx deleted file mode 100644 index 4b73b0622..000000000 --- a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/tabs/viral-load-results.component.tsx +++ /dev/null @@ -1,192 +0,0 @@ -import React, { useEffect, useState, useMemo, useCallback } from 'react'; - -import styles from './patient-list.scss'; -import { useTranslation } from 'react-i18next'; -import { age, navigate, openmrsFetch, useConfig } from '@openmrs/esm-framework'; -import { DataTableSkeleton, Pagination, Search } from '@carbon/react'; -import { capitalize } from 'lodash-es'; -import { - EmptyState, - OTable, - fetchPatientList, - encounterRepresentation, - getObsFromEncounter, -} from '@ohri/openmrs-esm-ohri-commons-lib'; -import { Link, BrowserRouter as Router } from 'react-router-dom'; -import { LabresultsFormViewer } from '../lab-results-form-viewer'; -import { filterPatientsByName } from './cd4-results.component'; - -interface ViralLoadResultsListProps { - patientUuid: string; -} - -const ViralLoadResultsList: React.FC = () => { - const { t } = useTranslation(); - const [patients, setPatients] = useState([]); - const [patientToViralLoadMap, setPatientToViralLoadMap] = useState([]); - const [allRows, setAllRows] = useState([]); - const [filteredResults, setFilteredResults] = useState([]); - const [searchTerm, setSearchTerm] = useState(null); - const [isLoading, setIsLoading] = useState(true); - const rowCount = 5; - const [page, setPage] = useState(1); - const [pageSize, setPageSize] = useState(10); - const [totalPatientCount, setPatientCount] = useState(0); - const [nextOffSet, setNextOffSet] = useState(0); - const headerTitle = ''; - const tableHeaders = [ - { key: 'name', header: t('patientName', 'Patient Name'), isSortable: true }, - { key: 'gender', header: t('sex', 'Sex') }, - { key: 'age', header: t('age', 'Age') }, - { key: 'viralLoadResult', header: t('recentVL', 'Recent VL') }, - { key: 'viralLoadResultDate', header: t('recentVLDate', 'Recent VL Date') }, - { key: 'actions', header: t('actions', 'Actions') }, - ]; - - const { obsConcepts, encounterTypes } = useConfig(); - - useEffect(() => { - setIsLoading(true); - fetchPatientList(nextOffSet, pageSize).then(({ data }) => { - setPatients(data.entry); - setPatientCount(data.total); - setIsLoading(false); - }); - }, [nextOffSet, page, pageSize]); - - useEffect(() => { - let rows = []; - for (let patient of patients) { - const lastviralLoadResult = patientToViralLoadMap.find((entry) => entry.patientId === patient.resource.id) - ?.viralLoadResult; - const lastviralLoadResultDate = patientToViralLoadMap.find((entry) => entry.patientId === patient.resource.id) - ?.viralLoadResultDate; - const lastViralLoadEncounterUuid = patientToViralLoadMap.find((entry) => entry.patientId === patient.resource.id) - ?.viralEncounterUuid; - const patientActions = ( - - ); - - rows.push({ - id: patient.resource.id, - name: ( - - - {`${patient.resource.name[0].given.join(' ')} ${patient.resource.name[0].family}`} - - - ), - gender: capitalize(patient.resource.gender), - age: age(patient.resource.birthDate), - viralLoadResult: lastviralLoadResult ? lastviralLoadResult : '--', - viralLoadResultDate: lastviralLoadResultDate ? lastviralLoadResultDate : '--', - actions: patientActions, - patientSearchName: `${patient.resource.name[0].given.join(' ')} ${patient.resource.name[0].family}`, - }); - } - setAllRows(rows); - }, [patients, patientToViralLoadMap]); - - const fetchPatientLastViralEncounters = useCallback( - async (patientUuid) => { - let latestViralEncounter = { - result: '--', - date: '--', - encounterUuid: '', - }; - const query = `encounterType=${encounterTypes.ViralLoadResultsEncounter_UUID}&patient=${patientUuid}`; - const viralResults = await openmrsFetch(`/ws/rest/v1/encounter?${query}&v=${encounterRepresentation}`); - if (viralResults.data.results?.length > 0) { - const sortedEncounters = viralResults.data.results.sort( - (firstEncounter, secondEncounter) => - new Date(secondEncounter.encounterDatetime).getTime() - - new Date(firstEncounter.encounterDatetime).getTime(), - ); - const lastEncounter = sortedEncounters[0]; - - latestViralEncounter.result = getObsFromEncounter(lastEncounter, obsConcepts.ViralLoadResult_UUID); - latestViralEncounter.date = getObsFromEncounter(lastEncounter, obsConcepts.ViralLoadResultDate_UUID, true); - latestViralEncounter.encounterUuid = lastEncounter.uuid; - } - return latestViralEncounter; - }, - [ - encounterTypes.ViralLoadResultsEncounter_UUID, - obsConcepts.ViralLoadResult_UUID, - obsConcepts.ViralLoadResultDate_UUID, - ], - ); - - useEffect(() => { - const patientToviralLoadResultsPromises = patients.map((patient) => - fetchPatientLastViralEncounters(patient.resource.id), - ); - Promise.all(patientToviralLoadResultsPromises).then((values) => { - setPatientToViralLoadMap( - values.map((value, index) => ({ - viralLoadResult: value.result, - viralLoadResultDate: value.date, - patientId: patients[index].resource.id, - viralEncounterUuid: value.encounterUuid, - })), - ); - }); - }, [fetchPatientLastViralEncounters, patients]); - - const handleSearch = useCallback( - (searchTerm) => { - setSearchTerm(searchTerm); - const filtrate = filterPatientsByName(searchTerm, allRows); - setFilteredResults(filtrate); - return true; - }, - [allRows], - ); - const getPatientURL = (patientUuid) => `/openmrs/spa/patient/${patientUuid}/chart/hts-summary`; - return ( - <> - {isLoading ? ( - - ) : allRows.length > 0 ? ( - <> -
- handleSearch(target['value'])} - /> -
-
- -
- { - setSearchTerm(null); - setPage(page); - setNextOffSet((page - 1) * pageSize); - setPageSize(pageSize); - }} - /> -
-
- - ) : ( - - )} - - ); -}; - -export default ViralLoadResultsList; diff --git a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/patient-list-tabs/ct-patient-list-schema-config.json b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/patient-list-tabs/ct-patient-list-schema-config.json new file mode 100644 index 000000000..e706929e2 --- /dev/null +++ b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/patient-list-tabs/ct-patient-list-schema-config.json @@ -0,0 +1,70 @@ +{ + "menuId": "careAndTreatment", + "tabDefinitions": [ + { + "tabName": "All C&T Clients", + "cohortId": "clientsEnrolledToCare", + "isReportingCohort": true, + "cohortSlotName": "all-ct-clients-slot", + "launchableForm": { + "package": "hiv-care-treatment", + "name": "Clinical Visit Form", + "actionText": "Start Follow Up Visit", + "intent": "CT_CLINICAL_VISIT_FOLLOW_UP", + "targetDashboard": "hts-summary" + }, + "excludedColumns": ["timeAddedToList", "waitingTime", "location"], + "otherColumns": [ + { + "id": "clientId", + "title": "Client ID", + "type": "patientId", + "index": 1 + }, + { + "id": "lastAppointment", + "title": "Last Appointment", + "type": "lastDate" + }, + { + "id": "appointmentDate", + "title": "Appointment Date", + "type": "appointmentDate" + } + ] + }, + { + "tabName": "Today's Appointments", + "cohortId": "todayzAppointmentsCT", + "isReportingCohort": true, + "cohortSlotName": "ct-todays-appointments", + "launchableForm": { + "package": "hiv-care-treatment", + "name": "POC Clinical Visit Form", + "actionText": "Start Follow Up Visit", + "intent": "CT_CLINICAL_VISIT_FOLLOW_UP", + "targetDashboard": "hts-summary" + }, + "excludedColumns": ["timeAddedToList", "waitingTime", "location"], + "hasQueryParams": true, + "otherColumns": [ + { + "id": "clientId", + "title": "Client ID", + "type": "patientId", + "index": 1 + }, + { + "id": "lastAppointment", + "title": "Last Appointment", + "type": "lastDate" + }, + { + "id": "appointmentDate", + "title": "Appointment Date", + "type": "appointmentDate" + } + ] + } + ] +} diff --git a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/patient-list-tabs/ct-patient-list-tabs.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/patient-list-tabs/ct-patient-list-tabs.component.tsx index 4d287cec2..245c71348 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/patient-list-tabs/ct-patient-list-tabs.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/patient-list-tabs/ct-patient-list-tabs.component.tsx @@ -1,92 +1,15 @@ import React from 'react'; -import { OHRIPatientListTabs } from '@ohri/openmrs-esm-ohri-commons-lib'; -import { useTranslation } from 'react-i18next'; +import { OHRIPatientListTabs, getPatientListTabsData } from '@ohri/openmrs-esm-ohri-commons-lib'; import { moduleName } from '../../../index'; import { useConfig } from '@openmrs/esm-framework'; +import ctPatientListTabsConfig from './ct-patient-list-schema-config.json'; function CTHomePatientTabs() { - const { t } = useTranslation(); - const { obsConcepts, cohorts } = useConfig(); + const config = useConfig(); - const tabsConfigs = [ - { - label: t('allCTClients', 'All C&T Clients'), - cohortId: cohorts.clientsEnrolledToCare, - isReportingCohort: true, - cohortSlotName: 'all-ct-clients-slot', - launchableForm: { - name: 'Clinical Visit Form', - actionText: t('startFollowUpVisit', 'Start Follow Up Visit'), - intent: 'CT_CLINICAL_VISIT_FOLLOW_UP', - targetDashboard: 'hts-summary', - }, - excludeColumns: ['timeAddedToList', 'waitingTime', 'location'], - otherColumns: [ - { - key: 'clientId', - header: t('clientId', 'Client ID'), - getValue: (patient) => { - return patient.id; - }, - index: 1, - }, - { - key: 'lastAppointment', - header: t('lastAppointment', 'Last Appointment'), - getValue: (patient) => { - return '13/01/2021'; - }, - }, - { - key: 'appointmentDate', - header: t('appointmentDate', 'Appointment Date'), - getValue: (patient) => { - return '03/03/2021'; - }, - }, - ], - }, - { - label: t('todaysAppointments', "Today's Appointments"), - cohortId: cohorts.todayzAppointmentsCT, - isReportingCohort: true, - cohortSlotName: 'ct-todays-appointments', - launchableForm: { - package: 'hiv', - name: 'POC Clinical Visit Form', - actionText: t('followUpVisit', 'Start Follow Up Visit'), - intent: 'CT_CLINICAL_VISIT_FOLLOW_UP', - targetDashboard: 'hts-summary', - }, - excludeColumns: ['timeAddedToList', 'waitingTime', 'location'], - queryParams: [`value1=${new Date().toISOString().split('T')[0]}`], - otherColumns: [ - { - key: 'clientId', - header: t('clientId', 'Client ID'), - getValue: (patient) => { - return patient.id; - }, - index: 1, - }, - { - key: 'lastAppointment', - header: t('lastAppointment', 'Last Appointment'), - getValue: (patient) => { - return '13/01/2021'; - }, - }, - { - key: 'appointmentDate', - header: t('appointmentDate', 'Appointment Date'), - getValue: (patient) => { - return '03/03/2021'; - }, - }, - ], - }, - ]; - return ; + const patientListTabs = getPatientListTabsData(ctPatientListTabsConfig, config); + + return ; } export default CTHomePatientTabs; diff --git a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/general-counselling/general-conselling-config.json similarity index 100% rename from packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/general-counselling/general-conselling-config.json diff --git a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/general-counselling/general-counselling-summary.component.tsx similarity index 97% rename from packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/general-counselling/general-counselling-summary.component.tsx index 5c0cd7506..efa67dbf3 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/general-counselling/general-counselling-summary.component.tsx @@ -4,7 +4,7 @@ import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import generalConsellingConfigSchema from './general-conselling-config.json'; -import styles from '../common.scss'; +import styles from '../../common.scss'; interface OverviewListProps { patientUuid: string; diff --git a/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/partner-notification-services/partner-notification-services.component.tsx similarity index 97% rename from packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/partner-notification-services/partner-notification-services.component.tsx index ac41990af..daa18cf30 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/partner-notification-services/partner-notification-services.component.tsx @@ -4,7 +4,7 @@ import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import partnerNotificationsConfigSchema from './patner-notification-config.json'; -import styles from '../common.scss'; +import styles from '../../common.scss'; interface OverviewListProps { patientUuid: string; diff --git a/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/patner-notification-config.json b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/partner-notification-services/patner-notification-config.json similarity index 100% rename from packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/patner-notification-config.json rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/partner-notification-services/patner-notification-config.json diff --git a/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-config.json b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/program-management/program-management-config.json similarity index 100% rename from packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-config.json rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/program-management/program-management-config.json diff --git a/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/program-management/program-management-summary.component.tsx similarity index 97% rename from packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/program-management/program-management-summary.component.tsx index bf425d6c0..874341615 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/program-management/program-management-summary.component.tsx @@ -4,7 +4,7 @@ import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import programManagementTabConfigSchema from './program-management-config.json'; -import styles from '../common.scss'; +import styles from '../../common.scss'; interface OverviewListProps { patientUuid: string; diff --git a/packages/esm-hiv-care-treatment-app/src/views/service-summary/encounter-list/service-summary-characteristics.json b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/service-summary/service-summary-characteristics.json similarity index 100% rename from packages/esm-hiv-care-treatment-app/src/views/service-summary/encounter-list/service-summary-characteristics.json rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/service-summary/service-summary-characteristics.json diff --git a/packages/esm-hiv-care-treatment-app/src/views/service-summary/encounter-list/service-summary-encounter-list.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/service-summary/service-summary-encounter-list.component.tsx similarity index 100% rename from packages/esm-hiv-care-treatment-app/src/views/service-summary/encounter-list/service-summary-encounter-list.component.tsx rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/service-summary/service-summary-encounter-list.component.tsx diff --git a/packages/esm-hiv-care-treatment-app/src/views/service-summary/encounter-list/service-summary-hiv-monitoring.json b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/service-summary/service-summary-hiv-monitoring.json similarity index 100% rename from packages/esm-hiv-care-treatment-app/src/views/service-summary/encounter-list/service-summary-hiv-monitoring.json rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/service-summary/service-summary-hiv-monitoring.json diff --git a/packages/esm-hiv-care-treatment-app/src/views/service-summary/encounter-list/service-summary-visit.json b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/service-summary/service-summary-visit.json similarity index 100% rename from packages/esm-hiv-care-treatment-app/src/views/service-summary/encounter-list/service-summary-visit.json rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/service-summary/service-summary-visit.json diff --git a/packages/esm-hiv-care-treatment-app/src/views/visits/clinical-visit-config.json b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/visits/clinical-visit-config.json similarity index 100% rename from packages/esm-hiv-care-treatment-app/src/views/visits/clinical-visit-config.json rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/visits/clinical-visit-config.json diff --git a/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/visits/visits-summary.component.tsx similarity index 97% rename from packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx rename to packages/esm-hiv-care-treatment-app/src/views/patient-chart/visits/visits-summary.component.tsx index 7c6d96805..7af156619 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/patient-chart/visits/visits-summary.component.tsx @@ -4,7 +4,7 @@ import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import clinicalVisitConfigSchema from './clinical-visit-config.json'; -import styles from '../common.scss'; +import styles from '../../common.scss'; interface OverviewListProps { patientUuid: string; diff --git a/packages/esm-hiv-prevention-app/src/hts-home.component.tsx b/packages/esm-hiv-prevention-app/src/hts-home.component.tsx index 6b990c470..694321ae1 100644 --- a/packages/esm-hiv-prevention-app/src/hts-home.component.tsx +++ b/packages/esm-hiv-prevention-app/src/hts-home.component.tsx @@ -1,7 +1,7 @@ import { OHRIWelcomeSection } from '@ohri/openmrs-esm-ohri-commons-lib'; import React from 'react'; -import OHRIPatientTabs from './views/testing-services/patient-tabs/ohri-patient-tabs.component'; -import HTSSummaryTiles from './views/testing-services/summary-tiles/hts-summary-tiles.component'; +import OHRIPatientTabs from './views/home-dashboard-testing-services/patient-tabs/hts-patient-tabs.component'; +import HTSSummaryTiles from './views/home-dashboard-testing-services/summary-tiles/hts-summary-tiles.component'; const Homecomponent = () => { return ( diff --git a/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/patient-tabs/hts-patient-tab-schema.json b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/patient-tabs/hts-patient-tab-schema.json new file mode 100644 index 000000000..e51a3b21c --- /dev/null +++ b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/patient-tabs/hts-patient-tab-schema.json @@ -0,0 +1,70 @@ +{ + "menuId": "htsServices", + "tabDefinitions": [ + { + "tabName": "Waiting for pre-test counselling", + "cohortContent": { + "cohortId": "preTestCounsellingCohort", + "cohortSlotName": "pre-test-counseling-slot", + "associatedEncounterType": "htsRetrospectiveEncounterType", + "addPatientToListOptions": { + "isEnabled": true, + "excludeCohorts": [ + "Post-Test Counselling" + ] + }, + "launchableForm": { + "name": "POC OHRI HTS Form", + "intent": "HTS_PRETEST", + "actionText": "Start Pre-test", + "editLatestEncounter": true, + "encounterType": "htsRetrospectiveEncounterType", + "targetDashboard": "hts-summary" + }, + "moduleName": "@ohri/openmrs-esm-ohri-hiv-prevention-app" + } + }, + { + "tabName": "Waiting for HIV test", + "cohortContent": { + "cohortId": "preTestCounsellingCohort", + "cohortSlotName": "waiting-for-hiv-testing-slot", + "encounterType": "htsRetrospectiveEncounterType", + "addPatientToListOptions": { + "isEnabled": true, + "excludeCohorts": [] + }, + "launchableForm": { + "name": "POC OHRI HTS Form", + "intent": "HTS_HIVTEST", + "actionText": "Start HIV Test", + "editLatestEncounter": true, + "encounterType": "htsRetrospectiveEncounterType", + "targetDashboard": "hts-summary" + }, + "moduleName": "@ohri/openmrs-esm-ohri-hiv-prevention-app" + } + }, + { + "tabName": "Waiting for post-test counselling", + "cohortContent": { + "cohortId": "postTestCounsellingCohort", + "cohortSlotName": "post-test-counseling-slot", + "encounterType": "htsRetrospectiveEncounterType", + "addPatientToListOptions": { + "isEnabled": true, + "excludeCohorts": [] + }, + "launchableForm": { + "name": "POC OHRI HTS Form", + "intent": "HTS_POSTTEST", + "actionText": "Start Post-test counselling", + "editLatestEncounter": true, + "encounterType": "htsRetrospectiveEncounterType", + "targetDashboard": "hts-summary" + }, + "moduleName": "@ohri/openmrs-esm-ohri-hiv-prevention-app" + } + } + ] +} diff --git a/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/patient-tabs/hts-patient-tabs.component.tsx b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/patient-tabs/hts-patient-tabs.component.tsx new file mode 100644 index 000000000..fc6432e74 --- /dev/null +++ b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/patient-tabs/hts-patient-tabs.component.tsx @@ -0,0 +1,32 @@ +import React from 'react'; +import { useConfig } from '@openmrs/esm-framework'; +import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; +import { CohortPatientList, getCohortListTabsData } from '@ohri/openmrs-esm-ohri-commons-lib'; +import htsCohortTabsSchema from './hts-patient-tab-schema.json'; + +import styles from './hts-patient-tabs.scss'; + +function OHRIPatientTabs() { + const config = useConfig(); + + const tabs = getCohortListTabsData(htsCohortTabsSchema, config); + + return ( + + + {tabs.map((tab) => ( + {tab.name} + ))} + + + {tabs.map((tab) => ( + + + + ))} + + + ); +} + +export default OHRIPatientTabs; diff --git a/packages/esm-hiv-prevention-app/src/views/testing-services/patient-tabs/ohri-patient-tabs.scss b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/patient-tabs/hts-patient-tabs.scss similarity index 100% rename from packages/esm-hiv-prevention-app/src/views/testing-services/patient-tabs/ohri-patient-tabs.scss rename to packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/patient-tabs/hts-patient-tabs.scss diff --git a/packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/hts-summary-tiles.component.tsx b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/hts-summary-tiles.component.tsx similarity index 100% rename from packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/hts-summary-tiles.component.tsx rename to packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/hts-summary-tiles.component.tsx diff --git a/packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/linked-to-care-in-last-14-days-list-tile.component.tsx b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/linked-to-care-in-last-14-days-list-tile.component.tsx similarity index 100% rename from packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/linked-to-care-in-last-14-days-list-tile.component.tsx rename to packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/linked-to-care-in-last-14-days-list-tile.component.tsx diff --git a/packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/positive-in-last-14-days-list-tile.component.tsx b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/positive-in-last-14-days-list-tile.component.tsx similarity index 100% rename from packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/positive-in-last-14-days-list-tile.component.tsx rename to packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/positive-in-last-14-days-list-tile.component.tsx diff --git a/packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/summary-tile.scss b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/summary-tile.scss similarity index 100% rename from packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/summary-tile.scss rename to packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/summary-tile.scss diff --git a/packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/today-client-list-tile.component.tsx b/packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/today-client-list-tile.component.tsx similarity index 100% rename from packages/esm-hiv-prevention-app/src/views/testing-services/summary-tiles/today-client-list-tile.component.tsx rename to packages/esm-hiv-prevention-app/src/views/home-dashboard-testing-services/summary-tiles/today-client-list-tile.component.tsx diff --git a/packages/esm-hiv-prevention-app/src/views/testing-services/patient-tabs/ohri-patient-tabs.component.tsx b/packages/esm-hiv-prevention-app/src/views/testing-services/patient-tabs/ohri-patient-tabs.component.tsx deleted file mode 100644 index b4e7dd40d..000000000 --- a/packages/esm-hiv-prevention-app/src/views/testing-services/patient-tabs/ohri-patient-tabs.component.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import React from 'react'; -import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; -import styles from './ohri-patient-tabs.scss'; -import { CohortPatientList } from '@ohri/openmrs-esm-ohri-commons-lib'; -import { useTranslation } from 'react-i18next'; -import { moduleName } from '../../../index'; -import { useConfig } from '@openmrs/esm-framework'; - -function OHRIPatientTabs() { - const { t } = useTranslation(); - const { encounterTypes, cohorts } = useConfig(); - const formName = 'POC OHRI HTS Form'; - return ( - - - {t('waitingForPretestCounselling', 'Waiting for pre-test counselling')} - {t('wiatingForHivTest', 'Waiting for HIV test')} - {t('WaitingForPosttestCounselling')} - - - - - - - - - - - - - - ); -} - -export default OHRIPatientTabs;