diff --git a/src/lib/components/dictionary/test/page/tabs/calculation.svelte b/src/lib/components/dictionary/test/page/tabs/calculation.svelte index 6b94b21..bd2264b 100644 --- a/src/lib/components/dictionary/test/page/tabs/calculation.svelte +++ b/src/lib/components/dictionary/test/page/tabs/calculation.svelte @@ -9,10 +9,13 @@ import DictionaryFormRenderer from '$lib/components/reusable/form/dictionary-form-renderer.svelte'; let props = $props(); - - const operators = ['+', '-', '*', '/', '^', '(', ')']; - const logicalop = ['IF', 'THEN', 'ELSE', 'END', 'AND', 'OR', 'NOT', 'MIN', 'MAX', 'RESULT']; +$inspect(props.calFormState.errors) + const mathop = ['+', '-', '*', '/', '%','**', '(', ')']; const comparisonop = ['=', '!=', '<', '>', '<=', '>=']; + const logicalop = ['AND', 'OR', 'NOT']; + const conditionalop = ['?:', '??']; + const booleanop = ['TRUE', 'FALSE', 'NULL']; + const availableVar =['{ RESULT }', '{ GENDER }', '{ AGE }']; let tokens = $state([]); let cursorIndex = $state(0); @@ -30,6 +33,32 @@ syncFormState(); } + function insertTernary() { + // insert '?' di cursor sekarang + const questionToken = { id: uid(), type: 'conditional', value: '?' }; + const colonToken = { id: uid(), type: 'conditional', value: ':' }; + + // insert keduanya, dengan 1 slot kosong di antara (cursor di antara ? dan :) + tokens = [ + ...tokens.slice(0, cursorIndex), + questionToken, + colonToken, + ...tokens.slice(cursorIndex) + ]; + // cursor setelah '?' supaya user langsung isi nilai true-nya + cursorIndex += 1; + syncFormState(); + } + + function insertNullCoalescing() { + insertToken('conditional', '??'); + } + + function addConditional(op) { + if (op === '?:') insertTernary(); + else if (op === '??') insertNullCoalescing(); + } + function addValue(val) { insertToken('test', val); } @@ -102,6 +131,7 @@ function unselectAll(key) { props.calFormState.form[key] = []; props.calFormState.validateField?.(key, [], false); + props.calFormState.errors.FormulaCode = null; } $inspect(props.calFormState.selectOptions) @@ -110,9 +140,12 @@ -
+
{#if type === 'text'}
{:else if type === 'formulabuilder'} -
-
- +
+
{ @@ -546,7 +547,7 @@ {/if}
- - - - + +
+ + + + + +
-
- {#if formState.form.FormulaInput?.length > 0} -
-
- -
- {#each formState.form.FormulaInput as item (item)} - - {/each} -
-
+ {#if formState.form.FormulaInput?.length} +
+

Selected Tests

+
+ {#each formState.form.FormulaInput as item} + + {/each}
- {/if} -
-
- -
- - - {#snippet child({ props: triggerProps })} - - {/snippet} - - -
-
-

Enter Text Value

- { - if (e.key === 'Enter' && stringLiteralInput.trim()) { - onAddLiteral(`"${stringLiteralInput.trim()}"`); - stringLiteralInput = ''; - } - }} - /> -
- -
-
-
-
-
- - - - {#snippet child({ props: triggerProps })} - - {/snippet} - - -
-
-

Enter Number Value

- + {/if} +
+
+

Math Operator

+
+ {#each mathop as op} + + {/each} +
+
+
+

Comparison Operator

+
+ {#each comparisonop as op} + + {/each} +
+
+
+

Logical Operator

+
+ {#each logicalop as op} + + {/each} +
+
+
+

Conditional Operator

+
+ {#each conditionalop as op} + + {/each} +
+
+
+

Boolean Operator

+
+ {#each booleanop as op} + + {/each} +
+
+
+

Variables

+
+ {#each availableVar as op} + + {/each} +
+
+
+

Custom Values

+
+ + + {#snippet child({ props: triggerProps })} + + {/snippet} + + +
+
+

Enter Text Value

+ { - if (e.key === 'Enter' && numberLiteralInput != null && !isNaN(numberLiteralInput)) { + if (e.key === 'Enter' && stringLiteralInput.trim()) { + onAddLiteral(`"${stringLiteralInput.trim()}"`); + stringLiteralInput = ''; + } + }} + /> +
+ +
+
+
+
+
+ + + {#snippet child({ props: triggerProps })} + + {/snippet} + + +
+
+

Enter Number Value

+ { + if (e.key === 'Enter' && numberLiteralInput != null && !isNaN(numberLiteralInput)) { + onAddLiteral(String(numberLiteralInput)); + numberLiteralInput = null; + } + }} + /> +
+ -
-
+ > + Add +
-
-
-
-
-
- -
- {#each logicalop as op} - - {/each} -
-
-
- -
- {#each comparisonop as op} - - {/each} -
-
-
- -
- {#each operators as op} - - {/each} -
+
+
+ +
- {#if tokens.length > 0} -
- -
-
{expressionString}
+
+
+ +
+
+ {expressionString}
{/if} diff --git a/src/lib/components/reusable/reusable-data-table copy.svelte b/src/lib/components/reusable/reusable-data-table copy.svelte deleted file mode 100644 index 90f2bdc..0000000 --- a/src/lib/components/reusable/reusable-data-table copy.svelte +++ /dev/null @@ -1,210 +0,0 @@ - - - -
- {#if props.searchable ?? true} -
- { - globalFilter = e.currentTarget.value; - }} - class="h-7 w-64 text-xs px-2" - /> -
- {/if} - - -
- - -
- - - - {#each table.getHeaderGroups() as headerGroup (headerGroup.id)} - - {#each headerGroup.headers as header (header.id)} - - {#if !header.isPlaceholder} - - {/if} - - {/each} - - {/each} - - - - - {#each table.getRowModel().rows as row (row.id)} - props.handleRowClick(row.original)} - class="cursor-pointer" - > - {#each row.getVisibleCells() as cell, i (cell.id)} - - - - {/each} - - {:else} - - - No results. - - - {/each} - - -
- - -
-
-

Rows

- { - table.setPageSize(Number(value)); - }} - > - - {String(table.getState().pagination.pageSize)} - - - {#each [5, 10, 15, 20, 25] as pageSize (pageSize)} - - {pageSize} - - {/each} - - -
-
-
- Page {table.getState().pagination.pageIndex + 1} of - {table.getPageCount()} -
-
- - - - -
-
-
-
-
- - \ No newline at end of file diff --git a/src/lib/components/reusable/reusable-data-table.svelte b/src/lib/components/reusable/reusable-data-table.svelte index 4d7f04e..c0c15e3 100644 --- a/src/lib/components/reusable/reusable-data-table.svelte +++ b/src/lib/components/reusable/reusable-data-table.svelte @@ -15,7 +15,7 @@ let props = $props(); - let pagination = $state({ pageIndex: 0, pageSize: 10 }); + let pagination = $state({ pageIndex: 0, pageSize: 12 }); let columnFilters = $state([]); let globalFilter = $state(""); let activeRowId = $state(null); @@ -131,7 +131,7 @@ {String(table.getState().pagination.pageSize)} - {#each [5, 10, 15, 20, 25] as pageSize (pageSize)} + {#each [12, 24, 36, 48] as pageSize (pageSize)} {pageSize} diff --git a/src/routes/patient/list/+page.svelte b/src/routes/patient/list/+page.svelte index 62c0046..938a375 100644 --- a/src/routes/patient/list/+page.svelte +++ b/src/routes/patient/list/+page.svelte @@ -20,6 +20,7 @@ modeOpt: 'cascade', saveEndpoint: createPatient, editEndpoint: editPatient, + idKey: 'InternalPID', mapToForm: (data) => ({ ...data, PatIdt_IdentifierType: data.PatIdt?.IdentifierType ?? "",