formanitor 0.0.14 → 0.0.16

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.d.cts CHANGED
@@ -217,6 +217,52 @@ interface SmartTextareaFieldDef extends BaseFieldDef {
217
217
  /** Debounce delay in ms before NLP + search triggers. Default: 1000. */
218
218
  debounceDelay?: number;
219
219
  }
220
+ interface MedicationFrequentItem {
221
+ id: string;
222
+ name: string;
223
+ short_name?: string;
224
+ /** Optional brand name to prefill into the medication row (falls back to name). */
225
+ brand_name?: string;
226
+ frequency?: string;
227
+ route?: string;
228
+ /**
229
+ * Optional human-readable duration like "5 days" or "2 weeks".
230
+ * If provided, Forminator will parse it unless duration_value/unit are set.
231
+ */
232
+ duration?: string;
233
+ /** Optional structured duration components (preferred over duration when present). */
234
+ duration_value?: string;
235
+ duration_unit?: 'days' | 'weeks' | 'months' | string;
236
+ /** Optional schedule slots; when omitted, Forminator falls back to "0". */
237
+ morning?: string;
238
+ afternoon?: string;
239
+ night?: string;
240
+ /** Optional food-timing hint; when omitted, Forminator defaults to "AFTER FOOD". */
241
+ before_after?: 'AFTER FOOD' | 'BEFORE FOOD' | string;
242
+ /** Optional notes; when omitted, Forminator may derive a note from route. */
243
+ notes?: string;
244
+ usage_count?: number;
245
+ last_used_at?: string;
246
+ }
247
+ interface InvestigationFrequentItem {
248
+ id: string;
249
+ name: string;
250
+ code?: string | null;
251
+ usage_count?: number;
252
+ last_used_at?: string;
253
+ }
254
+ interface ProcedureFrequentItem {
255
+ id: string;
256
+ name: string;
257
+ code?: string | null;
258
+ usage_count?: number;
259
+ last_used_at?: string;
260
+ }
261
+ interface DoctorFrequentItems {
262
+ medications?: MedicationFrequentItem[];
263
+ investigations?: InvestigationFrequentItem[];
264
+ procedures?: ProcedureFrequentItem[];
265
+ }
220
266
  type FieldDef = TextFieldDef | NumberFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | BaseFieldDef;
221
267
  interface Condition {
222
268
  field?: string;
@@ -493,10 +539,16 @@ type FieldHandler = {
493
539
  };
494
540
  type FieldHandlersMap = Record<string, FieldHandler>;
495
541
  declare function useFieldHandlers(fieldId: string): FieldHandler;
542
+ declare function useFrequentItems(): DoctorFrequentItems;
496
543
  interface FormProviderProps {
497
544
  schema: FormDef;
498
545
  config?: StoreConfig;
499
546
  fieldHandlers?: FieldHandlersMap;
547
+ /**
548
+ * Doctor-scoped frequently used items (e.g. from GET /api/doctor-state/frequent-items/).
549
+ * Consumer fetches and passes this; Forminator flows it to medications, investigations, and procedures widgets.
550
+ */
551
+ frequentItems?: DoctorFrequentItems;
500
552
  children: React.ReactNode;
501
553
  }
502
554
  declare const FormProvider: React.FC<FormProviderProps>;
@@ -658,14 +710,14 @@ type AIMedication = {
658
710
  };
659
711
 
660
712
  type MedicationSearchResult = {
661
- id: number;
713
+ id: string;
662
714
  name: string;
663
715
  generic_name?: string;
664
716
  manufacturer?: string;
665
717
  score?: number;
666
718
  };
667
719
  type Medication = {
668
- id: number;
720
+ id: string;
669
721
  brand_name: string;
670
722
  generic_name: string;
671
723
  frequency: string;
@@ -684,6 +736,8 @@ type AddMedicationFieldProps = {
684
736
  onChange: (items: Medication[]) => void;
685
737
  onSearch: (query: string) => Promise<MedicationSearchResult[]>;
686
738
  recentlyUsed?: MedicationSearchResult[];
739
+ /** Doctor-scoped frequently used medications (from FormProvider frequentItems) */
740
+ frequentItems?: MedicationFrequentItem[];
687
741
  /** AI-suggested medications shown as badges; clicking adds to value */
688
742
  suggestedMedications?: AIMedication[];
689
743
  };
@@ -720,6 +774,8 @@ type AddInvestigationFieldProps = {
720
774
  onChange: (items: Investigation[]) => void;
721
775
  onSearch: (query: string) => Promise<InvestigationSearchResult[]>;
722
776
  recentlyUsed?: InvestigationSearchResult[];
777
+ /** Doctor-scoped frequently used investigations (from FormProvider frequentItems) */
778
+ frequentItems?: InvestigationFrequentItem[];
723
779
  };
724
780
  declare const AddInvestigationField: React.FC<AddInvestigationFieldProps>;
725
781
 
@@ -762,4 +818,4 @@ declare const SmartTextareaWidget: React.FC<{
762
818
  fieldId: string;
763
819
  }>;
764
820
 
765
- export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, 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 InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type MatchedCondition, type Medication, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, 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, useSmartKeywords, validateField, validateForm };
821
+ export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, 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 Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, 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 };
package/dist/index.d.ts CHANGED
@@ -217,6 +217,52 @@ interface SmartTextareaFieldDef extends BaseFieldDef {
217
217
  /** Debounce delay in ms before NLP + search triggers. Default: 1000. */
218
218
  debounceDelay?: number;
219
219
  }
