From 34a029d5df22c7afca55625691fd1a958dc01980 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 15 Sep 2023 10:15:50 -0700 Subject: [PATCH] cross-version extensions --- .../hl7/fhir/r5/model/PackageInformation.java | 15 ++++++++++++--- .../r5/test/CanonicalResourceManagerTests.java | 16 ++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/PackageInformation.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/PackageInformation.java index 028fddb46..6afc130ef 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/PackageInformation.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/PackageInformation.java @@ -16,8 +16,9 @@ public class PackageInformation { private String web; private List dependencies = new ArrayList<>(); + private String fhirVersion; - public PackageInformation(String id, String version, Date date, String name, String canonical, String web) { + public PackageInformation(String id, String version, String fhirVersion, Date date, String name, String canonical, String web) { super(); this.id = id; this.version = version; @@ -25,12 +26,14 @@ public class PackageInformation { this.name = name; this.canonical = canonical; this.web = web; + this.fhirVersion = fhirVersion; } - public PackageInformation(String src, Date date) { + public PackageInformation(String src, String fhirVersion, Date date) { super(); this.id = src; this.date = date; + this.fhirVersion = fhirVersion; } public PackageInformation(NpmPackage pi) { @@ -41,13 +44,15 @@ public class PackageInformation { this.name = pi.title(); this.canonical = pi.canonical(); this.web = pi.getWebLocation(); + this.fhirVersion = pi.fhirVersion(); dependencies.addAll(pi.dependencies()); } - public PackageInformation(String id, String version, Date date) { + public PackageInformation(String id, String version, String fhirVersion, Date date) { super(); this.id = id; this.version = version; + this.fhirVersion = fhirVersion; this.date = date; } @@ -93,6 +98,10 @@ public class PackageInformation { return id+"#"+version; } + public String getFhirVersion() { + return fhirVersion; + } + public String toString() { return getVID(); } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CanonicalResourceManagerTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CanonicalResourceManagerTests.java index a60c2ce36..0e9f7e991 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CanonicalResourceManagerTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CanonicalResourceManagerTests.java @@ -431,12 +431,12 @@ public class CanonicalResourceManagerTests { vs2.setVersion("2000.0.0"); vs2.setName("2"); - mrm.see(vs1, new PackageInformation("hl7.fhir.r4.core", "4.0.1", new Date())); + mrm.see(vs1, new PackageInformation("hl7.fhir.r4.core", "4.0.1", "4.0.1", new Date())); Assertions.assertNotNull(mrm.get("http://terminology.hl7.org/ValueSet/234")); Assertions.assertNotNull(mrm.get("http://terminology.hl7.org/ValueSet/234", "2.0.0")); Assertions.assertTrue(mrm.get("http://terminology.hl7.org/ValueSet/234").getName().equals("1")); - mrm.see(vs2, new PackageInformation("hl7.terminology.r4", "4.0.1", new Date())); + mrm.see(vs2, new PackageInformation("hl7.terminology.r4", "4.0.1", "4.0.1", new Date())); Assertions.assertNotNull(mrm.get("http://terminology.hl7.org/ValueSet/234")); Assertions.assertTrue(mrm.get("http://terminology.hl7.org/ValueSet/234").getName().equals("2")); Assertions.assertNull(mrm.get("http://terminology.hl7.org/ValueSet/234", "2.0.0")); // this will get dropped completely because of UTG rules @@ -822,14 +822,14 @@ public class CanonicalResourceManagerTests { vs1.setVersion("4.0.1"); vs1.setName("1"); DeferredLoadTestResource vs1d = new DeferredLoadTestResource(vs1); - mrm.see(vs1, new PackageInformation("pid.one", "1.0.0", new Date())); + mrm.see(vs1, new PackageInformation("pid.one", "1.0.0", "4.0.1", new Date())); ValueSet vs2 = new ValueSet(); vs2.setId("2346"); vs2.setUrl("http://url/ValueSet/234"); vs2.setVersion("4.0.1"); vs2.setName("2"); - mrm.see(vs2, new PackageInformation("pid.two", "1.0.0", new Date())); + mrm.see(vs2, new PackageInformation("pid.two", "1.0.0", "4.0.1", new Date())); List pvl1 = new ArrayList<>(); pvl1.add("pid.one#1.0.0"); @@ -862,14 +862,14 @@ public class CanonicalResourceManagerTests { csb1.setUrl("http://url/CodeSystem/234"); csb1.setVersion("4.0.1"); csb1.setName("1"); - mrm.see(csb1, new PackageInformation("pid.one", "1.0.0", new Date())); + mrm.see(csb1, new PackageInformation("pid.one", "1.0.0", "4.0.1", new Date())); CodeSystem csb2 = new CodeSystem(); csb2.setId("2346"); csb2.setUrl("http://url/CodeSystem/234"); csb2.setVersion("4.0.1"); csb2.setName("2"); - mrm.see(csb2, new PackageInformation("pid.two", "1.0.0", new Date())); + mrm.see(csb2, new PackageInformation("pid.two", "1.0.0", "4.0.1", new Date())); CodeSystem css1 = new CodeSystem(); css1.setId("s2345"); @@ -877,7 +877,7 @@ public class CanonicalResourceManagerTests { css1.setVersion("4.0.1"); css1.setName("s1"); css1.setSupplements("http://url/CodeSystem/234"); - mrm.see(css1, new PackageInformation("pid.one", "1.0.0", new Date())); + mrm.see(css1, new PackageInformation("pid.one", "1.0.0", "4.0.1", new Date())); CodeSystem css2 = new CodeSystem(); css2.setId("s2346"); @@ -885,7 +885,7 @@ public class CanonicalResourceManagerTests { css2.setVersion("4.0.1"); css2.setName("s2"); css2.setSupplements("http://url/CodeSystem/234"); - mrm.see(css2, new PackageInformation("pid.two", "1.0.0", new Date())); + mrm.see(css2, new PackageInformation("pid.two", "1.0.0", "4.0.1", new Date())); List sl = mrm.getSupplements("http://url/CodeSystem/234"); Assertions.assertEquals(2, sl.size());