📁 Docs
Script it

Script Pharmacy distributor

⚠️
We recommend finishing Tutorial: Task list to understand general usage before continuing here.

To create enterprise Pharmacy distributor, open terminal in the route studio by clicking the link https://web.neome.ai/studio (opens in a new tab).

Enterprise

The whole script to build the example below is available here. Open .neo files with a text editor of your choice, and copy and paste them into the terminal. Alternatively, walk the example below step by step.

Add an enterprise "Pharmacy distributor" by sending the commands below into the terminal.

// Create enterprise
add enterprise name:"Your Pharmacy distributor"
update enterprise about:"We sell drugs"
update enterprise timeZone:"Asia/Kolkata"
update enterprise displayDateFormat:"dd/MM/yyyy, HH:mm:ss"

Backend

1. Variables

// add variable to store ₹ symbol
ensure variable VarTextRupeeSymbol kind:"Text"
update variable VarTextRupeeSymbol value:"₹"

2. Roles

//add role Owner
ensure role Owner

3. Spreadsheets

a. BrandMaster

• Create form
// create form FormBrand to provide structure to the spreadsheet BrandMaster
 
ensure form FormBrand
update form FormBrand label:"Brand"
 
ensure section Details
 
ensure field Brand type:"text"
• Associate form
//add spreadsheet BrandMaster
ensure spreadsheet BrandMaster form:"FormBrand"
update spreadsheet BrandMaster searchableFields:"Brand"
• Associate permissions
ensure spreadsheetPermission insertRoles:"Owner"
ensure spreadsheetPermission updateRoles:"Owner"
ensure spreadsheetPermission removeRoles:"Owner"
• Associate layout
// Associate layout to spreadsheet BrandMaster
ensure spreadsheetLayout ListLayout kind:"list"
update spreadsheetLayout ListLayout showSearchBar:"yes"
update spreadsheetLayoutListItem line:"first" segment:"first" source:"field" text:"Brand"

b. DoseMaster

• Create form
// create form FormDose to provide structure to the spreadsheet DoseMaster
 
ensure form FormDose
update form FormDose label:"Dose"
 
ensure section Details
 
ensure field Dose type:"text"
• Associate form
//add spreadsheet DoseMaster
ensure spreadsheet DoseMaster form:"FormDose"
update spreadsheet DoseMaster searchableFields:"Dose"
• Associate permissions
ensure spreadsheetPermission insertRoles:"Owner"
ensure spreadsheetPermission updateRoles:"Owner"
ensure spreadsheetPermission removeRoles:"Owner"
• Associate layout
// Associate layout to spreadsheet DoseMaster
ensure spreadsheetLayout ListLayout kind:"list"
update spreadsheetLayout ListLayout showSearchBar:"yes"
update spreadsheetLayoutListItem line:"first" segment:"first" source:"field" text:"Dose"

c. PackMaster

• Create form
//add form FormPack
ensure form FormPack
update form FormPack label:"Pack"
 
ensure section Details
 
ensure field Pack type:"text"
• Associate form
//add spreadsheet packMaster
ensure spreadsheet PackMaster form:"FormPack"
update spreadsheet PackMaster searchableFields:"Pack"
• Associate permissions
ensure spreadsheetPermission insertRoles:"Owner"
ensure spreadsheetPermission updateRoles:"Owner"
ensure spreadsheetPermission removeRoles:"Owner"
• Associate layout
// Associate layout to spreadsheet packMaster
 
ensure spreadsheetLayout ListLayout kind:"list"
update spreadsheetLayout ListLayout showSearchBar:"yes"
update spreadsheetLayoutListItem line:"first" segment:"first" source:"field" text:"Pack"

d. ItemMaster

• Create form
// associate the form FormItem with the spreadsheet ItemMaster
 
ensure form FormItem
update form FormItem label:"Medicine"
 
//** section Details
 
ensure section Details
 
ensure field Name type:"Text"
update Field Name required:"yes"
 
ensure field Ingredient type:"text"
update field Ingredient required:"yes"
 
ensure field MRP type:"number"
update field MRP prefix:"VarTextRupeeSymbol"
update field MRP required:"yes"
 
ensure field Discount type:"number"
update field Discount suffix:"%"
update field Discount label:"Discount %"
 
ensure field DiscountedPrice type:"number"
update field DiscountedPrice prefix:"VarTextRupeeSymbol"
update field DiscountedPrice formula:"(${f:Details.MRP} - (${f:Details.MRP} * (${f:Details.Discount} / 100)))"
 
