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

Release operation updates #698

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.hl7.fhir.r4.model.MetadataResource;
import org.hl7.fhir.r4.model.PlanDefinition;
import org.hl7.fhir.r4.model.RelatedArtifact;
import org.hl7.fhir.r4.model.ValueSet;

public class KnowledgeArtifactAdapter<T extends MetadataResource> {
protected T resource;
Expand Down Expand Up @@ -117,6 +118,8 @@ public List<RelatedArtifact> getDependencies() {
return getDependenciesOfMeasure();
case "PlanDefinition":
return getDependenciesOfPlanDefinition();
case "ValueSet":
return getDependenciesOfValueSet();
default :
return new ArrayList<>();
}
Expand Down Expand Up @@ -183,6 +186,27 @@ private List<RelatedArtifact> getDependenciesOfPlanDefinition() {
return dependencies;
}

private List<RelatedArtifact> getDependenciesOfValueSet() {
List<RelatedArtifact> dependencies = new ArrayList<>();
ValueSet valueSet = (ValueSet)resource;

if (valueSet.hasCompose() && valueSet.getCompose().hasInclude()) {
for (var conceptSet : valueSet.getCompose().getInclude()) {
if (conceptSet.hasValueSet()) {
for (var valueSetRef : conceptSet.getValueSet()) {
dependencies.add(
new RelatedArtifact()
.setType(RelatedArtifact.RelatedArtifactType.DEPENDSON)
.setResource(valueSetRef.getValue())
);
}
}
}
}

return dependencies;
}

public List<ContactDetail> getEndorser() {
switch (resource.getClass().getSimpleName()) {
case "Library":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ private void processReferencedResourceForDraft(FhirDal fhirDal, Bundle reference

/* $release */
public MetadataResource releaseVersion(IdType idType, String version, CodeType versionBehavior, boolean latestFromTxServer, FhirDal fhirDal) {
// TODO: This check is to avoid partial releases and should be removed once the argument is supported (or it is transactional).
if (latestFromTxServer) {
throw new NotImplementedException("Support for 'latestFromTxServer' is not yet implemented.");
}

if (version == null || version.isEmpty()) {
throw new InvalidOperatorArgument("version must be provided as an argument to the $release operation.");
}
Expand Down Expand Up @@ -260,6 +265,7 @@ public MetadataResource releaseVersion(IdType idType, String version, CodeType v
String.format("The artifact was approved on '%s', but was last modified on '%s'. An approval must be provided after the most-recent update.", currentApprovalDate, rootArtifact.getDate()));
}

// Determine which version should be used.
String existingVersion = rootArtifact.hasVersion() ? rootArtifact.getVersion() : null;
String releaseVersion = getReleaseVersion(version, versionBehavior, existingVersion);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ public Library draftOperation(RequestDetails requestDetails, @IdParam IdType the

@Operation(name = "$release", idempotent = true, global = true, type = MetadataResource.class)
@Description(shortDefinition = "$release", value = "Release an existing draft artifact")
public Library releaseOperation(RequestDetails requestDetails,
@IdParam IdType theId,
@OperationParam(name = "version") String version,
@OperationParam(name = "version-behavior") CodeType versionBehavior,
@OperationParam(name = "latest-from-tx-server", typeName = "Boolean") IPrimitiveType<Boolean> latestFromTxServer)
public Library releaseOperation(
RequestDetails requestDetails,
@IdParam IdType theId,
@OperationParam(name = "version") String version,
@OperationParam(name = "version-behavior") CodeType versionBehavior,
@OperationParam(name = "latest-from-tx-server", typeName = "Boolean") IPrimitiveType<Boolean> latestFromTxServer)
throws FHIRException {

FhirDal fhirDal = this.fhirDalFactory.create(requestDetails);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void release_missing_approvalDate_validation_test() {
Parameters params1 = parameters(
stringPart("version", "1234"),
codePart("version-behavior", "default"),
booleanPart("latest-from-tx-server", true)
booleanPart("latest-from-tx-server", false)
);

try {
Expand Down