icdContentModel);
if (definitions != null) {
for (Iterator itdef = definitions.iterator(); itdef
.hasNext();) {
RDFResource defTerm = (RDFResource) itdef.next();
String defText = this.getDefinitionTermText(defTerm,
icdContentModel);
String defRubricID = this.getTermRubricID(defTerm,
icdContentModel);
if (defText != null) {
sb.append(this.getClaMLDefinition(defRubricID, defText));
}
}
}
// Inclusion
Collection colInclusions = this.getInclusionTerms(icdCategory,
icdContentModel);
Collection colSortedInclusions = new ArrayList();
Map mapSortedInclusions = new HashMap();
if (colInclusions != null) {
for (Iterator it3 = colInclusions.iterator(); it3.hasNext();) {
RDFResource inclusion = (RDFResource) it3.next();
String inclusionLabel = this.getInclusionTermText(
inclusion, icdContentModel);
String inclusionId = this.getTermRubricID(inclusion,
icdContentModel);
String inclusionLabelId = inclusionLabel + "|"
+ inclusionId;
colSortedInclusions.add(inclusionLabelId);
mapSortedInclusions.put(inclusionLabelId, inclusion);
}
// alphabetically sort the rubrics
Object[] arraySortedInclusions = colSortedInclusions.toArray();
List listSortedInclusions = Arrays.asList(arraySortedInclusions);
Collections.sort(listSortedInclusions,String.CASE_INSENSITIVE_ORDER);
for (ListIterator li0 = listSortedInclusions.listIterator(); li0.hasNext();) {
String sortedInclusionLabelId = (String) li0.next();
String[] labelId = sortedInclusionLabelId.split("\\|");
RDFResource sortedInclusion = (RDFResource) mapSortedInclusions
.get(sortedInclusionLabelId);
Collection<RDFResource> clamlRefCodes = this.getTermClaMLReferences(sortedInclusion, icdContentModel);
StringBuffer refCodeInclusion = new StringBuffer();;
try {
if (clamlRefCodes != null) {
for (RDFResource clamlRefCode : clamlRefCodes) {
String thisCode = (String) clamlRefCode
.getPropertyValue(icdContentModel
.getTextProperty());
if (thisCode.indexOf("-") >= 0) {
thisCode = this
.getCodeFromLabel(thisCode);
}
String thisGeneratedCode = this
.getGeneratedCodeForICDCategoryCode(
thisCode, mapGeneratedCodes);
if (thisGeneratedCode == null) {
thisGeneratedCode = thisCode;
}
refCodeInclusion.append(this.getClaMLReferenceCode(thisGeneratedCode));
//sb.append(this.getClaMLInclusionLabel(labelId[1],labelId[0], thisGeneratedCode));
}
}
} catch (Exception e) {
//e.printStackTrace();
continue;
}
if(refCodeInclusion.toString().length() < 1){
sb.append(this.getClaMLInclusionLabel(labelId[1], labelId[0]));
}else{
sb.append(this.getClaMLInclusionLabel(labelId[1],
labelId[0], refCodeInclusion.toString()));
}
}
}
// exclusion terms
Collection colExclusions = this.getExclusionTerms(icdCategory,
icdContentModel);
Collection<String> colSortedExclusions = new ArrayList();
Map<String, RDFResource> mapSortedExclusions = new HashMap();
if (colExclusions != null) {
for (Iterator it4 = colExclusions.iterator(); it4.hasNext();) {
RDFResource exclusion = (RDFResource) it4.next();
String exclusionLabel = this.getExclusionTermText(
exclusion, icdContentModel);
String exclusionId = this.getTermRubricID(exclusion,
icdContentModel);
String exclusionLabelId = exclusionLabel + "|"
+ exclusionId;
colSortedExclusions.add(exclusionLabelId);
mapSortedExclusions.put(exclusionLabelId, exclusion);
}
// alphabetically sort the rubrics
Object[] arraySortedExclusions = colSortedExclusions
.toArray();
List listSortedExclusions = Arrays
.asList(arraySortedExclusions);
Collections.sort(listSortedExclusions,
String.CASE_INSENSITIVE_ORDER);
for (ListIterator li1 = listSortedExclusions.listIterator(); li1
.hasNext();) {
// for(int jj = 0; jj < arraySortedExclusions.length;
// jj++){
String sortedExclusionLabelId = (String) li1.next();
String[] labelId = sortedExclusionLabelId.split("\\|");
RDFResource sortedExclusion = (RDFResource) mapSortedExclusions
.get(sortedExclusionLabelId);
Collection<RDFResource> clamlRefCodes = this
.getTermClaMLReferences(sortedExclusion,
icdContentModel);