Skip to content

Commit

Permalink
MAT-5567 fetch source data criteria for measure cql
Browse files Browse the repository at this point in the history
  • Loading branch information
adongare committed May 25, 2023
1 parent df56374 commit d41eb2e
Show file tree
Hide file tree
Showing 39 changed files with 3,239 additions and 2,737 deletions.
36 changes: 18 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,23 @@
<version>2.3.3</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>

<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.32</version>
</dependency>

<dependency>
<groupId>gov.cms.madie</groupId>
<artifactId>madie-java-models</artifactId>
<version>0.4.5-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
Expand All @@ -229,28 +246,11 @@
</exclusions>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.32</version>
</dependency>

<dependency>
<groupId>gov.cms.madie</groupId>
<artifactId>madie-java-models</artifactId>
<version>0.4.5-SNAPSHOT</version>
</dependency>
</dependencies>

<!-- Required to fetch artifacts from repositories other than maven central -->
Expand Down Expand Up @@ -299,7 +299,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,141 +5,156 @@

@NoArgsConstructor
public class HumanReadableCodeModel implements HumanReadableTerminologyModel {
private String name;
private String oid;
private String codesystemName;
private String codesystemVersion;
private boolean isCodesystemVersionIncluded;
private String datatype;
private String terminologyDisplay;
private String dataCriteriaDisplay;

public HumanReadableCodeModel(String name, String oid, String codesystemName, boolean isCodeSystemVersionIncluded, String codesystemVersion, String datatype) {
this.name = name;
this.oid = oid;
this.codesystemName = codesystemName;
this.codesystemVersion = codesystemVersion;
this.isCodesystemVersionIncluded = isCodeSystemVersionIncluded;
this.datatype = datatype;
createDataCriteriaDisplay();
createTerminologyDisplay();
}

@Override
public String getName() {
return name;
}

@Override
public void setName(String name) {
this.name = name;
}

public String getOid() {
return oid;
}

public void setOid(String oid) {
this.oid = oid;
}

public String getCodesystemName() {
return codesystemName;
}

public void setCodesystemName(String taxonomy) {
this.codesystemName = taxonomy;
}

public boolean getIsCodesystemVersionIncluded() {
return isCodesystemVersionIncluded;
}

public void setIsCodesystemVersionIncluded(boolean isCodeSystemIncluded) {
this.isCodesystemVersionIncluded = isCodeSystemIncluded;
}

public String getTerminologyDisplay() {
createTerminologyDisplay();
return this.terminologyDisplay;
}

private void createTerminologyDisplay() {
String codeSystemVersion = "";
if (isCodesystemVersionIncluded) {
codeSystemVersion = " version " + codesystemVersion;
}

String codeOutput = "code \"" + name + "\" (\"" + codesystemName + codeSystemVersion + " Code (" + oid
+ ")\")";
this.terminologyDisplay = codeOutput;
}

@Override
public void setTerminologyDisplay(String display) {
this.terminologyDisplay = display;
}

public String getCodesystemVersion() {
return codesystemVersion;
}

public void setCodesystemVersion(String codesystemVersion) {
this.codesystemVersion = codesystemVersion;
}

public String getDatatype() {
return datatype;
}

public void setDatatype(String datatype) {
this.datatype = datatype;
}

private void createDataCriteriaDisplay() {
if("attribute".equals(datatype)){
datatype = "Attribute";
}

String output = "";
if(isCodesystemVersionIncluded) {
output = String.format("\"%s: %s\" using \"%s (%s version %s Code %s)\"", datatype, name, name, codesystemName, codesystemVersion, oid);
} else {
output = String.format("\"%s: %s\" using \"%s (%s Code %s)\"", datatype, name, name, codesystemName, oid);
}

this.dataCriteriaDisplay = output;
}

@Override
public String getDataCriteriaDisplay() {
createDataCriteriaDisplay();
return dataCriteriaDisplay;
}

@Override
public void setDataCriteriaDisplay(String dataCriteriaDisplay) {
this.dataCriteriaDisplay = dataCriteriaDisplay;
}

@Override
public int hashCode() {
return Objects.hash(name, oid, codesystemName, codesystemVersion, datatype);
}

@Override
public boolean equals(Object obj) {
HumanReadableCodeModel model = (HumanReadableCodeModel) obj;
return name.equals(model.name) && oid.equals(model.oid) && codesystemName.equals(model.codesystemName) && codesystemVersion.equals(model.codesystemVersion) && isDatatypeEqual(datatype, model.datatype);
}

private boolean isDatatypeEqual(String d1, String d2) {
// if datatype 1 is not null, then check the equality to datatype 2.
// if datatype 1 is null, then check to see if datatype 2 is null.
if(d1 != null) {
return d1.equals(d2);
} else {
return d2 == null;
}
}
private String name;
private String oid;
private String codesystemName;
private String codesystemVersion;
private boolean isCodesystemVersionIncluded;
private String datatype;
private String terminologyDisplay;
private String dataCriteriaDisplay;

public HumanReadableCodeModel(
String name,
String oid,
String codesystemName,
boolean isCodeSystemVersionIncluded,
String codesystemVersion,
String datatype) {
this.name = name;
this.oid = oid;
this.codesystemName = codesystemName;
this.codesystemVersion = codesystemVersion;
this.isCodesystemVersionIncluded = isCodeSystemVersionIncluded;
this.datatype = datatype;
createDataCriteriaDisplay();
createTerminologyDisplay();
}

@Override
public String getName() {
return name;
}

@Override
public void setName(String name) {
this.name = name;
}

public String getOid() {
return oid;
}

public void setOid(String oid) {
this.oid = oid;
}

public String getCodesystemName() {
return codesystemName;
}

public void setCodesystemName(String taxonomy) {
this.codesystemName = taxonomy;
}

public boolean getIsCodesystemVersionIncluded() {
return isCodesystemVersionIncluded;
}

public void setIsCodesystemVersionIncluded(boolean isCodeSystemIncluded) {
this.isCodesystemVersionIncluded = isCodeSystemIncluded;
}

public String getTerminologyDisplay() {
createTerminologyDisplay();
return this.terminologyDisplay;
}

private void createTerminologyDisplay() {
String codeSystemVersion = "";
if (isCodesystemVersionIncluded) {
codeSystemVersion = " version " + codesystemVersion;
}

String codeOutput =
"code \"" + name + "\" (\"" + codesystemName + codeSystemVersion + " Code (" + oid + ")\")";
this.terminologyDisplay = codeOutput;
}

@Override
public void setTerminologyDisplay(String display) {
this.terminologyDisplay = display;
}

public String getCodesystemVersion() {
return codesystemVersion;
}

public void setCodesystemVersion(String codesystemVersion) {
this.codesystemVersion = codesystemVersion;
}

public String getDatatype() {
return datatype;
}

public void setDatatype(String datatype) {
this.datatype = datatype;
}

private void createDataCriteriaDisplay() {
if ("attribute".equals(datatype)) {
datatype = "Attribute";
}

String output = "";
if (isCodesystemVersionIncluded) {
output =
String.format(
"\"%s: %s\" using \"%s (%s version %s Code %s)\"",
datatype, name, name, codesystemName, codesystemVersion, oid);
} else {
output =
String.format(
"\"%s: %s\" using \"%s (%s Code %s)\"", datatype, name, name, codesystemName, oid);
}

this.dataCriteriaDisplay = output;
}

@Override
public String getDataCriteriaDisplay() {
createDataCriteriaDisplay();
return dataCriteriaDisplay;
}

@Override
public void setDataCriteriaDisplay(String dataCriteriaDisplay) {
this.dataCriteriaDisplay = dataCriteriaDisplay;
}

@Override
public int hashCode() {
return Objects.hash(name, oid, codesystemName, codesystemVersion, datatype);
}

@Override
public boolean equals(Object obj) {
HumanReadableCodeModel model = (HumanReadableCodeModel) obj;
return name.equals(model.name)
&& oid.equals(model.oid)
&& codesystemName.equals(model.codesystemName)
&& codesystemVersion.equals(model.codesystemVersion)
&& isDatatypeEqual(datatype, model.datatype);
}

private boolean isDatatypeEqual(String d1, String d2) {
// if datatype 1 is not null, then check the equality to datatype 2.
// if datatype 1 is null, then check to see if datatype 2 is null.
if (d1 != null) {
return d1.equals(d2);
} else {
return d2 == null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ private String idFromName(String name) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if (c >= 48 && c <= 57 || //0-9
c >= 65 && c <= 90 || //A-Z
c >= 97 && c <= 122 || //a-z
c == 95) { //_
if (c >= 48 && c <= 57
|| // 0-9
c >= 65 && c <= 90
|| // A-Z
c >= 97 && c <= 122
|| // a-z
c == 95) { // _
result.append(c);
} else {
result.append('_');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ public class HumanReadablePopulationCriteriaModel {
private String id;
private int sequence;
private List<HumanReadablePopulationModel> populations;
@Builder.Default
private String scoreUnit = "";
@Builder.Default private String scoreUnit = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ public class HumanReadablePopulationModel {
private boolean inGroup;
private String associatedPopulationName;
private String display;
private String type; }
private String type;
}
Loading

0 comments on commit d41eb2e

Please sign in to comment.