Skip to content

Commit

Permalink
Merge pull request #94 from samply/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
torbrenner authored May 14, 2024
2 parents 21cc6b2 + 9b17588 commit b7027ba
Show file tree
Hide file tree
Showing 10 changed files with 357 additions and 42 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@samply/lens",
"description": "A web component library for clinical data search and visualisation",
"version": "0.0.5",
"version": "0.1.0",
"type": "module",
"module": "dist/lens.js",
"main": "dist/lens.umd.js",
Expand Down
191 changes: 162 additions & 29 deletions packages/demo/public/catalogues/catalogue-dktk.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion packages/demo/public/options.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"iconOptions": {
"infoUrl": "info-circle-svgrepo-com.svg"
"infoUrl": "info-circle-svgrepo-com.svg",
"selectAll": {
"text": "Add all"
}
},
"chartOptions": {
"patients": {
Expand Down
16 changes: 16 additions & 0 deletions packages/lib/src/components/Options.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@
) {
store.set("infoUrl", options.iconOptions.infoUrl);
}
if (
"selectAll" in options.iconOptions &&
typeof options.iconOptions["selectAll"] === "object" &&
options.iconOptions.selectAll
) {
// Allow for future possibility of iconUrl instead of text
if (
"text" in options.iconOptions.selectAll &&
typeof options.iconOptions.selectAll["text"] ===
"string"
)
store.set(
"selectAllText",
options.iconOptions.selectAll.text,
);
}
}
}
Expand Down
41 changes: 40 additions & 1 deletion packages/lib/src/components/catalogue/DataTreeElement.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { addItemToQuery, activeQueryGroupIndex } from "../../stores/query";
import type { Category } from "../../types/treeData";
import DataTreeElement from "./DataTreeElement.svelte";
import NumberInputComponent from "./NumberInputComponent.svelte";
Expand Down Expand Up @@ -37,7 +38,6 @@
* watches the open tree nodes store to update the open state of the subcategorys
*/
let open: boolean = false;
$: {
if (subCategoryName) {
open = $openTreeNodes
Expand Down Expand Up @@ -93,6 +93,13 @@
});
};
let finalParent: boolean =
!("childCategories" in element) &&
(!("fieldType" in element) ||
("fieldType" in element &&
typeof element.fieldType === "string" &&
element.fieldType == "single-select"));
/**
* watches the number input store to update the number input components
*/
Expand Down Expand Up @@ -131,6 +138,32 @@
}
return store;
});
$: selectAllText = $iconStore.get("selectAllText");
const selectAllOptions = (): void => {
if (!("criteria" in element)) return;
element.criteria.forEach((criterion) => {
const queryItem: QueryItem = {
id: uuidv4(),
key: element.key,
name: element.name,
system: "system" in element ? element.system : "",
type: "type" in element ? element.type : "",
values: [
{
name: criterion.name,
value: criterion.aggregatedValue
? criterion.aggregatedValue
: criterion.key,
queryBindId: uuidv4(),
},
],
};
addItemToQuery(queryItem, $activeQueryGroupIndex);
});
};
</script>

<div part="data-tree-element">
Expand Down Expand Up @@ -160,6 +193,12 @@
<InfoButtonComponent message={element.infoButtonText} />
{/if}

