/** * Fills in an extended phenotype field using the base phenotype field. * * @param baseFieldName the name of the field holding the basic list of phenotypes * @param extendedFieldName the name of the target field that will hold the extended list of phenotypes * @param patientRecordObj the object to update */ private void updateField(String baseFieldName, String extendedFieldName, BaseObject patientRecordObj) { @SuppressWarnings("unchecked") List<String> phenotypes = patientRecordObj.getListValue(baseFieldName); Set<String> extendedPhenotypes = new TreeSet<String>(); Set<String> sortedPhenotypes = new TreeSet<String>(); for (String phenotype : phenotypes) { sortedPhenotypes.add(phenotype); OntologyTerm phenotypeTerm = this.ontologyManager.resolveTerm(phenotype); if (phenotypeTerm != null) { for (OntologyTerm term : phenotypeTerm.getAncestorsAndSelf()) { extendedPhenotypes.add(term.getId()); } } else { extendedPhenotypes.add(phenotype); } } patientRecordObj.setDBStringListValue(extendedFieldName, new ArrayList<String>(extendedPhenotypes)); patientRecordObj.setDBStringListValue(baseFieldName, new ArrayList<String>(sortedPhenotypes)); } }