@openmrs/esm-appointments-app 9.2.1-pre.7358 → 9.2.1-pre.7362

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,106 +0,0 @@
1
- import React, { useState } from 'react';
2
- import classNames from 'classnames';
3
- import { useTranslation } from 'react-i18next';
4
- import { StructuredListSkeleton, Tab, Tabs } from '@carbon/react';
5
- import { formatDate, type OpenmrsResource, parseDate, useLayoutType } from '@openmrs/esm-framework';
6
- import { type Observation } from '../types';
7
- import { usePastVisits } from './past-visit.resource';
8
- import EncounterList from './encounter-list.component';
9
- import styles from './past-visit.scss';
10
-
11
- interface PastVisitProps {
12
- patientUuid: string;
13
- }
14
-
15
- export interface FormattedEncounter {
16
- id: string;
17
- datetime: string;
18
- encounterType: string;
19
- form: OpenmrsResource;
20
- obs: Array<Observation>;
21
- provider: string;
22
- visitType: string;
23
- visitUuid: string;
24
- }
25
-
26
- const PastVisit: React.FC<PastVisitProps> = ({ patientUuid }) => {
27
- const { t } = useTranslation();
28
- const { data: pastVisits, error, isLoading } = usePastVisits(patientUuid);
29
- const [selectedTabIndex, setSelectedTabIndex] = useState(0);
30
- const isTablet = useLayoutType() === 'tablet';
31
-
32
- if (isLoading) {
33
- return <StructuredListSkeleton role="progressbar" />;
34
- }
35
-
36
- if (pastVisits?.length) {
37
- const encounters = mapEncounters(pastVisits[0]);
38
-
39
- const tabsClasses = classNames(styles.verticalTabs, {
40
- [styles.tabletTabs]: isTablet,
41
- [styles.desktopTabs]: !isTablet,
42
- });
43
-
44
- const tabClass = (index) =>
45
- classNames(styles.tab, styles.bodyLong01, {
46
- [styles.selectedTab]: selectedTabIndex === index,
47
- });
48
-
49
- return (
50
- <div className={styles.wrapper}>
51
- <div className={styles.visitType}>
52
- <span> {pastVisits?.length ? pastVisits[0]?.visitType.display : '--'}</span>
53
- <p className={styles.date}>
54
- {pastVisits?.length ? formatDate(parseDate(pastVisits[0]?.startDatetime)) : '--'}
55
- </p>
56
- </div>
57
- <div className={styles.visitContainer}>
58
- <Tabs className={tabsClasses}>
59
- <Tab
60
- className={tabClass[0]}
61
- id="vitals-tab"
62
- onClick={() => setSelectedTabIndex(0)}
63
- label={t('vitals', 'Vitals')}></Tab>
64
-
65
- <Tab
66
- className={tabClass[1]}
67
- id="notes-tab"
68
- onClick={() => setSelectedTabIndex(1)}
69
- label={t('notes', 'Notes')}></Tab>
70
-
71
- <Tab
72
- className={tabClass[2]}
73
- id="medications-tab"
74
- onClick={() => setSelectedTabIndex(2)}
75
- label={t('medications', 'Medications')}></Tab>
76
-
77
- <Tab
78
- className={tabClass[3]}
79
- id="encounters-tab"
80
- onClick={() => setSelectedTabIndex(3)}
81
- label={t('encounters', 'Encounters')}>
82
- <EncounterList encounters={encounters} />
83
- </Tab>
84
- </Tabs>
85
- </div>
86
- </div>
87
- );
88
- }
89
- return <p className={styles.bodyLong01}>{t('noPreviousVisitFound', 'No previous visit found')}</p>;
90
- };
91
-
92
- export function mapEncounters(visit) {
93
- return visit?.encounters?.map((encounter) => ({
94
- id: encounter?.uuid,
95
- datetime: encounter?.encounterDatetime,
96
- encounterType: encounter?.encounterType?.display,
97
- form: encounter?.form,
98
- obs: encounter?.obs,
99
- provider:
100
- encounter?.encounterProviders?.length > 0 ? encounter.encounterProviders[0].provider?.person?.display : '--',
101
- visitUuid: visit?.visitType.uuid,
102
- visitType: visit?.visitType?.name,
103
- }));
104
- }
105
-
106
- export default PastVisit;
@@ -1,25 +0,0 @@
1
- import useSWR from 'swr';
2
- import { openmrsFetch, restBaseUrl, type Visit } from '@openmrs/esm-framework';
3
-
4
- export function usePastVisits(patientUuid: string) {
5
- const customRepresentation =
6
- 'custom:(uuid,encounters:(uuid,encounterDatetime,' +
7
- 'form:(uuid,name),location:ref,' +
8
- 'encounterType:ref,encounterProviders:(uuid,display,' +
9
- 'provider:(uuid,display))),patient:(uuid,uuid),' +
10
- 'visitType:(uuid,name,display),attributes:(uuid,display,value),location:(uuid,name,display),startDatetime,' +
11
- 'stopDatetime)';
12
-
13
- const apiUrl = `${restBaseUrl}/visit?patient=${patientUuid}&v=${customRepresentation}`;
14
- const { data, error, isLoading, isValidating } = useSWR<{ data: { results: Array<Visit> } }, Error>(
15
- patientUuid ? apiUrl : null,
16
- openmrsFetch,
17
- );
18
-
19
- return {
20
- data: data ? data.data.results : null,
21
- error,
22
- isLoading,
23
- isValidating,
24
- };
25
- }
@@ -1,111 +0,0 @@
1
- @use '@carbon/layout';
2
- @use '@carbon/type';
3
- @use '@openmrs/esm-styleguide/src/vars' as *;
4
-
5
- .wrapper {
6
- margin-top: layout.$spacing-03;
7
- }
8
-
9
- .bodyShort02 {
10
- @include type.type-style('body-compact-02');
11
- }
12
-
13
- .bodyLong01 {
14
- @include type.type-style('body-01');
15
- }
16
-
17
- .date {
18
- @include type.type-style('label-01');
19
- color: $text-02;
20
- margin: layout.$spacing-03 0 layout.$spacing-02;
21
- }
22
-
23
- .visitType {
24
- @include type.type-style('heading-compact-02');
25
- }
26
-
27
- .container {
28
- background-color: $ui-background;
29
- border: 1px solid $grey-2;
30
- padding: layout.$spacing-05;
31
- margin: layout.$spacing-05 0 layout.$spacing-05;
32
- width: 100%;
33
- }
34
-
35
- .tabs > :global(.cds--tab-content) {
36
- padding: layout.$spacing-05 0 !important;
37
- }
38
-
39
- .header::after {
40
- content: '';
41
- display: block;
42
- width: layout.$spacing-07;
43
- padding-top: 0.188rem;
44
- border-bottom: 0.375rem solid var(--brand-03);
45
- }
46
-
47
- .visitContainer {
48
- background-color: $ui-background;
49
- display: grid;
50
- grid-template-columns: max-content auto;
51
- }
52
-
53
- .flexSections {
54
- display: flex;
55
- }
56
-
57
- .verticalTabs {
58
- margin: layout.$spacing-04 0;
59
-
60
- &:global(.cds--tabs--scrollable .cds--tabs--scrollable__nav-item + .cds--tabs--scrollable__nav-item) {
61
- margin-left: 0;
62
- }
63
- }
64
-
65
- .verticalTabs > ul {
66
- flex-direction: column !important;
67
- }
68
-
69
- .desktopTabs {
70
- button {
71
- height: layout.$spacing-07;
72
- }
73
- }
74
-
75
- .tabletTabs {
76
- button {
77
- height: layout.$spacing-09;
78
- }
79
- }
80
-
81
- .tab > button {
82
- border-bottom: 0 !important;
83
- border-left: 3px solid $ui-03 !important;
84
- }
85
-
86
- .tab > button,
87
- .tab > button:focus,
88
- .tab > button:active {
89
- outline: 0 !important;
90
- outline-offset: 0 !important;
91
- }
92
-
93
- .selectedTab > button {
94
- border-left: 3px solid var(--brand-03) !important;
95
- border-bottom: 0 !important;
96
- font-weight: 600 !important;
97
- }
98
-
99
- .tabContent {
100
- border-top: 1px solid $ui-03;
101
- padding: layout.$spacing-05 0;
102
- width: 70%;
103
- }
104
-
105
- .textColor {
106
- color: $color-blue-60-2;
107
- }
108
-
109
- .text02 {
110
- color: $text-02;
111
- }