📁 Showcase
Drug master

Drug master

Set backend

1. Create SS of drug brands

// this spreadsheet stores information of drug brand
 
ensure spreadsheet: DrugBrandMaster
  withFields: [Brand]
  ofTypes: [text]
  modules: ["Pharmacy"]
  readRoleSet: [Owner]
  insertRoleSet: [Owner]
  removeRoleSet: [Owner]
  updateRoleSet: [Owner]
 
ensure spreadsheet DrugBrandMaster 
  searchables: [Brand]
 
ensure layoutSpreadsheet ListLayout kind: list
  filter.showSearchBar: true 
  firstLine.first.lineFields: [Brand]
 
ensure form FormDrugBrandMaster 
  label: "Brand"
  modules: ["Pharmacy"]
ctx rename EntityDrugBrand
 

2. Create SS of drug doses

// this spreadsheet stores information of drug dose
 
ensure spreadsheet: DrugDoseMaster
  withFields: [Dose]
  ofTypes: [text]
  modules: ["Pharmacy"]
  readRoleSet: [Owner]
  insertRoleSet: [Owner]
  removeRoleSet: [Owner]
  updateRoleSet: [Owner]
 
ensure spreadsheet DrugDoseMaster 
  searchables: [Dose]
 
ensure layoutSpreadsheet ListLayout kind: list 
  filter.showSearchBar: true 
  firstLine.first.lineFields: [Dose]
 
ensure form FormDrugDoseMaster 
  label: "Dose"
  modules: ["Pharmacy"]
ctx rename EntityDrugDose
 

3. Create SS of drug packages

// this spreadsheet stores information of drug package
 
ensure spreadsheet: DrugPackMaster
  withFields: [Pack]
  ofTypes: [text]
  modules: ["Pharmacy"]
  readRoleSet: [Owner]
  insertRoleSet: [Owner]
  removeRoleSet: [Owner]
  updateRoleSet: [Owner]
 
ensure spreadsheet DrugPackMaster 
  searchables: [Pack]
 
ensure layoutSpreadsheet ListLayout kind: list 
  filter.showSearchBar: true 
  firstLine.first.lineFields: [Pack]
 
ensure form FormDrugPackMaster 
  label: "Pack"
  modules: ["Pharmacy"]
ctx rename EntityDrugPack
 

3. Create SS of drugs

// this spreadsheet stores information of drug
 
ensure spreadsheet: DrugMaster
  withFields: [Name, Ingredient, MRP, Discount, DiscountedPrice]
  ofTypes: [text, text, number, number, number]
  modules: ["Pharmacy"]
  readRoleSet: [Owner]
  insertRoleSet: [Owner]
  removeRoleSet: [Owner]
  updateRoleSet: [Owner]
 
 
ensure form FormDrugMaster 
  label: "Drug"
  modules: ["Pharmacy"]
ctx rename EntityDrug
 
ensure section: Details
ensure Discount suffix: "%"
ensure MRP
  prefixVar: {
    'var': 'VarRupeeSymbol'
  }
ensure DiscountedPrice disabled: true
ensure field BrandRef kind: ref
  spreadsheet: DrugBrandMaster
  layoutSpreadsheet: ListLayout
  copyFieldMap: {
    'BrandMasterRowId': '$RowId',
    'Brand': 'Brand'
  }
ensure field BrandMasterRowId defaultValue: now
  permissionMatrix: {
      'defaultPermission': 'hide'
    }
ensure field DoseRef kind: ref
  spreadsheet: DrugDoseMaster
  layoutSpreadsheet: ListLayout
  copyFieldMap: {
    'DoseMasterRowId': '$RowId',
    'Dose': 'Dose'
  }
ensure field DoseMasterRowId defaultValue: now
  permissionMatrix: {
      'defaultPermission': 'hide'
    }
ensure field PackRef kind: ref
  spreadsheet: DrugPackMaster
  layoutSpreadsheet: ListLayout
  copyFieldMap: {
    'PackMasterRowId': '$RowId',
    'Pack': 'Pack'
  }
ensure field PackMasterRowId defaultValue: now
  permissionMatrix: {
      'defaultPermission': 'hide'
    }
 
//TODO this is lookup id but currently simple
ensure field BrandRef 
  categoryFilterDisplayField : Brand
 
ensure field BrandRef 
  categoryFilterDisplayField : Dose
 
ensure field PackRef 
  categoryFilterDisplayField : Pack
 
ensure formula DiscountedPriceFormula 
  assignToField: DiscountedPrice 
  formula: "(${f:MRP} - (${f:MRP} * (${f.Discount} / 100)))"
 
ensure spreadsheet DrugMaster 
  searchables: [Name, Ingredient, Brand, Dose, Pack, DiscountedPrice, MRP, Discount]
  queryables: [Brand, Dose, Pack, BrandMasterRowId, DoseMasterRowId, PackMasterRowId, DiscountedPrice]
 