220
+ interface MedicationFrequentItem {
221
+ id: string;
222
+ name: string;
223
+ short_name?: string;
224
+ /** Optional brand name to prefill into the medication row (falls back to name). */
225
+ brand_name?: string;
226
+ frequency?: string;
227
+ route?: string;
228
+ /**
229
+ * Optional human-readable duration like "5 days" or "2 weeks".
230
+ * If provided, Forminator will parse it unless duration_value/unit are set.
231
+ */
232
+ duration?: string;
233
+ /** Optional structured duration components (preferred over duration when present). */
234
+ duration_value?: string;
235
+ duration_unit?: 'days' | 'weeks' | 'months' | string;
236
+ /** Optional schedule slots; when omitted, Forminator falls back to "0". */
237
+ morning?: string;
238
+ afternoon?: string;
239
+ night?: string;
240
+ /** Optional food-timing hint; when omitted, Forminator defaults to "AFTER FOOD". */
241
+ before_after?: 'AFTER FOOD' | 'BEFORE FOOD' | string;
242
+ /** Optional notes; when omitted, Forminator may derive a note from route. */
243
+ notes?: string;
244
+ usage_count?: number;
245
+ last_used_at?: string;
246
+ }
247
+ interface InvestigationFrequentItem {
248
+ id: string;
249
+ name: string;
250
+ code?: string | null;
251
+ usage_count?: number;
252
+ last_used_at?: string;
253
+ }
254
+ interface ProcedureFrequentItem {
255
+ id: string;
256
+ name: string;
257
+ code?: string | null;
258
+ usage_count?: number;
259
+ last_used_at?: string;
260
+ }
261
+ interface DoctorFrequentItems {
262
+ medications?: MedicationFrequentItem[];
263
+ investigations?: InvestigationFrequentItem[];
264
+ procedures?: ProcedureFrequentItem[];
265
+ }
220
266
  type FieldDef = TextFieldDef | NumberFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | BaseFieldDef;
221
267
  interface Condition {
222
268
  field?: string;
@@ -493,10 +539,16 @@ type FieldHandler = {
493
539
  };
494
540
  type FieldHandlersMap = Record<string, FieldHandler>;
495
541
  declare function useFieldHandlers(fieldId: string): FieldHandler;
542
+ declare function useFrequentItems(): DoctorFrequentItems;
496
543
  interface FormProviderProps {
497
544
  schema: FormDef;
498
545
  config?: StoreConfig;
499
546
  fieldHandlers?: FieldHandlersMap;
547
+ /**
548
+ * Doctor-scoped frequently used items (e.g. from GET /api/doctor-state/frequent-items/).
549
+ * Consumer fetches and passes this; Forminator flows it to medications, investigations, and procedures widgets.
550
+ */
551
+ frequentItems?: DoctorFrequentItems;
500
552
  children: React.ReactNode;
501
553
  }
502
554
  declare const FormProvider: React.FC<FormProviderProps>;
@@ -658,14 +710,14 @@ type AIMedication = {
658
710
  };
659
711
 
660
712
  type MedicationSearchResult = {
661
- id: number;
713
+ id: string;
662
714
  name: string;
663
715
  generic_name?: string;
664
716
  manufacturer?: string;
665
717
  score?: number;
666
718
  };
667
719
  type Medication = {
668
- id: number;
720
+ id: string;
669
721
  brand_name: string;
670
722
  generic_name: string;
671
723
  frequency: string;
@@ -684,6 +736,8 @@ type AddMedicationFieldProps = {
684
736
  onChange: (items: Medication[]) => void;
685
737
  onSearch: (query: string) => Promise<MedicationSearchResult[]>;
686
738
  recentlyUsed?: MedicationSearchResult[];
739
+ /** Doctor-scoped frequently used medications (from FormProvider frequentItems) */
740
+ frequentItems?: MedicationFrequentItem[];
687
741
  /** AI-suggested medications shown as badges; clicking adds to value */
688
742
  suggestedMedications?: AIMedication[];
689
743
  };
@@ -720,6 +774,8 @@ type AddInvestigationFieldProps = {
720
774
  onChange: (items: Investigation[]) => void;
721
775
  onSearch: (query: string) => Promise<InvestigationSearchResult[]>;
722
776
  recentlyUsed?: InvestigationSearchResult[];
777
+ /** Doctor-scoped frequently used investigations (from FormProvider frequentItems) */
778
+ frequentItems?: InvestigationFrequentItem[];
723
779
  };
724
780
  declare const AddInvestigationField: React.FC<AddInvestigationFieldProps>;
725
781
 
@@ -762,4 +818,4 @@ declare const SmartTextareaWidget: React.FC<{
762
818
  fieldId: string;
763
819
  }>;
764
820
 
765
- export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, 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 InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type MatchedCondition, type Medication, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, 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, useSmartKeywords, validateField, validateForm };
821
+ export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, 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 Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, 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 };