Skip to content

Commit d9de92d

Browse files
IG Refresh Updates (#556)
* IG Refresh Updates - PlanDefinition refresh support - Updated extension url constants - Lots of small cleanup tasks * Fixed tests * Fixed issue with multiple namespaces loading from duplicate dependencies * Removed ig-loader check in library processor * Updated PlanDefinition refresh extensions and additional cleanup * Fix failing build * Update software system codesystem url... Fix build fail --------- Co-authored-by: Bryn Rhodes <bryn@databaseconsultinggroup.com>
1 parent 0bb4a7e commit d9de92d

File tree

48 files changed

+1248
-602
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1248
-602
lines changed

tooling/src/main/java/org/opencds/cqf/tooling/common/BaseCqfmSoftwareSystemHelper.java

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.opencds.cqf.tooling.common;
2+
3+
import org.opencds.cqf.tooling.utilities.IOUtils;
4+
5+
import java.io.File;
6+
import java.util.Objects;
7+
8+
9+
public abstract class BaseSoftwareSystemHelper {
10+
private String rootDir;
11+
protected String getRootDir() {
12+
return this.rootDir;
13+
}
14+
15+
public static String cqfRulerDeviceName = "cqf-ruler";
16+
protected static String devicePath = IOUtils.concatFilePath(File.separator,
17+
"input", "resources", "device");
18+
19+
public BaseSoftwareSystemHelper() { }
20+
21+
public BaseSoftwareSystemHelper(String rootDir) {
22+
this.rootDir = Objects.requireNonNull(rootDir, "SoftwareSystemHelper rootDir argument can not be null");
23+
}
24+
25+
protected Boolean getSystemIsValid(SoftwareSystem system) {
26+
boolean isValid = false;
27+
28+
if (system != null) {
29+
boolean hasSoftwareSystemName = system.getName() != null && !system.getName().isEmpty();
30+
boolean hasVersion = system.getVersion() != null && !system.getVersion().isEmpty();
31+
isValid = hasSoftwareSystemName && hasVersion;
32+
}
33+
34+
return isValid;
35+
}
36+
37+
protected void EnsureDevicePath() {
38+
IOUtils.ensurePath(rootDir + devicePath);
39+
if (!IOUtils.resourceDirectories.contains(rootDir + devicePath)) {
40+
IOUtils.resourceDirectories.add(rootDir + devicePath);
41+
}
42+
}
43+
}

tooling/src/main/java/org/opencds/cqf/tooling/common/CqfmSoftwareSystem.java renamed to tooling/src/main/java/org/opencds/cqf/tooling/common/SoftwareSystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.opencds.cqf.tooling.common;
22

33

4-
public class CqfmSoftwareSystem {
4+
public class SoftwareSystem {
55
protected String name;
66
public String getName() { return this.name; }
77

@@ -11,13 +11,13 @@ public class CqfmSoftwareSystem {
1111
protected String manufacturer;
1212
public String getManufacturer() { return this.manufacturer; }
1313

14-
public CqfmSoftwareSystem(String name, String version, String manufacturer) {
14+
public SoftwareSystem(String name, String version, String manufacturer) {
1515
this.name = name;
1616
this.version = version;
1717
this.manufacturer = manufacturer;
1818

1919
if (this.version == null) {
20-
this.version = CqfmSoftwareSystem.class.getPackage().getSpecificationVersion();
20+
this.version = SoftwareSystem.class.getPackage().getSpecificationVersion();
2121
}
2222

2323
if (this.version == null) {
Lines changed: 38 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,52 @@
11
package org.opencds.cqf.tooling.common.r4;
22

3-
import java.io.File;
4-
import java.io.FileReader;
5-
import java.io.IOException;
6-
import java.util.ArrayList;
7-
import java.util.List;
8-
import java.util.stream.Collectors;
9-
3+
import ca.uhn.fhir.context.FhirContext;
4+
import ca.uhn.fhir.parser.JsonParser;
5+
import ca.uhn.fhir.parser.XmlParser;
106
import org.cqframework.cql.Main;
11-
import org.hl7.fhir.r4.model.CodeableConcept;
12-
import org.hl7.fhir.r4.model.Coding;
13-
import org.hl7.fhir.r4.model.Device;
14-
import org.hl7.fhir.r4.model.DomainResource;
15-
import org.hl7.fhir.r4.model.Extension;
16-
import org.hl7.fhir.r4.model.Meta;
17-
import org.hl7.fhir.r4.model.Reference;
18-
import org.hl7.fhir.r4.model.Resource;
19-
import org.hl7.fhir.r4.model.ResourceType;
20-
import org.hl7.fhir.r4.model.StringType;
21-
import org.opencds.cqf.tooling.common.BaseCqfmSoftwareSystemHelper;
22-
import org.opencds.cqf.tooling.common.CqfmSoftwareSystem;
7+
import org.hl7.fhir.r4.model.*;
8+
import org.opencds.cqf.tooling.common.BaseSoftwareSystemHelper;
9+
import org.opencds.cqf.tooling.common.SoftwareSystem;
2310
import org.opencds.cqf.tooling.utilities.IOUtils;
11+
import org.opencds.cqf.tooling.utilities.constants.CqfConstants;
12+
import org.opencds.cqf.tooling.utilities.constants.CrmiConstants;
2413
import org.slf4j.Logger;
2514
import org.slf4j.LoggerFactory;
2615

27-
import ca.uhn.fhir.context.FhirContext;
28-
import ca.uhn.fhir.parser.JsonParser;
29-
import ca.uhn.fhir.parser.XmlParser;
16+
import java.io.FileReader;
17+
import java.io.IOException;
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
import java.util.stream.Collectors;
3021

3122

32-
public class CqfmSoftwareSystemHelper extends BaseCqfmSoftwareSystemHelper {
23+
public class SoftwareSystemHelper extends BaseSoftwareSystemHelper {
3324

34-
private static Logger logger = LoggerFactory.getLogger(CqfmSoftwareSystemHelper.class);
25+
private static final Logger logger = LoggerFactory.getLogger(SoftwareSystemHelper.class);
3526

36-
public CqfmSoftwareSystemHelper() { }
27+
public SoftwareSystemHelper() { }
3728

38-
public CqfmSoftwareSystemHelper(String rootDir) {
29+
public SoftwareSystemHelper(String rootDir) {
3930
super(rootDir);
4031
}
4132

42-
@SuppressWarnings("serial")
4333
protected <T extends DomainResource> void validateResourceForSoftwareSystemExtension(T resource) {
4434
if (resource == null) {
4535
throw new IllegalArgumentException("No resource provided.");
4636
}
47-
48-
List<String> eligibleResourceTypes = new ArrayList<String>() { {
49-
add("Library");
50-
add("Measure");
51-
} };
52-
53-
String eligibleResourceTypesList = String.join(", ", eligibleResourceTypes);
54-
String fhirType = "Library";//resource.get resource.fhirType();
55-
if (!eligibleResourceTypes.contains(fhirType)) {
56-
throw new IllegalArgumentException(String.format("cqfm-softwaresystem extension is only supported for the following resources: { %s }, not %s", eligibleResourceTypesList, fhirType));
57-
}
5837
}
5938

60-
public <T extends DomainResource> void ensureSoftwareSystemExtensionAndDevice(T resource, List<CqfmSoftwareSystem> softwareSystems, FhirContext fhirContext) {
39+
public <T extends DomainResource> void ensureSoftwareSystemExtensionAndDevice(T resource, List<SoftwareSystem> softwareSystems, FhirContext fhirContext) {
6140
validateResourceForSoftwareSystemExtension(resource);
6241

6342
if (softwareSystems != null && !softwareSystems.isEmpty()) {
64-
for (CqfmSoftwareSystem system : softwareSystems) {
43+
for (SoftwareSystem system : softwareSystems) {
6544
ensureSoftwareSystemExtensionAndDevice(resource, system, fhirContext);
6645
}
6746
}
6847
}
6948

70-
public <T extends DomainResource> void ensureSoftwareSystemExtensionAndDevice(T resource, CqfmSoftwareSystem system, FhirContext fhirContext) {
49+
public <T extends DomainResource> void ensureSoftwareSystemExtensionAndDevice(T resource, SoftwareSystem system, FhirContext fhirContext) {
7150
validateResourceForSoftwareSystemExtension(resource);
7251

7352
if (this.getSystemIsValid(system)) {
@@ -85,25 +64,25 @@ public <T extends DomainResource> void ensureSoftwareSystemExtensionAndDevice(T
8564
if (path.endsWith("xml")) {
8665
deviceOutputEncoding = IOUtils.Encoding.XML;
8766
XmlParser xmlParser = (XmlParser)fhirContext.newXmlParser();
88-
try (FileReader reader = new FileReader(new File(path))) {
67+
try (FileReader reader = new FileReader(path)) {
8968
resourceInPath = (DomainResource) xmlParser.parseResource(reader);
9069
} catch (IOException e) {
91-
e.printStackTrace();
70+
logger.warn("Error parsing " + e.getLocalizedMessage(), e);
9271
throw new RuntimeException("Error parsing " + e.getLocalizedMessage());
9372
}
9473
}
9574
else {
9675
JsonParser jsonParser = (JsonParser)fhirContext.newJsonParser();
97-
try (FileReader reader = new FileReader(new File(path))) {
76+
try (FileReader reader = new FileReader(path)) {
9877
resourceInPath = (DomainResource) jsonParser.parseResource(reader);
9978
} catch (IOException e) {
100-
e.printStackTrace();
79+
logger.warn("Error parsing " + e.getLocalizedMessage(), e);
10180
throw new RuntimeException("Error parsing " + e.getLocalizedMessage());
10281
}
10382
}
10483

10584
// NOTE: Takes the first device that matches on ID.
106-
if (resourceInPath.getResourceType().toString().toLowerCase().equals("device")) {
85+
if (resourceInPath.getResourceType().toString().equalsIgnoreCase("device")) {
10786
Device prospectDevice = (Device)resourceInPath;
10887
if (prospectDevice.getIdElement().getIdPart().equals(systemDeviceId)) {
10988
device = (Device)resourceInPath;
@@ -121,7 +100,7 @@ public <T extends DomainResource> void ensureSoftwareSystemExtensionAndDevice(T
121100

122101
/* Ensure that device has the current/proposed version */
123102
Device.DeviceVersionComponent proposedVersion = new Device.DeviceVersionComponent(new StringType(system.getVersion()));
124-
List<Device.DeviceVersionComponent> proposedVersionList = new ArrayList<Device.DeviceVersionComponent>();
103+
List<Device.DeviceVersionComponent> proposedVersionList = new ArrayList<>();
125104
proposedVersionList.add(proposedVersion);
126105
device.setVersion(proposedVersionList);
127106

@@ -153,22 +132,22 @@ public <T extends DomainResource> void ensureSoftwareSystemExtensionAndDevice(T
153132
}
154133
}
155134

156-
if (softwareSystemExtension == null && device != null) {
135+
if (softwareSystemExtension == null) {
157136
softwareSystemExtension = new Extension();
158-
softwareSystemExtension.setUrl(this.getCqfmSoftwareSystemExtensionUrl());
137+
softwareSystemExtension.setUrl(CrmiConstants.SOFTWARE_SYSTEM_EXT_URL);
159138
final Reference reference = new Reference();
160139
reference.setReference(systemReference);
161140
softwareSystemExtension.setValue(reference);
162141

163142
resource.addExtension(softwareSystemExtension);
164143
}
165-
else if (softwareSystemExtension != null && !systemReference.equals(((Reference)softwareSystemExtension.getValue()).getReference())) {
144+
else if (!systemReference.equals(((Reference)softwareSystemExtension.getValue()).getReference())) {
166145
((Reference)softwareSystemExtension.getValue()).setReference(systemReference);
167146
}
168-
else if (device == null) {
169-
if (resource.hasExtension(this.getCqfmSoftwareSystemExtensionUrl())) {
147+
else {
148+
if (resource.hasExtension(CrmiConstants.SOFTWARE_SYSTEM_EXT_URL)) {
170149
resource.setExtension(extensions.stream()
171-
.filter(extension -> !extension.getUrl().equals(this.getCqfmSoftwareSystemExtensionUrl()))
150+
.filter(extension -> !extension.getUrl().equals(CrmiConstants.SOFTWARE_SYSTEM_EXT_URL))
172151
.collect(Collectors.toList()));
173152
}
174153
}
@@ -210,7 +189,7 @@ else if (device == null) {
210189
}
211190
}
212191

213-
public Device createSoftwareSystemDevice(CqfmSoftwareSystem system) {
192+
public Device createSoftwareSystemDevice(SoftwareSystem system) {
214193
Device device = null;
215194

216195
if (this.getSystemIsValid(system)) {
@@ -219,15 +198,15 @@ public Device createSoftwareSystemDevice(CqfmSoftwareSystem system) {
219198

220199
/* meta.profile */
221200
Meta meta = new Meta();
222-
meta.addProfile("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/device-softwaresystem-cqfm");
201+
meta.addProfile(CrmiConstants.SOFTWARE_SYSTEM_DEVICE_PROFILE_URL);
223202
device.setMeta(meta);
224203

225204
device.addDeviceName().setName(system.getName()).setType(Device.DeviceNameType.MANUFACTURERNAME);
226205
device.setManufacturer(system.getName());
227206

228207
/* type */
229208
Coding typeCoding = new Coding();
230-
typeCoding.setSystem("http://hl7.org/fhir/us/cqfmeasures/CodeSystem/software-system-type");
209+
typeCoding.setSystem(CrmiConstants.SOFTWARE_SYSTEM_DEVICE_TYPE_SYSTEM_URL);
231210
typeCoding.setCode("tooling");
232211

233212
List<Coding> typeCodingList = new ArrayList<>();
@@ -253,14 +232,14 @@ public Device createSoftwareSystemDevice(CqfmSoftwareSystem system) {
253232
// }
254233

255234
public <T extends DomainResource> void ensureCQFToolingExtensionAndDevice(T resource, FhirContext fhirContext) {
256-
CqfmSoftwareSystem cqfToolingSoftwareSystem = new CqfmSoftwareSystem(this.getCqfToolingDeviceName(), CqfmSoftwareSystemHelper.class.getPackage().getImplementationVersion(), Main.class.getPackage().getImplementationVendor());
235+
SoftwareSystem cqfToolingSoftwareSystem = new SoftwareSystem(CqfConstants.CQF_TOOLING_DEVICE_NAME, SoftwareSystemHelper.class.getPackage().getImplementationVersion(), Main.class.getPackage().getImplementationVendor());
257236
ensureSoftwareSystemExtensionAndDevice(resource, cqfToolingSoftwareSystem, fhirContext);
258237
}
259238

260239
private void addVersion(Device device, String version) {
261-
// NOTE: The cqfm-softwaresystem extension restricts the cardinality of version to 0..1, so we overwrite any existing version entries each time
240+
// NOTE: The crmi-softwaresystem extension restricts the cardinality of version to 0..1, so we overwrite any existing version entries each time
262241
Device.DeviceVersionComponent versionComponent = new Device.DeviceVersionComponent(new StringType(version));
263-
List<Device.DeviceVersionComponent> versionList = new ArrayList<Device.DeviceVersionComponent>();
242+
List<Device.DeviceVersionComponent> versionList = new ArrayList<>();
264243
versionList.add(versionComponent);
265244

266245
device.setVersion(versionList);

0 commit comments

Comments
 (0)