Skip to content

COH-64 add FHIR API to the Cohort module#40

Open
parthfloyd wants to merge 12 commits intoopenmrs:masterfrom
parthfloyd:test-integrate-group-translator
Open

COH-64 add FHIR API to the Cohort module#40
parthfloyd wants to merge 12 commits intoopenmrs:masterfrom
parthfloyd:test-integrate-group-translator

Conversation

@parthfloyd
Copy link
Copy Markdown
Member

to support adding cohort using fhir api.

Integrate GroupTranslator & ResourceProvider to cohort module
Related talk: Adding Cohort member through FHIR API.

cc: @ibacher , @dkayiwa @icrc-jofrancisco

@parthfloyd
Copy link
Copy Markdown
Member Author

@dkayiwa the build is failing on RestConstants (unless i am mistaken with any config error). Lmk if this solution makes sense: parthfloyd@692d2ea

@dkayiwa
Copy link
Copy Markdown
Member

dkayiwa commented Oct 3, 2025

@parthfloyd did you get a chance to look at the build failure?

Copy link
Copy Markdown
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

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

Generally, for these kinds of things, instead of adding FHIR dependencies in the API submodule, it would be cleaner to create a fhir submodule. That submodule can then be selectively loaded depending on whether the FHIR2 module is present and we avoid needing to force everyone who uses this module to use the FHIR2 module. See the patientflags module for an example of this.

Comment thread omod/src/main/resources/webModuleApplicationContext.xml
coding.setCode(cohortType.getUuid());
}
if (StringUtils.isNotBlank(cohortType.getName())) {
coding.setDisplay(cohortType.getName());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For display strings, we'd usually want to call the FhirUtils#getMetadataTranslation() class to get the display string. This way the display value is translatable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It does mean, however, that there is no easy way to go from the CohortType display name to the CohortType defintion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @ibacher for the suggestion.
since FhirUtils method expected OpenmrsMetaData child, I created a seperate class CohortFhirUtils#getDataTranslation() to translate BaseOpenmrsData. Let me know if this approach requires change.

Comment thread pom.xml Outdated
- seperate module for fhir
- added default rest uri prefix for tests.
@parthfloyd
Copy link
Copy Markdown
Member Author

@ibacher thank you so much for the feedback. I've integrated required changes.
@dkayiwa there was a build failure related to default uri not found in rest tests. I've added a commit for the fix. Lmk if it's ok or I am missing something. Thanks again for your time & guidance!

@parthfloyd parthfloyd requested a review from ibacher October 11, 2025 00:35
Comment thread pom.xml Outdated
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-omod</artifactId>
<version>2.5.0</version>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Which fhir2 version are you using? 2.5.0 or 2.7.0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right, should be 2.7.0 | Looks like a missed commit, pushing it

Comment thread pom.xml
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-api</artifactId>
<version>${openmrsFhir2Version}</version>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Of what scope is this dependency?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am updating with provided scope assuming if a person uses fhir apis for cohort would have fhir2 module active in the system.

Comment thread pom.xml
Comment thread omod-fhir/src/main/resources/config.xml Outdated
-->
<!DOCTYPE module PUBLIC "-//OpenMRS//DTD OpenMRS Config 1.0//EN"
"https://resources.openmrs.org/doctype/config-1.6.dtd">
<module configVersion="1.6">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Each module only has one config.xml—at least that actually does anything—and that's in the OMOD. This change should be applied there, but marking the FHIR2 module as an aware_of_module with a conditional_resource that loads the Jar from this project if the FHIR2 module is present.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @ibacher I've updated accordingly.
feel free to let me know if any change is required.

parthfloyd and others added 2 commits October 13, 2025 12:09
Co-authored-by: Ian <52504170+ibacher@users.noreply.github.com>
@parthfloyd parthfloyd requested review from dkayiwa and ibacher October 21, 2025 19:41
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.

3 participants