Skip to content

Commit

Permalink
Fixed inserting of structured data from TDP.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Lee committed Oct 16, 2018
1 parent df1e322 commit 5ce05f9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
23 changes: 11 additions & 12 deletions src/summary/TabularListVisualizer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,34 +222,33 @@ export default class TabularListVisualizer extends Component {
});
}

renderedStructuredData(item, element, elementId, elementText, subsectionName, subsectionActions, arrayIndex, when) {
renderedStructuredData(firstCellValue, col, elementId, elementText, subsectionName, subsectionActions, arrayIndex, when) {
return (
<div>
<span
data-test-summary-item={item}
data-test-summary-item={firstCellValue}
onClick={(event) => this.openInsertionMenu(event, elementId)}
>
{elementText}
</span>
{this.renderedMenu(item, element.value, elementId, elementText, subsectionName, subsectionActions, arrayIndex)}
{this.renderedMenu(firstCellValue, col, elementId, elementText, subsectionName, subsectionActions, arrayIndex)}
</div>
);
}

// Render a given list item as a row in a table
renderedListItem(item, subsectionindex, itemIndex, rowClass, subsectionName, subsectionActions, formatFunction) {
renderedListItem(row, subsectionindex, itemIndex, rowClass, subsectionName, subsectionActions, formatFunction) {
// Array of all columns for row (item)
const renderedColumns = [];

const numColumns = item.length;
const numColumns = row.length;
const colSize = (100 / numColumns) + "%";

if (subsectionActions.length > 0 || this.props.actions.length > 0) {
rowClass += " has-action-menu";
}

item.forEach((col, colIndex) => {
renderedColumns.push(this.renderColumn(item, subsectionindex, itemIndex, subsectionName, subsectionActions, formatFunction, col, colIndex, colSize));
row.forEach((col, colIndex) => {
renderedColumns.push(this.renderColumn(row, subsectionindex, itemIndex, subsectionName, subsectionActions, formatFunction, col, colIndex, colSize));
});

return (
Expand All @@ -262,15 +261,15 @@ export default class TabularListVisualizer extends Component {
);
}

renderColumn = (item, subsectionindex, itemIndex, subsectionName, subsectionActions, formatFunction, col, colIndex, colSize) => {
renderColumn = (row, subsectionindex, itemIndex, subsectionName, subsectionActions, formatFunction, col, colIndex, colSize) => {
const columnId = `${subsectionindex}-${itemIndex}-item-${colIndex}`
const isInsertable = Lang.isUndefined(col.isInsertable) ? true : col.isInsertable;
let columnItem = null;
const when = (col.value ? (col.value.when || null) : null);
const isUnsigned = (col.value) ? col.value.isUnsigned || false : false;
let colText = Lang.isObject(col.value) ? col.value.value : col.value;
const longElementText = colText;

if (!Lang.isNull(colText) && colText.length > 100) colText = colText.substring(0, 100) + "...";

let itemClass = isUnsigned ? 'list-unsigned' : 'list-captured';
Expand All @@ -288,7 +287,7 @@ export default class TabularListVisualizer extends Component {
if (Lang.isUndefined(colText) || Lang.isNull(colText) || (typeof(colText) === 'string' && colText.length === 0)) {
columnItem = (
<TableCell
data-test-summary-item={item[0]}
data-test-summary-item={row[0]}
key={columnId}
>
<span className={"list-missing"}>
Expand All @@ -303,7 +302,7 @@ export default class TabularListVisualizer extends Component {
key={columnId}
>
<span className={itemClass}>
{this.renderedStructuredData(item[0].value, col, columnId, colText, subsectionName, subsectionActions, colIndex, when)}
{this.renderedStructuredData(row[0].value, col, columnId, colText, subsectionName, subsectionActions, colIndex, when)}
</span>
<span>
{whenRendering}
Expand Down
2 changes: 1 addition & 1 deletion src/summary/VisualizerManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class VisualizerManager {
list = items.map((item, i) => {
const itemValue = (Lang.isNull(item.value)) ? null : (Lang.isFunction(item.value) ? item.value(patient, condition, this.user) : item.value);
return [ { value: item.name, isInsertable: false},
{ value: itemValue || null, shortcut: item.shortcut || null}]
{ value: itemValue || null}]
});

// need to eliminate when value is an array as came from value of a name/value pair. In that case the value array
Expand Down
2 changes: 2 additions & 0 deletions src/summary/VisualizerMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export default class VisualizerMenu extends Component {
isUnsigned: a.value[1],
source: a.value[2],
shortcut: a.shortcut };
} else if(Lang.isObject(a.value)) {
return a.value;
} else {
return a;
}
Expand Down
4 changes: 2 additions & 2 deletions src/summary/metadata/BreastCancerMetadata.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ export default class BreastCancerMetadata extends MetadataSection {
value: (patient, currentConditionEntry) => {
return { value: currentConditionEntry.type,
isUnsigned: patient.isUnsigned(currentConditionEntry),
source: this.determineSource(patient, currentConditionEntry)
source: this.determineSource(patient, currentConditionEntry),
shortcut: "@condition"
};
},
shortcut: "@condition"
},
{
name: "Laterality",
Expand Down
4 changes: 2 additions & 2 deletions src/summary/metadata/SarcomaSummarySection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ export default class SarcomaSummarySection extends MetadataSection {
value: (patient, currentConditionEntry) => {
return { value: currentConditionEntry.type,
isUnsigned: patient.isUnsigned(currentConditionEntry),
source: this.determineSource(patient, currentConditionEntry)
source: this.determineSource(patient, currentConditionEntry),
shortcut: "@condition"
};
},
shortcut: "@condition"
},
{
name: "Location",
Expand Down

0 comments on commit 5ce05f9

Please sign in to comment.