diff --git a/packages/esm-covid-app/src/covid.resource.ts b/packages/esm-covid-app/src/covid.resource.ts deleted file mode 100644 index 7a058514c..000000000 --- a/packages/esm-covid-app/src/covid.resource.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { openmrsFetch } from '@openmrs/esm-framework'; - -const BASE_WS_API_URL = '/ws/rest/v1/'; -const BASE_FHIR_API_URL = '/ws/fhir2/R4/'; - -export function fetchPatientCovidOutcome(covidOutcomesCohortUUID) { - return openmrsFetch(`${BASE_WS_API_URL}reportingrest/cohort/${covidOutcomesCohortUUID}`).then(({ data }) => { - if (data.members?.length) { - let patientRefs = data.members.map((member) => { - return member.uuid; - }); - patientRefs = new Set([...patientRefs]); - patientRefs = Array.from(patientRefs); - return Promise.all( - patientRefs.map((ref) => { - return openmrsFetch(BASE_FHIR_API_URL + '/Person/' + ref); - }), - ); - } - return []; - }); -} diff --git a/packages/esm-covid-app/src/covid/dashboard/summary-tiles/outcome-list-tile.component.tsx b/packages/esm-covid-app/src/covid/dashboard/summary-tiles/outcome-list-tile.component.tsx deleted file mode 100644 index 3d4e54429..000000000 --- a/packages/esm-covid-app/src/covid/dashboard/summary-tiles/outcome-list-tile.component.tsx +++ /dev/null @@ -1,157 +0,0 @@ -import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { age, attach, detach, ExtensionSlot, useConfig } from '@openmrs/esm-framework'; -import { capitalize } from 'lodash-es'; -import { fetchPatientCovidOutcome } from '../../../covid.resource'; -import { - getObsFromEncounter, - filterFHIRPatientsByName, - TableEmptyState, - basePath, -} from '@ohri/openmrs-esm-ohri-commons-lib'; -import { useTranslation } from 'react-i18next'; - -export const Outcomes: React.FC<{}> = () => { - const [patients, setPatients] = useState([]); - const [totalPatientCount, setTotalPatientCount] = useState(0); - const [isLoading, setIsLoading] = useState(true); - const [currentPage, setCurrentPage] = useState(1); - const [pageSize, setPageSize] = useState(10); - const [searchTerm, setSearchTerm] = useState(null); - const [counter, setCounter] = useState(0); - const [filteredResults, setFilteredResults] = useState([]); - const [filteredResultsCounts, setFilteredResultsCounts] = useState(0); - const { t } = useTranslation(); - const config = useConfig(); - - const columns = useMemo( - () => [ - { - key: 'name', - header: t('name', 'Name'), - getValue: (patient) => { - return `${patient.name[0].given.join(' ')} ${patient.name[0].family}`; - }, - link: { - getUrl: (patient) => `${basePath}${patient.id}/chart`, - }, - }, - { - key: 'outcomegender', - header: t('sex', 'Sex'), - getValue: (patient) => { - return capitalize(patient.gender); - }, - }, - { - key: 'outcomeage', - header: t('age', 'Age'), - getValue: (patient) => { - return age(patient.birthDate); - }, - }, - { - key: 'outcomeAssessmentDate', - header: t('AssessmentDate', 'AssessmentDate Date'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, config.obsConcepts.covidEncounterDateTime_UUID, true); - }, - }, - { - key: 'outcomePresentation', - header: t('presentation', 'Presentation'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, config.obsConcepts.covidPresentSymptonsConcept_UUID); - }, - }, - { - key: 'outcome', - header: t('outcome', 'Outcome'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, config.obsConcepts.covidOutcomeUUID); - }, - }, - { - key: 'outcomeDate', - header: t('outcomeDate', 'Outcome Date'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, config.obsConcepts.covidOutcome); - }, - }, - ], - [ - config.obsConcepts.covidEncounterDateTime_UUID, - config.obsConcepts.covidOutcome, - config.obsConcepts.covidOutcomeUUID, - config.obsConcepts.covidPresentSymptonsConcept_UUID, - t, - ], - ); - - useEffect(() => { - fetchPatientCovidOutcome(config.cohorts.covidOutcomesCohortUUID).then((response: Array) => { - setPatients(response.map((pat) => pat.data)); - setTotalPatientCount(response.length); - setIsLoading(false); - }); - }, [pageSize, currentPage, config.cohorts.covidOutcomesCohortUUID]); - - useEffect(() => { - attach('outcomes-table-slot', 'patient-table'); - return () => detach('outcomes-table-slot', 'patient-table'); - }, []); - - const pagination = useMemo(() => { - return { - usePagination: false, - currentPage: currentPage, - onChange: (props) => { - setCurrentPage(props.page); - setPageSize(props.pageSize); - }, - pageSize: pageSize, - totalItems: searchTerm ? filteredResultsCounts : totalPatientCount, - }; - }, [currentPage, filteredResultsCounts, pageSize, totalPatientCount, searchTerm]); - - const handleSearch = useCallback( - (searchTerm) => { - setSearchTerm(searchTerm); - if (searchTerm) { - const filtrate = filterFHIRPatientsByName(searchTerm, patients); - setFilteredResults(filtrate); - setFilteredResultsCounts(filtrate.length); - } - }, - [patients], - ); - - const state = useMemo( - () => ({ - patients: searchTerm ? filteredResults : patients, - columns, - search: { - placeHolder: t('searchClientList', 'Search client list'), - onSearch: handleSearch, - currentSearchTerm: searchTerm, - }, - pagination, - isLoading, - autoFocus: true, - }), - [searchTerm, filteredResults, patients, columns, t, handleSearch, pagination, isLoading], - ); - - useEffect(() => { - setCounter(counter + 1); - }, [counter, state]); - - return ( -
- {!isLoading && !patients.length ? ( - - ) : ( - - )} -
- ); -}; diff --git a/packages/esm-covid-app/src/covid/dashboard/summary-tiles/vaccination-tile-list.component.tsx b/packages/esm-covid-app/src/covid/dashboard/summary-tiles/vaccination-tile-list.component.tsx deleted file mode 100644 index d9631f1ed..000000000 --- a/packages/esm-covid-app/src/covid/dashboard/summary-tiles/vaccination-tile-list.component.tsx +++ /dev/null @@ -1,151 +0,0 @@ -import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { age, attach, detach, ExtensionSlot, useConfig } from '@openmrs/esm-framework'; -import { capitalize } from 'lodash-es'; -import { - basePath, - finalHIVCodeConcept, - finalPositiveHIVValueConcept, -} from '@ohri/openmrs-esm-ohri-commons-lib/src/constants'; -import { - fetchPatientsFromObservationCodeConcept, - filterFHIRPatientsByName, - getReportingCohort, - TableEmptyState, -} from '@ohri/openmrs-esm-ohri-commons-lib'; -import { useTranslation } from 'react-i18next'; - -export const Vaccinations: React.FC<{}> = () => { - const [patients, setPatients] = useState([]); - const [totalPatientCount, setTotalPatientCount] = useState(0); - const [isLoading, setIsLoading] = useState(true); - const [currentPage, setCurrentPage] = useState(1); - const [pageSize, setPageSize] = useState(10); - const [searchTerm, setSearchTerm] = useState(null); - const [counter, setCounter] = useState(0); - const [filteredResults, setFilteredResults] = useState([]); - const [filteredResultsCounts, setFilteredResultsCounts] = useState(0); - const { t } = useTranslation(); - const config = useConfig(); - - const columns = useMemo( - () => [ - { - key: 'name', - header: t('vaccinationName', 'Name'), - getValue: (patient) => { - return `${patient.name[0].given.join(' ')} ${patient.name[0].family}`; - }, - link: { - getUrl: (patient) => `${basePath}${patient.id}/chart`, - }, - }, - { - key: 'gender', - header: t('sex', 'Sex'), - getValue: (patient) => { - return capitalize(patient.gender); - }, - }, - { - key: 'Vaccinationage', - header: t('Age', 'Age'), - getValue: (patient) => { - return age(patient.birthDate); - }, - }, - { - key: 'lastVaccineAdministered', - header: t('vaccinationLastVaccineAdmin', 'Last Vaccine Administered'), - getValue: (patient) => { - return '--'; - }, - }, - { - key: 'lastVaccineDoseAdministered', - header: t('vaccinationLastVaccineDoseAdmin', 'Last Vaccine Dose Administered'), - getValue: (patient) => { - return '--'; - }, - }, - ], - [t], - ); - - useEffect(() => { - getReportingCohort(config.cohorts.covidVaccinatedClients).then((data) => { - setCovidVaccinatedClients(data.members.length); - }); - fetchPatientsFromObservationCodeConcept(finalHIVCodeConcept, finalPositiveHIVValueConcept, 14).then( - (response: Array) => { - setPatients(response.map((pat) => pat.data)); - setTotalPatientCount(response.length); - setIsLoading(false); - }, - ); - }, [pageSize, currentPage, config.cohorts.covidVaccinatedClients]); - - useEffect(() => { - attach('covid-vaccination-table-slot', 'patient-table'); - return () => { - detach('covid-vaccination-table-slot', 'patient-table'); - }; - }, []); - - const pagination = useMemo(() => { - return { - usePagination: false, - currentPage: currentPage, - onChange: (props) => { - setCurrentPage(props.page); - setPageSize(props.pageSize); - }, - pageSize: pageSize, - totalItems: searchTerm ? filteredResultsCounts : totalPatientCount, - }; - }, [currentPage, filteredResultsCounts, pageSize, totalPatientCount, searchTerm]); - - const handleSearch = useCallback( - (searchTerm) => { - setSearchTerm(searchTerm); - if (searchTerm) { - const filtrate = filterFHIRPatientsByName(searchTerm, patients); - setFilteredResults(filtrate); - setFilteredResultsCounts(filtrate.length); - } - }, - [patients], - ); - - const state = useMemo( - () => ({ - patients: searchTerm ? filteredResults : patients, - columns, - search: { - placeHolder: t('searchClientList', 'Search client list'), - onSearch: handleSearch, - currentSearchTerm: searchTerm, - }, - pagination, - isLoading, - autoFocus: true, - }), - [searchTerm, filteredResults, patients, columns, t, handleSearch, pagination, isLoading], - ); - - useEffect(() => { - setCounter(counter + 1); - }, [counter, state]); - - return ( -
- {!isLoading && !patients.length ? ( - - ) : ( - - )} -
- ); -}; -function setCovidVaccinatedClients(length: any) { - throw new Error('Function not implemented.'); -}