ensure field BrandRef type:"ref" spreadsheet:"BrandMaster"
update field BrandRef spreadsheetLayout:"ListLayout"
update field BrandRef copyFields:"Brand,$RowId"
update field BrandRef categoryFilterDisplayField:"Brand"
 
ensure field DoseRef type:"ref" spreadsheet:"DoseMaster"
update field DoseRef spreadsheetLayout:"ListLayout"
update field DoseRef copyFields:"Dose,$RowId"
update field DoseRef categoryFilterDisplayField:"Dose"
 
ensure field PackRef type:"ref" spreadsheet:"PackMaster"
update field PackRef spreadsheetLayout:"ListLayout"
update field PackRef copyFields:"Pack,$RowId"
update field PackRef categoryFilterDisplayField:"Pack"
• Associate form
// Add spreadsheet ItemMaster
ensure spreadsheet ItemMaster form:"FormItem"
update spreadsheet ItemMaster searchableFields:"Name,Ingredient,Brand,Dose,Pack,DiscountedPrice,MRP,Discount"
update spreadsheet ItemMaster queryableFields:"Brand,Dose,Pack,BrandMasterRowId,DoseMasterRowId,PackMasterRowId,DiscountedPrice"
• Associate permissions
ensure spreadsheetPermission insertRoles:"Owner"
ensure spreadsheetPermission updateRoles:"Owner"
ensure spreadsheetPermission removeRoles:"Owner"
• Associate layout
ensure spreadsheetLayout ListLayout kind:"list"
 
update spreadsheetLayout ListLayout kind:"tree" showSearchBar:"yes"
update spreadsheetLayout ListLayout categoryFields:"BrandRef,DoseRef,PackRef"
update spreadsheetLayout ListLayout advanceFilterFields:"DiscountedPrice"
 
update spreadsheetLayoutListItem line:"first" segment:"first" source:"field" text:"Name"
update spreadsheetLayoutListItem line:"second" segment:"first" source:"field" text:"Ingredient" showLabels:"yes"
update spreadsheetLayoutListItem line:"third" segment:"first" source:"field" text:"Brand" showLabels:"yes"
update spreadsheetLayoutListItem line:"fourth" segment:"first" source:"field" text:"Dose,Pack" showLabels:"yes"
update spreadsheetLayoutListItem line:"fifth" segment:"first" source:"field" text:"MRP,Discount,DiscountedPrice" showLabels:"yes"

e. OrderBook

• Create form
// add the form FormOrder to provide structure to the spreadsheet OrderBook
 
ensure form FormOrder
update form FormOrder label:"Order"
ensure formPermission commentRoles:"Owner,$Public" allowToPrintForm:"Yes"
 
//** grid Items
 
ensure grid Items
 
ensure field Quantity type:"counter"
 
ensure field MedicineRef type:"ref" spreadsheet:"ItemMaster"
 
update field MedicineRef spreadsheetLayout:"ListLayout"
update field MedicineRef copyFields:"$RowId,Name,Ingredient,Brand,Dose,Pack,DiscountedPrice,MRP"
update field MedicineRef forceOpenOnFormCreate:"yes"
update fieldRefOverlayLayout line:"first" segment:"caption" source:"field" text:"Items.Quantity"
 
ensure field Total type:"number"
update field Total formula:"${f:Items.DiscountedPrice} * ${f:Items.Quantity}"
 
// attach list layout to grid Items
 
ensure gridLayout ListLayout kind:"list"
 
update gridLayoutListItem line:"first" segment:"first" source:"field" text:"Name"
update gridLayoutListItem line:"first" segment:"caption" source:"field" text:"Quantity"
update gridLayoutListItem line:"second" segment:"first" source:"field" text:"Ingredient" showLabels:"yes"
update gridLayoutListItem line:"third" segment:"first" source:"field" text:"Brand" showLabels:"yes"
update gridLayoutListItem line:"fourth" segment:"first" source:"field" text:"Dose,Pack" showLabels:"yes"
update gridLayoutListItem line:"fifth" segment:"first" source:"field" text:"DiscountedPrice" showLabels:"yes"
 
update grid Items asideDefaultLayout:"ListLayout"
 
// attach table layout to grid Items
 
ensure gridLayout TableLayout kind:"table"
 
update gridLayout TableLayout showFields:"Name,Ingredient,Brand,Dose,Pack,DiscountedPrice,Quantity,Total"
update gridLayout TableLayout columnSizes:"AutoSize"
 
//** section details
 
ensure section Details
 
ensure field Date type:"Date"
update field Date defaultValue:"now"
 
ensure field Name type:"text"
update field Name required:"yes"
 
