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 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.041s 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

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

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
@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.

Fixes openemr#9409 by have an option to say the record is not a primary record and
to choose a user from the address book. At some point when we disentangle
external organizations from the address book and put them in facility we can
handle external organizations in addition to practitioners. If a user is
chosen without an NPI it will show the Primary Business Entity as the
reported organization.
Fixed the code search with the way system codes work for observation
form, care experience, and treatment intervention
Fixes openemr#9368 patient context population for patient context restriction
Fixes openemr#9423 fix token serialization / deserialization

The token was not deserializing in inferno due to the + character from
encryption so needed to base64 encode it.

Also left out the context population from the rest api refactor. Made it
so the patient context gets populated on the request
Add the us core server url for the capability statement
Fixes openemr#9428
Adds in the practitioner address support for FHIR Practitioner and
PractitionerRole which gets these resources passing certification.

Fixes openemr#9247
Added category dropdown for questionnaire category registration so we
can group the categories and report them in FHIR via their category
attribute.
Added the ability to have practioners be non-OpenEMR users so that
diagnostic report references can reference them.  See the issue for more
details.

Fixes openemr#9429
Instead of using website as the system, we use url as the telecom
location element.
@adunsulag
Copy link
Member Author

This has gotten too big, once I've got resolved any failing tests and rector (rector suggests a fix that phpstan won't accept), my plan is to bring this in.

The only thing outstanding at this point for BULK Fhir export is fixing up the observation laboratory resources for whatever reason inferno isn't picking them.

@adunsulag
Copy link
Member Author

Going to have to try on a fresh database as I'm not getting these same errors.

Had an encrypted string that was from a specific OpenEMR instance left
in the code.
Had another case where inferno was passing but vanilla openemr was not
@adunsulag adunsulag changed the title WIP: Feat openemr #9373 bulk fhir Feat openemr #9373 bulk fhir Nov 14, 2025
@adunsulag
Copy link
Member Author

Bringing this in so I can focus on granular scope access.

@adunsulag adunsulag merged commit 4af4c82 into openemr:master Nov 14, 2025
37 checks passed
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