Skip to content

Commit

Permalink
changes for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantaustin13 committed Jul 16, 2024
1 parent f8d7dc8 commit 4f45021
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 73 deletions.
6 changes: 0 additions & 6 deletions tooling/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,6 @@
<artifactId>mockserver-client-java</artifactId>
<version>5.14.0</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
<scope>compile</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public Map<String, StructureDefinitionBindingObject> visitStructureDefinition(St
getBindings(sdName, eds, sdURL, sdVersion, bindingObjects);
}
if (sd.hasBaseDefinition()) {
bindingObjects.putAll(visitStructureDefinition(this.canonicalResourceDependenciesAtlas.getStructureDefinitions().getByCanonicalUrlWithVersion(sd.getBaseDefinition()), snapshotOnly)); }
bindingObjects.putAll(visitStructureDefinition(this.canonicalResourceDependenciesAtlas.getStructureDefinitions().getByCanonicalUrlWithVersion(sd.getBaseDefinition()), snapshotOnly));
}
}
return bindingObjects;
}
Expand Down Expand Up @@ -71,7 +72,7 @@ private void getBindings(String sdName, List<ElementDefinition> eds, String sdUR
sdbo.setSdURL(sdURL);
sdbo.setSdVersion(sdVersion);
sdbo.setBindingStrength(ed.getBinding().getStrength().toString().toLowerCase());
if(ed.hasMin() && ed.hasMax()){
if (ed.hasMin() && ed.hasMax()) {
String edCardinality = ed.getMin() + "..." + ed.getMax();
sdbo.setCardinality(edCardinality);
}
Expand All @@ -97,16 +98,16 @@ private void getBindings(String sdName, List<ElementDefinition> eds, String sdUR
valueSetVersion = pipeVersion;
}
if (null != elementValueSet) {
StringBuilder codeSystemURLs = new StringBuilder();;
StringBuilder codeSystemURLs = new StringBuilder();
Map<String, String> codeSystemsMap = new HashMap<>();
getValueSetCodeSystems(elementValueSet, codeSystemsMap);
if(null != codeSystemsMap && !codeSystemsMap.isEmpty()) {
AtomicReference <Integer> valueCount = new AtomicReference<>(0);
codeSystemsMap.values().forEach((url)->{
if (null != codeSystemsMap && !codeSystemsMap.isEmpty()) {
AtomicReference<Integer> valueCount = new AtomicReference<>(0);
codeSystemsMap.values().forEach((url) -> {
codeSystemURLs.append(url);
valueCount.set(valueCount.get() + 1);
if(valueCount.get() > 0 &&
valueCount.get() < codeSystemsMap.size()) {
if (valueCount.get() > 0 &&
valueCount.get() < codeSystemsMap.size()) {
codeSystemURLs.append(";");
}
});
Expand All @@ -121,16 +122,14 @@ private void getBindings(String sdName, List<ElementDefinition> eds, String sdUR
sdbo.setBindingValueSetVersion(valueSetVersion);
bindingObjects.put(sdName + "." + sdbo.getElementId(), sdbo);
}
else if(ed.getId().equalsIgnoreCase("patient.extension:race")
|| ed.getId().equalsIgnoreCase("patient.extension:ethnicity")){
// getBindings(sdName, Collections.singletonList(ed), sdURL, sdVersion, bindingObjects);
else if (ed.hasExtension()) {
visitExtensions(ed, bindingObjects, sdName, sdURL, sdVersion);
}
index.set(index.get() + 1);
}
}

private void visitExtensions(ElementDefinition ed, Map<String, StructureDefinitionBindingObject> bindingObjects, String sdName, String sdURL, String sdVersion){
private void visitExtensions(ElementDefinition ed, Map<String, StructureDefinitionBindingObject> bindingObjects, String sdName, String sdURL, String sdVersion) {
StructureDefinitionBindingObject sdbo = new StructureDefinitionBindingObject();
sdbo.setSdName(sdName);
sdbo.setSdURL(sdURL);
Expand All @@ -141,69 +140,82 @@ private void visitExtensions(ElementDefinition ed, Map<String, StructureDefiniti
} else {
sdbo.setMustSupport("N");
}
if(ed.hasMin()){
if (ed.hasMin()) {
String edCardinality = ed.getMin() + "..." + ed.getMax();
sdbo.setCardinality(edCardinality);
}
CanonicalType canonicalType = new CanonicalType();
canonicalType.setValue(String.valueOf(ed.getType().get(0).getProfile().get(0)));
ed.getType().get(0).getProfile().get(0).getValueAsString();
String urlValue = ed.getType().get(0).getProfile().get(0).toString();
Iterable<StructureDefinition> sdList = this.canonicalResourceDependenciesAtlas.getStructureDefinitions().getByCanonicalUrl(ed.getType().get(0).getProfile().get(0).getValueAsString());
sdList.forEach((structDef)->{
List<ElementDefinition> edsds = structDef.getDifferential().getElement();
edsds.forEach(edsd->{
if(edsd.hasBinding()){
sdbo.setBindingStrength(edsd.getBinding().getStrength().toString().toLowerCase());
String bindingValueSet = edsd.getBinding().getValueSet();
String pipeVersion = "";
if (bindingValueSet.contains("|")) {
pipeVersion = bindingValueSet.substring(bindingValueSet.indexOf("|") + 1);
bindingValueSet = bindingValueSet.substring(0, bindingValueSet.indexOf("|"));
}
sdbo.setBindingValueSetURL(bindingValueSet);
String valueSetVersion = "";
ValueSet elementValueSet = null;
if (null != this.canonicalResourceAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL())) {
valueSetVersion = this.canonicalResourceAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL()).getVersion();
sdbo.setBindingValueSetName(this.canonicalResourceAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL()).getName());
elementValueSet = this.canonicalResourceAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL());
} else if (null != this.canonicalResourceDependenciesAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL())) {
valueSetVersion = this.canonicalResourceDependenciesAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL()).getVersion();
sdbo.setBindingValueSetName(this.canonicalResourceDependenciesAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL()).getName());
elementValueSet = this.canonicalResourceDependenciesAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL());
} else if (valueSetVersion.length() < 1 && bindingValueSet.contains("|")) {
valueSetVersion = pipeVersion;
}
sdbo.setBindingValueSetVersion(valueSetVersion);
if (null != elementValueSet) {
StringBuilder codeSystemURLs = new StringBuilder();;
Map<String, String> codeSystemsMap = new HashMap<>();
getValueSetCodeSystems(elementValueSet, codeSystemsMap);
if(null != codeSystemsMap && !codeSystemsMap.isEmpty()) {
AtomicReference <Integer> valueCount = new AtomicReference<>(0);
codeSystemsMap.values().forEach((url)->{
codeSystemURLs.append(url);
valueCount.set(valueCount.get() + 1);
if(valueCount.get() > 0 &&
valueCount.get() < codeSystemsMap.size()) {
codeSystemURLs.append(";");
}
});
sdbo.setCodeSystemsURLs(codeSystemURLs.toString());
Iterable<StructureDefinition> sdList = null;
try {
if (ed.getType().get(0).getProfile().size() != 0) {
canonicalType.setValue(String.valueOf(ed.getType().get(0).getProfile().get(0)));
sdList = this.canonicalResourceDependenciesAtlas.getStructureDefinitions().getByCanonicalUrl(ed.getType().get(0).getProfile().get(0).getValueAsString());
} else if (ed.getType().get(0).getTargetProfile().size() != 0) {
canonicalType.setValue(String.valueOf(ed.getType().get(0).getTargetProfile()));
sdList = this.canonicalResourceDependenciesAtlas.getStructureDefinitions().getByCanonicalUrl(ed.getType().get(0).getTargetProfile().get(0).getValueAsString());
}
else{
return;
}
} catch (Exception ex) {
return;
}
if (sdList != null) {
sdList.forEach((structDef) -> {
List<ElementDefinition> edsds = structDef.getDifferential().getElement();
edsds.forEach(edsd -> {
if (edsd.hasBinding()) {
sdbo.setBindingStrength(edsd.getBinding().getStrength().toString().toLowerCase());
String bindingValueSet = edsd.getBinding().getValueSet();
String pipeVersion = "";
if (bindingValueSet.contains("|")) {
pipeVersion = bindingValueSet.substring(bindingValueSet.indexOf("|") + 1);
bindingValueSet = bindingValueSet.substring(0, bindingValueSet.indexOf("|"));
}
sdbo.setBindingValueSetURL(bindingValueSet);
String valueSetVersion = "";
ValueSet elementValueSet = null;
if (null != this.canonicalResourceAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL())) {
valueSetVersion = this.canonicalResourceAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL()).getVersion();
sdbo.setBindingValueSetName(this.canonicalResourceAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL()).getName());
elementValueSet = this.canonicalResourceAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL());
} else if (null != this.canonicalResourceDependenciesAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL())) {
valueSetVersion = this.canonicalResourceDependenciesAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL()).getVersion();
sdbo.setBindingValueSetName(this.canonicalResourceDependenciesAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL()).getName());
elementValueSet = this.canonicalResourceDependenciesAtlas.getValueSets().getByCanonicalUrlWithVersion(sdbo.getBindingValueSetURL());
} else if (valueSetVersion.isEmpty() && bindingValueSet.contains("|")) {
valueSetVersion = pipeVersion;
}
sdbo.setBindingValueSetVersion(valueSetVersion);
if (null != elementValueSet) {
StringBuilder codeSystemURLs = new StringBuilder();
Map<String, String> codeSystemsMap = new HashMap<>();
getValueSetCodeSystems(elementValueSet, codeSystemsMap);
if (!codeSystemsMap.isEmpty()) {
AtomicReference<Integer> valueCount = new AtomicReference<>(0);
codeSystemsMap.values().forEach((url) -> {
codeSystemURLs.append(url);
valueCount.set(valueCount.get() + 1);
if (valueCount.get() > 0 &&
valueCount.get() < codeSystemsMap.size()) {
codeSystemURLs.append(";");
}
});
sdbo.setCodeSystemsURLs(codeSystemURLs.toString());
}
}
}
}
});
});
});
}
bindingObjects.put(sdName + "." + sdbo.getElementId(), sdbo);
}

