We were earlier assuming there will be exactly 1 resource per capture and directly trying to access using sensingEngine.listResourceInfoInCapture(captureId!!)[0] to store it in fhir resource.
However there are 2 things to take care of:-
For some reason if no resource is captured, the list will be empty and trying to access[0] will give a null pointer exception
There can be multiple resources that can be created per capture
So what we do is simply map the listOfResourceInfo to a List<DocumentRefernce. DocumentReferenceContentComponent> which stores an Attachment object. This list is added to the DocumentReference object and stored as a fhir resource.
We were earlier assuming there will be exactly 1 resource per capture and directly trying to access using
sensingEngine.listResourceInfoInCapture(captureId!!)[0]
to store it in fhir resource.However there are 2 things to take care of:-
So what we do is simply map the listOfResourceInfo to a
List<DocumentRefernce. DocumentReferenceContentComponent>
which stores an Attachment object. This list is added to the DocumentReference object and stored as a fhir resource.