@ltht-react/diagnosis-summary 2.0.100 → 2.0.103

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.100",
3
+ "version": "2.0.103",
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.100",
32
- "@ltht-react/hooks": "^2.0.100",
33
- "@ltht-react/icon": "^2.0.100",
34
- "@ltht-react/list": "^2.0.100",
35
- "@ltht-react/styles": "^2.0.100",
36
- "@ltht-react/type-summary": "^2.0.100",
37
- "@ltht-react/types": "^2.0.100",
38
- "@ltht-react/utils": "^2.0.100",
31
+ "@ltht-react/button": "^2.0.103",
32
+ "@ltht-react/hooks": "^2.0.103",
33
+ "@ltht-react/icon": "^2.0.103",
34
+ "@ltht-react/list": "^2.0.103",
35
+ "@ltht-react/styles": "^2.0.103",
36
+ "@ltht-react/type-summary": "^2.0.103",
37
+ "@ltht-react/types": "^2.0.103",
38
+ "@ltht-react/utils": "^2.0.103",
39
39
  "react": "^18.2.0"
40
40
  },
41
- "gitHead": "c92e42c76892b458ab7f3b2aee49fbe179ea9740"
41
+ "gitHead": "19e84e672e6fbb27d5eee808e0e328a1ade84090"
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,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,38 +1,38 @@
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 { titleCase } from '@ltht-react/utils'
7
-
8
- const StyledConditionStatus = 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 DiagnosisStatus: FC<Props> = ({ condition, enteredInError, ...rest }) => {
17
- const values = []
18
-
19
- if (condition.clinicalStatus) values.push(titleCase(condition.clinicalStatus))
20
- if (condition.verificationStatus) values.push(titleCase(condition.verificationStatus))
21
-
22
- return (
23
- <StyledConditionStatus enteredInError={enteredInError} {...rest}>
24
- {values.length > 0 ? values.join(' - ') : 'Insufficient data provided'}
25
- </StyledConditionStatus>
26
- )
27
- }
28
-
29
- interface Props extends HTMLAttributes<HTMLDivElement> {
30
- condition: Condition
31
- enteredInError: boolean
32
- }
33
-
34
- interface IStyledDescription {
35
- enteredInError: boolean
36
- }
37
-
38
- export default DiagnosisStatus
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 { titleCase } from '@ltht-react/utils'
7
+
8
+ const StyledConditionStatus = 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 DiagnosisStatus: FC<Props> = ({ condition, enteredInError, ...rest }) => {
17
+ const values = []
18
+
19
+ if (condition.clinicalStatus) values.push(titleCase(condition.clinicalStatus))
20
+ if (condition.verificationStatus) values.push(titleCase(condition.verificationStatus))
21
+
22
+ return (
23
+ <StyledConditionStatus enteredInError={enteredInError} {...rest}>
24
+ {values.length > 0 ? values.join(' - ') : 'Insufficient data provided'}
25
+ </StyledConditionStatus>
26
+ )
27
+ }
28
+
29
+ interface Props extends HTMLAttributes<HTMLDivElement> {
30
+ condition: Condition
31
+ enteredInError: boolean
32
+ }
33
+
34
+ interface IStyledDescription {
35
+ enteredInError: boolean
36
+ }
37
+
38
+ export default DiagnosisStatus
@@ -1,34 +1,34 @@
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 { SNIPPET_HOVER_TEXT } from '../constants'
7
-
8
- const StyledConditionTitle = styled.div<IStyledDescription>`
9
- color: ${TEXT_COLOURS.PRIMARY};
10
- text-align: left;
11
- text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
12
- `
13
-
14
- const DiagnosisTitle: FC<Props> = ({ condition, enteredInError, ...rest }) => {
15
- const snippetMetadataTag = condition?.metadata.tag?.find((coding) => coding?.system === SNIPPET_HOVER_TEXT)
16
- const conditionCoding = condition?.code
17
-
18
- return (
19
- <StyledConditionTitle enteredInError={enteredInError} {...rest}>
20
- {snippetMetadataTag?.display || conditionCoding?.text}
21
- </StyledConditionTitle>
22
- )
23
- }
24
-
25
- interface Props extends HTMLAttributes<HTMLDivElement> {
26
- condition: Condition
27
- enteredInError: boolean
28
- }
29
-
30
- interface IStyledDescription {
31
- enteredInError: boolean
32
- }
33
-
34
- export default DiagnosisTitle
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 { SNIPPET_HOVER_TEXT } from '../constants'
7
+
8
+ const StyledConditionTitle = styled.div<IStyledDescription>`
9
+ color: ${TEXT_COLOURS.PRIMARY};
10
+ text-align: left;
11
+ text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
12
+ `
13
+
14
+ const DiagnosisTitle: FC<Props> = ({ condition, enteredInError, ...rest }) => {
15
+ const snippetMetadataTag = condition?.metadata.tag?.find((coding) => coding?.system === SNIPPET_HOVER_TEXT)
16
+ const conditionCoding = condition?.code
17
+
18
+ return (
19
+ <StyledConditionTitle enteredInError={enteredInError} {...rest}>
20
+ {snippetMetadataTag?.display || conditionCoding?.text}
21
+ </StyledConditionTitle>
22
+ )
23
+ }
24
+
25
+ interface Props extends HTMLAttributes<HTMLDivElement> {
26
+ condition: Condition
27
+ enteredInError: boolean
28
+ }
29
+
30
+ interface IStyledDescription {
31
+ enteredInError: boolean
32
+ }
33
+
34
+ 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,183 +1,183 @@
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 { BTN_COLOURS, MOBILE_MAXIMUM_MEDIA_QUERY, SMALL_SCREEN_MAXIMUM_MEDIA_QUERY } from '@ltht-react/styles'
10
- import Title from '../atoms/diagnosis-title'
11
- import OnsetDateEstimated from '../atoms/diagnosis-onset-estimated'
12
- import Redacted from '../molecules/diagnosis-redacted'
13
-
14
- const StyledTitle = styled.div`
15
- display: inline-block;
16
- `
17
- const StyledSummary = styled.div`
18
- display: flex;
19
- justify-content: center;
20
- `
21
- const StyledDescription = styled.div`
22
- flex-grow: 1;
23
- `
24
- const StyledLeftContainer = styled.div`
25
- display: flex;
26
- flex-grow: 1;
27
- flex-direction: row;
28
- gap: 0.3rem;
29
-
30
- ${MOBILE_MAXIMUM_MEDIA_QUERY} {
31
- flex-direction: column;
32
- }
33
- `
34
- const StyledResponsiveContainer = styled.div`
35
- display: flex;
36
- margin: 0 10px 0 10px;
37
- flex-direction: column;
38
- gap: 0.3rem;
39
- align-items: center;
40
- justify-content: center;
41
-
42
- ${MOBILE_MAXIMUM_MEDIA_QUERY} {
43
- margin: 0;
44
- flex-flow: row wrap;
45
- justify-content: start;
46
-
47
- & > * {
48
- width: fit-content;
49
- }
50
- }
51
-
52
- ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
53
- margin: 0;
54
- flex-direction: column wrap;
55
-
56
- & > * {
57
- width: 100%;
58
- max-width: 200px;
59
- display: flex;
60
- justify-content: center;
61
- }
62
- }
63
- `
64
- const StyledButton = styled(Button)`
65
- font-size: 0.8em !important;
66
- padding: 1px 5px;
67
-
68
- ${MOBILE_MAXIMUM_MEDIA_QUERY} {
69
- width: fit-content;
70
- }
71
-
72
- ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
73
- width: 100%;
74
- max-width: 200px;
75
- }
76
- `
77
- const StyledDate = styled.div`
78
- text-align: left;
79
- width: 15%;
80
- `
81
- const IconButtonWrapper = styled(Button)`
82
- -webkit-box-align: center;
83
- align-items: center;
84
- -webkit-box-pack: center;
85
- justify-content: center;
86
- margin-right: 0.5rem;
87
- display: inline-block !important;
88
- margin-left: 0.5rem;
89
- width: auto;
90
- `
91
- const IconWrapper = styled.div`
92
- margin-left: 0.5rem;
93
- display: inline-block;
94
- `
95
-
96
- const DiagnosisSummary: FC<Props> = ({
97
- condition,
98
- extendedTemplateDisplayName,
99
- extensionTemplateDisplayName,
100
- extensionClickHandler,
101
- isReadOnly = false,
102
- dateOnlyView = false,
103
- canExtendDiagnosis = false,
104
- controls = [],
105
- tags = [],
106
- ...rest
107
- }) => {
108
- if (condition.metadata.isRedacted) {
109
- return (
110
- <StyledSummary {...rest}>
111
- <Redacted condition={condition} />
112
- </StyledSummary>
113
- )
114
- }
115
-
116
- const enteredInError = condition.verificationStatus === ConditionVerificationStatus.EnteredInError
117
-
118
- return (
119
- <StyledSummary {...rest}>
120
- <StyledLeftContainer>
121
- <StyledDescription>
122
- <StyledTitle>
123
- <Title enteredInError={enteredInError} condition={condition} />
124
- </StyledTitle>
125
- {extensionTemplateDisplayName && !isReadOnly && canExtendDiagnosis && !enteredInError && (
126
- <IconButtonWrapper
127
- onClick={extensionClickHandler}
128
- type="button"
129
- styling={{ buttonStyle: 'clear' }}
130
- value=""
131
- icon={<Icon type="folder-plus" size="medium" />}
132
- iconPlacement="center"
133
- iconColour={BTN_COLOURS.PRIMARY.VALUE}
134
- title={`This diagnosis can be extended further using form '${extensionTemplateDisplayName}' by clicking here`}
135
- />
136
- )}
137
- {extendedTemplateDisplayName && (
138
- <IconWrapper>
139
- <Icon
140
- type="comment"
141
- size="medium"
142
- title={`This diagnosis has been extended beyond standard diagnosis with form '${extendedTemplateDisplayName}'.
143
- To view these extra details, click into the full diagnosis detail or edit the existing form.`}
144
- />
145
- </IconWrapper>
146
- )}
147
- </StyledDescription>
148
-
149
- {tags.length > 0 && (
150
- <StyledResponsiveContainer>
151
- {tags?.map((tag, index) => (tag.key ? tag : cloneElement(tag, { key: index })))}
152
- </StyledResponsiveContainer>
153
- )}
154
-
155
- {!isReadOnly && controls.length > 0 && (
156
- <StyledResponsiveContainer>
157
- {controls.map((props, index) => (
158
- <StyledButton key={index} {...props} />
159
- ))}
160
- </StyledResponsiveContainer>
161
- )}
162
- </StyledLeftContainer>
163
- <StyledDate>
164
- <DateSummary enteredInError={enteredInError} datetime={condition?.assertedDate} dateOnlyView={dateOnlyView} />
165
- <OnsetDateEstimated enteredInError={enteredInError} condition={condition} />
166
- </StyledDate>
167
- </StyledSummary>
168
- )
169
- }
170
-
171
- interface Props extends HTMLAttributes<HTMLDivElement> {
172
- condition: Condition
173
- extendedTemplateDisplayName?: string | undefined
174
- extensionTemplateDisplayName?: string | undefined
175
- extensionClickHandler?(): void
176
- isReadOnly: boolean
177
- dateOnlyView?: boolean
178
- controls?: ButtonProps[]
179
- tags?: ReactElement[]
180
- canExtendDiagnosis?: boolean
181
- }
182
-
183
- 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 { BTN_COLOURS, MOBILE_MAXIMUM_MEDIA_QUERY, SMALL_SCREEN_MAXIMUM_MEDIA_QUERY } from '@ltht-react/styles'
10
+ import Title from '../atoms/diagnosis-title'
11
+ import OnsetDateEstimated from '../atoms/diagnosis-onset-estimated'
12
+ import Redacted from '../molecules/diagnosis-redacted'
13
+
14
+ const StyledTitle = styled.div`
15
+ display: inline-block;
16
+ `
17
+ const StyledSummary = styled.div`
18
+ display: flex;
19
+ justify-content: center;
20
+ `
21
+ const StyledDescription = styled.div`
22
+ flex-grow: 1;
23
+ `
24
+ const StyledLeftContainer = styled.div`
25
+ display: flex;
26
+ flex-grow: 1;
27
+ flex-direction: row;
28
+ gap: 0.3rem;
29
+
30
+ ${MOBILE_MAXIMUM_MEDIA_QUERY} {
31
+ flex-direction: column;
32
+ }
33
+ `
34
+ const StyledResponsiveContainer = styled.div`
35
+ display: flex;
36
+ margin: 0 10px 0 10px;
37
+ flex-direction: column;
38
+ gap: 0.3rem;
39
+ align-items: center;
40
+ justify-content: center;
41
+
42
+ ${MOBILE_MAXIMUM_MEDIA_QUERY} {
43
+ margin: 0;
44
+ flex-flow: row wrap;
45
+ justify-content: start;
46
+
47
+ & > * {
48
+ width: fit-content;
49
+ }
50
+ }
51
+
52
+ ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
53
+ margin: 0;
54
+ flex-direction: column wrap;
55
+
56
+ & > * {
57
+ width: 100%;
58
+ max-width: 200px;
59
+ display: flex;
60
+ justify-content: center;
61
+ }
62
+ }
63
+ `
64
+ const StyledButton = styled(Button)`
65
+ font-size: 0.8em !important;
66
+ padding: 1px 5px;
67
+
68
+ ${MOBILE_MAXIMUM_MEDIA_QUERY} {
69
+ width: fit-content;
70
+ }
71
+
72
+ ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
73
+ width: 100%;
74
+ max-width: 200px;
75
+ }
76
+ `
77
+ const StyledDate = styled.div`
78
+ text-align: left;
79
+ width: 15%;
80
+ `
81
+ const IconButtonWrapper = styled(Button)`
82
+ -webkit-box-align: center;
83
+ align-items: center;
84
+ -webkit-box-pack: center;
85
+ justify-content: center;
86
+ margin-right: 0.5rem;
87
+ display: inline-block !important;
88
+ margin-left: 0.5rem;
89
+ width: auto;
90
+ `
91
+ const IconWrapper = styled.div`
92
+ margin-left: 0.5rem;
93
+ display: inline-block;
94
+ `
95
+
96
+ const DiagnosisSummary: FC<Props> = ({
97
+ condition,
98
+ extendedTemplateDisplayName,
99
+ extensionTemplateDisplayName,
100
+ extensionClickHandler,
101
+ isReadOnly = false,
102
+ dateOnlyView = false,
103
+ canExtendDiagnosis = false,
104
+ controls = [],
105
+ tags = [],
106
+ ...rest
107
+ }) => {
108
+ if (condition.metadata.isRedacted) {
109
+ return (
110
+ <StyledSummary {...rest}>
111
+ <Redacted condition={condition} />
112
+ </StyledSummary>
113
+ )
114
+ }
115
+
116
+ const enteredInError = condition.verificationStatus === ConditionVerificationStatus.EnteredInError
117
+
118
+ return (
119
+ <StyledSummary {...rest}>
120
+ <StyledLeftContainer>
121
+ <StyledDescription>
122
+ <StyledTitle>
123
+ <Title enteredInError={enteredInError} condition={condition} />
124
+ </StyledTitle>
125
+ {extensionTemplateDisplayName && !isReadOnly && canExtendDiagnosis && !enteredInError && (
126
+ <IconButtonWrapper
127
+ onClick={extensionClickHandler}
128
+ type="button"
129
+ styling={{ buttonStyle: 'clear' }}
130
+ value=""
131
+ icon={<Icon type="folder-plus" size="medium" />}
132
+ iconPlacement="center"
133
+ iconColour={BTN_COLOURS.PRIMARY.VALUE}
134
+ title={`This diagnosis can be extended further using form '${extensionTemplateDisplayName}' by clicking here`}
135
+ />
136
+ )}
137
+ {extendedTemplateDisplayName && (
138
+ <IconWrapper>
139
+ <Icon
140
+ type="comment"
141
+ size="medium"
142
+ title={`This diagnosis has been extended beyond standard diagnosis with form '${extendedTemplateDisplayName}'.
143
+ To view these extra details, click into the full diagnosis detail or edit the existing form.`}
144
+ />
145
+ </IconWrapper>
146
+ )}
147
+ </StyledDescription>
148
+
149
+ {tags.length > 0 && (
150
+ <StyledResponsiveContainer>
151
+ {tags?.map((tag, index) => (tag.key ? tag : cloneElement(tag, { key: index })))}
152
+ </StyledResponsiveContainer>
153
+ )}
154
+
155
+ {!isReadOnly && controls.length > 0 && (
156
+ <StyledResponsiveContainer>
157
+ {controls.map((props, index) => (
158
+ <StyledButton key={index} {...props} />
159
+ ))}
160
+ </StyledResponsiveContainer>
161
+ )}
162
+ </StyledLeftContainer>
163
+ <StyledDate>
164
+ <DateSummary enteredInError={enteredInError} datetime={condition?.assertedDate} dateOnlyView={dateOnlyView} />
165
+ <OnsetDateEstimated enteredInError={enteredInError} condition={condition} />
166
+ </StyledDate>
167
+ </StyledSummary>
168
+ )
169
+ }
170
+
171
+ interface Props extends HTMLAttributes<HTMLDivElement> {
172
+ condition: Condition
173
+ extendedTemplateDisplayName?: string | undefined
174
+ extensionTemplateDisplayName?: string | undefined
175
+ extensionClickHandler?(): void
176
+ isReadOnly: boolean
177
+ dateOnlyView?: boolean
178
+ controls?: ButtonProps[]
179
+ tags?: ReactElement[]
180
+ canExtendDiagnosis?: boolean
181
+ }
182
+
183
+ export default DiagnosisSummary