ensure field Address type:"paragraph"
update field Address required:"yes"
 
ensure field MobileNumber type:"mobileNumber"
update field MobileNumber helperText:"Start with +91xxxxxxxxxx"
update field MobileNumber required:"yes"
 
//** section Summary
 
ensure section Summary
 
ensure field TotalBill type:"number"
update field TotalBill prefix:"VarTextRupeeSymbol"
update field TotalBill formula:"SUM(${f:Items.Total})"
• Associate Content Layout
// add form content layout
 
ensure formLayoutContent DlOrderContentlayout
update formLayoutContent DlOrderContentlayout direction:"vertical"
 
update formLayoutContent DlOrderContentlayout position:"start" fields:"Date,Name,Address,MobileNumber"
update formLayoutContent DlOrderContentlayout position:"start" showItemBorders:"top,bottom" showItemPadding:"top,bottom" padding:"thick"
 
update formLayoutContent DlOrderContentlayout position:"flexCenter" gridLayouts:"Items.TableLayout"
update formLayoutContent DlOrderContentlayout position:"flexCenter" showItemPadding:"top,bottom" padding:"thick"
 
update formLayoutContent DlOrderContentlayout position:"end" fields:"TotalBill"
update formLayoutContent DlOrderContentlayout position:"end" showItemBorders:"top" showItemPadding:"top,bottom" padding:"thick"
 
// add form layout header
 
update formLayoutHeader showEnterprise:"yes"
• Associate form
// associate the form FormOrder with the spreadsheet OrderBook
 
ensure spreadsheet OrderBook form:"FormOrder"
update Spreadsheet OrderBook searchableFields:"Name,Address,MobileNumber,TotalBill"
• Associate permissions
ensure spreadsheetPermission insertRoles:"Owner,$Public"
ensure spreadsheetPermission readRoles:"Owner"
ensure spreadsheetPermission updateRoles:"Owner"
ensure spreadsheetPermission removeRoles:"Owner"
• Associate layout
// Add a table layout to spreadsheet OrderBook
ensure spreadsheetLayout TableLayout kind:"table"
 
update spreadsheetLayout TableLayout showFields:"Date,Name,Address,MobileNumber,TotalBill"
update spreadsheetLayout TableLayout masterDetailGrids:"Items"
update spreadsheetLayout TableLayout columnSizes:"AutoSize"
update spreadsheetLayout TableLayout showCommentCount:"yes"

Frontend

Actions

a. AddBrand

// Add action AddBrand to allow admin to add brand of medicine
ensure action AddBrand kind:"rowInsert"
 
update action AddBrand spreadsheet:"BrandMaster"
update action AddBrand icon:"AddRounded"
update action AddBrand sendMessageToInbox:"yes"

b. BrandMaster

ensure action BrandMaster kind:"spreadsheetEditor"
 
update action BrandMaster spreadsheet:"BrandMaster"
update action BrandMaster spreadsheetLayout:"ListLayout"
update action BrandMaster icon:"CategoryRounded"

c. AddDose

// Add action AddDose to allow admin to add dose of medicine
ensure action AddDose kind:"rowInsert"
 
update action AddDose spreadsheet:"DoseMaster"
update action AddDose icon:"AddRounded"
update action AddDose sendMessageToInbox:"yes"

d. DoseMaster

ensure action DoseMaster kind:"spreadsheetEditor"
 
update action DoseMaster spreadsheet:"DoseMaster"
update action DoseMaster spreadsheetLayout:"ListLayout"
update action DoseMaster icon:"CategoryRounded"

e. AddPack

// Add action AddPack to allow Owner to add pack of medicine
ensure action AddPack kind:"rowInsert"
 
update action AddPack spreadsheet:"PackMaster"
update action AddPack icon:"AddRounded"
update action AddPack sendMessageToInbox:"yes"

f. PackMaster

ensure action PackMaster kind:"spreadsheetEditor"
 
update action PackMaster spreadsheet:"PackMaster"
update action PackMaster spreadsheetLayout:"ListLayout"
update action PackMaster icon:"CategoryRounded"

g. AddItem

// Add action AddItem to allow Owner to add medicines
ensure action AddItem kind:"rowInsert"
 
update action AddItem spreadsheet:"ItemMaster"
update action AddItem icon:"AddRounded"
update action AddItem sendMessageToInbox:"yes"

h. ItemMaster

// Create action to display ItemSheet
ensure action ItemMaster kind:"spreadsheetEditor"
 
update action ItemMaster spreadsheet:"ItemMaster"
update action ItemMaster spreadsheetLayout:"ListLayout"
update action ItemMaster icon:"DatasetRounded"

