Skip to content

Commit

Permalink
First slice AK HIV changes (cqframework#491)
Browse files Browse the repository at this point in the history
* Fix codesystem parsing bug in accelerator kit processor.

* Added extension handling for test case example builder.

---------

Co-authored-by: ZackAustin <[email protected]>
  • Loading branch information
JPercival and ZackAustin authored Nov 29, 2023
1 parent a3e7544 commit 103bba8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.opencds.cqf.tooling.acceleratorkit;

import org.hl7.fhir.r4.model.ConceptMap;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.StructureDefinition;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.*;

public class CanonicalResourceAtlas {
private CanonicalResourceProvider<StructureDefinition> structureDefinitions;
Expand Down Expand Up @@ -41,4 +38,13 @@ public CanonicalResourceAtlas setConceptMaps(CanonicalResourceProvider<ConceptMa
this.conceptMaps = conceptMaps;
return this;
}

private CanonicalResourceProvider<StructureDefinition> extensions;
public CanonicalResourceProvider<StructureDefinition> getExtensions() {
return extensions;
}
public CanonicalResourceAtlas setExtensions(CanonicalResourceProvider<StructureDefinition> extensions) {
this.extensions = extensions;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;

public class ExampleBuilder {
Expand Down Expand Up @@ -378,7 +375,14 @@ private void visitElement(StructureDefinition sd, List<ElementDefinition> eds, A
extension.setValue((Type)elementValue);
elementValue = extension;
}
value.setProperty(getElementName(ed.getPath()), elementValue);
if (!elementName.equals("extension")) {
value.setProperty(getElementName(ed.getPath()), elementValue);
}
else {
Extension subExtension = (Extension) ((Extension) elementValue).getValue();
subExtension.setUrl(((Extension) elementValue).getUrl());
value.setProperty(getElementName(ed.getPath()), subExtension);
}

index.set(index.get() + 1);
while (index.get() < eds.size()) {
Expand Down Expand Up @@ -677,6 +681,21 @@ else if (value instanceof CodeableConcept) {
.setDisplay("Example");
}
}
else if (value instanceof Extension) {
if (ed.getType("Extension") != null && ed.getType("Extension").getProfile() != null && atlas != null && atlas.getValueSets() != null && atlas.getExtensions() != null) {
StructureDefinition sdExtension = atlas.getExtensions().getByCanonicalUrlWithVersion(ed.getType("Extension").getProfile().get(0).getValue());
ElementDefinition extensionElement = sdExtension.getDifferential().getElement().stream()
.filter(x -> x.hasBinding() && x.getBinding().hasValueSetElement()).findFirst().get();

Type extensionValue = null;
if (extensionElement.getType("CodeableConcept") != null) {
extensionValue = new CodeableConcept();
}

generateValue(sdExtension, extensionElement, extensionValue, givenValue);
value.addExtension(new Extension().setUrl(extensionElement.getShort()).setValue(extensionValue));
}
}
}

private void buildElements(StructureDefinition sd, Resource r, Map<String, Object> elementValues) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,14 @@ private String getCodeComments(Row row, HashMap<String, Integer> colIds, String
}

private String getCodeSystemCommentColName(String codeSystem) {
switch (codeSystem) {
switch (codeSystem.toUpperCase()) {
case "ICD-10": return "ICD-10Comments";
case "ICD-11": return "ICD-11Comments";
case "ICHI": return "ICHIComments";
case "ICF": return "ICFComments";
case "SNOMED-CT": return "SNOMEDComments";
case "LOINC": return "LOINCComments";
case "RXNorm": return "RXNormComments";
case "RXNORM": return "RXNormComments";
case "CPT": return "CPTComments";
case "HCPCS": return "HCPCSComments";
case "NDC": return "NDCComments";
Expand Down Expand Up @@ -2549,7 +2549,8 @@ private CanonicalResourceAtlas getAtlas() {
new CanonicalResourceAtlas()
.setValueSets(new InMemoryCanonicalResourceProvider<ValueSet>(this.valueSets))
.setCodeSystems(new InMemoryCanonicalResourceProvider<CodeSystem>(this.codeSystems))
.setConceptMaps(new InMemoryCanonicalResourceProvider<ConceptMap>(this.conceptMaps.values()));
.setConceptMaps(new InMemoryCanonicalResourceProvider<ConceptMap>(this.conceptMaps.values()))
.setExtensions(new InMemoryCanonicalResourceProvider<StructureDefinition>(this.extensions));
}
return atlas;
}
Expand Down

0 comments on commit 103bba8

Please sign in to comment.