export enum MedicineForm {
  TABLET = 'tablet',
  CAPSULE = 'capsule',
  LIQUID = 'liquid',
  INJECTION = 'injection',
  OTHER = 'other',
}

export enum StrengthUnit {
  MG = 'mg',
  MCG = 'mcg',
  G = 'g',
  ML = 'ml',
  IU = 'IU',
  PERCENT = '%',
  OTHER = 'other',
}

export enum MedicineCategory {
  PRESCRIPTION = 'prescription',
  OTC = 'otc',
  SUPPLEMENT = 'supplement',
  OTHER = 'other',
}

export enum MedicineProductSource {
  MANUAL = 'manual',
  IMPORT = 'import',
}

export enum DosageUnit {
  TABLET = 'tablet',
  CAPSULE = 'capsule',
  ML = 'ml',
  VIAL = 'vial',
  DOSE = 'dose',
}

export enum ConcentrationUnit {
  MG_PER_ML = 'mg/mL',
  MCG_PER_ML = 'mcg/mL',
  UNITS_PER_ML = 'units/mL',
}

/** Returns the allowed DosageUnit values for a given MedicineForm. */
export function allowedUnitsForForm(form: MedicineForm): DosageUnit[] {
  switch (form) {
    case MedicineForm.TABLET:
      return [DosageUnit.TABLET];
    case MedicineForm.CAPSULE:
      return [DosageUnit.CAPSULE];
    case MedicineForm.LIQUID:
      return [DosageUnit.ML];
    case MedicineForm.INJECTION:
      return [DosageUnit.VIAL, DosageUnit.ML];
    case MedicineForm.OTHER:
      return [DosageUnit.DOSE];
  }
}

/** Returns the default DosageUnit for a given MedicineForm. */
export function defaultUnitForForm(form: MedicineForm): DosageUnit {
  return allowedUnitsForForm(form)[0];
}
