@ltht-react/diagnosis-summary 2.0.137 → 2.0.139

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.
package/README.md CHANGED
@@ -1,22 +1,22 @@
1
- # DiagnosisSummary
2
-
3
- <!-- STORY -->
4
-
5
- ### Import
6
-
7
- ```js
8
- import DiagnosisSummary from '@ltht-react/diagnosis-summary'
9
- ```
10
-
11
- ### Usage
12
-
13
- ```jsx
14
- <DiagnosisSummary title="Conditions" conditions={conditions} clickHandler={handleCLick} />
15
- ```
16
-
17
- ### Properties
18
-
19
- | Prop | Required | Default | Type | Description |
20
- | :------------- | :------- | :-------- | :---------- | :------------------------------------------------------------ |
21
- | `conditions` | Yes | | Condition[] | Array of conditions to display |
22
- | `clickHandler` | No | undefined | Function | Callback click handler containing the selected condition item |
1
+ # DiagnosisSummary
2
+
3
+ <!-- STORY -->
4
+
5
+ ### Import
6
+
7
+ ```js
8
+ import DiagnosisSummary from '@ltht-react/diagnosis-summary'
9
+ ```
10
+
11
+ ### Usage
12
+
13
+ ```jsx
14
+ <DiagnosisSummary title="Conditions" conditions={conditions} clickHandler={handleCLick} />
15
+ ```
16
+
17
+ ### Properties
18
+
19
+ | Prop | Required | Default | Type | Description |
20
+ | :------------- | :------- | :-------- | :---------- | :------------------------------------------------------------ |
21
+ | `conditions` | Yes | | Condition[] | Array of conditions to display |
22
+ | `clickHandler` | No | undefined | Function | Callback click handler containing the selected condition item |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ltht-react/diagnosis-summary",
3
- "version": "2.0.137",
3
+ "version": "2.0.139",
4
4
  "description": "ltht-react clinical DiagnosisSummary component.",
5
5
  "author": "LTHT",
6
6
  "homepage": "",
@@ -28,15 +28,15 @@
28
28
  "dependencies": {
29
29
  "@emotion/react": "^11.0.0",
30
30
  "@emotion/styled": "^11.0.0",
31
- "@ltht-react/button": "^2.0.137",
32
- "@ltht-react/hooks": "^2.0.137",
33
- "@ltht-react/icon": "^2.0.137",
34
- "@ltht-react/list": "^2.0.137",
35
- "@ltht-react/styles": "^2.0.137",
36
- "@ltht-react/type-summary": "^2.0.137",
37
- "@ltht-react/types": "^2.0.137",
38
- "@ltht-react/utils": "^2.0.137",
31
+ "@ltht-react/button": "^2.0.139",
32
+ "@ltht-react/hooks": "^2.0.139",
33
+ "@ltht-react/icon": "^2.0.139",
34
+ "@ltht-react/list": "^2.0.139",
35
+ "@ltht-react/styles": "^2.0.139",
36
+ "@ltht-react/type-summary": "^2.0.139",
37
+ "@ltht-react/types": "^2.0.139",
38
+ "@ltht-react/utils": "^2.0.139",
39
39
  "react": "^18.2.0"
40
40
  },
41
- "gitHead": "8f8de949dd580b6433ab60a5930c81aad2ef52e0"
41
+ "gitHead": "125c4d49af461809ebc1a2080afdc8865c86b8cb"
42
42
  }
