Skip to content

Commit

Permalink
Add Note (annotation) support to Observation resources. (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
joebutler2 committed Feb 22, 2023
1 parent f8f55df commit d21d418
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/components/resources/Observation/Observation.js
Expand Up @@ -18,6 +18,7 @@ import {
} from '../../ui';
import Reference from '../../datatypes/Reference';
import { getResourceDate } from '../../../utils/getResourceDate';
import Annotation from "../../datatypes/Annotation";

const Observation = ({
fhirResource,
Expand Down Expand Up @@ -50,6 +51,9 @@ const Observation = ({
let valueQuantityValueNumber = valueQuantityValue;

const subject = _get(fhirResource, 'subject');
const note = _get(fhirResource, 'note');
const hasNote = Array.isArray(note);

const tableData = [
{
label: 'Issued on',
Expand All @@ -71,6 +75,12 @@ const Observation = ({
)),
status: !_isEmpty(valueCodeableConceptCoding),
},
{
label: 'Notes',
testId: 'hasNote',
data: hasNote && <Annotation fhirData={note} />,
status: hasNote,
},
];

const observationDatesPaths = [
Expand Down
1 change: 1 addition & 0 deletions src/components/resources/Observation/Observation.test.js
Expand Up @@ -132,6 +132,7 @@ describe('should render component correctly', () => {
expect(getByTestId('issuedOn').textContent).toEqual('05/18/2016');
expect(getByTestId('subject').textContent).toContain('Patient/infant');
expect(queryByText(/373066001/g)).not.toBeNull();
expect(getByTestId('hasNote').textContent).toContain('Was exposed to second-hand smoke.');
});

test('should display not rounded value', () => {
Expand Down
7 changes: 6 additions & 1 deletion src/fixtures/r4/resources/observation/example3.json
Expand Up @@ -46,5 +46,10 @@
}
],
"text": "YES"
}
},
"note": [
{
"text": "Was exposed to second-hand smoke."
}
]
}

0 comments on commit d21d418

Please sign in to comment.