formanitor 0.0.32 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +338 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -2
- package/dist/index.d.ts +29 -2
- package/dist/index.mjs +336 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -308,6 +308,18 @@ interface DoctorFrequentItems {
|
|
|
308
308
|
investigations?: InvestigationFrequentItem[];
|
|
309
309
|
procedures?: ProcedureFrequentItem[];
|
|
310
310
|
}
|
|
311
|
+
interface DiagnosticPackageTest {
|
|
312
|
+
id: string;
|
|
313
|
+
name: string;
|
|
314
|
+
}
|
|
315
|
+
interface DiagnosticPackage {
|
|
316
|
+
id: string;
|
|
317
|
+
name: string;
|
|
318
|
+
code: string;
|
|
319
|
+
description?: string;
|
|
320
|
+
department?: string;
|
|
321
|
+
tests: DiagnosticPackageTest[];
|
|
322
|
+
}
|
|
311
323
|
type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | MediaUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | DiagnosisTextareaFieldDef | BaseFieldDef;
|
|
312
324
|
interface Condition {
|
|
313
325
|
field?: string;
|
|
@@ -435,6 +447,9 @@ interface FormState {
|
|
|
435
447
|
pendingUploads: number;
|
|
436
448
|
}
|
|
437
449
|
|
|
450
|
+
declare const MAR_MEDICATION_ORDERS_META_KEY: "mar_medication_orders";
|
|
451
|
+
declare function fieldMetaRequestsMarMedicationOrdersButton(meta: Record<string, unknown> | undefined): boolean;
|
|
452
|
+
|
|
438
453
|
interface SavedState {
|
|
439
454
|
values: FormValues;
|
|
440
455
|
meta: {
|
|
@@ -598,10 +613,21 @@ type FieldHandler = {
|
|
|
598
613
|
* from diagnosis text input.
|
|
599
614
|
*/
|
|
600
615
|
onFetchDiagnosisGrades?: (query: string) => Promise<any>;
|
|
616
|
+
/**
|
|
617
|
+
* Host opens MAR / medication-orders UI (e.g. IPD discharge). On success the host
|
|
618
|
+
* should update this field's value in form state.
|
|
619
|
+
*/
|
|
620
|
+
onOpenMedicationOrders?: () => void | Promise<void>;
|
|
621
|
+
/**
|
|
622
|
+
* Host opens CMDash discharge medication orders slide-over. On save, return the
|
|
623
|
+
* prescription payload so the widget can normalize and store it in form state.
|
|
624
|
+
*/
|
|
625
|
+
onOpenDischargeMedicationOrders?: () => Promise<any | null> | any | null;
|
|
601
626
|
};
|
|
602
627
|
type FieldHandlersMap = Record<string, FieldHandler>;
|
|
603
628
|
declare function useFieldHandlers(fieldId: string): FieldHandler;
|
|
604
629
|
declare function useFrequentItems(): DoctorFrequentItems;
|
|
630
|
+
declare function usePackages(): DiagnosticPackage[];
|
|
605
631
|
interface FormProviderProps {
|
|
606
632
|
schema: FormDef;
|
|
607
633
|
config?: StoreConfig;
|
|
@@ -611,6 +637,7 @@ interface FormProviderProps {
|
|
|
611
637
|
* Consumer fetches and passes this; Forminator flows it to medications, investigations, and procedures widgets.
|
|
612
638
|
*/
|
|
613
639
|
frequentItems?: DoctorFrequentItems;
|
|
640
|
+
packages?: DiagnosticPackage[];
|
|
614
641
|
children: React.ReactNode;
|
|
615
642
|
}
|
|
616
643
|
declare const FormProvider: React.FC<FormProviderProps>;
|
|
@@ -882,8 +909,8 @@ type AddInvestigationFieldProps = {
|
|
|
882
909
|
onChange: (items: Investigation[]) => void;
|
|
883
910
|
onSearch: (query: string) => Promise<InvestigationSearchResult[]>;
|
|
884
911
|
recentlyUsed?: InvestigationSearchResult[];
|
|
885
|
-
/** Doctor-scoped frequently used investigations (from FormProvider frequentItems) */
|
|
886
912
|
frequentItems?: InvestigationFrequentItem[];
|
|
913
|
+
packages?: DiagnosticPackage[];
|
|
887
914
|
};
|
|
888
915
|
declare const AddInvestigationField: React.FC<AddInvestigationFieldProps>;
|
|
889
916
|
|
|
@@ -926,4 +953,4 @@ declare const SmartTextareaWidget: React.FC<{
|
|
|
926
953
|
fieldId: string;
|
|
927
954
|
}>;
|
|
928
955
|
|
|
929
|
-
export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, EMAIL_REGEX, type EditableTableColumnDef, type EditableTableFieldDef, type EventDefinition, type ExtractedKeywordMatch, type FieldDef, type FieldHandler, type FieldHandlersMap, type FieldPrefill, FieldRenderer, type FieldState, type FieldType, type FollowupFieldDef, type FollowupValue, FormControls, type FormControlsProps, type FormDef, type FormErrors, FormProvider, type FormState, FormStore, type FormValues, type FormulaComputation, type FormulaExpr, type ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type MatchedCondition, type MediaUploadFieldDef, MediaUploadWidget, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, type RichTextFieldDef, RichTextWidget, type Rule, type RuleAction, type RuleResult, type ScoreComputation, type ScoreRange, type Section, type SectionChild, type SelectFieldDef, type SelectOption, type SignatureFieldDef, SignatureUploadWidget, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SumComputation, type TextFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, useSmartKeywords, validateField, validateForm };
|
|
956
|
+
export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, type DiagnosticPackage, type DiagnosticPackageTest, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, EMAIL_REGEX, type EditableTableColumnDef, type EditableTableFieldDef, type EventDefinition, type ExtractedKeywordMatch, type FieldDef, type FieldHandler, type FieldHandlersMap, type FieldPrefill, FieldRenderer, type FieldState, type FieldType, type FollowupFieldDef, type FollowupValue, FormControls, type FormControlsProps, type FormDef, type FormErrors, FormProvider, type FormState, FormStore, type FormValues, type FormulaComputation, type FormulaExpr, type ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, MAR_MEDICATION_ORDERS_META_KEY, type MatchedCondition, type MediaUploadFieldDef, MediaUploadWidget, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, type RichTextFieldDef, RichTextWidget, type Rule, type RuleAction, type RuleResult, type ScoreComputation, type ScoreRange, type Section, type SectionChild, type SelectFieldDef, type SelectOption, type SignatureFieldDef, SignatureUploadWidget, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SumComputation, type TextFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|
package/dist/index.d.ts
CHANGED
|
@@ -308,6 +308,18 @@ interface DoctorFrequentItems {
|
|
|
308
308
|
investigations?: InvestigationFrequentItem[];
|
|
309
309
|
procedures?: ProcedureFrequentItem[];
|
|
310
310
|
}
|
|
311
|
+
interface DiagnosticPackageTest {
|
|
312
|
+
id: string;
|
|
313
|
+
name: string;
|
|
314
|
+
}
|
|
315
|
+
interface DiagnosticPackage {
|
|
316
|
+
id: string;
|
|
317
|
+
name: string;
|
|
318
|
+
code: string;
|
|
319
|
+
description?: string;
|
|
320
|
+
department?: string;
|
|
321
|
+
tests: DiagnosticPackageTest[];
|
|
322
|
+
}
|
|
311
323
|
type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | MediaUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | DiagnosisTextareaFieldDef | BaseFieldDef;
|
|
312
324
|
interface Condition {
|
|
313
325
|
field?: string;
|
|
@@ -435,6 +447,9 @@ interface FormState {
|
|
|
435
447
|
pendingUploads: number;
|
|
436
448
|
}
|
|
437
449
|
|
|
450
|
+
declare const MAR_MEDICATION_ORDERS_META_KEY: "mar_medication_orders";
|
|
451
|
+
declare function fieldMetaRequestsMarMedicationOrdersButton(meta: Record<string, unknown> | undefined): boolean;
|
|
452
|
+
|
|
438
453
|
interface SavedState {
|
|
439
454
|
values: FormValues;
|
|
440
455
|
meta: {
|
|
@@ -598,10 +613,21 @@ type FieldHandler = {
|
|
|
598
613
|
* from diagnosis text input.
|
|
599
614
|
*/
|
|
600
615
|
onFetchDiagnosisGrades?: (query: string) => Promise<any>;
|
|
616
|
+
/**
|
|
617
|
+
* Host opens MAR / medication-orders UI (e.g. IPD discharge). On success the host
|
|
618
|
+
* should update this field's value in form state.
|
|
619
|
+
*/
|
|
620
|
+
onOpenMedicationOrders?: () => void | Promise<void>;
|
|
621
|
+
/**
|
|
622
|
+
* Host opens CMDash discharge medication orders slide-over. On save, return the
|
|
623
|
+
* prescription payload so the widget can normalize and store it in form state.
|
|
624
|
+
*/
|
|
625
|
+
onOpenDischargeMedicationOrders?: () => Promise<any | null> | any | null;
|
|
601
626
|
};
|
|
602
627
|
type FieldHandlersMap = Record<string, FieldHandler>;
|
|
603
628
|
declare function useFieldHandlers(fieldId: string): FieldHandler;
|
|
604
629
|
declare function useFrequentItems(): DoctorFrequentItems;
|
|
630
|
+
declare function usePackages(): DiagnosticPackage[];
|
|
605
631
|
interface FormProviderProps {
|
|
606
632
|
schema: FormDef;
|
|
607
633
|
config?: StoreConfig;
|
|
@@ -611,6 +637,7 @@ interface FormProviderProps {
|
|
|
611
637
|
* Consumer fetches and passes this; Forminator flows it to medications, investigations, and procedures widgets.
|
|
612
638
|
*/
|
|
613
639
|
frequentItems?: DoctorFrequentItems;
|
|
640
|
+
packages?: DiagnosticPackage[];
|
|
614
641
|
children: React.ReactNode;
|
|
615
642
|
}
|
|
616
643
|
declare const FormProvider: React.FC<FormProviderProps>;
|
|
@@ -882,8 +909,8 @@ type AddInvestigationFieldProps = {
|
|
|
882
909
|
onChange: (items: Investigation[]) => void;
|
|
883
910
|
onSearch: (query: string) => Promise<InvestigationSearchResult[]>;
|
|
884
911
|
recentlyUsed?: InvestigationSearchResult[];
|
|
885
|
-
/** Doctor-scoped frequently used investigations (from FormProvider frequentItems) */
|
|
886
912
|
frequentItems?: InvestigationFrequentItem[];
|
|
913
|
+
packages?: DiagnosticPackage[];
|
|
887
914
|
};
|
|
888
915
|
declare const AddInvestigationField: React.FC<AddInvestigationFieldProps>;
|
|
889
916
|
|
|
@@ -926,4 +953,4 @@ declare const SmartTextareaWidget: React.FC<{
|
|
|
926
953
|
fieldId: string;
|
|
927
954
|
}>;
|
|
928
955
|
|
|
929
|
-
export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, EMAIL_REGEX, type EditableTableColumnDef, type EditableTableFieldDef, type EventDefinition, type ExtractedKeywordMatch, type FieldDef, type FieldHandler, type FieldHandlersMap, type FieldPrefill, FieldRenderer, type FieldState, type FieldType, type FollowupFieldDef, type FollowupValue, FormControls, type FormControlsProps, type FormDef, type FormErrors, FormProvider, type FormState, FormStore, type FormValues, type FormulaComputation, type FormulaExpr, type ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type MatchedCondition, type MediaUploadFieldDef, MediaUploadWidget, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, type RichTextFieldDef, RichTextWidget, type Rule, type RuleAction, type RuleResult, type ScoreComputation, type ScoreRange, type Section, type SectionChild, type SelectFieldDef, type SelectOption, type SignatureFieldDef, SignatureUploadWidget, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SumComputation, type TextFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, useSmartKeywords, validateField, validateForm };
|
|
956
|
+
export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, type DiagnosticPackage, type DiagnosticPackageTest, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, EMAIL_REGEX, type EditableTableColumnDef, type EditableTableFieldDef, type EventDefinition, type ExtractedKeywordMatch, type FieldDef, type FieldHandler, type FieldHandlersMap, type FieldPrefill, FieldRenderer, type FieldState, type FieldType, type FollowupFieldDef, type FollowupValue, FormControls, type FormControlsProps, type FormDef, type FormErrors, FormProvider, type FormState, FormStore, type FormValues, type FormulaComputation, type FormulaExpr, type ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, MAR_MEDICATION_ORDERS_META_KEY, type MatchedCondition, type MediaUploadFieldDef, MediaUploadWidget, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, type RichTextFieldDef, RichTextWidget, type Rule, type RuleAction, type RuleResult, type ScoreComputation, type ScoreRange, type Section, type SectionChild, type SelectFieldDef, type SelectOption, type SignatureFieldDef, SignatureUploadWidget, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SumComputation, type TextFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|
package/dist/index.mjs
CHANGED
|
@@ -23,6 +23,13 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
|
23
23
|
import nlp from 'compromise';
|
|
24
24
|
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
25
25
|
|
|
26
|
+
// src/core/marMedicationOrdersMeta.ts
|
|
27
|
+
var MAR_MEDICATION_ORDERS_META_KEY = "mar_medication_orders";
|
|
28
|
+
function fieldMetaRequestsMarMedicationOrdersButton(meta) {
|
|
29
|
+
if (!meta || typeof meta !== "object") return false;
|
|
30
|
+
return meta[MAR_MEDICATION_ORDERS_META_KEY] === true;
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
// src/core/validate.ts
|
|
27
34
|
var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
28
35
|
function validateField(value, field) {
|
|
@@ -690,6 +697,7 @@ var emptyFrequentItems = {
|
|
|
690
697
|
procedures: []
|
|
691
698
|
};
|
|
692
699
|
var FrequentItemsContext = createContext(emptyFrequentItems);
|
|
700
|
+
var PackagesContext = createContext([]);
|
|
693
701
|
var FieldHandlersContext = createContext({});
|
|
694
702
|
function useFieldHandlers(fieldId) {
|
|
695
703
|
const map = useContext(FieldHandlersContext);
|
|
@@ -698,11 +706,15 @@ function useFieldHandlers(fieldId) {
|
|
|
698
706
|
function useFrequentItems() {
|
|
699
707
|
return useContext(FrequentItemsContext);
|
|
700
708
|
}
|
|
709
|
+
function usePackages() {
|
|
710
|
+
return useContext(PackagesContext);
|
|
711
|
+
}
|
|
701
712
|
var FormProvider = ({
|
|
702
713
|
schema,
|
|
703
714
|
config,
|
|
704
715
|
fieldHandlers,
|
|
705
716
|
frequentItems,
|
|
717
|
+
packages,
|
|
706
718
|
children
|
|
707
719
|
}) => {
|
|
708
720
|
const storeRef = useRef(null);
|
|
@@ -718,7 +730,7 @@ var FormProvider = ({
|
|
|
718
730
|
storeRef.current?.load();
|
|
719
731
|
}, []);
|
|
720
732
|
const frequentItemsValue = frequentItems ?? emptyFrequentItems;
|
|
721
|
-
return /* @__PURE__ */ jsx(FormContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsx(FieldHandlersContext.Provider, { value: fieldHandlers ?? {}, children: /* @__PURE__ */ jsx(FrequentItemsContext.Provider, { value: frequentItemsValue, children: /* @__PURE__ */ jsx(VoiceContextProvider, { children }) }) }) });
|
|
733
|
+
return /* @__PURE__ */ jsx(FormContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsx(FieldHandlersContext.Provider, { value: fieldHandlers ?? {}, children: /* @__PURE__ */ jsx(FrequentItemsContext.Provider, { value: frequentItemsValue, children: /* @__PURE__ */ jsx(PackagesContext.Provider, { value: packages ?? [], children: /* @__PURE__ */ jsx(VoiceContextProvider, { children }) }) }) }) });
|
|
722
734
|
};
|
|
723
735
|
function useFormStore() {
|
|
724
736
|
const context = useContext(FormContext);
|
|
@@ -3071,18 +3083,20 @@ var AddEntityDialog = ({
|
|
|
3071
3083
|
open,
|
|
3072
3084
|
onClose,
|
|
3073
3085
|
title,
|
|
3086
|
+
chipSections,
|
|
3074
3087
|
recentlyUsedSlot,
|
|
3075
3088
|
chipSectionLabel = "Recently Used",
|
|
3076
3089
|
children,
|
|
3077
3090
|
actionSlot
|
|
3078
3091
|
}) => {
|
|
3079
|
-
|
|
3092
|
+
const sections = chipSections ?? (recentlyUsedSlot ? [{ label: chipSectionLabel, content: recentlyUsedSlot }] : []);
|
|
3093
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (o) => !o && onClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-4xl w-full p-0 gap-0 flex flex-col max-h-[90vh] overflow-hidden", children: [
|
|
3080
3094
|
/* @__PURE__ */ jsx(DialogHeader, { className: "px-6 pt-6 pb-4 shrink-0", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-lg font-semibold", children: title }) }),
|
|
3081
3095
|
/* @__PURE__ */ jsxs("div", { className: "px-6 flex flex-col gap-4 overflow-y-auto flex-1 min-h-0 pb-4", children: [
|
|
3082
|
-
|
|
3083
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mb-2", children:
|
|
3084
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children:
|
|
3085
|
-
] }),
|
|
3096
|
+
sections.map((section) => /* @__PURE__ */ jsxs("div", { children: [
|
|
3097
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mb-2", children: section.label }),
|
|
3098
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: section.content })
|
|
3099
|
+
] }, section.label)),
|
|
3086
3100
|
children
|
|
3087
3101
|
] }),
|
|
3088
3102
|
actionSlot != null && /* @__PURE__ */ jsx("div", { className: "px-6 py-4 flex justify-end shrink-0 border-t border-border bg-background", children: actionSlot })
|
|
@@ -3624,7 +3638,8 @@ var AddInvestigationField = ({
|
|
|
3624
3638
|
onChange,
|
|
3625
3639
|
onSearch,
|
|
3626
3640
|
recentlyUsed = [],
|
|
3627
|
-
frequentItems = []
|
|
3641
|
+
frequentItems = [],
|
|
3642
|
+
packages = []
|
|
3628
3643
|
}) => {
|
|
3629
3644
|
const [open, setOpen] = useState(false);
|
|
3630
3645
|
const [query, setQuery] = useState("");
|
|
@@ -3635,6 +3650,8 @@ var AddInvestigationField = ({
|
|
|
3635
3650
|
const debounceRef = useRef(null);
|
|
3636
3651
|
const valueRef = useRef([]);
|
|
3637
3652
|
const searchInputRef = useRef(null);
|
|
3653
|
+
const addedByPackage = useRef(/* @__PURE__ */ new Map());
|
|
3654
|
+
const [selectedPackageIds, setSelectedPackageIds] = useState(/* @__PURE__ */ new Set());
|
|
3638
3655
|
const safeValue = Array.isArray(value) ? value : [];
|
|
3639
3656
|
valueRef.current = safeValue;
|
|
3640
3657
|
const addedIds = new Set(safeValue.map((inv) => inv.id));
|
|
@@ -3709,6 +3726,27 @@ var AddInvestigationField = ({
|
|
|
3709
3726
|
setAddingFrequentId(null);
|
|
3710
3727
|
}
|
|
3711
3728
|
}
|
|
3729
|
+
function handlePackageToggle(pkg) {
|
|
3730
|
+
const alreadyAdded = addedByPackage.current.has(pkg.id);
|
|
3731
|
+
if (alreadyAdded) {
|
|
3732
|
+
const idsToRemove = new Set(addedByPackage.current.get(pkg.id) ?? []);
|
|
3733
|
+
onChange(valueRef.current.filter((inv) => !idsToRemove.has(inv.id)));
|
|
3734
|
+
addedByPackage.current.delete(pkg.id);
|
|
3735
|
+
setSelectedPackageIds((prev) => {
|
|
3736
|
+
const next = new Set(prev);
|
|
3737
|
+
next.delete(pkg.id);
|
|
3738
|
+
return next;
|
|
3739
|
+
});
|
|
3740
|
+
} else {
|
|
3741
|
+
const currentIds = new Set(valueRef.current.map((inv) => inv.id));
|
|
3742
|
+
const newTests = pkg.tests.filter((t) => !currentIds.has(t.id)).map((t) => mapToInvestigation(t));
|
|
3743
|
+
if (newTests.length > 0) {
|
|
3744
|
+
onChange([...valueRef.current, ...newTests]);
|
|
3745
|
+
}
|
|
3746
|
+
addedByPackage.current.set(pkg.id, newTests.map((t) => t.id));
|
|
3747
|
+
setSelectedPackageIds((prev) => new Set(prev).add(pkg.id));
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3712
3750
|
const recentlyUsedChips = recentlyUsed.map((r) => {
|
|
3713
3751
|
const isAdded = addedIds.has(r.id);
|
|
3714
3752
|
return /* @__PURE__ */ jsxs(
|
|
@@ -3752,6 +3790,38 @@ var AddInvestigationField = ({
|
|
|
3752
3790
|
item.id
|
|
3753
3791
|
);
|
|
3754
3792
|
}) : [];
|
|
3793
|
+
const packageChips = packages.map((pkg) => {
|
|
3794
|
+
const isAdded = selectedPackageIds.has(pkg.id);
|
|
3795
|
+
return /* @__PURE__ */ jsxs(
|
|
3796
|
+
"button",
|
|
3797
|
+
{
|
|
3798
|
+
type: "button",
|
|
3799
|
+
onClick: () => handlePackageToggle(pkg),
|
|
3800
|
+
className: cn(
|
|
3801
|
+
"rounded-full border text-xs px-4 py-1.5 transition-colors flex items-center gap-2",
|
|
3802
|
+
isAdded ? "border-green-300 bg-green-50 text-green-700" : "border-border bg-white hover:bg-gray-50"
|
|
3803
|
+
),
|
|
3804
|
+
children: [
|
|
3805
|
+
isAdded && /* @__PURE__ */ jsx("span", { children: "\u2713" }),
|
|
3806
|
+
/* @__PURE__ */ jsx("span", { className: "font-semibold", children: pkg.name }),
|
|
3807
|
+
/* @__PURE__ */ jsx("span", { className: cn(
|
|
3808
|
+
"rounded-full px-1.5 py-0.5 text-[10px] font-medium",
|
|
3809
|
+
isAdded ? "bg-green-100 text-green-600" : "bg-purple-100 text-purple-600"
|
|
3810
|
+
), children: pkg.tests.length })
|
|
3811
|
+
]
|
|
3812
|
+
},
|
|
3813
|
+
pkg.id
|
|
3814
|
+
);
|
|
3815
|
+
});
|
|
3816
|
+
const chipSections = [];
|
|
3817
|
+
if (frequentItemChips.length > 0) {
|
|
3818
|
+
chipSections.push({ label: "Frequently used", content: /* @__PURE__ */ jsx(Fragment, { children: frequentItemChips }) });
|
|
3819
|
+
} else if (recentlyUsedChips.length > 0) {
|
|
3820
|
+
chipSections.push({ label: "Recently Used", content: /* @__PURE__ */ jsx(Fragment, { children: recentlyUsedChips }) });
|
|
3821
|
+
}
|
|
3822
|
+
if (packageChips.length > 0) {
|
|
3823
|
+
chipSections.push({ label: "Packages", content: /* @__PURE__ */ jsx(Fragment, { children: packageChips }) });
|
|
3824
|
+
}
|
|
3755
3825
|
return /* @__PURE__ */ jsxs("div", { className: "rounded-md overflow-hidden flex flex-col bg-white border border-[#D0D0D0] space-y-3 p-3 h-fit", children: [
|
|
3756
3826
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
3757
3827
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-semibold", children: label }),
|
|
@@ -3790,8 +3860,7 @@ var AddInvestigationField = ({
|
|
|
3790
3860
|
open,
|
|
3791
3861
|
onClose: () => setOpen(false),
|
|
3792
3862
|
title: "Add Investigation",
|
|
3793
|
-
|
|
3794
|
-
chipSectionLabel: frequentItemChips.length > 0 ? "Frequently used" : void 0,
|
|
3863
|
+
chipSections: chipSections.length > 0 ? chipSections : void 0,
|
|
3795
3864
|
children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
3796
3865
|
/* @__PURE__ */ jsx(
|
|
3797
3866
|
Input,
|
|
@@ -3832,6 +3901,7 @@ var AddInvestigationWidget = ({ fieldId }) => {
|
|
|
3832
3901
|
const { value, setValue } = useField(fieldId);
|
|
3833
3902
|
const handlers = useFieldHandlers(fieldId);
|
|
3834
3903
|
const { investigations: frequentInvestigations } = useFrequentItems();
|
|
3904
|
+
const packages = usePackages();
|
|
3835
3905
|
const safeValue = Array.isArray(value) ? value : [];
|
|
3836
3906
|
return /* @__PURE__ */ jsx(
|
|
3837
3907
|
AddInvestigationField,
|
|
@@ -3840,7 +3910,8 @@ var AddInvestigationWidget = ({ fieldId }) => {
|
|
|
3840
3910
|
onChange: setValue,
|
|
3841
3911
|
onSearch: handlers.onSearch,
|
|
3842
3912
|
recentlyUsed: handlers.recentlyUsed,
|
|
3843
|
-
frequentItems: frequentInvestigations
|
|
3913
|
+
frequentItems: frequentInvestigations,
|
|
3914
|
+
packages
|
|
3844
3915
|
}
|
|
3845
3916
|
);
|
|
3846
3917
|
};
|
|
@@ -7539,6 +7610,206 @@ var OrthopedicExamWidget = ({ fieldId }) => {
|
|
|
7539
7610
|
) : null
|
|
7540
7611
|
] });
|
|
7541
7612
|
};
|
|
7613
|
+
var MarMedicationOrdersWidget = ({ fieldId }) => {
|
|
7614
|
+
const { fieldDef, value, setTouched, error, disabled, touched } = useField(fieldId);
|
|
7615
|
+
const { state } = useForm();
|
|
7616
|
+
const handlers = useFieldHandlers(fieldId);
|
|
7617
|
+
const showError = !!error && (touched || state.submitAttempted);
|
|
7618
|
+
const onOpen = useCallback(async () => {
|
|
7619
|
+
await handlers.onOpenMedicationOrders?.();
|
|
7620
|
+
setTouched();
|
|
7621
|
+
}, [handlers, setTouched]);
|
|
7622
|
+
if (!fieldDef || fieldDef.type !== "textarea") return null;
|
|
7623
|
+
const textDef = fieldDef;
|
|
7624
|
+
const height = textDef.height;
|
|
7625
|
+
const theme = getThemeConfig("textarea", fieldDef.theme);
|
|
7626
|
+
const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
|
|
7627
|
+
const labelClass = theme?.labelClassName;
|
|
7628
|
+
const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7629
|
+
fieldDef.label,
|
|
7630
|
+
" ",
|
|
7631
|
+
fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
|
|
7632
|
+
] });
|
|
7633
|
+
const labelEl = theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, children: labelContent });
|
|
7634
|
+
const text = typeof value === "string" ? value : value == null ? "" : String(value);
|
|
7635
|
+
const hasHandler = typeof handlers.onOpenMedicationOrders === "function";
|
|
7636
|
+
return /* @__PURE__ */ jsxs("div", { className: wrapperClass, children: [
|
|
7637
|
+
labelEl,
|
|
7638
|
+
fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: fieldDef.description }),
|
|
7639
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-3", children: [
|
|
7640
|
+
/* @__PURE__ */ jsx(
|
|
7641
|
+
"div",
|
|
7642
|
+
{
|
|
7643
|
+
id: fieldId,
|
|
7644
|
+
className: cn(
|
|
7645
|
+
"min-h-[80px] flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm whitespace-pre-wrap",
|
|
7646
|
+
showError && "border-red-500",
|
|
7647
|
+
!text && "text-muted-foreground"
|
|
7648
|
+
),
|
|
7649
|
+
style: height != null ? { minHeight: height } : void 0,
|
|
7650
|
+
"aria-readonly": "true",
|
|
7651
|
+
children: text || fieldDef.placeholder || "No medication orders added."
|
|
7652
|
+
}
|
|
7653
|
+
),
|
|
7654
|
+
/* @__PURE__ */ jsx(
|
|
7655
|
+
Button,
|
|
7656
|
+
{
|
|
7657
|
+
type: "button",
|
|
7658
|
+
variant: "default",
|
|
7659
|
+
disabled: disabled || !hasHandler,
|
|
7660
|
+
onClick: onOpen,
|
|
7661
|
+
className: "shrink-0 sm:mt-0",
|
|
7662
|
+
children: "Add medication orders"
|
|
7663
|
+
}
|
|
7664
|
+
)
|
|
7665
|
+
] }),
|
|
7666
|
+
showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
|
|
7667
|
+
] });
|
|
7668
|
+
};
|
|
7669
|
+
function parseFieldValue(value) {
|
|
7670
|
+
if (value == null) return { orders: [], display_lines: [] };
|
|
7671
|
+
if (Array.isArray(value)) {
|
|
7672
|
+
return {
|
|
7673
|
+
orders: value,
|
|
7674
|
+
display_lines: value.map(() => null)
|
|
7675
|
+
};
|
|
7676
|
+
}
|
|
7677
|
+
if (typeof value === "object") {
|
|
7678
|
+
const v = value;
|
|
7679
|
+
const orders = Array.isArray(v.orders) ? v.orders : [];
|
|
7680
|
+
const rawLines = Array.isArray(v.display_lines) ? v.display_lines : Array.isArray(v.displayLines) ? v.displayLines : [];
|
|
7681
|
+
const display_lines = orders.map((_, i) => rawLines[i] ?? null);
|
|
7682
|
+
return { orders, display_lines };
|
|
7683
|
+
}
|
|
7684
|
+
return { orders: [], display_lines: [] };
|
|
7685
|
+
}
|
|
7686
|
+
function normalizePrescription(res) {
|
|
7687
|
+
const pharmacyOrderId = res.pharmacy_order_id ?? void 0;
|
|
7688
|
+
const orders = Array.isArray(res.orders) ? res.orders : [];
|
|
7689
|
+
const linesRaw = Array.isArray(res.display_lines) ? res.display_lines : [];
|
|
7690
|
+
const mapped = orders.filter((o) => o && typeof o.id === "string").map((o) => ({
|
|
7691
|
+
id: o.id,
|
|
7692
|
+
item_id: o.item_id == null ? void 0 : String(o.item_id),
|
|
7693
|
+
item_name: o.item_name ?? void 0,
|
|
7694
|
+
generic_name: o.generic_name ?? void 0,
|
|
7695
|
+
dose: o.dose == null ? void 0 : String(o.dose),
|
|
7696
|
+
route: o.route ?? void 0,
|
|
7697
|
+
frequency: o.frequency ?? void 0,
|
|
7698
|
+
admin_times: Array.isArray(o.admin_times) ? o.admin_times : void 0,
|
|
7699
|
+
meal_sleep_timing: o.meal_sleep_timing ?? void 0,
|
|
7700
|
+
start_date: o.start_date ?? void 0,
|
|
7701
|
+
end_date: o.end_date ?? void 0,
|
|
7702
|
+
order_type: o.order_type ?? void 0,
|
|
7703
|
+
status: o.status ?? void 0,
|
|
7704
|
+
notes: o.notes ?? null,
|
|
7705
|
+
pharmacy_order_id: pharmacyOrderId
|
|
7706
|
+
}));
|
|
7707
|
+
const display_lines = mapped.map((_, i) => linesRaw[i] ?? null);
|
|
7708
|
+
return { orders: mapped, display_lines };
|
|
7709
|
+
}
|
|
7710
|
+
function formatDuration(start, end) {
|
|
7711
|
+
if (!start && !end) return null;
|
|
7712
|
+
if (start && end) return `${start} \u2192 ${end}`;
|
|
7713
|
+
return start ? `Start: ${start}` : `End: ${end}`;
|
|
7714
|
+
}
|
|
7715
|
+
var DischargeMedicationOrdersWidget = ({ fieldId }) => {
|
|
7716
|
+
const { fieldDef, value, setValue, setTouched, error, disabled, touched, visible } = useField(fieldId);
|
|
7717
|
+
const { state } = useForm();
|
|
7718
|
+
const handlers = useFieldHandlers(fieldId);
|
|
7719
|
+
const showError = !!error && (touched || state.submitAttempted);
|
|
7720
|
+
const { orders, display_lines } = useMemo(() => parseFieldValue(value), [value]);
|
|
7721
|
+
const onAdd = useCallback(async () => {
|
|
7722
|
+
setTouched();
|
|
7723
|
+
const fn = handlers.onOpenDischargeMedicationOrders;
|
|
7724
|
+
if (!fn) return;
|
|
7725
|
+
const res = await fn();
|
|
7726
|
+
if (!res || typeof res !== "object") return;
|
|
7727
|
+
const normalized = normalizePrescription(res);
|
|
7728
|
+
setValue({
|
|
7729
|
+
orders: normalized.orders,
|
|
7730
|
+
display_lines: normalized.display_lines
|
|
7731
|
+
});
|
|
7732
|
+
}, [handlers.onOpenDischargeMedicationOrders, setTouched, setValue]);
|
|
7733
|
+
const onDelete = useCallback(
|
|
7734
|
+
(id) => {
|
|
7735
|
+
setTouched();
|
|
7736
|
+
const idx = orders.findIndex((o) => o.id === id);
|
|
7737
|
+
if (idx === -1) return;
|
|
7738
|
+
setValue({
|
|
7739
|
+
orders: orders.filter((o) => o.id !== id),
|
|
7740
|
+
display_lines: display_lines.filter((_, i) => i !== idx)
|
|
7741
|
+
});
|
|
7742
|
+
},
|
|
7743
|
+
[orders, display_lines, setTouched, setValue]
|
|
7744
|
+
);
|
|
7745
|
+
if (!visible || !fieldDef) return null;
|
|
7746
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
7747
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
7748
|
+
/* @__PURE__ */ jsxs(Label, { className: "text-sm font-medium", children: [
|
|
7749
|
+
fieldDef.label,
|
|
7750
|
+
" ",
|
|
7751
|
+
fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
|
|
7752
|
+
] }),
|
|
7753
|
+
/* @__PURE__ */ jsx(Button, { type: "button", onClick: onAdd, disabled: disabled || !handlers.onOpenDischargeMedicationOrders, children: "Add medicine" })
|
|
7754
|
+
] }),
|
|
7755
|
+
fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: fieldDef.description }),
|
|
7756
|
+
orders.length === 0 ? /* @__PURE__ */ jsx(
|
|
7757
|
+
"div",
|
|
7758
|
+
{
|
|
7759
|
+
className: cn(
|
|
7760
|
+
"rounded-md border border-input bg-background px-3 py-3 text-sm text-muted-foreground",
|
|
7761
|
+
showError && "border-red-500"
|
|
7762
|
+
),
|
|
7763
|
+
children: "No medicines added."
|
|
7764
|
+
}
|
|
7765
|
+
) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: orders.map((o, rowIdx) => {
|
|
7766
|
+
const line = display_lines[rowIdx];
|
|
7767
|
+
const duration = formatDuration(o.start_date, o.end_date);
|
|
7768
|
+
const header = typeof line?.name === "string" && line.name.trim() || o.item_name || "Medicine";
|
|
7769
|
+
const sub = o.generic_name ? o.generic_name : null;
|
|
7770
|
+
const line1 = [o.dose && `Dose: ${o.dose}`, o.route && `Route: ${o.route}`].filter(Boolean).join(" \u2022 ");
|
|
7771
|
+
const line2 = [
|
|
7772
|
+
o.frequency && `Freq: ${o.frequency}`,
|
|
7773
|
+
o.meal_sleep_timing && `Meal/Sleep: ${o.meal_sleep_timing}`,
|
|
7774
|
+
o.admin_times?.length ? `Times: ${o.admin_times.join(", ")}` : null
|
|
7775
|
+
].filter(Boolean).join(" \u2022 ");
|
|
7776
|
+
const line3 = [
|
|
7777
|
+
duration ? `Duration: ${duration}` : null,
|
|
7778
|
+
o.order_type ? `Type: ${o.order_type}` : null,
|
|
7779
|
+
o.status ? `Status: ${o.status}` : null
|
|
7780
|
+
].filter(Boolean).join(" \u2022 ");
|
|
7781
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-input bg-background p-3", children: [
|
|
7782
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
7783
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
7784
|
+
/* @__PURE__ */ jsx("div", { className: "font-semibold text-sm truncate", children: header }),
|
|
7785
|
+
sub && /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground mt-0.5 truncate", children: sub })
|
|
7786
|
+
] }),
|
|
7787
|
+
/* @__PURE__ */ jsx(
|
|
7788
|
+
Button,
|
|
7789
|
+
{
|
|
7790
|
+
type: "button",
|
|
7791
|
+
variant: "ghost",
|
|
7792
|
+
className: "h-8 w-8 p-0 text-destructive",
|
|
7793
|
+
onClick: () => onDelete(o.id),
|
|
7794
|
+
"aria-label": "Delete medicine",
|
|
7795
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
|
|
7796
|
+
}
|
|
7797
|
+
)
|
|
7798
|
+
] }),
|
|
7799
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-2 space-y-1 text-xs text-muted-foreground", children: [
|
|
7800
|
+
line1 && /* @__PURE__ */ jsx("div", { children: line1 }),
|
|
7801
|
+
line2 && /* @__PURE__ */ jsx("div", { children: line2 }),
|
|
7802
|
+
line3 && /* @__PURE__ */ jsx("div", { children: line3 }),
|
|
7803
|
+
o.notes && /* @__PURE__ */ jsxs("div", { className: "text-foreground/80", children: [
|
|
7804
|
+
"Notes: ",
|
|
7805
|
+
o.notes
|
|
7806
|
+
] })
|
|
7807
|
+
] })
|
|
7808
|
+
] }, o.id);
|
|
7809
|
+
}) }),
|
|
7810
|
+
showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
|
|
7811
|
+
] });
|
|
7812
|
+
};
|
|
7542
7813
|
var FieldRenderer = ({ fieldId }) => {
|
|
7543
7814
|
const { fieldDef, visible } = useField(fieldId);
|
|
7544
7815
|
if (!visible || !fieldDef) {
|
|
@@ -7552,6 +7823,9 @@ function renderWidget(fieldId, fieldDef) {
|
|
|
7552
7823
|
case "number":
|
|
7553
7824
|
return /* @__PURE__ */ jsx(TextWidget, { fieldId });
|
|
7554
7825
|
case "textarea":
|
|
7826
|
+
if (fieldMetaRequestsMarMedicationOrdersButton(fieldDef.meta)) {
|
|
7827
|
+
return /* @__PURE__ */ jsx(MarMedicationOrdersWidget, { fieldId });
|
|
7828
|
+
}
|
|
7555
7829
|
return /* @__PURE__ */ jsx(TextWidget, { fieldId });
|
|
7556
7830
|
case "richtext":
|
|
7557
7831
|
return /* @__PURE__ */ jsx(RichTextWidget, { fieldId });
|
|
@@ -7579,6 +7853,8 @@ function renderWidget(fieldId, fieldDef) {
|
|
|
7579
7853
|
return /* @__PURE__ */ jsx(EditableTableWidget, { fieldId });
|
|
7580
7854
|
case "medications":
|
|
7581
7855
|
return /* @__PURE__ */ jsx(AddMedicationWidget, { fieldId });
|
|
7856
|
+
case "discharge_medication_orders":
|
|
7857
|
+
return /* @__PURE__ */ jsx(DischargeMedicationOrdersWidget, { fieldId });
|
|
7582
7858
|
case "investigations":
|
|
7583
7859
|
return /* @__PURE__ */ jsx(AddInvestigationWidget, { fieldId });
|
|
7584
7860
|
case "procedures":
|
|
@@ -8206,6 +8482,53 @@ var ReadOnlyReferral = ({ fieldDef, value }) => {
|
|
|
8206
8482
|
}) })
|
|
8207
8483
|
] });
|
|
8208
8484
|
};
|
|
8485
|
+
function isOrderArray(value) {
|
|
8486
|
+
return Array.isArray(value) && value.every(
|
|
8487
|
+
(v) => v != null && typeof v === "object" && typeof v.id === "string"
|
|
8488
|
+
);
|
|
8489
|
+
}
|
|
8490
|
+
function formatDuration2(start, end) {
|
|
8491
|
+
if (!start && !end) return null;
|
|
8492
|
+
if (start && end) return `${start} \u2192 ${end}`;
|
|
8493
|
+
return start ? `Start: ${start}` : `End: ${end}`;
|
|
8494
|
+
}
|
|
8495
|
+
var ReadOnlyDischargeMedicationOrders = ({ fieldDef, value }) => {
|
|
8496
|
+
const orders = useMemo(() => isOrderArray(value) ? value : [], [value]);
|
|
8497
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
8498
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-gray-700", children: fieldDef.label }),
|
|
8499
|
+
orders.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-gray-900 border border-gray-200 rounded-md p-3 bg-gray-50 min-h-[2.5rem]", children: /* @__PURE__ */ jsx("span", { className: "text-gray-400 italic", children: "No medicines added" }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: orders.map((o) => {
|
|
8500
|
+
const duration = formatDuration2(o.start_date, o.end_date);
|
|
8501
|
+
const header = o.item_name ?? "Medicine";
|
|
8502
|
+
const sub = o.generic_name ? o.generic_name : null;
|
|
8503
|
+
const line1 = [o.dose && `Dose: ${o.dose}`, o.route && `Route: ${o.route}`].filter(Boolean).join(" \u2022 ");
|
|
8504
|
+
const line2 = [
|
|
8505
|
+
o.frequency && `Freq: ${o.frequency}`,
|
|
8506
|
+
o.meal_sleep_timing && `Meal/Sleep: ${o.meal_sleep_timing}`,
|
|
8507
|
+
o.admin_times?.length ? `Times: ${o.admin_times.join(", ")}` : null
|
|
8508
|
+
].filter(Boolean).join(" \u2022 ");
|
|
8509
|
+
const line3 = [
|
|
8510
|
+
duration ? `Duration: ${duration}` : null,
|
|
8511
|
+
o.order_type ? `Type: ${o.order_type}` : null,
|
|
8512
|
+
o.status ? `Status: ${o.status}` : null
|
|
8513
|
+
].filter(Boolean).join(" \u2022 ");
|
|
8514
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-gray-200 bg-gray-50 p-3", children: [
|
|
8515
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
8516
|
+
/* @__PURE__ */ jsx("div", { className: "font-semibold text-sm truncate text-gray-900", children: header }),
|
|
8517
|
+
sub && /* @__PURE__ */ jsx("div", { className: "text-xs text-gray-500 mt-0.5 truncate", children: sub })
|
|
8518
|
+
] }),
|
|
8519
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-2 space-y-1 text-xs text-gray-600", children: [
|
|
8520
|
+
line1 && /* @__PURE__ */ jsx("div", { children: line1 }),
|
|
8521
|
+
line2 && /* @__PURE__ */ jsx("div", { children: line2 }),
|
|
8522
|
+
line3 && /* @__PURE__ */ jsx("div", { children: line3 }),
|
|
8523
|
+
o.notes && /* @__PURE__ */ jsxs("div", { className: "text-gray-800/90", children: [
|
|
8524
|
+
"Notes: ",
|
|
8525
|
+
o.notes
|
|
8526
|
+
] })
|
|
8527
|
+
] })
|
|
8528
|
+
] }, o.id);
|
|
8529
|
+
}) })
|
|
8530
|
+
] });
|
|
8531
|
+
};
|
|
8209
8532
|
var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
|
|
8210
8533
|
if (!fieldDef) return null;
|
|
8211
8534
|
switch (fieldDef.type) {
|
|
@@ -8238,6 +8561,8 @@ var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
|
|
|
8238
8561
|
return /* @__PURE__ */ jsx(ReadOnlyTable, { fieldDef, value });
|
|
8239
8562
|
case "referral":
|
|
8240
8563
|
return /* @__PURE__ */ jsx(ReadOnlyReferral, { fieldDef, value });
|
|
8564
|
+
case "discharge_medication_orders":
|
|
8565
|
+
return /* @__PURE__ */ jsx(ReadOnlyDischargeMedicationOrders, { fieldDef, value });
|
|
8241
8566
|
case "static_text": {
|
|
8242
8567
|
const def = fieldDef;
|
|
8243
8568
|
const size = def.size ?? "regular";
|
|
@@ -8439,6 +8764,6 @@ function createUploadHandler(options) {
|
|
|
8439
8764
|
};
|
|
8440
8765
|
}
|
|
8441
8766
|
|
|
8442
|
-
export { AddInvestigationField, AddMedicationField, DifferentialDiagnosis, DynamicForm, EMAIL_REGEX, FieldRenderer, FormControls, FormProvider, FormStore, ImageUploadWidget, MediaUploadWidget, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, RichTextWidget, SignatureUploadWidget, SmartForm, SmartTextareaWidget, createUploadHandler, evaluateRules, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, useSmartKeywords, validateField, validateForm };
|
|
8767
|
+
export { AddInvestigationField, AddMedicationField, DifferentialDiagnosis, DynamicForm, EMAIL_REGEX, FieldRenderer, FormControls, FormProvider, FormStore, ImageUploadWidget, MAR_MEDICATION_ORDERS_META_KEY, MediaUploadWidget, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, RichTextWidget, SignatureUploadWidget, SmartForm, SmartTextareaWidget, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|
|
8443
8768
|
//# sourceMappingURL=index.mjs.map
|
|
8444
8769
|
//# sourceMappingURL=index.mjs.map
|