Skip to content

Commit

Permalink
removed println and added missing stuff from merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantaustin13 committed Nov 19, 2024
1 parent a617e38 commit 6056d6b
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import org.hl7.fhir.r4.model.CanonicalType;
import org.hl7.fhir.r4.model.ElementDefinition;
import org.hl7.fhir.r4.model.StructureDefinition;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.*;

import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -78,8 +75,7 @@ private void getBindings(String sdName, List<ElementDefinition> eds, String sdUR
if(ed.getMin() > 0){sdbo.setCardinalityMin(ed.getMin());}
}
if(getBindingObjectExtension(ed).equalsIgnoreCase("qicore-keyelement")){
System.out.println("qicore-keyelement");
sdbo.setBindingObjectExtension("qicore-keyelement");
sdbo.setBindingObjectExtension("qicore-keyelement");
}
String bindingValueSet = ed.getBinding().getValueSet();
String pipeVersion = "";
Expand Down Expand Up @@ -134,6 +130,99 @@ else if (ed.hasExtension()) {
}
}

private String getBindingObjectExtension(ElementDefinition ed) {
for (Extension ext : ed.getExtension()) {
if (!ext.getUrl().isEmpty()) {
if (ext.getUrl().contains("qicore-keyelement")) {
return "qicore-keyelement";
}
}
}
return "";
}

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);
sdbo.setSdVersion(sdVersion);
sdbo.setElementId(ed.getId());
if (ed.getMustSupport()) {
sdbo.setMustSupport("Y");
} else {
sdbo.setMustSupport("N");
}
if (ed.hasMin()) {
String edCardinality = ed.getMin() + "..." + ed.getMax();
sdbo.setCardinality(edCardinality);
}
CanonicalType canonicalType = new CanonicalType();
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void addBindingObjectRowDataToCurrentSheet(XSSFSheet currentSheet, int r
if ((null != bo.getBindingStrength() && bo.getBindingStrength().equalsIgnoreCase("required")) ||
null != bo.getMustSupport() && bo.getMustSupport().equalsIgnoreCase("Y") ||
null != bo.getBindingObjectExtension() && bo.getBindingObjectExtension().equalsIgnoreCase("qicore-keyElement") ||
bo.getCardinalityMin() >0
bo.getCardinalityMin() > 0
) {
currentCell.setCellValue("Needed");
}
Expand Down

0 comments on commit 6056d6b

Please sign in to comment.