private void getValueSetCodeSystems(ValueSet elementValueSet, Map<String, String> codeSystemsMap) {
ValueSet.ValueSetComposeComponent compose = elementValueSet.getCompose();
if (null != compose) {
for (ValueSet.ConceptSetComponent include : compose.getInclude()) {
if(include.hasSystem()){
if (include.hasSystem()) {
codeSystemsMap.put(include.getSystem(), include.getSystem());
}
for (CanonicalType r : include.getValueSet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ private void createOutput(List<StructureDefinitionBindingObject> bindingObjects)
XSSFRow currentRow = firstSheet.createRow(rowCount.getAndAccumulate(1, ibo));
SpreadsheetCreatorHelper.createHeaderRow(workBook, createHeaderNameList(), currentRow);
bindingObjects.forEach((bindingObject) -> {
addBindingObjectRowDataToCurrentSheet(firstSheet, rowCount.getAndAccumulate(1, ibo), bindingObject);
try {
addBindingObjectRowDataToCurrentSheet(firstSheet, rowCount.getAndAccumulate(1, ibo), bindingObject);
}catch(Exception ex){
ex.printStackTrace();
}
});
SpreadsheetCreatorHelper.writeSpreadSheet(workBook,
IOUtils.concatFilePath(getOutputPath(), modelName + " " + modelVersion + " Profile Elements.xlsx"));
Expand Down Expand Up @@ -129,11 +133,13 @@ private void addBindingObjectRowDataToCurrentSheet(XSSFSheet currentSheet, int r
currentCell.setCellValue(bo.getBindingValueSetName());

currentCell = currentRow.createCell(cellCount++);
currentCell.setCellValue(bo.getBindingValueSetURL());
link = (XSSFHyperlink)helper.createHyperlink(HyperlinkType.URL);
link.setAddress(bo.getBindingValueSetURL());
currentCell.setHyperlink(link);
currentCell.setCellStyle(linkStyle);
if(bo.getBindingValueSetURL() != null) {
currentCell.setCellValue(bo.getBindingValueSetURL());
link = (XSSFHyperlink) helper.createHyperlink(HyperlinkType.URL);
link.setAddress(bo.getBindingValueSetURL());
currentCell.setHyperlink(link);
currentCell.setCellStyle(linkStyle);
}

currentCell = currentRow.createCell(cellCount++);
currentCell.setCellValue(bo.getBindingValueSetVersion());
Expand Down

0 comments on commit 4f45021

Please sign in to comment.