diff --git a/src/lib/components/dictionary/test/config/test-form-config.js b/src/lib/components/dictionary/test/config/test-form-config.js index 235c83a..677fb49 100644 --- a/src/lib/components/dictionary/test/config/test-form-config.js +++ b/src/lib/components/dictionary/test/config/test-form-config.js @@ -26,8 +26,6 @@ export const testCalSchema = z.object({ } ); - - export const testInitialForm = { TestSiteID: "", SiteID: "", @@ -85,6 +83,21 @@ export const refNumInitialForm = { Notes: "", } +export const refTxtInitialForm = { + RefTxtID: "", + SiteID: "", + TestSiteID: "", + SpcType: "", + Sex: "", + Criteria: "", + AgeStart: "", + AgeEnd: "", + TxtRefType: "", + RefTxt: "", + Flag: "", + Notes: "", +}; + export const testDefaultErrors = { TestSiteCode: "Required", TestSiteName: "Required", @@ -94,6 +107,8 @@ export const testCalDefaultErrors = {}; export const refNumDefaultErrors = {}; +export const refTxtDefaultErrors = {}; + export const testFormFields = [ { title: "Basic Information", @@ -537,6 +552,125 @@ export const refNumFormFields = [ }, ]; +export const refTxtFormFields = [ + { + rows: [ + { + type: "row", + columns: [ + { + key: "SiteID", + label: "Site", + required: false, + type: "select", + optionsEndpoint: `${API.BASE_URL}${API.SITE}`, + valueKey: "SiteID", + labelKey: (item) => `${item.SiteCode} - ${item.SiteName}`, + fullWidth: false + }, + ] + } + ] + }, + { + title: "Criteria Definition", + rows: [ + { + type: "row", + columns: [ + { + key: "Sex", + label: "Sex", + required: false, + type: "select", + optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/sex`, + }, + { + key: "SpcType", + label: "Specimen Type", + required: false, + type: "select", + optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/specimen_type`, + }, + ] + }, + { + type: "row", + columns: [ + { + key: "AgeStart", + label: "Age Start", + required: false, + type: "agejoin", + }, + { + key: "AgeEnd", + label: "Age End", + required: false, + type: "agejoin", + }, + ] + }, + ] + }, + { + title: "Reference Range Configuration", + rows: [ + { + type: "row", + columns: [ + { + key: "TxtRefType", + label: "Reference Type", + required: false, + type: "text", + fullWidth: false + }, + ] + }, + { + type: "row", + columns: [ + { + key: "RefTxt", + label: "Reference Text", + required: false, + type: "textarea", + }, + ] + }, + ] + }, + { + title: "Flag & Notes", + rows: [ + { + type: "row", + columns: [ + { + key: "Flag", + label: "Flag", + required: false, + type: "text", + fullWidth: false + }, + ] + }, + { + type: "row", + columns: [ + { + key: "Notes", + label: "Notes", + required: false, + type: "textarea", + }, + ] + }, + ] + }, +]; + export function getTestFormActions(handlers) { return [ { diff --git a/src/lib/components/dictionary/test/page/create-page.svelte b/src/lib/components/dictionary/test/page/create-page.svelte index 3a8724f..c2ce1d2 100644 --- a/src/lib/components/dictionary/test/page/create-page.svelte +++ b/src/lib/components/dictionary/test/page/create-page.svelte @@ -6,7 +6,7 @@ import ReusableAlertDialog from "$lib/components/reusable/reusable-alert-dialog.svelte"; import * as Tabs from "$lib/components/ui/tabs/index.js"; import { useForm } from "$lib/components/composable/use-form.svelte"; - import { buildTestPayload, testCalSchema, testCalInitialForm, testCalDefaultErrors, testCalFormFields, refNumInitialForm, refNumFormFields } from "$lib/components/dictionary/test/config/test-form-config"; + import { buildTestPayload, testCalSchema, testCalInitialForm, testCalDefaultErrors, testCalFormFields, refNumInitialForm, refNumFormFields, refTxtInitialForm, refTxtFormFields } from "$lib/components/dictionary/test/config/test-form-config"; import ReusableEmpty from "$lib/components/reusable/reusable-empty.svelte"; import RefNum from "./tabs/ref-num.svelte"; import RefTxt from "./tabs/ref-txt.svelte"; @@ -26,12 +26,12 @@ const refNumState = useForm({ schema: null, initialForm: refNumInitialForm, - defaultErrors: {}, - mode: 'create', - modeOpt: 'default', - saveEndpoint: null, - editEndpoint: null, - }) + }); + + const refTxtState = useForm({ + schema: null, + initialForm: refTxtInitialForm, + }); const helpers = useDictionaryForm(formState); @@ -186,7 +186,7 @@ {#if refComponent === 'numeric'} {:else if refComponent === 'text'} - + {:else}
diff --git a/src/lib/components/dictionary/test/page/tabs/ref-num.svelte b/src/lib/components/dictionary/test/page/tabs/ref-num.svelte index da42ecc..239957b 100644 --- a/src/lib/components/dictionary/test/page/tabs/ref-num.svelte +++ b/src/lib/components/dictionary/test/page/tabs/ref-num.svelte @@ -14,7 +14,7 @@ let tempNumeric = $state([]); let editingId = $state(null); let idCounter = $state(0); -$inspect(tempNumeric) + let joinFields = $state({ AgeStart: { DD: "", MM: "", YY: "" }, AgeEnd: { DD: "", MM: "", YY: "" }, @@ -82,6 +82,14 @@ $inspect(tempNumeric) f.Flag = row.Flag; f.Interpretation = row.Interpretation; f.Notes = row.Notes; + + for (const key of ["AgeStart", "AgeEnd"]) { + const val = row[key] ?? ""; + const match = val.match(/(\d+)Y\s*(\d+)M\s*(\d+)D/); + joinFields[key] = match + ? { YY: match[1], MM: match[2], DD: match[3] } + : { DD: "", MM: "", YY: "" }; + } } function handleUpdate() { @@ -112,7 +120,8 @@ $inspect(tempNumeric) return found ? found.code : value; } - const rangeTypeBadge = (type) => ({ REF: "REF", CRTC: "CRTC" }[type] ?? type); + const rangeTypeBadge = (type) => ({ REF: "REF", CRTC: "CRTC" }[type] ?? null); + const numRefTypeBadge = (type) => ({ RANGE: "R", THOLD: "T" }[type] ?? null);; const rangeDisplay = (row) => { if (row.NumRefType === "RANGE") return `${row.LowValue} - ${row.HighValue}`; @@ -213,14 +222,20 @@ $inspect(tempNumeric) > {row.SpcType ? getLabel("SpcType", row.SpcType) : "-"} {row.Sex ? getLabel("Sex", row.Sex) : "-"} - {row.AgeStart} - {row.AgeEnd} + {row.AgeStart} – {row.AgeEnd} - {rangeTypeBadge(row.RangeType)} + {#if rangeTypeBadge(row.RangeType)} + {rangeTypeBadge(row.RangeType)} + {:else} + - + {/if} - - - {row.LowSign ? row.LowSign : ""} {row.Low || ""} - - {row.HighSign ? row.HighSign : ""} {row.High || ""} + +
+ {row.LowSign ? row.LowSign : ""} {row.Low || ""} – + {row.HighSign ? row.HighSign : ""} {row.High || ""} +
+ {numRefTypeBadge(row.NumRefType)}
{row.Flag} {row.Interpretation} diff --git a/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte b/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte index 84c22fd..09a4930 100644 --- a/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte +++ b/src/lib/components/dictionary/test/page/tabs/ref-txt.svelte @@ -1 +1,229 @@ -txt \ No newline at end of file + + +
+
+ +
+ {#if editingId !== null} + + + {:else} + + {/if} +
+
+ + + +
+ + + + Specimen Type + Sex + Age Range + Text/ValueSet + Flag + Notes + + + + + {#if tempTxt.length === 0} + + + No data. Fill the form above and click Insert. + + + {:else} + {#each tempTxt as row (row.id)} + + {row.SpcType ? getLabel("SpcType", row.SpcType) : "-"} + {row.Sex ? getLabel("Sex", row.Sex) : "-"} + {row.AgeStart} – {row.AgeEnd} + + {row.RefTxt ? row.RefTxt : "-"} + + {txtRefTypeBadge(row.TxtRefType)} + + + {row.Flag ? row.Flag : "-"} + {row.Notes ? row.Notes : "-"} + +
+ + +
+
+
+ {/each} + {/if} +
+
+
+
\ No newline at end of file diff --git a/src/lib/components/reusable/form/dictionary-form-renderer.svelte b/src/lib/components/reusable/form/dictionary-form-renderer.svelte index 6d79546..6d558f9 100644 --- a/src/lib/components/reusable/form/dictionary-form-renderer.svelte +++ b/src/lib/components/reusable/form/dictionary-form-renderer.svelte @@ -94,7 +94,7 @@ validateFieldAsync(key, mode, originalData?.[key]); } }} - readonly={key === "NumRefType"} + readonly={key === "NumRefType" || key === "TxtRefType"} /> {:else if type === "email"}