@ltht-react/diagnosis-summary 2.0.151 → 2.0.152

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.151",
3
+ "version": "2.0.152",
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.151",
32
- "@ltht-react/hooks": "^2.0.151",
33
- "@ltht-react/icon": "^2.0.151",
34
- "@ltht-react/list": "^2.0.151",
35
- "@ltht-react/styles": "^2.0.151",
36
- "@ltht-react/type-summary": "^2.0.151",
37
- "@ltht-react/types": "^2.0.151",
38
- "@ltht-react/utils": "^2.0.151",
31
+ "@ltht-react/button": "^2.0.152",
32
+ "@ltht-react/hooks": "^2.0.152",
33
+ "@ltht-react/icon": "^2.0.152",
34
+ "@ltht-react/list": "^2.0.152",
35
+ "@ltht-react/styles": "^2.0.152",
36
+ "@ltht-react/type-summary": "^2.0.152",
37
+ "@ltht-react/types": "^2.0.152",
38
+ "@ltht-react/utils": "^2.0.152",
39
39
  "react": "^18.2.0"
40
40
  },
41
- "gitHead": "5881065bf15de01a222f005eb126a30fc2f9f323"
41
+ "gitHead": "4438f604949fc9f5a0b77f4aa7a4bb717f11d1c6"
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,45 +1,45 @@
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
- text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
12
- `
13
-
14
- const extractDataSourceDisplayNames = (condition: Condition) => {
15
- const dataSourceDisplayNames: string[] = []
16
-
17
- condition?.metadata?.dataSources?.forEach((dataSource, _) => {
18
- if (dataSource?.display) {
19
- dataSourceDisplayNames.push(dataSource.display)
20
- }
21
- })
22
-
23
- return dataSourceDisplayNames.join(', ')
24
- }
25
-
26
- const DiagnosisDataSource: FC<Props> = ({ condition, enteredInError, ...rest }) => {
27
- const dataSourceDisplayNames = extractDataSourceDisplayNames(condition)
28
-
29
- return (
30
- <StyledConditionStatus enteredInError={enteredInError} {...rest}>
31
- {dataSourceDisplayNames ? `Source: ${dataSourceDisplayNames}` : `Source: Unknown`}
32
- </StyledConditionStatus>
33
- )
34
- }
35
-
36
- interface Props extends HTMLAttributes<HTMLDivElement> {
37
- condition: Condition
38
- enteredInError: boolean
39
- }
40
-
41
- interface IStyledDescription {
42
- enteredInError: boolean
43
- }
44
-
45
- 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
+ text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
12
+ `
13
+
14
+ const extractDataSourceDisplayNames = (condition: Condition) => {
15
+ const dataSourceDisplayNames: string[] = []
16
+
17
+ condition?.metadata?.dataSources?.forEach((dataSource, _) => {
18
+ if (dataSource?.display) {
19
+ dataSourceDisplayNames.push(dataSource.display)
20
+ }
21
+ })
22
+
23
+ return dataSourceDisplayNames.join(', ')
24
+ }
25
+
26
+ const DiagnosisDataSource: FC<Props> = ({ condition, enteredInError, ...rest }) => {
27
+ const dataSourceDisplayNames = extractDataSourceDisplayNames(condition)
28
+
29
+ return (
30
+ <StyledConditionStatus enteredInError={enteredInError} {...rest}>
31
+ {dataSourceDisplayNames ? `Source: ${dataSourceDisplayNames}` : `Source: Unknown`}
32
+ </StyledConditionStatus>
33
+ )
34
+ }
35
+
36
+ interface Props extends HTMLAttributes<HTMLDivElement> {
37
+ condition: Condition
38
+ enteredInError: boolean
39
+ }
40
+
41
+ interface IStyledDescription {
42
+ enteredInError: boolean
43
+ }
44
+
45
+ export default DiagnosisDataSource
@@ -1,40 +1,40 @@
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-align: right;
15
- text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
16
- `
17
-
18
- const DiagnosisOnsetEstimated: FC<Props> = ({ condition, enteredInError, ...rest }) => {
19
- const onsetDateEstimated = getBooleanExtension(
20
- condition.extension,
21
- 'https://fhir.leedsth.nhs.uk/ValueSet/diagnosis-onset-date-estimated-1'
22
- )
23
-
24
- return (
25
- <StyledOnsetEstimated enteredInError={enteredInError} {...rest}>
26
- {onsetDateEstimated ? '(estimated)' : ''}
27
- </StyledOnsetEstimated>
28
- )
29
- }
30
-
31
- interface Props extends HTMLAttributes<HTMLDivElement> {
32
- condition: Condition
33
- enteredInError: boolean
34
- }
35
-
36
- interface IStyledDescription {
37
- enteredInError: boolean
38
- }
39
-
40
- 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-align: right;
15
+ text-decoration: ${({ enteredInError }) => (enteredInError ? 'line-through' : 'none')};
16
+ `
17
+
18
+ const DiagnosisOnsetEstimated: FC<Props> = ({ condition, enteredInError, ...rest }) => {
19
+ const onsetDateEstimated = getBooleanExtension(
20
+ condition.extension,
21
+ 'https://fhir.leedsth.nhs.uk/ValueSet/diagnosis-onset-date-estimated-1'
22
+ )
23
+
24
+ return (
25
+ <StyledOnsetEstimated enteredInError={enteredInError} {...rest}>
26
+ {onsetDateEstimated ? '(estimated)' : ''}
27
+ </StyledOnsetEstimated>
28
+ )
29
+ }
30
+
31
+ interface Props extends HTMLAttributes<HTMLDivElement> {
32
+ condition: Condition
33
+ enteredInError: boolean
34
+ }
35
+
36
+ interface IStyledDescription {
37
+ enteredInError: boolean
38
+ }
39
+
40
+ 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,249 +1,249 @@
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, SMALL_SCREEN_MAXIMUM_MEDIA_QUERY, TABLET_MINIMUM_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
- import DiagnosisDataSource from '../atoms/diagnosis-data-source'
14
-
15
- const StyledTitle = styled.div`
16
- display: flex;
17
- `
18
-
19
- const StyledSummary = styled.div`
20
- display: flex;
21
- justify-content: center;
22
- flex-direction: column;
23
- `
24
-
25
- const StyledDescription = styled.div`
26
- flex-grow: 1;
27
- `
28
-
29
- const StyledTitleAndDateContainer = styled.div`
30
- display: flex;
31
- flex-grow: 1;
32
- flex-direction: row;
33
- gap: 5px;
34
-
35
- ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
36
- flex-flow: column nowrap;
37
- align-items: flex-start;
38
- div {
39
- text-align: left;
40
- }
41
- }
42
- `
43
-
44
- const StyledButtonAndTagContainer = styled.div`
45
- display: flex;
46
- flex-grow: 1;
47
- flex-direction: row;
48
- gap: 5px;
49
- margin-top: 5px;
50
-
51
- ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
52
- flex-direction: row;
53
- justify-content: space-between;
54
- }
55
- `
56
-
57
- const StyledResponsiveButtonContainer = styled.div`
58
- display: flex;
59
- margin-right: auto;
60
- flex-flow: row wrap;
61
- gap: 5px;
62
- height: fit-content;
63
- flex-grow: 1;
64
-
65
- & > * {
66
- height: 1.2rem;
67
- padding: 0 5px;
68
-
69
- ${TABLET_MINIMUM_MEDIA_QUERY} {
70
- font-size: 0.8rem !important;
71
- }
72
- }
73
-
74
- ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
75
- margin: 0;
76
- flex-direction: column;
77
-
78
- span {
79
- width: 100%;
80
- max-width: 10rem;
81
- }
82
- }
83
- `
84
-
85
- const StyledResponsiveTagContainer = styled.div`
86
- display: flex;
87
- margin-left: auto;
88
- flex-flow: row wrap;
89
- gap: 5px;
90
- height: fit-content;
91
- justify-content: flex-end;
92
- flex-grow: 1;
93
-
94
- & > * {
95
- display: flex;
96
- align-items: center;
97
- height: 1.2rem;
98
- margin: 0 !important;
99
- font-size: 0.8rem !important;
100
- padding: 0 10px;
101
- justify-content: center;
102
-
103
- ${TABLET_MINIMUM_MEDIA_QUERY} {
104
- font-size: 0.8rem !important;
105
- }
106
- }
107
-
108
- ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
109
- flex-direction: column;
110
- margin: 0;
111
-
112
- & > * {
113
- margin: 0;
114
- width: 100%;
115
- max-width: 10rem;
116
- padding: 0 10px;
117
- }
118
- }
119
- `
120
-
121
- const StyledButton = styled(Button)`
122
- padding: 0 5px;
123
- width: fit-content;
124
-
125
- ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
126
- width: 100%;
127
- max-width: 10rem;
128
- }
129
- `
130
- const StyledDate = styled.div`
131
- display: flex;
132
- flex-flow: column nowrap;
133
- text-align: right;
134
- min-width: 6rem;
135
- justify-content: start;
136
- `
137
- const IconButtonWrapper = styled(Button)`
138
- -webkit-box-align: center;
139
- align-items: center;
140
- -webkit-box-pack: center;
141
- justify-content: center;
142
- margin-right: 0.5rem;
143
- display: inline-block !important;
144
- margin-left: 0.5rem;
145
- width: auto;
146
- padding: 0 5px;
147
- `
148
- const IconWrapper = styled.div`
149
- margin-left: 0.5rem;
150
- display: inline-block;
151
- `
152
-
153
- const DiagnosisSummary: FC<Props> = ({
154
- condition,
155
- extendedTemplateDisplayName,
156
- extensionTemplateDisplayName,
157
- extensionClickHandler,
158
- isReadOnly = false,
159
- dateOnlyView = false,
160
- canExtendDiagnosis = false,
161
- displaySource = false,
162
- controls = [],
163
- tags = [],
164
- systemExclusionsFilter = [],
165
- ...rest
166
- }) => {
167
- if (condition.metadata.isRedacted) {
168
- return (
169
- <StyledSummary {...rest}>
170
- <Redacted condition={condition} />
171
- </StyledSummary>
172
- )
173
- }
174
-
175
- const enteredInError = condition.verificationStatus === ConditionVerificationStatus.EnteredInError
176
-
177
- return (
178
- <StyledSummary {...rest}>
179
- <StyledTitleAndDateContainer>
180
- <StyledDescription>
181
- <StyledTitle>
182
- <Title
183
- enteredInError={enteredInError}
184
- condition={condition}
185
- systemExclusionsFilter={systemExclusionsFilter}
186
- />
187
- {extensionTemplateDisplayName && !isReadOnly && canExtendDiagnosis && !enteredInError && (
188
- <IconButtonWrapper
189
- onClick={extensionClickHandler}
190
- type="button"
191
- styling={{ buttonStyle: 'clear' }}
192
- value=""
193
- icon={<Icon type="folder-plus" size="medium" />}
194
- iconPlacement="center"
195
- iconColour={BTN_COLOURS.PRIMARY.VALUE}
196
- title={`This diagnosis can be extended further using form '${extensionTemplateDisplayName}' by clicking here`}
197
- />
198
- )}
199
- {extendedTemplateDisplayName && (
200
- <IconWrapper>
201
- <Icon
202
- type="comment"
203
- size="medium"
204
- title={`This diagnosis has been extended beyond standard diagnosis with form '${extendedTemplateDisplayName}'.
205
- To view these extra details, click into the full diagnosis detail or edit the existing form.`}
206
- />
207
- </IconWrapper>
208
- )}
209
- </StyledTitle>
210
- {displaySource && <DiagnosisDataSource condition={condition} enteredInError={enteredInError} />}
211
- </StyledDescription>
212
- <StyledDate>
213
- <DateSummary enteredInError={enteredInError} datetime={condition?.assertedDate} dateOnlyView={dateOnlyView} />
214
- <OnsetDateEstimated enteredInError={enteredInError} condition={condition} />
215
- </StyledDate>
216
- </StyledTitleAndDateContainer>
217
-
218
- {!isReadOnly && (controls.length > 0 || tags.length > 0) && (
219
- <StyledButtonAndTagContainer>
220
- <StyledResponsiveButtonContainer>
221
- {controls.map((props, index) => (
222
- <StyledButton key={index} {...props} />
223
- ))}
224
- </StyledResponsiveButtonContainer>
225
-
226
- <StyledResponsiveTagContainer>
227
- {tags?.map((tag, index) => (tag.key ? tag : cloneElement(tag, { key: index })))}
228
- </StyledResponsiveTagContainer>
229
- </StyledButtonAndTagContainer>
230
- )}
231
- </StyledSummary>
232
- )
233
- }
234
-
235
- interface Props extends HTMLAttributes<HTMLDivElement> {
236
- condition: Condition
237
- extendedTemplateDisplayName?: string | undefined
238
- extensionTemplateDisplayName?: string | undefined
239
- isReadOnly: boolean
240
- dateOnlyView?: boolean
241
- displaySource?: boolean
242
- controls?: ButtonProps[]
243
- tags?: ReactElement[]
244
- canExtendDiagnosis?: boolean
245
- extensionClickHandler?(): void
246
- systemExclusionsFilter?: string[]
247
- }
248
-
249
- 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, SMALL_SCREEN_MAXIMUM_MEDIA_QUERY, TABLET_MINIMUM_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
+ import DiagnosisDataSource from '../atoms/diagnosis-data-source'
14
+
15
+ const StyledTitle = styled.div`
16
+ display: flex;
17
+ `
18
+
19
+ const StyledSummary = styled.div`
20
+ display: flex;
21
+ justify-content: center;
22
+ flex-direction: column;
23
+ `
24
+
25
+ const StyledDescription = styled.div`
26
+ flex-grow: 1;
27
+ `
28
+
29
+ const StyledTitleAndDateContainer = styled.div`
30
+ display: flex;
31
+ flex-grow: 1;
32
+ flex-direction: row;
33
+ gap: 5px;
34
+
35
+ ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
36
+ flex-flow: column nowrap;
37
+ align-items: flex-start;
38
+ div {
39
+ text-align: left;
40
+ }
41
+ }
42
+ `
43
+
44
+ const StyledButtonAndTagContainer = styled.div`
45
+ display: flex;
46
+ flex-grow: 1;
47
+ flex-direction: row;
48
+ gap: 5px;
49
+ margin-top: 5px;
50
+
51
+ ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
52
+ flex-direction: row;
53
+ justify-content: space-between;
54
+ }
55
+ `
56
+
57
+ const StyledResponsiveButtonContainer = styled.div`
58
+ display: flex;
59
+ margin-right: auto;
60
+ flex-flow: row wrap;
61
+ gap: 5px;
62
+ height: fit-content;
63
+ flex-grow: 1;
64
+
65
+ & > * {
66
+ height: 1.2rem;
67
+ padding: 0 5px;
68
+
69
+ ${TABLET_MINIMUM_MEDIA_QUERY} {
70
+ font-size: 0.8rem !important;
71
+ }
72
+ }
73
+
74
+ ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
75
+ margin: 0;
76
+ flex-direction: column;
77
+
78
+ span {
79
+ width: 100%;
80
+ max-width: 10rem;
81
+ }
82
+ }
83
+ `
84
+
85
+ const StyledResponsiveTagContainer = styled.div`
86
+ display: flex;
87
+ margin-left: auto;
88
+ flex-flow: row wrap;
89
+ gap: 5px;
90
+ height: fit-content;
91
+ justify-content: flex-end;
92
+ flex-grow: 1;
93
+
94
+ & > * {
95
+ display: flex;
96
+ align-items: center;
97
+ height: 1.2rem;
98
+ margin: 0 !important;
99
+ font-size: 0.8rem !important;
100
+ padding: 0 10px;
101
+ justify-content: center;
102
+
103
+ ${TABLET_MINIMUM_MEDIA_QUERY} {
104
+ font-size: 0.8rem !important;
105
+ }
106
+ }
107
+
108
+ ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
109
+ flex-direction: column;
110
+ margin: 0;
111
+
112
+ & > * {
113
+ margin: 0;
114
+ width: 100%;
115
+ max-width: 10rem;
116
+ padding: 0 10px;
117
+ }
118
+ }
119
+ `
120
+
121
+ const StyledButton = styled(Button)`
122
+ padding: 0 5px;
123
+ width: fit-content;
124
+
125
+ ${SMALL_SCREEN_MAXIMUM_MEDIA_QUERY} {
126
+ width: 100%;
127
+ max-width: 10rem;
128
+ }
129
+ `
130
+ const StyledDate = styled.div`
131
+ display: flex;
132
+ flex-flow: column nowrap;
133
+ text-align: right;
134
+ min-width: 6rem;
135
+ justify-content: start;
136
+ `
137
+ const IconButtonWrapper = styled(Button)`
138
+ -webkit-box-align: center;
139
+ align-items: center;
140
+ -webkit-box-pack: center;
141
+ justify-content: center;
142
+ margin-right: 0.5rem;
143
+ display: inline-block !important;
144
+ margin-left: 0.5rem;
145
+ width: auto;
146
+ padding: 0 5px;
147
+ `
148
+ const IconWrapper = styled.div`
149
+ margin-left: 0.5rem;
150
+ display: inline-block;
151
+ `
152
+
153
+ const DiagnosisSummary: FC<Props> = ({
154
+ condition,
155
+ extendedTemplateDisplayName,
156
+ extensionTemplateDisplayName,
157
+ extensionClickHandler,
158
+ isReadOnly = false,
159
+ dateOnlyView = false,
160
+ canExtendDiagnosis = false,
161
+ displaySource = false,
162
+ controls = [],
163
+ tags = [],
164
+ systemExclusionsFilter = [],
165
+ ...rest
166
+ }) => {
167
+ if (condition.metadata.isRedacted) {
168
+ return (
169
+ <StyledSummary {...rest}>
170
+ <Redacted condition={condition} />
171
+ </StyledSummary>
172
+ )
173
+ }
174
+
175
+ const enteredInError = condition.verificationStatus === ConditionVerificationStatus.EnteredInError
176
+
177
+ return (
178
+ <StyledSummary {...rest}>
179
+ <StyledTitleAndDateContainer>
180
+ <StyledDescription>
181
+ <StyledTitle>
182
+ <Title
183
+ enteredInError={enteredInError}
184
+ condition={condition}
185
+ systemExclusionsFilter={systemExclusionsFilter}
186
+ />
187
+ {extensionTemplateDisplayName && !isReadOnly && canExtendDiagnosis && !enteredInError && (
188
+ <IconButtonWrapper
189
+ onClick={extensionClickHandler}
190
+ type="button"
191
+ styling={{ buttonStyle: 'clear' }}
192
+ value=""
193
+ icon={<Icon type="folder-plus" size="medium" />}
194
+ iconPlacement="center"
195
+ iconColour={BTN_COLOURS.PRIMARY.VALUE}
196
+ title={`This diagnosis can be extended further using form '${extensionTemplateDisplayName}' by clicking here`}
197
+ />
198
+ )}
199
+ {extendedTemplateDisplayName && (
200
+ <IconWrapper>
201
+ <Icon
202
+ type="comment"
203
+ size="medium"
204
+ title={`This diagnosis has been extended beyond standard diagnosis with form '${extendedTemplateDisplayName}'.
205
+ To view these extra details, click into the full diagnosis detail or edit the existing form.`}
206
+ />
207
+ </IconWrapper>
208
+ )}
209
+ </StyledTitle>
210
+ {displaySource && <DiagnosisDataSource condition={condition} enteredInError={enteredInError} />}
211
+ </StyledDescription>
212
+ <StyledDate>
213
+ <DateSummary enteredInError={enteredInError} datetime={condition?.assertedDate} dateOnlyView={dateOnlyView} />
214
+ <OnsetDateEstimated enteredInError={enteredInError} condition={condition} />
215
+ </StyledDate>
216
+ </StyledTitleAndDateContainer>
217
+
218
+ {!isReadOnly && (controls.length > 0 || tags.length > 0) && (
219
+ <StyledButtonAndTagContainer>
220
+ <StyledResponsiveButtonContainer>
221
+ {controls.map((props, index) => (
222
+ <StyledButton key={index} {...props} />
223
+ ))}
224
+ </StyledResponsiveButtonContainer>
225
+
226
+ <StyledResponsiveTagContainer>
227
+ {tags?.map((tag, index) => (tag.key ? tag : cloneElement(tag, { key: index })))}
228
+ </StyledResponsiveTagContainer>
229
+ </StyledButtonAndTagContainer>
230
+ )}
231
+ </StyledSummary>
232
+ )
233
+ }
234
+
235
+ interface Props extends HTMLAttributes<HTMLDivElement> {
236
+ condition: Condition
237
+ extendedTemplateDisplayName?: string | undefined
238
+ extensionTemplateDisplayName?: string | undefined
239
+ isReadOnly: boolean
240
+ dateOnlyView?: boolean
241
+ displaySource?: boolean
242
+ controls?: ButtonProps[]
243
+ tags?: ReactElement[]
244
+ canExtendDiagnosis?: boolean
245
+ extensionClickHandler?(): void
246
+ systemExclusionsFilter?: string[]
247
+ }
248
+
249
+ export default DiagnosisSummary