i. AddOrder

// Add action AddOrder to allow Owner to add customer orders
ensure action AddOrder kind:"rowInsert"
 
update action AddOrder spreadsheet:"OrderBook"
update action AddOrder icon:"AddRounded"
update action AddOrder sendMessageToInbox:"yes"

j. OrderBook

// Create action to display OrderBook
ensure action OrderBook kind:"spreadsheetEditor"
 
update action OrderBook spreadsheet:"OrderBook"
update action OrderBook spreadsheetLayout:"TableLayout"
update action OrderBook icon:"AddShoppingCartRounded"

Groups

a. Add groups

//Add group ItemMaster to add medicines
ensure group ItemMaster
 
// Add OrderBook to add order
ensure group OrderBook

b. Associate actions

goto group ItemMaster
ensure groupAction action:"AddBrand" menuGroup:"ADD" roles:"Owner"
ensure groupAction action:"AddDose" menuGroup:"ADD" roles:"Owner"
ensure groupAction action:"AddPack" menuGroup:"ADD" roles:"Owner"
ensure groupAction action:"AddItem" menuGroup:"ADD" roles:"Owner"
 
ensure groupAction action:"BrandMaster" menuGroup:"MASTER" roles:"Owner"
ensure groupAction action:"DoseMaster" menuGroup:"MASTER" roles:"Owner"
ensure groupAction action:"PackMaster" menuGroup:"MASTER" roles:"Owner"
ensure groupAction action:"ItemMaster" menuGroup:"MASTER" roles:"Owner"
 
update group ItemMaster pinnedActions:"BrandMaster,DoseMaster,PackMaster,ItemMaster"
 
goto group OrderBook
ensure groupAction action:"AddOrder" roles:"$Public, Owner"
ensure groupAction action:"OrderBook" roles:"Owner"
update group OrderBook pinnedActions:"AddOrder,OrderBook"

3. Deeplinks

a. AddOrder

// share order form to customers for them to order medicines
 
ensure deeplink DlAddOrder kind:"spreadsheetInsert"
 
update deeplink DlAddOrder spreadsheet:"OrderBook"
update deeplink DlAddOrder visibilityConstraint:"makeFollower"
update deeplink DlAddOrder creationRoles:"Owner"
update deeplink DlAddOrder showHeader:"yes"
update deeplink DlAddOrder showEnterprise:"yes"
update deeplink DlAddOrder showSeparator:"yes"
update deeplink DlAddOrder showEnterprisePreviewImage:"yes"
update deeplink DlAddOrder expiry:"noExpiry"
 
// to show success message after order
 
update deeplink DlAddOrder successMessage:"Thank you, ${p1} for your purchase of ${p2} with us!"
 
ensure deeplinkProp prop:"successMessage" param:"p1" value:"Name"  binder:"field"
ensure deeplinkProp prop:"successMessage" param:"p2" value:"TotalBill"  binder:"field"
 
// add a button to order again
 
update deeplink DlAddOrder showRepeatButton:"yes"
update deeplink DlAddOrder repeatButtonLabel:"Order Again"
 
// add hyperlink to show your website link
 
ensure variable VarHyperlinkWebsite kind:"Hyperlink"
update variable VarHyperlinkWebsite value:"https://neome.ai/" displayText:"Pharmacy Distributor"
update variable VarHyperlinkWebsite kind: "general"
 
update deeplink DlAddOrder hyperlinkVars:"VarHyperlinkWebsite"

b. FormOrder

ensure deeplink DlFormOrder kind:"spreadsheetRow"
 
update deeplink DlFormOrder spreadsheet:"OrderBook" formContentLayout: "DlOrderContentlayout"
 
update deeplink DlFormOrder visibilityConstraint:"allowPublicSharing"
update deeplink DlFormOrder showEnterprisePreviewImage:"yes"
update deeplink DlFormOrder creationRoles:"Owner"
update deeplink DlFormOrder expiry:"noExpiry"

Deploy

Send the command below into the terminal to deploy the enterprise.

deploy enterprise

Try your creation

To add users to enterprise application Pharmacy distributor through a UI,

  1. Open the route production by clicking the link https://web.neome.ai/production (opens in a new tab).
  2. Add users and give them the roles.

Alternatively you can add users by executing following scripts in the route terminal (opens in a new tab).

a. Try for yourself

// Add yourself as a demo user
ensureSelf user roles:"Owner"

b. Try for others

add user name:"SomeOwner" handle:"[email protected]" roles:"Owner"
 
inviteAll users