diff --git a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/PhenoCube.java b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/PhenoCube.java index bb8c64ea..2a7199ad 100644 --- a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/PhenoCube.java +++ b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/PhenoCube.java @@ -218,14 +218,14 @@ public void setLoadingMap(List> newMap) { } public List> getValuesForKeys(List sortedPatientIds) { - List> values = new ArrayList<>(); + List> values = new ArrayList<>(); //133400068 int x = 0; for(Integer id : sortedPatientIds) { - while(x < sortedByKey.length && sortedByKey[x].key= sortedByKey.length) { return values; } - while(sortedByKey[x].key==id) { + while(sortedByKey[x].key == id) { values.add(sortedByKey[x]); x++; } diff --git a/data/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/PhenoCubeTest.java b/data/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/PhenoCubeTest.java new file mode 100644 index 00000000..d0772533 --- /dev/null +++ b/data/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/PhenoCubeTest.java @@ -0,0 +1,68 @@ +package edu.harvard.hms.dbmi.avillach.hpds.data.phenotype; + +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.*; + +public class PhenoCubeTest { + + @Test + public void killme() { + KeyAndValue[] kill = {new KeyAndValue<>(20998, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(67844, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(67844, "A01.09 Typhoid fever with other complications"), + new KeyAndValue<>(564280, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(1921279, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(1921279, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(2387865, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(2809924, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(2809924, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3103926, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3103926, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3109197, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3153064, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3664490, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3693389, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3693389, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3827355, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3970757, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(3970757, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(4894925, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(4894925, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(4894925, "A01.09 Typhoid fever with other complications"), + new KeyAndValue<>(32048174, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(32346130, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(35425794, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(37174253, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(37174253, "A01.09 Typhoid fever with other complications"), + new KeyAndValue<>(39409294, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(39409294, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(48241745, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(56769960, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(57516253, "A01.09 Typhoid fever with other complications"), + new KeyAndValue<>(57516253, "A01.09 Typhoid fever with other complications"), + new KeyAndValue<>(61049165, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(62229338, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(73817878, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(79715800, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(79851615, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(79851615, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(83263840, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(92167252, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(96724703, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(115214296, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(115214296, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(116448323, "A01.01 Typhoid meningitis"), + new KeyAndValue<>(116827996, "A01.00 Typhoid fever, unspecified"), + new KeyAndValue<>(116827996, "A01.09 Typhoid fever with other complications"), + new KeyAndValue<>(125506124, "A01.09 Typhoid fever with other complications"), + new KeyAndValue<>(133400068, "A01.00 Typhoid fever, unspecified")}; + + PhenoCube subject = new PhenoCube<>("bob", KeyAndValue.class); + subject.setSortedByKey(kill); + + subject.getValuesForKeys(List.of(133400068)); + } +} \ No newline at end of file