@@ -1,31 +1,31 @@
1
- import { FC, HTMLAttributes } from 'react'
2
- import styled from '@emotion/styled'
3
-
4
- import { TEXT_COLOURS } from '@ltht-react/styles'
5
- import { Condition } from '@ltht-react/types'
6
- import { codeableConceptDisplaySummary } from '@ltht-react/utils'
7
-
8
- const StyledConditionCategory = styled.div<IStyledDescription>`
9
- color: ${TEXT_COLOURS.SECONDARY.VALUE};
10
- text-align: left;
11
- font-size: smaller;
12
- padding-top: 0.25rem;
13
- text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
14
- `
15
-
16
- const DiagnosisCategory: FC<Props> = ({ condition, enteredInError, ...rest }) => (
17
- <StyledConditionCategory enteredInError={enteredInError} {...rest}>
18
- {codeableConceptDisplaySummary(condition.severity)}
19
- </StyledConditionCategory>
20
- )
21
-
22
- interface Props extends HTMLAttributes<HTMLDivElement> {
23
- condition: Condition
24
- enteredInError: boolean
25
- }
26
-
27
- interface IStyledDescription {
28
- enteredInError: boolean
29
- }
30
-
31
- export default DiagnosisCategory
1
+ import { FC, HTMLAttributes } from 'react'
2
+ import styled from '@emotion/styled'
3
+
4
+ import { TEXT_COLOURS } from '@ltht-react/styles'
5
+ import { Condition } from '@ltht-react/types'
6
+ import { codeableConceptDisplaySummary } from '@ltht-react/utils'
7
+
8
+ const StyledConditionCategory = styled.div<IStyledDescription>`
9
+ color: ${TEXT_COLOURS.SECONDARY.VALUE};
10
+ text-align: left;
11
+ font-size: smaller;
12
+ padding-top: 0.25rem;
13
+ text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
14
+ `
15
+
16
+ const DiagnosisCategory: FC<Props> = ({ condition, enteredInError, ...rest }) => (
17
+ <StyledConditionCategory enteredInError={enteredInError} {...rest}>
18
+ {codeableConceptDisplaySummary(condition.severity)}
19
+ </StyledConditionCategory>
20
+ )
21
+
22
+ interface Props extends HTMLAttributes<HTMLDivElement> {
23
+ condition: Condition
24
+ enteredInError: boolean
25
+ }
26
+
27
+ interface IStyledDescription {
28
+ enteredInError: boolean
29
+ }
30
+
31
+ export default DiagnosisCategory
@@ -1,46 +1,46 @@
1
- import { FC, HTMLAttributes } from 'react'
2
- import styled from '@emotion/styled'
3
-
4
- import { TEXT_COLOURS } from '@ltht-react/styles'
5
- import { Condition } from '@ltht-react/types'
6
-
7
- const StyledConditionStatus = styled.div<IStyledDescription>`
8
- color: ${TEXT_COLOURS.SECONDARY.VALUE};
9
- text-align: left;
10
- font-size: smaller;
11
- padding-top: 0.25rem;
12
- text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
13
- `
14
-
15
- const extractDataSourceDisplayNames = (condition: Condition) => {
16
- const dataSourceDisplayNames: string[] = []
17
-
18
- condition?.metadata?.dataSources?.forEach((dataSource, _) => {
19
- if (dataSource?.display) {
20
- dataSourceDisplayNames.push(dataSource.display)
21
- }
22
- })
23
-
24
- return dataSourceDisplayNames.join(', ')
25
- }
26
-
27
- const DiagnosisDataSource: FC<Props> = ({ condition, enteredInError, ...rest }) => {
28
- const dataSourceDisplayNames = extractDataSourceDisplayNames(condition)
29
-
30
- return (
31
- <StyledConditionStatus enteredInError={enteredInError} {...rest}>
32
- {dataSourceDisplayNames ? `Source: ${dataSourceDisplayNames}` : `Source: Unknown`}
33
- </StyledConditionStatus>
34
- )
35
- }
36
-
37
- interface Props extends HTMLAttributes<HTMLDivElement> {
38
- condition: Condition
39
- enteredInError: boolean
40
- }
41
-
42
- interface IStyledDescription {
43
- enteredInError: boolean
44
- }
45
-
46
- export default DiagnosisDataSource
1
+ import { FC, HTMLAttributes } from 'react'
2
+ import styled from '@emotion/styled'
3
+
4
+ import { TEXT_COLOURS } from '@ltht-react/styles'
5
+ import { Condition } from '@ltht-react/types'
6
+
7
+ const StyledConditionStatus = styled.div<IStyledDescription>`
8
+ color: ${TEXT_COLOURS.SECONDARY.VALUE};
9
+ text-align: left;
10
+ font-size: smaller;
11
+ padding-top: 0.25rem;
12
+ text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
13
+ `
14
+
15
+ const extractDataSourceDisplayNames = (condition: Condition) => {
16
+ const dataSourceDisplayNames: string[] = []
17
+
18
+ condition?.metadata?.dataSources?.forEach((dataSource, _) => {
19
+ if (dataSource?.display) {
20
+ dataSourceDisplayNames.push(dataSource.display)
21
+ }
22
+ })
23
+
24
+ return dataSourceDisplayNames.join(', ')
25
+ }
26
+
27
+ const DiagnosisDataSource: FC<Props> = ({ condition, enteredInError, ...rest }) => {
28
+ const dataSourceDisplayNames = extractDataSourceDisplayNames(condition)
29
+
30
+ return (
31
+ <StyledConditionStatus enteredInError={enteredInError} {...rest}>
32
+ {dataSourceDisplayNames ? `Source: ${dataSourceDisplayNames}` : `Source: Unknown`}
33
+ </StyledConditionStatus>
34
+ )
35
+ }
36
+
37
+ interface Props extends HTMLAttributes<HTMLDivElement> {
38
+ condition: Condition
39
+ enteredInError: boolean
40
+ }
41
+
42
+ interface IStyledDescription {
43
+ enteredInError: boolean
44
+ }
45
+
46
+ export default DiagnosisDataSource
@@ -1,39 +1,39 @@
1
- import { FC, HTMLAttributes } from 'react'
2
- import styled from '@emotion/styled'
3
-
4
- import { TEXT_COLOURS } from '@ltht-react/styles'
5
- import { Condition } from '@ltht-react/types'
6
-
7
- import { getBooleanExtension } from '@ltht-react/utils'
8
-
9
- const StyledOnsetEstimated = styled.div<IStyledDescription>`
10
- color: ${TEXT_COLOURS.INFO};
11
- font-size: x-small;
12
- white-space: pre-wrap;
13
- display: inline-block;
14
- text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
15
- `
16
-
17
- const DiagnosisOnsetEstimated: FC<Props> = ({ condition, enteredInError, ...rest }) => {
18
- const onsetDateEstimated = getBooleanExtension(
19
- condition.extension,
20
- 'https://fhir.leedsth.nhs.uk/ValueSet/diagnosis-onset-date-estimated-1'
21
- )
22
-
23
- return (
24
- <StyledOnsetEstimated enteredInError={enteredInError} {...rest}>
25
- {onsetDateEstimated ? ' (estimated)' : ''}
26
- </StyledOnsetEstimated>
27
- )
28
- }
29
-
30
- interface Props extends HTMLAttributes<HTMLDivElement> {
31
- condition: Condition
32
- enteredInError: boolean
33
- }
34
-
35
- interface IStyledDescription {
36
- enteredInError: boolean
37
- }
38
-
39
- export default DiagnosisOnsetEstimated
1
+ import { FC, HTMLAttributes } from 'react'
2
+ import styled from '@emotion/styled'
3
+
4
+ import { TEXT_COLOURS } from '@ltht-react/styles'
5
+ import { Condition } from '@ltht-react/types'
6
+
7
+ import { getBooleanExtension } from '@ltht-react/utils'
8
+
9
+ const StyledOnsetEstimated = styled.div<IStyledDescription>`
10
+ color: ${TEXT_COLOURS.INFO};
11
+ font-size: x-small;
12
+ white-space: pre-wrap;
13
+ display: inline-block;
14
+ text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
15
+ `
16
+
17
+ const DiagnosisOnsetEstimated: FC<Props> = ({ condition, enteredInError, ...rest }) => {
18
+ const onsetDateEstimated = getBooleanExtension(
19
+ condition.extension,
20
+ 'https://fhir.leedsth.nhs.uk/ValueSet/diagnosis-onset-date-estimated-1'
21
+ )
22
+
23
+ return (
24
+ <StyledOnsetEstimated enteredInError={enteredInError} {...rest}>
25
+ {onsetDateEstimated ? ' (estimated)' : ''}
26
+ </StyledOnsetEstimated>
27
+ )
28
+ }
29
+
30
+ interface Props extends HTMLAttributes<HTMLDivElement> {
31
+ condition: Condition
32
+ enteredInError: boolean
33
+ }
34
+
35
+ interface IStyledDescription {
36
+ enteredInError: boolean
37
+ }
38
+
39
+ export default DiagnosisOnsetEstimated
@@ -1,70 +1,70 @@
1
- import { FC, HTMLAttributes } from 'react'
2
- import styled from '@emotion/styled'
3
- import { titleCase, codeableConceptDisplaySummary } from '@ltht-react/utils'
4
-
5
- import { TEXT_COLOURS } from '@ltht-react/styles'
6
- import { Condition } from '@ltht-react/types'
7
- import { SNIPPET_HOVER_TEXT } from '../constants'
8
-
9
- const StyledConditionTitle = styled.div<IStyledDescription>`
10
- color: ${TEXT_COLOURS.PRIMARY};
11
- text-align: left;
12
- text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
13
- `
14
-
15
- const DiagnosisTitle: FC<Props> = ({ condition, enteredInError, systemExclusionsFilter }) => {
16
- const snippetTagText = extractSnippetTagDisplayValue(condition)
17
-
18
- if (snippetTagText) {
19
- return renderTitle(snippetTagText, enteredInError)
20
- }
21
-
22
- const conditionText = extractConditionOrFallbackText(condition, systemExclusionsFilter)
23
- const conditionStatusText = extractConditionStatusText(condition)
24
- const title = conditionStatusText ? `${conditionText}, ${conditionStatusText}` : conditionText
25
-
26
- return renderTitle(title, enteredInError)
27
- }
28
-
29
- const extractConditionOrFallbackText = (condition: Condition, systemExclusionsFilter?: string[]): string => {
30
- if (!condition?.code) {
31
- return titleCase('Unknown Condition')
32
- }
33
-
34
- const diagnosisTitle = codeableConceptDisplaySummary(condition.code, systemExclusionsFilter)
35
-
36
- return titleCase(diagnosisTitle || 'Unknown Condition')
37
- }
38
-
39
- const extractConditionStatusText = (condition: Condition): string => {
40
- const statusParts: string[] = []
41
-
42
- if (condition?.clinicalStatus) {
43
- statusParts.push(condition?.clinicalStatus)
44
- }
45
-
46
- if (condition?.verificationStatus) {
47
- statusParts.push(condition.verificationStatus)
48
- }
49
-
50
- return titleCase(statusParts.join(', '))
51
- }
52
-
53
- const extractSnippetTagDisplayValue = (condition: Condition) =>
54
- condition?.metadata.tag?.find((coding) => coding?.system === SNIPPET_HOVER_TEXT)?.display
55
-
56
- const renderTitle = (title: string, enteredInError: boolean) => (
57
- <StyledConditionTitle enteredInError={enteredInError}>{title}</StyledConditionTitle>
58
- )
59
-
60
- interface Props extends HTMLAttributes<HTMLDivElement> {
61
- condition: Condition
62
- enteredInError: boolean
63
- systemExclusionsFilter?: string[]
64
- }
65
-
66
- interface IStyledDescription {
67
- enteredInError: boolean
68
- }
69
-
70
- export default DiagnosisTitle
1
+ import { FC, HTMLAttributes } from 'react'
2
+ import styled from '@emotion/styled'
3
+ import { titleCase, codeableConceptDisplaySummary } from '@ltht-react/utils'
4
+
5
+ import { TEXT_COLOURS } from '@ltht-react/styles'
6
+ import { Condition } from '@ltht-react/types'
7
+ import { SNIPPET_HOVER_TEXT } from '../constants'
8
+
9
+ const StyledConditionTitle = styled.div<IStyledDescription>`
10
+ color: ${TEXT_COLOURS.PRIMARY};
11
+ text-align: left;
12
+ text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
13
+ `
14
+
15
+ const DiagnosisTitle: FC<Props> = ({ condition, enteredInError, systemExclusionsFilter }) => {
16
+ const snippetTagText = extractSnippetTagDisplayValue(condition)
17
+
18
+ if (snippetTagText) {
19
+ return renderTitle(snippetTagText, enteredInError)
20
+ }
21
+
22
+ const conditionText = extractConditionOrFallbackText(condition, systemExclusionsFilter)
23
+ const conditionStatusText = extractConditionStatusText(condition)
24
+ const title = conditionStatusText ? `${conditionText}, ${conditionStatusText}` : conditionText
25
+
26
+ return renderTitle(title, enteredInError)
27
+ }
28
+
29
+ const extractConditionOrFallbackText = (condition: Condition, systemExclusionsFilter?: string[]): string => {
30
+ if (!condition?.code) {
31
+ return titleCase('Unknown Condition')
32
+ }
33
+
34
+ const diagnosisTitle = codeableConceptDisplaySummary(condition.code, systemExclusionsFilter)
35
+
36
+ return titleCase(diagnosisTitle || 'Unknown Condition')
37
+ }
38
+
39
+ const extractConditionStatusText = (condition: Condition): string => {
40
+ const statusParts: string[] = []
41
+
42
+ if (condition?.clinicalStatus) {
43
+ statusParts.push(condition?.clinicalStatus)
44
+ }
45
+
46
+ if (condition?.verificationStatus) {
47
+ statusParts.push(condition.verificationStatus)
48
+ }
49
+
50
+ return titleCase(statusParts.join(', '))
51
+ }
52
+
53
+ const extractSnippetTagDisplayValue = (condition: Condition) =>
54
+ condition?.metadata.tag?.find((coding) => coding?.system === SNIPPET_HOVER_TEXT)?.display
55
+
56
+ const renderTitle = (title: string, enteredInError: boolean) => (
57
+ <StyledConditionTitle enteredInError={enteredInError}>{title}</StyledConditionTitle>
58
+ )
59
+
60
+ interface Props extends HTMLAttributes<HTMLDivElement> {
61
+ condition: Condition
62
+ enteredInError: boolean
63
+ systemExclusionsFilter?: string[]
64
+ }
65
+
66
+ interface IStyledDescription {
67
+ enteredInError: boolean
68
+ }
69
+
70
+ export default DiagnosisTitle
package/src/constants.ts CHANGED
@@ -1,5 +1,5 @@
1
- const SNIPPET_HOVER_TEXT = 'https://leedsth.nhs.uk/cds/snippet-hover-text'
2
- const EXTENSION_TEMPLATE_DISPLAY_NAME = 'https://leedsth.nhs.uk/cds/extension-template-display-name'
3
- const EXTENSION_TEMPLATE_VERSION = 'https://leedsth.nhs.uk/cds/extension-template-version'
4
-
5
- export { EXTENSION_TEMPLATE_DISPLAY_NAME, EXTENSION_TEMPLATE_VERSION, SNIPPET_HOVER_TEXT }
1
+ const SNIPPET_HOVER_TEXT = 'https://leedsth.nhs.uk/cds/snippet-hover-text'
2
+ const EXTENSION_TEMPLATE_DISPLAY_NAME = 'https://leedsth.nhs.uk/cds/extension-template-display-name'
3
+ const EXTENSION_TEMPLATE_VERSION = 'https://leedsth.nhs.uk/cds/extension-template-version'
4
+
5
+ export { EXTENSION_TEMPLATE_DISPLAY_NAME, EXTENSION_TEMPLATE_VERSION, SNIPPET_HOVER_TEXT }
package/src/index.tsx CHANGED
@@ -1,3 +1,3 @@
1
- import DiagnosisSummary from './organisms/diagnosis-summary'
2
-
3
- export default DiagnosisSummary
1
+ import DiagnosisSummary from './organisms/diagnosis-summary'
2
+
3
+ export default DiagnosisSummary
@@ -1,31 +1,31 @@
1
- import { FC } from 'react'
2
- import styled from '@emotion/styled'
3
-
4
- import { Condition } from '@ltht-react/types'
5
- import { DateSummary, RedactedDescription } from '@ltht-react/type-summary'
6
-
7
- const StyledRedactedDescription = styled.div`
8
- flex-grow: 1;
9
- text-align: left;
10
- `
11
-
12
- const StyledDateSummary = styled.div`
13
- text-align: right;
14
- `
15
-
16
- const DiagnosisRedacted: FC<Props> = ({ condition }) => (
17
- <>
18
- <StyledRedactedDescription>
19
- <RedactedDescription />
20
- </StyledRedactedDescription>
21
- <StyledDateSummary>
22
- <DateSummary datetime={condition?.onset?.dateTime} />
23
- </StyledDateSummary>
24
- </>
25
- )
26
-
27
- interface Props {
28
- condition?: Condition | null
29
- }
30
-
31
- export default DiagnosisRedacted
1
+ import { FC } from 'react'
2
+ import styled from '@emotion/styled'
3
+
4
+ import { Condition } from '@ltht-react/types'
5
+ import { DateSummary, RedactedDescription } from '@ltht-react/type-summary'
6
+
7
+ const StyledRedactedDescription = styled.div`
8
+ flex-grow: 1;
9
+ text-align: left;
10
+ `
11
+
12
+ const StyledDateSummary = styled.div`
13
+ text-align: right;
14
+ `
15
+
16
+ const DiagnosisRedacted: FC<Props> = ({ condition }) => (
17
+ <>
18
+ <StyledRedactedDescription>
19
+ <RedactedDescription />
20
+ </StyledRedactedDescription>
21
+ <StyledDateSummary>
22
+ <DateSummary datetime={condition?.onset?.dateTime} />
23
+ </StyledDateSummary>
24
+ </>
25
+ )
26
+
27
+ interface Props {
28
+ condition?: Condition | null
29
+ }
30
+
31
+ export default DiagnosisRedacted
@@ -1,223 +1,223 @@
1
- import { cloneElement, FC, HTMLAttributes, ReactElement } from 'react'
2
- import styled from '@emotion/styled'
3
-
4
- import { Condition, ConditionVerificationStatus } from '@ltht-react/types'
5
- import { DateSummary } from '@ltht-react/type-summary'
6
- import Icon from '@ltht-react/icon'
7
- import { Button, ButtonProps } from '@ltht-react/button'
8
-
9
- import {
10
- BTN_COLOURS,
11
- MOBILE_MAXIMUM_MEDIA_QUERY,
12
- SMALL_SCREEN_MAXIMUM_MEDIA_QUERY,
13
- TABLET_ONLY_MEDIA_QUERY,
14
- } from '@ltht-react/styles'
15
- import Title from '../atoms/diagnosis-title'
16
- import OnsetDateEstimated from '../atoms/diagnosis-onset-estimated'
17
- import Redacted from '../molecules/diagnosis-redacted'
18
- import DiagnosisDataSource from '../atoms/diagnosis-data-source'
19
-
20
- const StyledTitle = styled.div`
21
- display: inline-block;
22
- `
23
- const StyledSummary = styled.div`
24
- display: flex;
25
- justify-content: center;
26
- `
27
- const StyledDescription = styled.div`
28
- flex-grow: 1;
29
- `
30
- const StyledLeftContainer = styled.div`
31
- display: flex;
32
- flex-grow: 1;
33
- flex-direction: row;
34
- gap: 0.3rem;
35
-
36
- ${TABLET_ONLY_MEDIA_QUERY} {
37
- margin: 0;
38
- flex-flow: row wrap;
39
- justify-content: start;
40
-
41
- & > * {
42
- width: 80%;
43
- }
44
- }
45
-
46
- ${MOBILE_MAXIMUM_MEDIA_QUERY} {
47
- flex-direction: column;
48
- }
49
- `
50
- const StyledResponsiveContainer = styled.div`
51
- display: flex;
52
- margin: 0 10px 0 10px;
53
- flex-direction: column;
54
- gap: 0.3rem;
55
- align-items: center;
56
- justify-content: center;
57
-
58
- ${TABLET_ONLY_MEDIA_QUERY} {
59
- margin: 0;
60
- flex-flow: row wrap;
61
- justify-content: start;
62
-
63
- & > * {
64
- width: fit-content;
65
- }
66
- }
67
-
68
- ${MOBILE_MAXIMUM_MEDIA_QUERY} {
69
- margin: 0;
70
- flex-flow: row wrap;
71
- justify-content: start;
72
-
73
- & > * {
74
- width: fit-content;
75
- }
76
- }
77
-
78
- ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
79
- margin: 0;
80
- flex-direction: column;
81
-
82
- & > * {
83
- width: 100%;
84
- max-width: 200px;
85
- display: flex;
86
- justify-content: center;
87
- }
88
- }
89
- `
90
- const StyledButton = styled(Button)`
91
- font-size: 0.8em !important;
92
- padding: 1px 5px;
93
-
94
- ${TABLET_ONLY_MEDIA_QUERY} {
95
- width: fit-content;
96
- }
97
-
98
- ${MOBILE_MAXIMUM_MEDIA_QUERY} {
99
- width: fit-content;
100
- }
101
-
102
- ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
103
- width: 100%;
104
- max-width: 200px;
105
- }
106
- `
107
- const StyledDate = styled.div`
108
- text-align: left;
109
- width: 15%;
110
- `
111
- const IconButtonWrapper = styled(Button)`
112
- -webkit-box-align: center;
113
- align-items: center;
114
- -webkit-box-pack: center;
115
- justify-content: center;
116
- margin-right: 0.5rem;
117
- display: inline-block !important;
118
- margin-left: 0.5rem;
119
- width: auto;
120
- `
121
- const IconWrapper = styled.div`
122
- margin-left: 0.5rem;
123
- display: inline-block;
124
- `
125
-
126
- const DiagnosisSummary: FC<Props> = ({
127
- condition,
128
- extendedTemplateDisplayName,
129
- extensionTemplateDisplayName,
130
- extensionClickHandler,
131
- isReadOnly = false,
132
- dateOnlyView = false,
133
- canExtendDiagnosis = false,
134
- displaySource = false,
135
- controls = [],
136
- tags = [],
137
- systemExclusionsFilter = [],
138
- ...rest
139
- }) => {
140
- if (condition.metadata.isRedacted) {
141
- return (
142
- <StyledSummary {...rest}>
143
- <Redacted condition={condition} />
144
- </StyledSummary>
145
- )
146
- }
147
-
148
- const enteredInError = condition.verificationStatus === ConditionVerificationStatus.EnteredInError
149
-
150
- return (
151
- <StyledSummary {...rest}>
152
- <StyledLeftContainer>
153
- <StyledDescription>
154
- <StyledTitle>
155
- <Title
156
- enteredInError={enteredInError}
157
- condition={condition}
158
- systemExclusionsFilter={systemExclusionsFilter}
159
- />
160
- </StyledTitle>
161
- {extensionTemplateDisplayName && !isReadOnly && canExtendDiagnosis && !enteredInError && (
162
- <IconButtonWrapper
163
- onClick={extensionClickHandler}
164
- type="button"
165
- styling={{ buttonStyle: 'clear' }}
166
- value=""
167
- icon={<Icon type="folder-plus" size="medium" />}
168
- iconPlacement="center"
169
- iconColour={BTN_COLOURS.PRIMARY.VALUE}
170
- title={`This diagnosis can be extended further using form '${extensionTemplateDisplayName}' by clicking here`}
171
- />
172
- )}
173
- {extendedTemplateDisplayName && (
174
- <IconWrapper>
175
- <Icon
176
- type="comment"
177
- size="medium"
178
- title={`This diagnosis has been extended beyond standard diagnosis with form '${extendedTemplateDisplayName}'.
179
- To view these extra details, click into the full diagnosis detail or edit the existing form.`}
180
- />
181
- </IconWrapper>
182
- )}
183
-
184
- {displaySource && <DiagnosisDataSource condition={condition} enteredInError={enteredInError} />}
185
- </StyledDescription>
186
-
187
- {tags.length > 0 && (
188
- <StyledResponsiveContainer>
189
- {tags?.map((tag, index) => (tag.key ? tag : cloneElement(tag, { key: index })))}
190
- </StyledResponsiveContainer>
191
- )}
192
-
193
- {!isReadOnly && controls.length > 0 && (
194
- <StyledResponsiveContainer>
195
- {controls.map((props, index) => (
196
- <StyledButton key={index} {...props} />
197
- ))}
198
- </StyledResponsiveContainer>
199
- )}
200
- </StyledLeftContainer>
201
- <StyledDate>
202
- <DateSummary enteredInError={enteredInError} datetime={condition?.assertedDate} dateOnlyView={dateOnlyView} />
203
- <OnsetDateEstimated enteredInError={enteredInError} condition={condition} />
204
- </StyledDate>
205
- </StyledSummary>
206
- )
207
- }
208
-
209
- interface Props extends HTMLAttributes<HTMLDivElement> {
210
- condition: Condition
211
- extendedTemplateDisplayName?: string | undefined
212
- extensionTemplateDisplayName?: string | undefined
213
- isReadOnly: boolean
214
- dateOnlyView?: boolean
215
- displaySource?: boolean
216
- controls?: ButtonProps[]
217
- tags?: ReactElement[]
218
- canExtendDiagnosis?: boolean
219
- extensionClickHandler?(): void
220
- systemExclusionsFilter?: string[]
221
- }
222
-
223
- export default DiagnosisSummary
1
+ import { cloneElement, FC, HTMLAttributes, ReactElement } from 'react'
2
+ import styled from '@emotion/styled'
3
+
4
+ import { Condition, ConditionVerificationStatus } from '@ltht-react/types'
5
+ import { DateSummary } from '@ltht-react/type-summary'
6
+ import Icon from '@ltht-react/icon'
7
+ import { Button, ButtonProps } from '@ltht-react/button'
8
+
9
+ import {
10
+ BTN_COLOURS,
11
+ MOBILE_MAXIMUM_MEDIA_QUERY,
12
+ SMALL_SCREEN_MAXIMUM_MEDIA_QUERY,
13
+ TABLET_ONLY_MEDIA_QUERY,
14
+ } from '@ltht-react/styles'
15
+ import Title from '../atoms/diagnosis-title'
16
+ import OnsetDateEstimated from '../atoms/diagnosis-onset-estimated'
17
+ import Redacted from '../molecules/diagnosis-redacted'
18
+ import DiagnosisDataSource from '../atoms/diagnosis-data-source'
19
+
20
+ const StyledTitle = styled.div`
21
+ display: inline-block;
22
+ `
23
+ const StyledSummary = styled.div`
24
+ display: flex;
25
+ justify-content: center;
26
+ `
27
+ const StyledDescription = styled.div`
28
+ flex-grow: 1;
29
+ `
30
+ const StyledLeftContainer = styled.div`
31
+ display: flex;
32
+ flex-grow: 1;
33
+ flex-direction: row;
34
+ gap: 0.3rem;
35
+
36
+ ${TABLET_ONLY_MEDIA_QUERY} {
37
+ margin: 0;
38
+ flex-flow: row wrap;
39
+ justify-content: start;
40
+
41
+ & > * {
42
+ width: 80%;
43
+ }
44
+ }
45
+
46
+ ${MOBILE_MAXIMUM_MEDIA_QUERY} {
47
+ flex-direction: column;
48
+ }
49
+ `
50
+ const StyledResponsiveContainer = styled.div`
51
+ display: flex;
52
+ margin: 0 10px 0 10px;
53
+ flex-direction: column;
54
+ gap: 0.3rem;
55
+ align-items: center;
56
+ justify-content: center;
57
+
58
+ ${TABLET_ONLY_MEDIA_QUERY} {
59
+ margin: 0;
60
+ flex-flow: row wrap;
61
+ justify-content: start;
62
+
63
+ & > * {
64
+ width: fit-content;
65
+ }
66
+ }
67
+
68
+ ${MOBILE_MAXIMUM_MEDIA_QUERY} {
69
+ margin: 0;
70
+ flex-flow: row wrap;
71
+ justify-content: start;
72
+
73
+ & > * {
74
+ width: fit-content;
75
+ }
76
+ }
77
+
78
+ ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
79
+ margin: 0;
80
+ flex-direction: column;
81
+
82
+ & > * {
83
+ width: 100%;
84
+ max-width: 200px;
85
+ display: flex;
86
+ justify-content: center;
87
+ }
88
+ }
89
+ `
90
+ const StyledButton = styled(Button)`
91
+ font-size: 0.8em !important;
92
+ padding: 1px 5px;
93
+
94
+ ${TABLET_ONLY_MEDIA_QUERY} {
95
+ width: fit-content;
96
+ }
97
+
98
+ ${MOBILE_MAXIMUM_MEDIA_QUERY} {
99
+ width: fit-content;
100
+ }
101
+
102
+ ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
103
+ width: 100%;
104
+ max-width: 200px;
105
+ }
106
+ `
107
+ const StyledDate = styled.div`
108
+ text-align: left;
109
+ width: 15%;
110
+ `
111
+ const IconButtonWrapper = styled(Button)`
112
+ -webkit-box-align: center;
113
+ align-items: center;
114
+ -webkit-box-pack: center;
115
+ justify-content: center;
116
+ margin-right: 0.5rem;
117
+ display: inline-block !important;
118
+ margin-left: 0.5rem;
119
+ width: auto;
120
+ `
121
+ const IconWrapper = styled.div`
122
+ margin-left: 0.5rem;
123
+ display: inline-block;
124
+ `
125
+
126
+ const DiagnosisSummary: FC<Props> = ({
127
+ condition,
128
+ extendedTemplateDisplayName,
129
+ extensionTemplateDisplayName,
130
+ extensionClickHandler,
131
+ isReadOnly = false,
132
+ dateOnlyView = false,
133
+ canExtendDiagnosis = false,
134
+ displaySource = false,
135
+ controls = [],
136
+ tags = [],
137
+ systemExclusionsFilter = [],
138
+ ...rest
139
+ }) => {
140
+ if (condition.metadata.isRedacted) {
141
+ return (
142
+ <StyledSummary {...rest}>
143
+ <Redacted condition={condition} />
144
+ </StyledSummary>
145
+ )
146
+ }
147
+
148
+ const enteredInError = condition.verificationStatus === ConditionVerificationStatus.EnteredInError
149
+
150
+ return (
151
+ <StyledSummary {...rest}>
152
+ <StyledLeftContainer>
153
+ <StyledDescription>
154
+ <StyledTitle>
155
+ <Title
156
+ enteredInError={enteredInError}
157
+ condition={condition}
158
+ systemExclusionsFilter={systemExclusionsFilter}
159
+ />
160
+ </StyledTitle>
161
+ {extensionTemplateDisplayName && !isReadOnly && canExtendDiagnosis && !enteredInError && (
162
+ <IconButtonWrapper
163
+ onClick={extensionClickHandler}
164
+ type="button"
165
+ styling={{ buttonStyle: 'clear' }}
166
+ value=""
167
+ icon={<Icon type="folder-plus" size="medium" />}
168
+ iconPlacement="center"
169
+ iconColour={BTN_COLOURS.PRIMARY.VALUE}
170
+ title={`This diagnosis can be extended further using form '${extensionTemplateDisplayName}' by clicking here`}
171
+ />
172
+ )}
173
+ {extendedTemplateDisplayName && (
174
+ <IconWrapper>
175
+ <Icon
176
+ type="comment"
177
+ size="medium"
178
+ title={`This diagnosis has been extended beyond standard diagnosis with form '${extendedTemplateDisplayName}'.
179
+ To view these extra details, click into the full diagnosis detail or edit the existing form.`}
180
+ />
181
+ </IconWrapper>
182
+ )}
183
+
184
+ {displaySource && <DiagnosisDataSource condition={condition} enteredInError={enteredInError} />}
185
+ </StyledDescription>
186
+
187
+ {tags.length > 0 && (
188
+ <StyledResponsiveContainer>
189
+ {tags?.map((tag, index) => (tag.key ? tag : cloneElement(tag, { key: index })))}
190
+ </StyledResponsiveContainer>
191
+ )}
192
+
193
+ {!isReadOnly && controls.length > 0 && (
194
+ <StyledResponsiveContainer>
195
+ {controls.map((props, index) => (
196
+ <StyledButton key={index} {...props} />
197
+ ))}
198
+ </StyledResponsiveContainer>
199
+ )}
200
+ </StyledLeftContainer>
201
+ <StyledDate>
202
+ <DateSummary enteredInError={enteredInError} datetime={condition?.assertedDate} dateOnlyView={dateOnlyView} />
203
+ <OnsetDateEstimated enteredInError={enteredInError} condition={condition} />
204
+ </StyledDate>
205
+ </StyledSummary>
206
+ )
207
+ }
208
+
209
+ interface Props extends HTMLAttributes<HTMLDivElement> {
210
+ condition: Condition
211
+ extendedTemplateDisplayName?: string | undefined
212
+ extensionTemplateDisplayName?: string | undefined
213
+ isReadOnly: boolean
214
+ dateOnlyView?: boolean
215
+ displaySource?: boolean
216
+ controls?: ButtonProps[]
217
+ tags?: ReactElement[]
218
+ canExtendDiagnosis?: boolean
219
+ extensionClickHandler?(): void
220
+ systemExclusionsFilter?: string[]
221
+ }
222
+
223
+ export default DiagnosisSummary