Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenMRS FHIR IGenericClient spring bean #65

Merged
merged 3 commits into from
Sep 25, 2024
Merged

Conversation

corneliouzbett
Copy link
Member

  • This PR adds a convenient IGenericClient Spring bean to be used by downstream projects.

@corneliouzbett corneliouzbett requested a review from wluyima July 31, 2024 05:14
@@ -51,16 +69,7 @@ public void beforeApplicationStart(CamelContext camelContext) {
FhirConfiguration fhirConfiguration = new FhirConfiguration();
FhirContext ctx = FhirContext.forR4();
Copy link
Member

Choose a reason for hiding this comment

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

Aren't you supposed to get rid of these lines 69 and 70 since you're are now using the new spring bean?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, still need both. The new spring bean IGenericClient should be set to FhirConfiguration which is then set camel FHIR component.

@@ -42,28 +44,29 @@ public boolean isOauthEnabled() {
return isOauthEnabled;
}

@Bean
@Qualifier("openmrsFhirClient")
IGenericClient openmrsFhirClient() {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why these are not public?

Copy link
Member Author

Choose a reason for hiding this comment

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

openmrsFhirClient does not need to be public because it is only used within the OpenmrsFhirConfiguration class, not intended to publicly exposed and I don't want it to be misused. I could ask the reverse, why public?

IGenericClient client = FhirContext.forR4().newRestfulGenericClient(fhirServerUrl);
if (isOauthEnabled) {
client.registerInterceptor(oauth2Interceptor);
} else if (StringUtils.isNotBlank(fhirUsername) && StringUtils.isNotBlank(fhirPassword)) {
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean they are optional?

// verify BasicAuthInterceptor is registered
assertNotNull(interceptors);
assertTrue(interceptors.stream().anyMatch(BasicAuthInterceptor.class::isInstance));
}
Copy link
Member

Choose a reason for hiding this comment

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

From a pure unit test perspective, I don't think I like the way these tests are setup, because instead of calling the logic you're testing from the test method i.e. constructor, you're testing a pre-constructed bean by spring. I guess it's okay but I'd have preferred you call the constructor from the test method itself.

Copy link
Member

@wluyima wluyima left a comment

Choose a reason for hiding this comment

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

I left some minor comments

@corneliouzbett corneliouzbett merged commit 0649347 into master Sep 25, 2024
3 checks passed
@corneliouzbett corneliouzbett deleted the chores branch September 25, 2024 06:38
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.

2 participants