Error using '_since' param in fhir bulk export

Situation
I have set up the fhir api, created the client assertion etc. and all is working well. I was hoping to use the ‘_since’ parameter so that I can do a daily delta job. However, I’m getting an error. This is the url I’m using: http://localhost/apis/default/fhir/$export?_since=2023-01-01T00:00:00Z
and the error (from the error log) is:

Uncaught TypeError: OpenEMR\\FHIR\\Export\\ExportJob::setResourceIncludeTime(): Argument #1 ($resourceIncludeTime) must be of type DateTime, string given, called in /var/www/localhost/htdocs/openemr/src/RestControllers/FHIR/Operations/FhirOperationExportRestController.php on line 130 and defined in /var/www/localhost/htdocs/openemr/src/FHIR/Export/ExportJob.php:216\nStack trace:\n#0 /var/www/localhost/htdocs/openemr/src/RestControllers/FHIR/Operations/FhirOperationExportRestController.php(130): OpenEMR\\FHIR\\Export\\ExportJob->setResourceIncludeTime()\n#1 /var/www/localhost/htdocs/openemr/_rest_routes.inc.php(13333): OpenEMR\\RestControllers\\FHIR\\Operations\\FhirOperationExportRestController->processExport()\n#2 /var/www/localhost/htdocs/openemr/src/Common/Http/HttpRestRouteHandler.php(103): {closure}()\n#3 /var/www/localhost/htdocs/openemr/apis/dispatch.php(389): OpenEMR\\Common\\Http\\HttpRestRouteHandler::dispatch()\n#4 {main}\n  thrown in /var/www/localhost/htdocs/openemr/src/FHIR/Export/ExportJob.php on line 216

It says the issue is in the ExportJob.php file but I think it actually originates in the FhirOperationExportRestController.php file in this line:

$since = $exportParams['_since'] ?? new \DateTime(date("Y-m-d H:i:s", 0)); // since epoch time

I think if the param is there, then a string is being using and it should be converted to a date first.
I know very little about php so I could be on the wrong track entirely here but I’ve tried a bunch of different formats, long, short, epoch time, etc. and I always get the same error.

OpenEMR Version
I’m using the flex-3.20 container.

Browser:
I’m using: Edge

Operating System
I’m using: Linux and Windows

Search
Did you search the forum for similar questions? Yes.

Logs

Uncaught TypeError: OpenEMR\\FHIR\\Export\\ExportJob::setResourceIncludeTime(): Argument #1 ($resourceIncludeTime) must be of type DateTime, string given, called in /var/www/localhost/htdocs/openemr/src/RestControllers/FHIR/Operations/FhirOperationExportRestController.php on line 130 and defined in /var/www/localhost/htdocs/openemr/src/FHIR/Export/ExportJob.php:216\nStack trace:\n#0 /var/www/localhost/htdocs/openemr/src/RestControllers/FHIR/Operations/FhirOperationExportRestController.php(130): OpenEMR\\FHIR\\Export\\ExportJob->setResourceIncludeTime()\n#1 /var/www/localhost/htdocs/openemr/_rest_routes.inc.php(13333): OpenEMR\\RestControllers\\FHIR\\Operations\\FhirOperationExportRestController->processExport()\n#2 /var/www/localhost/htdocs/openemr/src/Common/Http/HttpRestRouteHandler.php(103): {closure}()\n#3 /var/www/localhost/htdocs/openemr/apis/dispatch.php(389): OpenEMR\\Common\\Http\\HttpRestRouteHandler::dispatch()\n#4 {main}\n  thrown in /var/www/localhost/htdocs/openemr/src/FHIR/Export/ExportJob.php on line 216

Hey @alan-cushla, I’ll look into this and let you know, at first glance what you are doing looks correct. That code hasn’t been touched in a while so I can’t think of anything that would have changed the behavior.

That’s great, thanks Stephen!

Can confirm this is not working. Opened a bug issue for tracking here. Working on a fix and will have more details here as we work on the solution bug: Bulk export _since parameter is throwing error · Issue #7746 · openemr/openemr · GitHub

We were set to release a new patch out in the next day or two but we’ll have to pause the patch until this is fixed. Hopefully we can get it resolved quickly and out in the patch.

  • Stephen

Awesome, thanks for that.