Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ffpe specimen #27

Merged
merged 5 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion packages/demo/public/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,44 @@
},
{
"title": "Bioproben*",
"dataKey": "specimen"
"aggregatedDataKeys": [
{
"groupCode": "specimen"
},
{
"stratifierCode": "Histlogoies",
"stratumCode": "1"
},
{
}
]
}
]
},
"resultSummaryOptions": {
"title": "Ergebnisse",
"dataTypes": [
{
"title": "Standorte",
"dataKey": "collections"
},
{
"title": "Patienten",
"dataKey": "patients"
},
{
"title": "Bioproben*",
"aggregatedDataKeys": [
{
"groupCode": "specimen"
},
{
"stratifierCode": "Histlogoies",
"stratumCode": "1"
},
{
}
]
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions packages/demo/src/AppCCP.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
dktkPatientsMeasure,
dktkProceduresMeasure,
dktkSpecimenMeasure,
dktkHistologyMeasure
} from "./measures";

let mockCatalogueData = "";
Expand All @@ -30,6 +31,7 @@
dktkSpecimenMeasure,
dktkProceduresMeasure,
dktkMedicationStatementsMeasure,
dktkHistologyMeasure
];

const backendMeasures = `DKTK_STRAT_DEF_IN_INITIAL_POPULATION`;
Expand Down Expand Up @@ -209,8 +211,6 @@
<div class="charts">
<div class="chart-wrapper result-summary">
<lens-result-summary
title="Ergebnisse"
resultSummaryDataTypes={JSON.stringify(resultSummaryConfig)}
/>
<lens-search-modified-display>Diagramme repräsentieren nicht mehr die aktuelle Suche!</lens-search-modified-display>
</div>
Expand Down
46 changes: 46 additions & 0 deletions packages/demo/src/measures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1025,3 +1025,49 @@ export const dktkMedicationStatementsMeasure = {
DKTK_STRAT_MEDICATION_STRATIFIER
`,
};

export const dktkHistologyMeasure = {
key: 'Histo',
measure: {
code: {
text: 'Histo',
},
extension: [
{
url: 'http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis',
valueCode: 'Observation',
},
],
population: [
{
code: {
coding: [
{
system:
'http://terminology.hl7.org/CodeSystem/measure-population',
code: 'initial-population',
},
],
},
criteria: {
language: 'text/cql-identifier',
expression: 'Histo',
},
},
],
stratifier: [
{
code: {
text: 'Histlogoies',
},
criteria: {
language: 'text/cql-identifier',
expression: 'Histlogoy',
},
},
],
},
cql: `
DKTK_STRAT_HISTOLOGY_STRATIFIER
`,
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,31 @@
/>

<script lang="ts">
import { uiSiteMappingsStore } from "../../stores/mappings";
import { lensOptions } from "../../stores/options";
import {
responseStore,
getAggregatedPopulation,
getAggregatedPopulationForStratumCode,
} from "../../stores/response";
import type { ResponseStore } from "../../types/backend";
import NegotiateButtonComponent from "../buttons/NegotiateButtonComponent.wc.svelte";

export let title: string = "";
export let resultSummaryDataTypes: { key: string; title: string; population?: string | number }[] = [];
export let negotiateButton: boolean = false;
export let negotiateButtonText: string = "Negotiate";

let options: any = {};
$: options = $lensOptions.resultSummaryOptions

let resultSummaryDataTypes: { key: string; title: string; population?: string | number }[]
$: resultSummaryDataTypes = options?.dataTypes || [];


/**
* Extracts the population for each result summary data type and adds it to the type object
* @param store
*/
const fillPopulationToSummaryTypes = (store: ResponseStore): void => {
if (!options?.dataTypes) {
return;
}
console.log(store);

/**
* show the number of sites with data and the number of sites claimed/succeeded
Expand All @@ -42,34 +49,56 @@
}
});

resultSummaryDataTypes = resultSummaryDataTypes.map((type) => {
resultSummaryDataTypes = options.dataTypes.map((type) => {
console.log(getAggregatedPopulationForStratumCode(store, '1', "Histlogoies"));
/**
* If the type is sites, the population is the length of the store
* TODO: very specific. this should be more generic
* If the type is collections, the population is the length of the store
*/
if (type.key === "sites") {
if (type.dataKey === "collections") {
type.population =`${sitesWithData} / ${sitesClaimed}`;
return type;
}

/**
* otherwise, get the population from the store
* if the type has only one dataKey, the population is the aggregated population of that dataKey
*/

if(type.dataKey) {
type.population = getAggregatedPopulation(store, type.dataKey);
return type;
}

/**
* if the type has multiple dataKeys to aggregate, the population is the aggregated population of all dataKeys
*/
type.population = getAggregatedPopulation(store, type.key);

let aggregatedPopulation: number = 0;

type.aggregatedDataKeys.forEach((dataKey) => {
if(dataKey.groupCode){
aggregatedPopulation += getAggregatedPopulation(store, dataKey.groupCode);
} else if(dataKey.stratifierCode && dataKey.stratumCode) {
aggregatedPopulation += getAggregatedPopulationForStratumCode(store, dataKey.stratumCode, dataKey.stratifierCode);
}
/**
* TODO: add support for stratifiers if needed?
* needs to be implemented in response.ts
*/
});

type.population = aggregatedPopulation;
return type;
});
};

responseStore.subscribe((store: ResponseStore): void => {
fillPopulationToSummaryTypes(store);
});
$: fillPopulationToSummaryTypes($responseStore);

</script>

{#if title}
{#if options?.title}
<div part="result-summary-header">
<h4 part="result-summary-header-title">
{title}
{options.title}
</h4>
</div>
{/if}
Expand All @@ -80,8 +109,4 @@
</div>
{/each}
</div>
{#if negotiateButton}
<div part="result-summary-footer">
<NegotiateButtonComponent title={negotiateButtonText} />
</div>
{/if}

35 changes: 30 additions & 5 deletions packages/lib/src/components/results/ResultTableComponent.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { negotiateStore } from "../../stores/negotiate";
import {
getSitePopulationForCode,
getSitePopulationForStratumCode,
responseStore,
} from "../../stores/response";
import TableItemComponent from "./TableItemComponent.svelte";
Expand All @@ -26,7 +27,7 @@
*/
let options: any;
$: options = ($lensOptions?.tableOptions && $lensOptions?.tableOptions) || {
headerData: [{ title: "", dataKey: "" }],
headerData: [{ title: "", dataKey: "", aggregatedDataKeys: []}],
};

$: options?.headerData?.forEach(
Expand All @@ -49,16 +50,40 @@

let tableRow: (string | number)[] = [];


/**
* builds the table items for each row
* the first item is the name of the collection
* the following items are the population for each data type (single or aggregated)
*/
options.headerData.forEach(
(header: HeaderData, index: number): void => {
if (index === 0) {
const name = $uiSiteMappingsStore.get(key);
tableRow.push(name);
} else {
tableRow.push(
getSitePopulationForCode(value.data, header.dataKey)
);
return;
}
if(header.dataKey) {
tableRow.push(getSitePopulationForCode(value.data, header.dataKey));
return;
}

let aggregatedPopulation: number = 0;

header.aggregatedDataKeys.forEach((dataKey) => {
if(dataKey.groupCode){
aggregatedPopulation += getSitePopulationForCode(value.data, dataKey.groupCode);
} else if(dataKey.stratifierCode && dataKey.stratumCode) {
aggregatedPopulation += getSitePopulationForStratumCode(value.data, dataKey.stratumCode, dataKey.stratifierCode);
}
/**
* TODO: add support for stratifiers if needed?
* needs to be implemented in response.ts
*/
});

tableRow.push(aggregatedPopulation);

}
);

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/stores/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writable } from "svelte/store";


export const lensOptions = writable<any>()
export const lensOptions = writable<any>({})
7 changes: 6 additions & 1 deletion packages/lib/src/types/biobanks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@

export type HeaderData = {
title: string;
dataKey: string;
dataKey?: string;
aggregatedDataKeys?: {
groupCode?: string;
stratifierCode?: string;
stratumCode?: string;
}[];
ascending?: boolean;
hintText?: string[];
};