Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
barhodes committed Apr 25, 2024
1 parent 3cb5732 commit e81827f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public PrefetchUrlList getPrefetchUrlList(PlanDefinition thePlanDefinition) {
PrefetchUrlList prefetchList = new PrefetchUrlList();
if (thePlanDefinition == null) return null;
Library library = resolvePrimaryLibrary(thePlanDefinition);
// TODO: resolve data requirements
if (!library.hasDataRequirement()) return null;
for (DataRequirement dataRequirement : library.getDataRequirement()) {
List<String> requestUrls = createRequestUrl(dataRequirement);
Expand All @@ -58,6 +57,7 @@ public PrefetchUrlList getPrefetchUrlList(PlanDefinition thePlanDefinition) {
return prefetchList;
}

@SuppressWarnings("ReassignedVariable")
protected Library resolvePrimaryLibrary(PlanDefinition thePlanDefinition) {
Library library = null;
Extension dataReqExt = thePlanDefinition.getExtensionByUrl(CRMI_EFFECTIVE_DATA_REQUIREMENTS);
Expand All @@ -82,7 +82,7 @@ protected List<String> createRequestUrl(DataRequirement theDataRequirement) {
List<Extension> fhirQueryExtList = theDataRequirement.getExtension().stream()
.filter(e -> e.getUrl().equals(CQF_FHIR_QUERY_PATTERN) && e.hasValue())
.collect(Collectors.toList());
if (fhirQueryExtList != null && !fhirQueryExtList.isEmpty()) {
if (!fhirQueryExtList.isEmpty()) {
for (Extension fhirQueryExt : fhirQueryExtList) {
urlList.add(fhirQueryExt.getValueAsPrimitive().getValueAsString());
}
Expand All @@ -105,12 +105,12 @@ protected List<String> createRequestUrl(DataRequirement theDataRequirement) {
return urlList;
}

@SuppressWarnings("ReassignedVariable")
protected void resolveCodeFilter(DataRequirement theDataRequirement, List<String> theUrlList, String theBaseQuery) {
for (DataRequirement.DataRequirementCodeFilterComponent codeFilterComponent :
theDataRequirement.getCodeFilter()) {
if (!codeFilterComponent.hasPath()) continue;
String path = mapCodePathToSearchParam(theDataRequirement.getType(), codeFilterComponent.getPath());

StringType codeFilterComponentString = null;
if (codeFilterComponent.hasValueSetStringType()) {
codeFilterComponentString = codeFilterComponent.getValueSetStringType();
Expand All @@ -126,7 +126,6 @@ protected void resolveCodeFilter(DataRequirement theDataRequirement, List<String
} else {
theUrlList.add("," + code);
}

isFirstCodingInFilter = false;
}
}
Expand All @@ -139,23 +138,22 @@ protected void resolveCodeFilter(DataRequirement theDataRequirement, List<String
}
}

@SuppressWarnings("ReassignedVariable")
protected List<String> resolveValueCodingCodes(List<Coding> theValueCodings) {
List<String> result = new ArrayList<>();

StringBuilder codes = new StringBuilder();
for (Coding coding : theValueCodings) {
if (coding.hasCode()) {
String system = coding.getSystem();
String code = coding.getCode();

codes = getCodesStringBuilder(result, codes, system, code);
}
}

result.add(codes.toString());
return result;
}

@SuppressWarnings("ReassignedVariable")
protected List<String> resolveValueSetCodes(StringType theValueSetId) {
ValueSet valueSet = (ValueSet) SearchHelper.searchRepositoryByCanonical(myRepository, theValueSetId);
List<String> result = new ArrayList<>();
Expand Down Expand Up @@ -187,17 +185,17 @@ protected List<String> resolveValueSetCodes(StringType theValueSetId) {
@SuppressWarnings("ReassignedVariable")
protected StringBuilder getCodesStringBuilder(
List<String> theStrings, StringBuilder theCodes, String theSystem, String theCode) {
StringBuilder codes = theCodes;
String codeToken = theSystem + "|" + theCode;
int postAppendLength = theCodes.length() + codeToken.length();

if (theCodes.length() > 0 && postAppendLength < myMaxUriLength) {
theCodes.append(",");
int postAppendLength = codes.length() + codeToken.length();
if (codes.length() > 0 && postAppendLength < myMaxUriLength) {
codes.append(",");
} else if (postAppendLength > myMaxUriLength) {
theStrings.add(theCodes.toString());
theCodes = new StringBuilder();
theStrings.add(codes.toString());
codes = new StringBuilder();
}
theCodes.append(codeToken);
return theCodes;
codes.append(codeToken);
return codes;
}

protected String mapCodePathToSearchParam(String theDataType, String thePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public PrefetchUrlList getPrefetchUrlList(PlanDefinition thePlanDefinition) {
return prefetchList;
}

@SuppressWarnings("ReassignedVariable")
protected Library resolvePrimaryLibrary(PlanDefinition thePlanDefinition) {
Library library = null;
Extension dataReqExt = thePlanDefinition.getExtensionByUrl(CRMI_EFFECTIVE_DATA_REQUIREMENTS);
Expand Down Expand Up @@ -121,7 +122,6 @@ protected void resolveCodeFilter(DataRequirement theDataRequirement, List<String
} else {
theUrlList.add("," + code);
}

isFirstCodingInFilter = false;
}
}
Expand All @@ -131,17 +131,14 @@ protected void resolveCodeFilter(DataRequirement theDataRequirement, List<String
@SuppressWarnings("ReassignedVariable")
protected List<String> resolveValueCodingCodes(List<Coding> theValueCodings) {
List<String> result = new ArrayList<>();

StringBuilder codes = new StringBuilder();
for (Coding coding : theValueCodings) {
if (coding.hasCode()) {
String system = coding.getSystem();
String code = coding.getCode();

codes = getCodesStringBuilder(result, codes, system, code);
}
}

result.add(codes.toString());
return result;
}
Expand All @@ -156,7 +153,6 @@ protected List<String> resolveValueSetCodes(CanonicalType theValueSetId) {
valueSet.getExpansion().getContains()) {
String system = contains.getSystem();
String code = contains.getCode();

codes = getCodesStringBuilder(result, codes, system, code);
}
} else if (valueSet.hasCompose() && valueSet.getCompose().hasInclude()) {
Expand All @@ -165,7 +161,6 @@ protected List<String> resolveValueSetCodes(CanonicalType theValueSetId) {
if (concepts.hasConcept()) {
for (ValueSet.ConceptReferenceComponent concept : concepts.getConcept()) {
String code = concept.getCode();

codes = getCodesStringBuilder(result, codes, system, code);
}
}
Expand All @@ -181,7 +176,6 @@ protected StringBuilder getCodesStringBuilder(
StringBuilder codes = theCodes;
String codeToken = theSystem + "|" + theCode;
int postAppendLength = codes.length() + codeToken.length();

if (codes.length() > 0 && postAppendLength < myMaxUriLength) {
codes.append(",");
} else if (postAppendLength > myMaxUriLength) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public PrefetchUrlList getPrefetchUrlList(PlanDefinition thePlanDefinition) {
return prefetchList;
}

@SuppressWarnings("ReassignedVariable")
protected Library resolvePrimaryLibrary(PlanDefinition thePlanDefinition) {
Library library = null;
Extension dataReqExt = thePlanDefinition.getExtensionByUrl(CRMI_EFFECTIVE_DATA_REQUIREMENTS);
Expand All @@ -79,7 +80,7 @@ protected List<String> createRequestUrl(DataRequirement theDataRequirement) {
List<Extension> fhirQueryExtList = theDataRequirement.getExtension().stream()
.filter(e -> e.getUrl().equals(CQF_FHIR_QUERY_PATTERN) && e.hasValue())
.collect(Collectors.toList());
if (fhirQueryExtList != null && !fhirQueryExtList.isEmpty()) {
if (!fhirQueryExtList.isEmpty()) {
for (Extension fhirQueryExt : fhirQueryExtList) {
urlList.add(fhirQueryExt.getValueAsPrimitive().getValueAsString());
}
Expand All @@ -102,6 +103,7 @@ protected List<String> createRequestUrl(DataRequirement theDataRequirement) {
return urlList;
}

@SuppressWarnings("ReassignedVariable")
protected void resolveCodeFilter(DataRequirement theDataRequirement, List<String> theUrlList, String theBaseQuery) {
for (DataRequirement.DataRequirementCodeFilterComponent codeFilterComponent :
theDataRequirement.getCodeFilter()) {
Expand All @@ -121,26 +123,23 @@ protected void resolveCodeFilter(DataRequirement theDataRequirement, List<String
} else {
theUrlList.add("," + code);
}

isFirstCodingInFilter = false;
}
}
}
}

@SuppressWarnings("ReassignedVariable")
protected List<String> resolveValueCodingCodes(List<Coding> theValueCodings) {
List<String> result = new ArrayList<>();

StringBuilder codes = new StringBuilder();
for (Coding coding : theValueCodings) {
if (coding.hasCode()) {
String system = coding.getSystem();
String code = coding.getCode();

codes = getCodesStringBuilder(result, codes, system, code);
}
}

result.add(codes.toString());
return result;
}
Expand Down Expand Up @@ -176,17 +175,17 @@ protected List<String> resolveValueSetCodes(CanonicalType theValueSetId) {
@SuppressWarnings("ReassignedVariable")
protected StringBuilder getCodesStringBuilder(
List<String> theStrings, StringBuilder theCodes, String theSystem, String theCode) {
StringBuilder codes = theCodes;
String codeToken = theSystem + "|" + theCode;
int postAppendLength = theCodes.length() + codeToken.length();

if (theCodes.length() > 0 && postAppendLength < myMaxUriLength) {
theCodes.append(",");
int postAppendLength = codes.length() + codeToken.length();
if (codes.length() > 0 && postAppendLength < myMaxUriLength) {
codes.append(",");
} else if (postAppendLength > myMaxUriLength) {
theStrings.add(theCodes.toString());
theCodes = new StringBuilder();
theStrings.add(codes.toString());
codes = new StringBuilder();
}
theCodes.append(codeToken);
return theCodes;
codes.append(codeToken);
return codes;
}

protected String mapCodePathToSearchParam(String theDataType, String thePath) {
Expand Down

0 comments on commit e81827f

Please sign in to comment.