Bulk FHIR Export Provenance algorithm incorrect and dies on export #5215
Description
With adding in the Medication resource as an endpoint in the system the Provenance bulk fhir export was triggering the max export time exception as it attempted to generate FHIR resources for the 22K drug records in the database for the Medication resource.
Examining the algorithm it looks like we are not handling the resource and patient filtering correctly. Provenance was ignoring what resources had been selected in the export and just grabbing anything that was a readable rest service. It also was improperly setting the patient uuids to filter on for the services.
Lastly encounter resources were not getting provenance resources generated.
We need to change up the algorithm so that we go through each individual service and set the patient context filtering parameter. We also need to generate provenance for encounters and make sure we skip over Medication resources as they have no provenance information in OpenEMR currently.