Skip to content

Commit

Permalink
Tests for Category 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Julia Helena Reuter committed Nov 13, 2023
1 parent 265559d commit 03758ef
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
105 changes: 105 additions & 0 deletions src/tools/lungRads2022/lungRads2022Utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,36 @@ const emptyInput: LungRads2022Input = {
suspicious: [],
}

const solidNoduleInput: LungRads2022Input = {
...emptyInput,
problematicExam: "none",
benignFeatures: "none",
nodule: true,
structure: "solid",
}

const partSolidNoduleInpput: LungRads2022Input = {
...emptyInput,
problematicExam: "none",
benignFeatures: "none",
nodule: true,
structure: "partsolid",
}

const groundGlassNoduleInput: LungRads2022Input = {
...emptyInput,
problematicExam: "none",
benignFeatures: "none",
nodule: true,
structure: "groundglass",
}

const previous3Input: LungRads2022Input = {
...emptyInput,
previous: "3",
timepoint: "follow-up",
}

describe("Calculate average diameter", () => {
it.each([
[2, 1, 1.5],
Expand All @@ -40,6 +70,7 @@ describe("Calculate average diameter", () => {
})
})

/** Category 0 */
describe("Category 0", () => {
it.each<[Partial<LungRads2022Input>]>([
[{ problematicExam: "prior-CT-not-available" }],
Expand All @@ -52,6 +83,7 @@ describe("Category 0", () => {
})
})

/** Category 1 */
describe("Category 1", () => {
it("should give correct result for no lung nodules", () => {
const finalInput: LungRads2022Input = {
Expand All @@ -71,3 +103,76 @@ describe("Category 1", () => {
expect(category).toBe(Category.Category1)
})
})

/** Category 2 */
describe("Category 2", () => {
it.each<[Partial<LungRads2022Input>]>([
[{ featuresSolid: "smooth-margins", longaxis: 10, shortaxis: 9 }],
[{ timepoint: "baseline", featuresSolid: "smooth-margins", longaxis: 10, shortaxis: 9 }],
[
{
timepoint: "follow-up",
featuresSolid: "smooth-margins",
longaxis: 10,
shortaxis: 9,
dynamic: "new",
},
],
])("should give correct result for juxtapleural nodule", (input) => {
const finalInput = { ...solidNoduleInput, ...input }
const category = defineLungRads2022(finalInput)
expect(category).toBe(Category.Category2)
})

it.each<[Partial<LungRads2022Input>]>([
[{ timepoint: "baseline", featuresSolid: "none", longaxis: 6, shortaxis: 5 }],
[{ timepoint: "follow-up", featuresSolid: "none", longaxis: 4, shortaxis: 3, dynamic: "new" }],
])("should give correct result for small solid nodules", (input) => {
const finalInput = { ...solidNoduleInput, ...input }
const category = defineLungRads2022(finalInput)
expect(category).toBe(Category.Category2)
})

it("should give correct result for small part solid nodules", () => {
const finalInput: LungRads2022Input = {
...partSolidNoduleInpput,
timepoint: "baseline",
longaxis: 6,
shortaxis: 5,
}
const category = defineLungRads2022(finalInput)
expect(category).toBe(Category.Category2)
})

it.each<[Partial<LungRads2022Input>]>([
[{ timepoint: "baseline", longaxis: 30, shortaxis: 29 }],
[{ timepoint: "follow-up", longaxis: 30, shortaxis: 29, dynamic: "new" }],
[{ timepoint: "follow-up", longaxis: 30, shortaxis: 29, dynamic: "growing" }],
[{ timepoint: "follow-up", longaxis: 30, shortaxis: 30, dynamic: "slowlyGrowing" }],
[{ timepoint: "follow-up", longaxis: 30, shortaxis: 30, dynamic: "stable" }],
])("should give correct result for GGN nodules", (input) => {
const finalInput = { ...groundGlassNoduleInput, ...input }
const category = defineLungRads2022(finalInput)
expect(category).toBe(Category.Category2)
})

it.each<[Partial<LungRads2022Input>]>([
[{ timepoint: "baseline", featuresSolid: "subsegmental-airway" }],
[{ timepoint: "follow-up", featuresSolid: "subsegmental-airway", dynamic: "new" }],
[{ timepoint: "follow-up", featuresSolid: "subsegmental-airway", dynamic: "stable" }],
])("should give correct result for subsegmental airway nodule", (input) => {
const finalInput = { ...solidNoduleInput, ...input }
const category = defineLungRads2022(finalInput)
expect(category).toBe(Category.Category2)
})

it.each<[Partial<LungRads2022Input>]>([
[{ nodule: true, dynamic: "stable", timeOfDynamicNodule: 4 }],
[{ cyst: true, dynamicMultilocular: "stable", timeOfDynamicCyst: 4 }],
[{ cyst: true, dynamicUnilocular: "stable", timeOfDynamicCyst: 4 }],
])("should give correct result for stable lesion", (input) => {
const finalInput = { ...previous3Input, ...input }
const category = defineLungRads2022(finalInput)
expect(category).toBe(Category.Category2)
})
})
5 changes: 5 additions & 0 deletions src/tools/lungRads2022/lungRads2022Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const defineLungRads2022 = ({
if (benignFeatures === "calcification" || benignFeatures === "fat") {
category = Category.Category1
} else if (
structure === "solid" &&
featuresSolid === "smooth-margins" &&
averageDiameter !== null &&
averageDiameter < 10
Expand Down Expand Up @@ -211,6 +212,9 @@ export const defineLungRads2022 = ({
if (
previous === "3" &&
timepoint === "follow-up" &&
featuresSolid !== "segmental-airway" &&
featuresSolid !== "subsegmental-airway" &&
structure !== "groundglass" &&
(dynamic === "stable" || dynamicUnilocular === "stable" || dynamicMultilocular === "stable")
) {
if (
Expand Down Expand Up @@ -305,4 +309,5 @@ export const giveLungRads2022Recommendation = (
/**
* TODO:
* - S Modifier in Utils
* - 4B lesion proven to be benign
*/

0 comments on commit 03758ef

Please sign in to comment.