Skip to content

Commit

Permalink
Merge pull request #496 from CBIIT/CRDCDH-1497
Browse files Browse the repository at this point in the history
  • Loading branch information
amattu2 authored Oct 18, 2024
2 parents 658acc3 + 3e93f79 commit 8b1df14
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions src/utils/dataModelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ export const traverseAndReplace = (
apiError: boolean,
parentKey = ""
) => {
const getCDEPublicID = (cdeCode, cdeVersion) =>
`https://cadsr.cancer.gov/onedata/dmdirect/NIH/NCI/CO/CDEDD?filter=CDEDD.ITEM_ID=${cdeCode}%20and%20ver_nr=${cdeVersion}`;

if (typeof node !== "object" || node === null) return;

if (node.properties) {
Expand All @@ -167,22 +170,29 @@ export const traverseAndReplace = (
const fullKey = `${parentKey}.${key}`.replace(/^\./, "");
const prefixMatch = mapKeyPrefixes.get(fullKey);
const noValuesMatch = mapKeyPrefixesNoValues.get(fullKey);
const property = node.properties[key];
const fallbackMessage = [
"Permissible values are currently not available. Please contact the Data Hub HelpDesk at [email protected]",
];

if (prefixMatch) {
const resultMapEntry = resultMap.get(prefixMatch);

if (resultMapEntry?.PermissibleValues?.length && node.properties[key].enum) {
node.properties[key].enum = resultMapEntry.PermissibleValues;
} else if (resultMapEntry?.PermissibleValues?.length === 0 && node.properties[key].enum) {
node.properties[key].enum = fallbackMessage;
const { CDECode, CDEFullName, CDEVersion, PermissibleValues } =
resultMap.get(prefixMatch);

if (PermissibleValues?.length && property.enum) {
property.enum = PermissibleValues;
property.CDEFullName = CDEFullName;
property.CDECode = CDECode;
property.CDEPublicID = getCDEPublicID(CDECode, CDEVersion);
property.CDEVersion = CDEVersion;
property.CDEOrigin = "caDSR";
} else if (PermissibleValues?.length === 0 && property.enum) {
property.enum = fallbackMessage;
}
}

if (noValuesMatch && apiError && node.properties[key].enum) {
node.properties[key].enum = fallbackMessage;
if (noValuesMatch && apiError && property.enum) {
property.enum = fallbackMessage;
}
}
}
Expand Down

0 comments on commit 8b1df14

Please sign in to comment.