feat(ResourceTimeline): add support for note
s on ResourceTimeline
#2756
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
There are a few
Resource
types which have anote
property. Currently the notes from thisnote
property only show up in the parentresource
in the timeline view.As described in #2715, we want to be able to add the notes on these resources such as
Specimen
orObservation
to theResourceTimeline
as a separate entry, sorted into the timeline based on when thenote
was recorded.What this PR does
ResourceTimeline
and derivative timeline components when anote
property is found on aResource
.Notes
to the timeline view #2715Notes about changes
There were are few things about this issue that made it a little more difficult than originally thought at first glance:
ResourceTimeline
expected items to beResource
ssortByDateAndPriority()
which deals with sortingResource
s based on different fields and whether a resource is marked with a specialpriority
. This makes it a bit tricky to sortnote
s which wouldn't have some of these fields necessarily and aren't shaped likeResource
s.The solution was to make
ResourceTimeline
generic on items which implement an interfaceTimeSortable
which guarantees a datatype is aResource
or has atime
property with a date string. We then created asortByDateAndPriorityGeneric()
which can sort these objects alongside resources. In the future, if needed, more logic can be added to extract different fields fromResource
s and put them and sort them in the timeline as well.