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

Aphl 784 remove effectiveperiod #758

Merged
merged 4 commits into from
Jan 3, 2024
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 @@ -413,6 +413,7 @@ private List<MetadataResource> createDraftsOfArtifactAndRelated(MetadataResource

if (newResource == null) {
KnowledgeArtifactAdapter<MetadataResource> sourceResourceAdapter = new KnowledgeArtifactAdapter<>(resourceToDraft);
sourceResourceAdapter.setEffectivePeriod(null);
newResource = sourceResourceAdapter.copy();
newResource.setStatus(Enumerations.PublicationStatus.DRAFT);
newResource.setVersion(draftVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,36 @@ void draftOperation_test() {
assertTrue(Canonicals.getVersion(relatedArtifacts.get(1).getResource()).equals(draftedVersion));
}
@Test
void draftOperation_no_effectivePeriod_test() {
loadTransaction("ersd-active-transaction-bundle-example.json");
Library baseLib = getClient()
.read()
.resource(Library.class)
.withId(specificationLibReference.split("/")[1])
.execute();
assertTrue(baseLib.hasEffectivePeriod());
PlanDefinition planDef = getClient()
.read()
.resource(PlanDefinition.class)
.withId("plandefinition-ersd-instance-example")
.execute();
assertTrue(planDef.hasEffectivePeriod());
String version = "1.01.21.273";
Parameters params = parameters(part("version", version) );
Bundle returnedBundle = getClient().operation()
.onInstance(specificationLibReference)
.named("$draft")
.withParameters(params)
.returnResourceType(Bundle.class)
.execute();
getMetadataResourcesFromBundle(returnedBundle)
.stream()
.forEach(resource -> {
KnowledgeArtifactAdapter<MetadataResource> adapter = new KnowledgeArtifactAdapter<MetadataResource>(resource);
assertFalse(adapter.getEffectivePeriod().hasStart() || adapter.getEffectivePeriod().hasEnd());
});
}
@Test
void draftOperation_version_conflict_test() {
loadTransaction("ersd-active-transaction-bundle-example.json");
loadResource("minimal-draft-to-test-version-conflict.json");
Expand Down Expand Up @@ -441,7 +471,26 @@ void releaseResource_propagate_effective_period() {
.execute();

assertNotNull(returnResource);
returnResource.getEntry()
getMetadataResourcesFromBundle(returnResource)
.stream()
.forEach(resource -> {
assertNotNull(resource);
if(!resource.getClass().getSimpleName().equals("ValueSet")){
KnowledgeArtifactAdapter<MetadataResource> adapter = new KnowledgeArtifactAdapter<>(resource);
assertTrue(adapter.getEffectivePeriod().hasStart());
Date start = adapter.getEffectivePeriod().getStart();
Calendar calendar = new GregorianCalendar();
calendar.setTime(start);
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
String startString = year + "-" + month + "-" + day;
assertTrue(startString.equals(effectivePeriodToPropagate));
}
});
}
List<MetadataResource> getMetadataResourcesFromBundle(Bundle bundle) {
return bundle.getEntry()
.stream()
.map(entry -> entry.getResponse().getLocation())
.map(location -> {
Expand All @@ -459,24 +508,8 @@ void releaseResource_propagate_effective_period() {
default:
return null;
}
})
.forEach(resource -> {
assertNotNull(resource);
if(!resource.getClass().getSimpleName().equals("ValueSet")){
KnowledgeArtifactAdapter<MetadataResource> adapter = new KnowledgeArtifactAdapter<>(resource);
assertTrue(adapter.getEffectivePeriod().hasStart());
Date start = adapter.getEffectivePeriod().getStart();
Calendar calendar = new GregorianCalendar();
calendar.setTime(start);
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
String startString = year + "-" + month + "-" + day;
assertTrue(startString.equals(effectivePeriodToPropagate));
}
});
}).collect(Collectors.toList());
}

@Test
void releaseResource_latestFromTx_NotSupported_test() {
loadTransaction("ersd-small-approved-draft-bundle.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"url": "http://hl7.org/fhir/us/ecr/Library/SpecificationLibrary",
"version": "1.0.0.23",
"approvalDate": "1990-01-01",
"effectivePeriod": {
"start": "2023-01-01",
"end": "2023-12-01"
},
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/artifact-releaseLabel",
Expand Down