summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2023-08-28 14:17:39 +0200
committerPaul-Christian Volkmer2023-08-28 14:18:00 +0200
commit74a6e7e79a56b016781d5eb07f85f1d40ef5b511 (patch)
treecba975e5eafaa2897b8e8599fd501734de16be51 /examples
parentaef9dd7889ddf03cc75f5d682a26380ac6fb75d3 (diff)
Issue #29: Add example script to insert ECOG Verlauf on form creation
Diffstat (limited to 'examples')
-rw-r--r--examples/uf-einzelempfehlung/klinik_anamnese-getEcogStatus.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/uf-einzelempfehlung/klinik_anamnese-getEcogStatus.js b/examples/uf-einzelempfehlung/klinik_anamnese-getEcogStatus.js
new file mode 100644
index 0000000..02a2fea
--- /dev/null
+++ b/examples/uf-einzelempfehlung/klinik_anamnese-getEcogStatus.js
@@ -0,0 +1,27 @@
+// 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 = new Date(item.date).toISOString().split('T')[0];
+ let ecog = [];
+ ecog.val = item.status;
+ ecog.version = version;
+ return {
+ Datum: [date, 'exact'], ECOG: ecog
+ };
+ });
+ setFieldValue('ECOGVerlauf', uf);
+ }
+}, false); \ No newline at end of file