Skip to content

Conversation

@adunsulag
Copy link
Member

Fixes #9373 bulk on fhir export

Fixes #9382

Implements Bulk on FHIR spec compliance for the following resources

  • Patient
  • Location
  • MedicationAdherence
  • MedicationDispense
  • Encounter
  • Immunization
  • DocumentReference
  • Observation(category=vitals,laboratory)

Fixes _outputFormat,_since Bulk on FHIR export.

Still have a number of issues working on. Can see #9373 for details.

A number of resources that rely on session values were failing as the
session was not populating in the Bulk Export and in the Provenance
resource.

Fixed queries that were breaking with the _since parameter that search
based on last updated.
Got the patient profile validation working properly with injection of
the globals in the controller and service classes.

Move IGlobalsAware to be a service interface instead of just a command
interface for OEGlobalsBag injection.
MedicationAdherence wasn't showing up for linked prescriptions so fixed
that issue.
Not sure how but somehow the class got renamed, so fixed that.
Moved the encounter dropdown from the TwigExtension into its own class
so it can be used in both twig and in PHP.
When updating a linked lists_medication record from an existing
prescription, the save was failing.
Fixed a bug when inventory is used where the drug_code is not properly
populated.

Fixes openemr#9382
Invalid request w/ outputFormat for BULK FHIR export was throwing a
fatal 500 operation outcome error.

Fixed it so its an bad request (400)  and now support the shorthand
ndjson format.
Specimen.value[x] must be a numeric value and not a string.
Removed usedReference as it was breaking the specification.
@adunsulag
Copy link
Member Author

Will come back to this on Monday but wanted to push this out for people to have a chance to see it. Its very fascinating to me that the BULK on FHIR profile validation seems to be more conformant to spec than the API Single Patient. It caught a number of issues that the API Single Patient validation did not via Inferno. Will have to come back and do a sweep in API Single Patient and hope that there isn't conflicting validation requirements.

Also noticed that the Inferno Validator java server (on docker) appears to have a memory leak. Memory usage has gone from 4GB of memory up to 12GB of memory over a 2 day period with nothing being freed. Doing a docker compose restart hl7_validator_service appears to free everything up once again.

@codecov
Copy link

codecov bot commented Nov 9, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1556 1 1555 55
View the top 1 failed test(s) by shortest run time
OpenEMR.Tests.E2e.BbCreateStaffTest::testUserAdd
Stack Traces | 42.4s run time
OpenEMR\Tests\E2e\BbCreateStaffTest::testUserAdd
Facebook\WebDriver\Exception\TimeoutException: Element "//table//a[text()='foobar']" not found within 30 seconds.

.../webdriver/lib/WebDriverWait.php:71
.../panther/src/Client.php:355
.../E2e/User/UserAddTrait.php:105
.../E2e/User/UserAddTrait.php:44
View the full list of 1 ❄️ flaky test(s)
OpenEMR.Tests.Services.FHIR.FhirMedicationRequestServiceUSCore8Test::testMustSupportReported

Flake rate in main: 21.88% (Passed 25 times, Failed 7 times)

Stack Traces | 0.0376s run time
OpenEMR\Tests\Services\FHIR\FhirMedicationRequestServiceUSCore8Test::testMustSupportReported
MedicationRequest should have reported[x] (must support)
Failed asserting that null is not null.

.../Services/FHIR/FhirMedicationRequestServiceUSCore8Test.php:203

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.


#IfMissingColumn immunizations encounter_id
ALTER TABLE `immunizations` ADD COLUMN `encounter_id` BIGINT(20) DEFAULT NULL COMMENT 'fk to form_encounter.encounter to link immunization to encounter record';
#EndIf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also need change in database.sql

We were not adding in the profiles to the diagnostic report resources
which failed bulk fhir profile validation.

Had old code in the clinical notes diagnostic profile that was adding in
sample records.
There were extra logs of resource uuids and patient pids
Resources were not conforming to profile

// Iterate through all PlaceOfServiceEnum cases and build the array
// AI Generated
foreach (PlaceOfServiceEnum::cases() as $posEnum) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅

{
private ?EncounterService $encounterService = null;

public function __construct(private $pid = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface doesn't require a constructor, and there's at least one other implementation of this interface with a different constructor sig. Just making sure this is what you want.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I'm trying to provide a pathway to have some conformity with the options.inc.php and the building of widgets (would be lovely for this to eventually become web components). The constructor I'm leaving up to the implementation to decide how to handle any additional state that is required. EncounterListOptionType relies on a global pid value in options.inc.php and a pid that's in context in the other location its used, whereas LocalProviderListType doesn't rely on any additional state than what is passed in through the interface function methods.

`date` AS last_updated,
"' . self::TYPE_PATIENT . '" AS `type`
"' . self::TYPE_PATIENT . '" AS `type`,
\'\' AS location_role_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest you use a heredoc to avoid the leaning toothpicks

Fixes openemr#9386 - issues with us core vitals.

Removes bp and pulse oximetry sub-components as observations and bundles
them into the correct component implementation.
Fixes openemr#9387 adding in missing fields in fhir
Was missing fields needed for specimen
Capability statement was not showing the correct profiles
access token was being forced to the bulk export system user
Added location search and fixed up permissions missing from the session
by using explicit vars instead of global $_SESSION
Fixed provenance with Care Experience and Treatment Intervention
observations.

Fixed missing oxygen saturation
@adunsulag
Copy link
Member Author

  • This leaves outstanding PractitionerRole which I think is what is causing Practitioner to fail validation
  • Smoking Status
  • and Screening Assessment Tests seems to be failing and not picking up some of the categories

That should then pass everything with single patient api and bulk on fhir api. Leaving just the granular security scopes & patient context to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: MedicationRequest with drugs inventory does not handle RXCUI code correctly. feat: SMART on FHIR V2 Multipatient / Bulk Export

3 participants