Skip to content

Commit

Permalink
chore(release): v5.0.4
Browse files Browse the repository at this point in the history
### 🧯 Bugs

* fix readme title ([182f269](182f269))
  • Loading branch information
dotbase-bot authored Dec 21, 2023
2 parents 9db07ff + 7e84be1 commit 438b324
Show file tree
Hide file tree
Showing 9 changed files with 1,904 additions and 6,787 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ API to search the german version of the 10th revision of the International Stati
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/dot-base/icd-10-api)](https://github.com/dot-base/icd-10-api/releases)


## Quick Nav
## Contents
1. [Production Deployment](#Production-Deployment)
1. [Configuration](#Configuration)
1. [Considerations](#Considerations)
Expand Down
8,584 changes: 1,851 additions & 6,733 deletions package-lock.json

Large diffs are not rendered by default.

37 changes: 18 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,39 @@
"production": "node -r tsconfig-paths/register build/server.js"
},
"dependencies": {
"@ahryman40k/ts-fhir-types": "4.0.34",
"body-parser": "^1.19.0",
"@ahryman40k/ts-fhir-types": "4.0.39",
"body-parser": "^1.20.2",
"express": "^4.18.2",
"fuse.js": "^6.4.0",
"tsconfig-paths": "^3.14.1",
"tslib": "^2.4.1"
"fuse.js": "^7.0.0",
"tsconfig-paths": "^4.2.0",
"tslib": "^2.6.2"
},
"devDependencies": {
"@types/express": "^4.17.14",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.4.1",
"jest": "^27.5.1",
"@types/express": "^4.17.21",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.7.0",
"jest-decorator": "^1.0.1",
"nodemon": "^2.0.20",
"prettier": "^2.7.1",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
"nodemon": "^3.0.2",
"prettier": "^3.1.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"eslintConfig": {
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
"ecmaVersion": 2020
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
"prettier"
],
"env": {
"es6": true,
Expand Down
10 changes: 5 additions & 5 deletions src/controller/icd10.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Fuse from "fuse.js";
import { FuseResult } from "fuse.js";
import { ICodeSystem_Concept } from "@ahryman40k/ts-fhir-types/lib/R4";
import CodeFilter from "@/services/codeFilter";
import TextFilter from "@/services/textFilter";
Expand All @@ -8,7 +8,7 @@ export class ICD10Controller {
private static icd10Regex = new RegExp("[A-TV-Z][0-9][0-9].?[0-9A-TV-Z]{0,4}", "i");
private static stripRegex = new RegExp("[ -]+");

public static getFiltered(searchstring: string): Fuse.FuseResult<ICodeSystem_Concept>[] {
public static getFiltered(searchstring: string): FuseResult<ICodeSystem_Concept>[] {
const searchTerms: string[] = ICD10Controller.splitTerms(searchstring);
const icd10Codes: string[] = ICD10Controller.filterCodes(searchTerms);

Expand All @@ -24,7 +24,7 @@ export class ICD10Controller {
if (searchTerms.length > Number(process.env.MAX_SEARCH_WORDS))
throw new HTTPError(
`Search query exceeded max. amount of ${process.env.MAX_SEARCH_WORDS} allowed terms.`,
400
400,
);

const searchResult = TextFilter.initSearch(searchTerms);
Expand Down Expand Up @@ -60,8 +60,8 @@ export class ICD10Controller {
* Fixes https://github.com/dot-base/icd-10-api/issues/24
*/
private static removeExtensions(
res: Fuse.FuseResult<ICodeSystem_Concept>[]
): Fuse.FuseResult<ICodeSystem_Concept>[] {
res: FuseResult<ICodeSystem_Concept>[],
): FuseResult<ICodeSystem_Concept>[] {
res.forEach((r) => {
r.item.extension = undefined;
r.item.modifierExtension = undefined;
Expand Down
12 changes: 6 additions & 6 deletions src/model/icd10CodeSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ class ICD10gm {
}

processedCodesystem.concept = processedCodesystem.concept.filter((elem) =>
elem.property ? ICD10gm.isTypeICDCode(elem.property) : false
elem.property ? ICD10gm.isTypeICDCode(elem.property) : false,
);

const incompleteConcepts = processedCodesystem.concept.filter(
(concept) => !ICD10gm.isComplete(concept)
(concept) => !ICD10gm.isComplete(concept),
);
if (incompleteConcepts.length > 0) {
const incompleteConceptsList = incompleteConcepts
.map((concept) => `{code: ${concept.code}, display: ${concept.display}}`)
.join(", ");
logger.warn(
`WARNING: The ICD10 codesystem contains ${incompleteConcepts.length} incomplete concept(s) missing either code or display. The affected concepts are: ${incompleteConceptsList}.`
`WARNING: The ICD10 codesystem contains ${incompleteConcepts.length} incomplete concept(s) missing either code or display. The affected concepts are: ${incompleteConceptsList}.`,
);
}

processedCodesystem.concept = processedCodesystem.concept.filter((concept) =>
ICD10gm.isComplete(concept)
ICD10gm.isComplete(concept),
);

processedCodesystem.concept = ICD10gm.trimAndCopySearchFields(processedCodesystem.concept);
Expand All @@ -70,7 +70,7 @@ class ICD10gm {

private static isTypeICDCode(property: R4.ICodeSystem_Property1[]) {
return property.some((prop) =>
prop.valueCode ? prop.valueCode === "category" && prop.code === "kind" : false
prop.valueCode ? prop.valueCode === "category" && prop.code === "kind" : false,
);
}

Expand All @@ -79,7 +79,7 @@ class ICD10gm {
}

private static trimAndCopySearchFields(
concept: R4.ICodeSystem_Concept[]
concept: R4.ICodeSystem_Concept[],
): R4.ICodeSystem_Concept[] {
const trimRegex = new RegExp("[^0-9A-ZÄÖÜ]", "gi");

Expand Down
10 changes: 5 additions & 5 deletions src/services/codeFilter.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import Fuse from "fuse.js";
import { ICodeSystem_Concept } from "@ahryman40k/ts-fhir-types/lib/R4";
import Filter from "@/services/filter";
import { QueryOptions, MatchType, LogicalOperator } from "@/types/queryOptions";
import FuseSearch from "@/services/fuseSearch";
import { Expression, FuseOptionKeyObject, FuseResult } from "fuse.js";

export default class CodeFilter extends Filter {
protected static keys: Fuse.FuseOptionKeyObject[] = [{ name: "code", weight: 1 }];
protected static keys: FuseOptionKeyObject<ICodeSystem_Concept>[] = [{ name: "code", weight: 1 }];

protected static queryOptions: QueryOptions = {
matchType: MatchType.exactMatch,
logicalOperator: LogicalOperator.OR,
};

public static initSearch(icdCodes: string[]): Fuse.FuseResult<ICodeSystem_Concept>[] {
public static initSearch(icdCodes: string[]): FuseResult<ICodeSystem_Concept>[] {
const queryStr: string = FuseSearch.getQueryString(icdCodes, CodeFilter.queryOptions);
const query: Fuse.Expression[] = CodeFilter.getQuery(queryStr);
const query: Expression[] = CodeFilter.getQuery(queryStr);
return FuseSearch.doSearch(CodeFilter.keys, query);
}

protected static getQuery(queryStr: string): Fuse.Expression[] {
protected static getQuery(queryStr: string): Expression[] {
return [{ code: queryStr }];
}
}
6 changes: 3 additions & 3 deletions src/services/filter.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Fuse from "fuse.js";
import { FuseOptionKeyObject, FuseResult } from "fuse.js";
import { ICodeSystem_Concept } from "@ahryman40k/ts-fhir-types/lib/R4";
import { QueryOptions } from "@/types/queryOptions";
import FuseSearch from "@/services/fuseSearch";

export default abstract class Filter extends FuseSearch {
protected static queryOptions: QueryOptions;
protected static keys: Fuse.FuseOptionKeyObject[];
protected static keys: FuseOptionKeyObject<ICodeSystem_Concept>[];

/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
public static initSearch(terms: string[]): Fuse.FuseResult<ICodeSystem_Concept>[] {
public static initSearch(terms: string[]): FuseResult<ICodeSystem_Concept>[] {
throw new Error("Error: Called method 'initSearch' on abstract class Filter.");
}

Expand Down
12 changes: 6 additions & 6 deletions src/services/fuseSearch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ICD10gm from "@/model/icd10CodeSystem";
import Fuse from "fuse.js";
import Fuse, { Expression, FuseOptionKeyObject, FuseResult, IFuseOptions } from "fuse.js";
import { ICodeSystem_Concept } from "@ahryman40k/ts-fhir-types/lib/R4";
import { QueryOptions } from "@/types/queryOptions";

Expand All @@ -18,9 +18,9 @@ export default class FuseSearch {
}

protected static doSearch(
keys: Fuse.FuseOptionKeyObject[],
query: Fuse.Expression[]
): Fuse.FuseResult<ICodeSystem_Concept>[] {
keys: FuseOptionKeyObject<ICodeSystem_Concept>[],
query: Expression[],
): FuseResult<ICodeSystem_Concept>[] {
const base = ICD10gm.processedCodesystem?.concept ?? [];
const options = FuseSearch.getOptions(keys);
const index = Fuse.createIndex(keys, base);
Expand All @@ -29,8 +29,8 @@ export default class FuseSearch {
}

private static getOptions(
keys: Fuse.FuseOptionKeyObject[]
): Fuse.IFuseOptions<ICodeSystem_Concept> {
keys: FuseOptionKeyObject<ICodeSystem_Concept>[],
): IFuseOptions<ICodeSystem_Concept> {
return {
includeScore: true,
includeMatches: true,
Expand Down
18 changes: 9 additions & 9 deletions src/services/textFilter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Fuse from "fuse.js";
import { ICodeSystem_Concept } from "@ahryman40k/ts-fhir-types/lib/R4";
import Filter from "@/services/filter";
import { QueryOptions, MatchType, LogicalOperator } from "@/types/queryOptions";
import FuseSearch from "@/services/fuseSearch";
import { Expression, FuseOptionKeyObject, FuseResult } from "fuse.js";

export default class TextFilter extends Filter {
protected static keys: Fuse.FuseOptionKeyObject[] = [
protected static keys: FuseOptionKeyObject<ICodeSystem_Concept>[] = [
{ name: "extension.valueString", weight: 0.6 },
{ name: "modifierExtension.valueString", weight: 0.4 },
];
Expand All @@ -15,25 +15,25 @@ export default class TextFilter extends Filter {
logicalOperator: LogicalOperator.AND,
};

public static initSearch(searchTerms: string[]): Fuse.FuseResult<ICodeSystem_Concept>[] {
let res: Fuse.FuseResult<ICodeSystem_Concept>[] = [];
public static initSearch(searchTerms: string[]): FuseResult<ICodeSystem_Concept>[] {
let res: FuseResult<ICodeSystem_Concept>[] = [];
let termCount = searchTerms.length;
const termCombs: string[][] = TextFilter.getCombinations(searchTerms);

while (res.length < 1 && termCount > 0) {
const termsByLength: string[][] = termCombs.filter((terms) => terms.length == termCount);
const queryStr: string[] = TextFilter.getMultipleTermsQuery(termsByLength);
const query: Fuse.Expression[] = TextFilter.getQuery(queryStr);
const query: Expression[] = TextFilter.getQuery(queryStr);
res = FuseSearch.doSearch(TextFilter.keys, query);
termCount--;
}
return res;
}

protected static getQuery(queryStr: string[]): Fuse.Expression[] {
const query: Fuse.Expression[] = [];
protected static getQuery(queryStr: string[]): Expression[] {
const query: Expression[] = [];
queryStr.forEach((str) =>
query.push({ "extension.valueString": str }, { "modifierExtension.valueString": str })
query.push({ "extension.valueString": str }, { "modifierExtension.valueString": str }),
);
return query;
}
Expand All @@ -44,7 +44,7 @@ export default class TextFilter extends Filter {
const subarr: string[][] = TextFilter.getCombinations(terms.slice(1));
return subarr.concat(
subarr.map((e) => e.concat([terms[0]])),
[[terms[0]]]
[[terms[0]]],
);
}

Expand Down

0 comments on commit 438b324

Please sign in to comment.