{#if finalParent && open}
<button part="add-all-options-button" on:click={selectAllOptions}>
{selectAllText ? selectAllText : "Add all"}
</button>
{/if}

{#if open}
{#if "childCategories" in element}
{#each element.childCategories as child}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@
/>

<script lang="ts">
import type { Category } from "../../types/treeData";
import { queryStore } from "../../stores/query";
import SearchBarComponent from "./SearchBarComponent.wc.svelte";
import type { QueryItem } from "../../types/queryData";
/**
* props
* @param treeData takes a Category tree to build the autocomplete items from
* @param noMatchesFoundMessage takes a string to display when no matches are found
*/
export let treeData: Category[] = [];
export let noMatchesFoundMessage: string = "No matches found";
export let placeholderText: string = "Type to filter conditions";
Expand All @@ -40,7 +33,6 @@
{#each $queryStore as _, index}
<div part="search-bar-wrapper">
<SearchBarComponent
{treeData}
{noMatchesFoundMessage}
{placeholderText}
{index}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ const getSingleton = (criterion: AstBottomLayerValue): string => {
if (myCQL) {
switch (myCriterion.type) {
case "gender":
case "BBMRI_gender":
case "histology":
case "conditionValue":
case "BBMRI_conditionValue":
case "BBMRI_conditionSampleDiagnosis":
case "conditionBodySite":
case "conditionLocalization":
case "observation":
Expand All @@ -131,6 +134,8 @@ const getSingleton = (criterion: AstBottomLayerValue): string => {
case "procedureResidualstatus":
case "medicationStatement":
case "specimen":
case "BBMRI_specimen":
case "BBMRI_hasSpecimen":
case "hasSpecimen":
case "Organization":
case "observationMolecularMarkerName":
Expand Down
116 changes: 116 additions & 0 deletions packages/lib/src/cql-translator-service/cqlquery-mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ export const alias = new Map<string, string>([
"http://dktk.dkfz.de/fhir/onco/core/CodeSystem/TNMmSymbolCS",
],
["molecularMarker", "http://www.genenames.org"],

["BBMRI_icd10", "http://hl7.org/fhir/sid/icd-10"],
["BBMRI_icd10gm", "http://fhir.de/CodeSystem/dimdi/icd-10-gm"],
[
"BBMRI_SampleMaterialType",
"https://fhir.bbmri.de/CodeSystem/SampleMaterialType",
], //specimentype
[
"BBMRI_StorageTemperature",
"https://fhir.bbmri.de/CodeSystem/StorageTemperature",
],
[
"BBMRI_SmokingStatus",
"http://hl7.org/fhir/uv/ips/ValueSet/current-smoking-status-uv-ips",
],
]);

export const cqltemplate = new Map<string, string>([
Expand Down Expand Up @@ -192,6 +207,69 @@ export const cqltemplate = new Map<string, string>([
"(exists ([Observation: Code '21908-9' from loinc] O where O.value.coding.code contains '{{C}}')) or (exists ([Observation: Code '21902-2' from loinc] O where O.value.coding.code contains '{{C}}'))",
],
["histology", "exists from [Observation: Code '59847-4' from loinc] O\n"],

["BBMRI_gender", "Patient.gender"],
[
"BBMRI_conditionSampleDiagnosis",
"((exists[Condition: Code '{{C}}' from {{A1}}]) or (exists[Condition: Code '{{C}}' from {{A2}}])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains '{{C}}'))",
],
["BBMRI_conditionValue", "exists [Condition: Code '{{C}}' from {{A1}}]"],
[
"BBMRI_conditionRangeDate",
"exists from [Condition] C\nwhere FHIRHelpers.ToDateTime(C.onset) between {{D1}} and {{D2}}",
],
[
"BBMRI_conditionRangeAge",
"exists from [Condition] C\nwhere AgeInYearsAt(FHIRHelpers.ToDateTime(C.onset)) between Ceiling({{D1}}) and Ceiling({{D2}})",
],
["BBMRI_age", "AgeInYears() between Ceiling({{D1}}) and Ceiling({{D2}})"],
[
"BBMRI_observation",
"exists from [Observation: Code '{{K}}' from {{A1}}] O\nwhere O.value.coding.code contains '{{C}}'",
],
[
"BBMRI_observationSmoker",
"exists from [Observation: Code '72166-2' from {{A1}}] O\nwhere O.value.coding.code contains '{{C}}'",
],
[
"BBMRI_observationRange",
"exists from [Observation: Code '{{K}}' from {{A1}}] O\nwhere O.value between {{D1}} and {{D2}}",
],
[
"BBMRI_observationBodyWeight",
"exists from [Observation: Code '29463-7' from {{A1}}] O\nwhere ((O.value as Quantity) < {{D1}} 'kg' and (O.value as Quantity) > {{D2}} 'kg')",
],
[
"BBMRI_observationBMI",
"exists from [Observation: Code '39156-5' from {{A1}}] O\nwhere ((O.value as Quantity) < {{D1}} 'kg/m2' and (O.value as Quantity) > {{D2}} 'kg/m2')",
],
["BBMRI_hasSpecimen", "exists [Specimen]"],
["BBMRI_specimen", "exists [Specimen: Code '{{C}}' from {{A1}}]"],
["BBMRI_retrieveSpecimenByType", "(S.type.coding.code contains '{{C}}')"],
[
"BBMRI_retrieveSpecimenByTemperature",
"(S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/StorageTemperature').value.coding.code contains '{{C}}')",
],
[
"BBMRI_retrieveSpecimenBySamplingDate",
"(FHIRHelpers.ToDateTime(S.collection.collected) between {{D1}} and {{D2}})",
],
[
"BBMRI_retrieveSpecimenByFastingStatus",
"(S.collection.fastingStatus.coding.code contains '{{C}}')",
],
[
"BBMRI_samplingDate",
"exists from [Specimen] S\nwhere FHIRHelpers.ToDateTime(S.collection.collected) between {{D1}} and {{D2}}",
],
[
"BBMRI_fastingStatus",
"exists from [Specimen] S\nwhere S.collection.fastingStatus.coding.code contains '{{C}}'",
],
[
"BBMRI_storageTemperature",
"exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/StorageTemperature').value.coding contains Code '{{C}}' from {{A1}})",
],
]);

export const criterionMap = new Map<string, { type: string; alias?: string[] }>(
Expand Down Expand Up @@ -309,5 +387,43 @@ export const criterionMap = new Map<string, { type: string; alias?: string[] }>(
["75186-7", { type: "observation", alias: ["loinc", "vitalstatuscs"] }], //Vitalstatus
//["Organization", {type: "Organization"}],
["Organization", { type: "department" }],

["BBMRI_gender", { type: "BBMRI_gender" }],
[
"BBMRI_diagnosis",
{
type: "BBMRI_conditionSampleDiagnosis",
alias: ["BBMRI_icd10", "BBMRI_icd10gm"],
},
],
[
"BBMRI_body_weight",
{ type: "BBMRI_observationBodyWeight", alias: ["loinc"] },
], //Body weight
["BBMRI_bmi", { type: "BBMRI_observationBMI", alias: ["loinc"] }], //BMI
[
"BBMRI_smoking_status",
{ type: "BBMRI_observationSmoker", alias: ["loinc"] },
], //Smoking habit
["BBMRI_donor_age", { type: "BBMRI_age" }],
["BBMRI_date_of_diagnosis", { type: "BBMRI_conditionRangeDate" }],
[
"BBMRI_sample_kind",
{ type: "BBMRI_specimen", alias: ["BBMRI_SampleMaterialType"] },
],
[
"BBMRI_storage_temperature",
{
type: "BBMRI_storageTemperature",
alias: ["BBMRI_StorageTemperature"],
},
],
["BBMRI_pat_with_samples", { type: "BBMRI_hasSpecimen" }],
["BBMRI_diagnosis_age_donor", { type: "BBMRI_conditionRangeAge" }],
[
"BBMRI_fasting_status",
{ type: "BBMRI_fastingStatus", alias: ["loinc"] },
],
["BBMRI_sampling_date", { type: "BBMRI_samplingDate" }],
],
);
11 changes: 11 additions & 0 deletions packages/lib/src/styles/catalogue.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ lens-catalogue::part(data-tree-element-toggle-icon) {
transition: all 0.1s ease-in-out;
}

lens-catalogue::part(add-all-options-button) {
background-color: var(--button-background-color);
border-radius: var(--border-radius-small);
color: var(--button-color);
position: relative;
padding: 3px 8px;
cursor: pointer;
border: none;
left: +15px;
}

lens-catalogue::part(data-tree-element-toggle-icon-open) {
transform: rotate(0deg);
}
Expand Down

0 comments on commit b7027ba

Please sign in to comment.