Set frontend

1. Action to add brand

a. Action

// this action adds drug's brand information to spreadsheet
 
ensure action AddBrand kind: rowInsert 
  modules: ["Pharmacy"] 
  icon: "AddRounded" 
  spreadsheet: DrugBrandMaster 
  sendMessageToInbox: true
 

b. Prompt for action

// prompt for the action add brand
 
ensure prompt PromptAddBrand 
  modules: ["Pharmacy"] 
  action: AddBrand 
  promptText: "add brand ${f:Brand}" 
  permissionRoles: [Owner]
 

2. Editor for brand

// editor for brand spreadsheet
 
ensure action BrandMaster kind: spreadsheetEditor 
  modules: ["Pharmacy"] 
  icon: "CategoryRounded" 
  spreadsheet: DrugBrandMaster 
  layoutSpreadsheet: ListLayout 
  bulkInsertRoleSet: [Owner]
 

3. Action to add drug dose

a. Action

// this action adds drug's dose information to spreadsheet
 
ensure action AddDose kind: rowInsert 
  modules: ["Pharmacy"] 
  icon: "AddRounded" 
  spreadsheet: DrugDoseMaster 
  sendMessageToInbox: true
 

b. Prompt for action

// prompt for the action add dose
 
ensure prompt PromptAddDose 
  modules: ["Pharmacy"] 
  action: AddDose 
  promptText: "add dose ${f:Dose}" 
  permissionRoles: [Owner]
 

4. Editor for dose

// editor for dose spreadsheet
 
ensure action DoseMaster kind: spreadsheetEditor 
  modules: ["Pharmacy"] 
  icon: "CategoryRounded" 
  spreadsheet: DrugDoseMaster 
  layoutSpreadsheet: ListLayout 
  bulkInsertRoleSet: [Owner]
 

5. Action to add drug package

a. Action

// this action adds drug's pack information to spreadsheet
 
ensure action AddPack kind: rowInsert 
  modules: ["Pharmacy"] 
  icon: "AddRounded" 
  spreadsheet: DrugPackMaster 
  sendMessageToInbox: true
 

b. Prompt for action

// prompt for the action add pack
 
ensure prompt PromptAddPack 
  modules: ["Pharmacy"] 
  action: AddPack 
  promptText: "add pack ${f:Pack}" 
  permissionRoles: [Owner]
 

6. Editor for package

// editor for package spreadsheet
 
ensure action PackMaster kind: spreadsheetEditor 
  modules: ["Pharmacy"] 
  icon: "CategoryRounded" 
  spreadsheet: DrugPackMaster 
  layoutSpreadsheet: ListLayout 
  bulkInsertRoleSet: [Owner]
 

7. Action to add drug

// this actions adds drug to spreadsheet
 
ensure action AddDrug kind: rowInsert 
  modules: ["Pharmacy"] 
  icon: "AddRounded" 
  spreadsheet: DrugMaster 
  sendMessageToInbox: true
 

8. Editor for drug

// editor for drug spreadsheet
ensure spreadsheet DrugMaster
 
ensure layoutSpreadsheet Table kind: table 
  showComps: [Name, Ingredient, MRP, Discount, DiscountedPrice, Brand, Dose, Pack] 
 
ensure action DrugMaster kind: spreadsheetEditor 
  modules: ["Pharmacy"] 
  icon: "DatasetRounded" 
  spreadsheet: DrugMaster 
  layoutSpreadsheet: Table 
  bulkInsertRoleSet: [Owner]
 

9. Expose Actions through a Group

// this group contains all the actions those are required to add a drug
 
ensure group DrugMaster 
  modules: ["Pharmacy"] 
  allowPromptAssistant: true
pinnedActions: [DrugMaster, AddDrug] 
  actionPermission: {
      'AddBrand': {
        'menuGroup': 'ADD',
        'roles': [
          'Owner'
        ]
      },
      'AddDose': {
        'menuGroup': 'ADD',
        'roles': [
          'Owner'
        ]
      },
      'AddPack': {
        'menuGroup': 'ADD',
        'roles': [
          'Owner'
        ]
      },
      'AddDrug': {
        'menuGroup': 'ADD',
        'roles': [
          'Owner'
        ]
      },
      'BrandMaster': {
        'menuGroup': 'MASTER',
        'roles': [
          'Owner'
        ]
      },
      'DoseMaster': {
        'menuGroup': 'MASTER',
        'roles': [
          'Owner'
        ]
      },
      'PackMaster': {
        'menuGroup': 'MASTER',
        'roles': [
          'Owner'
        ]
      },
      'DrugMaster': {
        'menuGroup': 'MASTER',
        'roles': [
          'Owner'
        ]
      }
    }