-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge $package operation from CQF-Ruler with ValueSet expansion capab…
…ility (#455) * Merge $package operation from CQF-Ruler with ValueSet expansion capability * Update URL constant and test data * Refactor - simplify functions and fix typos * Refactor -make local methods protected -throw unsupported error when invalid fhir version supplied -move constants -remove ResourceClassMapHelper -change checkIfValueSetNeedsCondition to reflect removal of ResourceClassMapHelper * Remove unnecessary search for resource
- Loading branch information
Showing
26 changed files
with
35,311 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
cqf-fhir-utility/src/main/java/org/opencds/cqf/fhir/utility/EndpointCredentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.opencds.cqf.fhir.utility; | ||
|
||
import ca.uhn.fhir.model.api.annotation.Child; | ||
import ca.uhn.fhir.model.api.annotation.Description; | ||
import org.hl7.fhir.r4.model.Endpoint; | ||
import org.hl7.fhir.r4.model.StringType; | ||
|
||
public class EndpointCredentials extends Endpoint { | ||
|
||
@Child( | ||
name = "vsacUsername", | ||
type = {StringType.class}, | ||
order = 11, | ||
min = 0, | ||
max = 1, | ||
modifier = false, | ||
summary = true) | ||
@Description( | ||
shortDefinition = "A name that this endpoint can be identified by", | ||
formalDefinition = "A friendly name that this endpoint can be referred to with.") | ||
protected StringType vsacUsername; | ||
|
||
@Child( | ||
name = "apiKey", | ||
type = {StringType.class}, | ||
order = 11, | ||
min = 0, | ||
max = 1, | ||
modifier = false, | ||
summary = true) | ||
@Description( | ||
shortDefinition = "A name that this endpoint can be identified by", | ||
formalDefinition = "A friendly name that this endpoint can be referred to with.") | ||
protected StringType apiKey; | ||
|
||
public StringType getVsacUsername() { | ||
return vsacUsername; | ||
} | ||
|
||
public void setVsacUsername(StringType vsacUsername) { | ||
this.vsacUsername = vsacUsername; | ||
} | ||
|
||
public StringType getApiKey() { | ||
return apiKey; | ||
} | ||
|
||
public void setApiKey(StringType apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...ir-utility/src/main/java/org/opencds/cqf/fhir/utility/client/TerminologyServerClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.opencds.cqf.fhir.utility.client; | ||
|
||
import ca.uhn.fhir.context.FhirContext; | ||
import ca.uhn.fhir.rest.client.api.IGenericClient; | ||
import java.util.Objects; | ||
import org.opencds.cqf.fhir.utility.Canonicals; | ||
|
||
public class TerminologyServerClient { | ||
|
||
private final FhirContext ctx; | ||
|
||
public TerminologyServerClient(FhirContext ctx) { | ||
this.ctx = ctx; | ||
} | ||
|
||
public org.hl7.fhir.dstu3.model.ValueSet expand( | ||
org.hl7.fhir.dstu3.model.ValueSet valueSet, | ||
String authoritativeSource, | ||
org.hl7.fhir.dstu3.model.Parameters expansionParameters, | ||
String username, | ||
String apiKey) { | ||
IGenericClient fhirClient = ctx.newRestfulGenericClient(getAuthoritativeSourceBase(authoritativeSource)); | ||
Clients.registerAdditionalRequestHeadersAuth(fhirClient, username, apiKey); | ||
|
||
// Invoke by Value Set ID | ||
return fhirClient | ||
.operation() | ||
.onInstance(valueSet.getId()) | ||
.named("$expand") | ||
.withParameters(expansionParameters) | ||
.returnResourceType(org.hl7.fhir.dstu3.model.ValueSet.class) | ||
.execute(); | ||
} | ||
|
||
public org.hl7.fhir.r4.model.ValueSet expand( | ||
org.hl7.fhir.r4.model.ValueSet valueSet, | ||
String authoritativeSource, | ||
org.hl7.fhir.r4.model.Parameters expansionParameters, | ||
String username, | ||
String apiKey) { | ||
IGenericClient fhirClient = ctx.newRestfulGenericClient(getAuthoritativeSourceBase(authoritativeSource)); | ||
Clients.registerAdditionalRequestHeadersAuth(fhirClient, username, apiKey); | ||
|
||
// Invoke by Value Set ID | ||
return fhirClient | ||
.operation() | ||
.onInstance(valueSet.getId()) | ||
.named("$expand") | ||
.withParameters(expansionParameters) | ||
.returnResourceType(org.hl7.fhir.r4.model.ValueSet.class) | ||
.execute(); | ||
} | ||
|
||
public org.hl7.fhir.r5.model.ValueSet expand( | ||
org.hl7.fhir.r5.model.ValueSet valueSet, | ||
String authoritativeSource, | ||
org.hl7.fhir.r5.model.Parameters expansionParameters, | ||
String username, | ||
String apiKey) { | ||
IGenericClient fhirClient = ctx.newRestfulGenericClient(getAuthoritativeSourceBase(authoritativeSource)); | ||
Clients.registerAdditionalRequestHeadersAuth(fhirClient, username, apiKey); | ||
|
||
// Invoke by Value Set ID | ||
return fhirClient | ||
.operation() | ||
.onInstance(valueSet.getId()) | ||
.named("$expand") | ||
.withParameters(expansionParameters) | ||
.returnResourceType(org.hl7.fhir.r5.model.ValueSet.class) | ||
.execute(); | ||
} | ||
|
||
// Strips resource and id from the authoritative source URL, these are not needed as the client constructs the URL. | ||
// Converts http URLs to https | ||
private String getAuthoritativeSourceBase(String authoritativeSource) { | ||
authoritativeSource = authoritativeSource.substring( | ||
0, | ||
authoritativeSource.indexOf(Objects.requireNonNull(Canonicals.getResourceType(authoritativeSource)))); | ||
if (authoritativeSource.startsWith("http:https://")) { | ||
authoritativeSource = authoritativeSource.replaceFirst("http:https://", "https://"); | ||
} | ||
return authoritativeSource; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.