summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/klinik_anamnese-getEcogStatus.js30
-rw-r--r--scripts/studien-dialog.js215
-rw-r--r--scripts/varianten-dialog.js266
3 files changed, 511 insertions, 0 deletions
diff --git a/scripts/klinik_anamnese-getEcogStatus.js b/scripts/klinik_anamnese-getEcogStatus.js
new file mode 100644
index 0000000..763b683
--- /dev/null
+++ b/scripts/klinik_anamnese-getEcogStatus.js
@@ -0,0 +1,30 @@
+// To be included in Script "Beim Neuanlegen" of form "DNPM Klink/Anamnese"
+
+executePluginMethod('DNPMHelper', 'getEcogStatus', {PatientId: getPatient().id}, (resp) => {
+ if (resp.status.code === 1) {
+ // Hack: Get version id of ECOG status as stored in Database
+ // by using initial empty entry and its version.
+ // Since OS always creates an initial empty entry for subforms
+ // this can be used to get required version id from within a form script.
+ let version = getFieldValue('ECOGVerlauf')[0].ECOG.version;
+
+ // Abort if no version available.
+ if (version == null) {
+ return;
+ }
+
+ let uf = resp.result
+ .map(item => {
+ let date = item.date.match(/^\d{4}-\d{2}-\d{2}/);
+ let ecog = [];
+ ecog.val = item.status;
+ ecog.version = version;
+ return {
+ Datum: [date ? date[0] : null, 'exact'], ECOG: ecog
+ };
+ })
+ // Ignore items without valid values
+ .filter(item => item.Datum[0] && (item.ECOG >= 0 && item.ECOG <= 5));
+ setFieldValue('ECOGVerlauf', uf);
+ }
+}, false); \ No newline at end of file
diff --git a/scripts/studien-dialog.js b/scripts/studien-dialog.js
new file mode 100644
index 0000000..4ec4da8
--- /dev/null
+++ b/scripts/studien-dialog.js
@@ -0,0 +1,215 @@
+const availableStore = new Ext.data.ArrayStore({
+ fields: [
+ {name: 'kategorieName'},
+ {name: 'version'},
+ {name: 'code'},
+ {name: 'type'},
+ {name: 'studiennummer'},
+ {name: 'shortDesc'},
+ {name: 'description'}
+ ]
+});
+
+let pluginRequestsDisabled = false;
+
+const findButtonFieldFormInformation = function (context) {
+ const findElemId = function (elem) {
+ if (elem.tagName === 'BODY') {
+ return undefined;
+ }
+
+ if (elem.tagName === 'TABLE') {
+ return elem.id;
+ }
+
+ return findElemId(elem.parentElement);
+ }
+
+ const formInfo = function (formItem, blockIndex = undefined) {
+ if (formItem.xtype === 'buttonField') {
+ return formInfo(formItem.ownerCt, formItem.blockIndex);
+ }
+
+ if (formItem.xtype === 'panel' || formItem.xtype === 'sectionField') {
+ return formInfo(formItem.ownerCt, blockIndex);
+ }
+
+ if (formItem.xtype === 'subformField') {
+ return {
+ isSubform: true,
+ formName: formItem.formName,
+ subformFieldName: formItem.subformName,
+ blockIndex: blockIndex
+ };
+ }
+
+ if (formItem.xtype === 'form') {
+ return {
+ isSubform: false,
+ };
+ }
+
+ console.warn('No information found!');
+ return undefined;
+ }
+
+ if (context.genericEditForm && document.activeElement.tagName === 'BUTTON') {
+ let elemId = findElemId(document.activeElement);
+ if (elemId) {
+ let formItem = context.genericEditForm.down('#' + elemId);
+ if (formItem) {
+ return formInfo(formItem);
+ }
+ }
+ }
+
+ return undefined;
+}
+
+const request = function (query, includeInactive) {
+ if (pluginRequestsDisabled) return;
+ executePluginMethod(
+ 'EinzelempfehlungAnalyzer',
+ 'getStudien',
+ includeInactive ? {q: query, inactive: true} : {q: query},
+ function (response) {
+ if (response.status.code < 0) {
+ onFailure();
+ return;
+ }
+ onSuccess(response.result);
+ },
+ false
+ );
+};
+
+const itemMapping = function (item) {
+ return [item.kategorieName, item.version, item.code, item.type, item.studiennummer, item.shortDesc, item.description];
+}
+
+const onFailure = function () {
+ pluginRequestsDisabled = true;
+ Ext.MessageBox.show({
+ title: 'Hinweis',
+ msg: 'Plugin "DNPM" nicht verfügbar.',
+ buttons: Ext.MessageBox.OKCANCEL
+ });
+};
+
+const onSuccess = function (d) {
+ available = d;
+ const extData = available.map(itemMapping);
+ availableStore.loadData(extData);
+}
+
+const save = (selectedItemIndex) => {
+ this.getFieldByEntriesArray('studie', blockIndex).setValue(available[selectedItemIndex].shortDesc);
+ this.getFieldByEntriesArray('studienct', blockIndex).setValue(available[selectedItemIndex].studiennummer);
+}
+
+const showDialog = function (blockIndex) {
+ let selectedItemIndex = -1;
+ let queryString = '';
+ let includeInactive = false;
+
+ const gridColumns = [
+ {header: 'Kategorie', width: 80, sortable: false, dataIndex: 'kategorieName'},
+ {header: 'Version', width: 80, sortable: false, dataIndex: 'version'},
+ {header: 'Typ', width: 120, sortable: false, dataIndex: 'type'},
+ {header: 'Studiennummer', width: 120, sortable: true, dataIndex: 'studiennummer'},
+ {header: 'Name', width: 320, sortable: true, dataIndex: 'shortDesc'},
+ {header: 'Beschreibung', width: 400, sortable: false, dataIndex: 'description'}
+ ];
+
+
+ const query = new Ext.form.field.Text({
+ name: 'query',
+ fieldLabel: 'Suche',
+ padding: 8,
+ listeners: {
+ change: (f) => {
+ queryString = f.value;
+ request(queryString, includeInactive);
+ }
+ }
+ });
+
+ const inactiveSelection = new Ext.form.field.Checkbox({
+ name: 'inactive',
+ fieldLabel: 'Inaktive Studien einschließen',
+ labelWidth: 240,
+ padding: 8,
+ listeners: {
+ handler: (_, checked) => {
+ includeInactive = checked;
+ request(queryString, includeInactive);
+ }
+ }
+ });
+
+ const availableGrid = new Ext.grid.GridPanel({
+ title: 'Verfügbare Studien',
+ store: availableStore,
+ loadMask: true,
+ border: true,
+ columns: gridColumns,
+ flex: 1,
+ listeners: {
+ itemclick: (dv, record, item, index) => {
+ selectedItemIndex = index;
+ },
+ itemdblclick: (dv, record, item, index) => {
+ save(selectedItemIndex);
+ let win = Ext.WindowManager.getActive();
+ if (win) {
+ win.close();
+ }
+ }
+ }
+ });
+
+ const layout = Ext.create('Ext.Panel', {
+ flex: 1,
+ layout: {
+ type: 'vbox',
+ align: 'stretch'
+ },
+ items: [query, inactiveSelection, availableGrid]
+ });
+
+ Ext.create('Ext.window.Window', {
+ title: 'Studienauswahl',
+ height: 600,
+ width: 1080,
+ layout: 'fit',
+ items: [layout],
+ buttons: [{
+ id: 'btnAdd',
+ text: 'Studie auswählen',
+ handler: () => {
+ save(selectedItemIndex);
+ let win = Ext.WindowManager.getActive();
+ if (win) {
+ win.close();
+ }
+ }
+ }, {
+ text: 'Abbrechen',
+ cls: 'onko-btn-cta',
+ handler: () => {
+ let win = Ext.WindowManager.getActive();
+ if (win) {
+ win.close();
+ }
+ }
+ }]
+ }).show();
+
+ request();
+};
+
+let buttonFieldFormInformation = findButtonFieldFormInformation(this);
+if (buttonFieldFormInformation && buttonFieldFormInformation.blockIndex) {
+ blockIndex = buttonFieldFormInformation.blockIndex;
+ showDialog(blockIndex);
+}
diff --git a/scripts/varianten-dialog.js b/scripts/varianten-dialog.js
new file mode 100644
index 0000000..c447bf8
--- /dev/null
+++ b/scripts/varianten-dialog.js
@@ -0,0 +1,266 @@
+const availableStore = new Ext.data.ArrayStore({
+ fields: [
+ {name: 'id'},
+ {name: 'ergebnis'},
+ {name: 'gen'},
+ {name: 'exon'},
+ {name: 'pathogenitaetsklasse'}
+ ]
+});
+
+const selectedStore = new Ext.data.ArrayStore({
+ fields: [
+ {name: 'id'},
+ {name: 'ergebnis'},
+ {name: 'gen'},
+ {name: 'exon'},
+ {name: 'pathogenitaetsklasse'}
+ ]
+});
+
+let pluginRequestsDisabled = false;
+let available = [];
+let selected = [];
+let blockIndex = null;
+
+const findButtonFieldFormInformation = function(context) {
+ const findElemId = function(elem) {
+ if (elem.tagName === 'BODY') {
+ return undefined;
+ }
+
+ if (elem.tagName === 'TABLE') {
+ return elem.id;
+ }
+
+ return findElemId(elem.parentElement);
+ }
+
+ const formInfo = function(formItem, blockIndex = undefined) {
+ if (formItem.xtype === 'buttonField') {
+ return formInfo(formItem.ownerCt, formItem.blockIndex);
+ }
+
+ if (formItem.xtype === 'panel' || formItem.xtype === 'sectionField') {
+ return formInfo(formItem.ownerCt, blockIndex);
+ }
+
+ if (formItem.xtype === 'subformField') {
+ return {
+ isSubform: true,
+ formName: formItem.formName,
+ subformFieldName: formItem.subformName,
+ blockIndex: blockIndex
+ };
+ }
+
+ if (formItem.xtype === 'form') {
+ return {
+ isSubform: false,
+ };
+ }
+
+ console.warn('No information found!');
+ return undefined;
+ }
+
+ if (context.genericEditForm && document.activeElement.tagName === 'BUTTON') {
+ let elemId = findElemId(document.activeElement);
+ if (elemId) {
+ let formItem = context.genericEditForm.down('#'+elemId);
+ if (formItem) {
+ return formInfo(formItem);
+ }
+ }
+ }
+
+ return undefined;
+}
+
+const request = function (id) {
+ if (pluginRequestsDisabled) return;
+ executePluginMethod(
+ 'EinzelempfehlungAnalyzer',
+ 'getVariants',
+ {id: id},
+ function (response) {
+ if (response.status.code < 0) {
+ onFailure();
+ return;
+ }
+ onSuccess(response.result);
+ },
+ false
+ );
+};
+
+const itemMapping = function (item) {
+ return [item.id, item.ergebnis, item.gen, item.exon, item.pathogenitaetsklasse];
+}
+
+const addItem = function (item) {
+ if (selected.map(item => item.id).indexOf(item.id) >= 0) {
+ return;
+ }
+ selected.push(item);
+ const extData = selected.map(itemMapping);
+ selectedStore.loadData(extData);
+};
+
+const removeItem = function (index) {
+ selected.splice(index, 1);
+ const extData = selected.map(itemMapping);
+ selectedStore.loadData(extData);
+};
+
+const save = () => {
+ const names = selected.map((item) => {
+ return `${item.ergebnis}: ${item.gen}, ${item.exon}, ${item.pathogenitaetsklasse}`;
+ }).join("\n");
+
+ this.getFieldByEntriesArray('stmolaltalle', blockIndex).setValue(names);
+ this.getFieldByEntriesArray('stmolaltvariantejson', blockIndex).setValue(JSON.stringify(selected));
+};
+
+const onFailure = function() {
+ pluginRequestsDisabled = true;
+ Ext.MessageBox.show({
+ title: 'Hinweis',
+ msg: 'Plugin "DNPM" nicht verfügbar.',
+ buttons: Ext.MessageBox.OKCANCEL
+ });
+};
+
+const onSuccess = function(d) {
+ available = d;
+ const extData = available.map(itemMapping);
+ availableStore.loadData(extData);
+}
+
+const showDialog = function (procedureId) {
+ let selectedItemIndex = -1;
+ let deselectedItemIndex = -1;
+
+ try {
+ selected = JSON.parse(getFieldValue('stmolaltvariantejson', blockIndex));
+ const extData = selected.map(itemMapping);
+ selectedStore.loadData(extData);
+ } catch (e) {
+ selected = [];
+ const extData = selected.map(itemMapping);
+ selectedStore.loadData(extData);
+ }
+
+ const gridColumns = [
+ {header: 'Ergebnis', width: 240, sortable: false, dataIndex: 'ergebnis'},
+ {header: 'Gen', width: 80, sortable: false, dataIndex: 'gen'},
+ {header: 'Exon', width: 80, sortable: false, dataIndex: 'exon'},
+ {header: 'Pathogenitätsklasse', sortable: false, dataIndex: 'pathogenitaetsklasse'},
+ ];
+
+ const availableGrid = new Ext.grid.GridPanel({
+ title: 'Verfügbar',
+ store: availableStore,
+ loadMask: true,
+ border: true,
+ columns: gridColumns,
+ flex: 1,
+ overflowY: 'scroll',
+ listeners: {
+ itemclick: (dv, record, item, index) => {
+ selectedItemIndex = index;
+ Ext.getCmp('btnAdd').setDisabled(false);
+ },
+ itemdblclick: (dv, record, item, index) => {
+ selectedItemIndex = -1
+ addItem(available[index]);
+ Ext.getCmp('btnAdd').setDisabled(true);
+ }
+ }
+ });
+
+ const selectedGrid = new Ext.grid.GridPanel({
+ title: 'Ausgewählt',
+ store: selectedStore,
+ loadMask: true,
+ border: true,
+ columns: gridColumns,
+ flex: 1,
+ overflowY: 'scroll',
+ listeners: {
+ itemclick: (dv, record, item, index) => {
+ deselectedItemIndex = index;
+ Ext.getCmp('btnRm').setDisabled(false);
+ },
+ itemdblclick: (dv, record, item, index) => {
+ deselectedItemIndex = -1
+ removeItem(index);
+ Ext.getCmp('btnRm').setDisabled(true);
+ }
+ }
+ });
+
+ const gridLayout = Ext.create('Ext.Panel', {
+ flex: 1,
+ layout: {
+ type: 'hbox',
+ align: 'stretch'
+ },
+ items: [availableGrid, { xtype: 'splitter' }, selectedGrid]
+ });
+
+ const layout = Ext.create('Ext.Panel', {
+ flex: 1,
+ layout: {
+ type: 'vbox',
+ align: 'stretch'
+ },
+ items: [gridLayout]
+ });
+
+ Ext.create('Ext.window.Window', {
+ title: 'Variante auswählen',
+ height: 600,
+ width: 1080,
+ layout: 'fit',
+ items: [layout],
+ buttons: [{
+ id: 'btnAdd',
+ text: 'Hinzufügen',
+ disabled: true,
+ handler: () => {
+ addItem(available[selectedItemIndex]);
+ Ext.getCmp('btnAdd').setDisabled(true);
+ }
+ }, {
+ id: 'btnRm',
+ text: 'Entfernen',
+ disabled: true,
+ handler: () => {
+ removeItem(deselectedItemIndex);
+ Ext.getCmp('btnRm').setDisabled(true);
+ }
+ }, {
+ text: 'Übernehmen',
+ cls: 'onko-btn-cta',
+ handler: () => {
+ save();
+ let win = Ext.WindowManager.getActive();
+ if (win) {
+ win.close();
+ }
+ }
+ }]
+ }).show();
+
+ request(procedureId);
+};
+
+let buttonFieldFormInformation = findButtonFieldFormInformation(this);
+if (buttonFieldFormInformation && buttonFieldFormInformation.blockIndex) {
+ blockIndex = buttonFieldFormInformation.blockIndex;
+}
+
+var procedureId = getFieldValue('refosmolekulargenetik', blockIndex).id;
+
+showDialog(procedureId); \ No newline at end of file