Skip to content

Commit

Permalink
Merge pull request #543 from cqframework/fix-539-fhir-source-provider
Browse files Browse the repository at this point in the history
#539: Fixed an issue with the FHIR library source provider incorrectl…
  • Loading branch information
brynrhodes authored Jul 1, 2020
2 parents 1777936 + 22c7010 commit f766351
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ public class FhirLibrarySourceProvider implements LibrarySourceProvider, Namespa

@Override
public InputStream getLibrarySource(VersionedIdentifier libraryIdentifier) {
// If the FHIRHelpers library is referenced in a namespace-enabled context,
// set the namespace to the FHIR namespace URI
if (namespaceManager != null && namespaceManager.hasNamespaces()) {
// If the context already has a namespace registered for FHIR, use that.
NamespaceInfo namespaceInfo = namespaceManager.getNamespaceInfoFromUri(namespaceUri);
if (namespaceInfo == null) {
namespaceInfo = new NamespaceInfo(namespaceName, namespaceUri);
namespaceManager.ensureNamespaceRegistered(namespaceInfo);
InputStream result = FhirLibrarySourceProvider.class.getResourceAsStream(String.format("/org/hl7/fhir/%s-%s.cql", libraryIdentifier.getId(),
libraryIdentifier.getVersion()));

if (result != null) {
// If the FHIRHelpers library is referenced in a namespace-enabled context,
// set the namespace to the FHIR namespace URI
if (namespaceManager != null && namespaceManager.hasNamespaces()) {
// If the context already has a namespace registered for FHIR, use that.
NamespaceInfo namespaceInfo = namespaceManager.getNamespaceInfoFromUri(namespaceUri);
if (namespaceInfo == null) {
namespaceInfo = new NamespaceInfo(namespaceName, namespaceUri);
namespaceManager.ensureNamespaceRegistered(namespaceInfo);
}
libraryIdentifier.setSystem(namespaceUri);
}
libraryIdentifier.setSystem(namespaceUri);
}

return FhirLibrarySourceProvider.class.getResourceAsStream(String.format("/org/hl7/fhir/%s-%s.cql", libraryIdentifier.getId(),
libraryIdentifier.getVersion()));
return result;
}

private NamespaceManager namespaceManager;
Expand Down

0 comments on commit f766351

Please sign in to comment.