{
    "pluginname": "CMCH APP",
    "systemplugin": "0",
    "version": "1.0",
	"icon": "mif-delicious",
    "table_def": [{
            "name": "cmch_doctors",
            "fields": [{
                    "name": "name",
                    "type": "varchar(50)",
                    "other": "NOT NULL"
                }, {
                    "name": "qualification",
                    "type": "varchar(50)",
                    "other": "NOT NULL"
                }, {
                    "name": "specialization",
                    "type": "varchar(50)",
                    "other": "NOT NULL"
                }, {
                    "name": "daystime",
                    "type": "varchar(50)",
                    "other": "NOT NULL"
                }, {
                    "name": "mobilenum",
                    "type": "varchar(20)",
                    "other": "NOT NULL"
                }, {
                    "name": "email",
                    "type": "varchar(20)",
                    "other": "NOT NULL"
                }, {
                    "name": "in_out_status",
                    "type": "tinyint",
                    "other": "NOT NULL DEFAULT 0"
                }, {

                    "name": "mbbscertficate",
                    "type": "varchar(50)"
                }, {
                    "name": "mcireg",
                    "type": "varchar(50)"
                }, {
                    "name": "othercert1",
                    "type": "varchar(50)"
                }, {
                    "name": "othercert2",
                    "type": "varchar(50)"
                }, {
                    "name": "availability",
                    "type": "varchar(20)",
                    "other": "NOT NULL"
                }, {
                    "name": "image",
                    "type": "varchar(20)"
                }
            ]
        }, {
            "name": "cmch_doctorsattendance",
            "fields": [{
                    "name": "docid",
                    "type": "char(36)",
                    "other": "NOT NULL"
                }, {
                    "name": "intime",
                    "type": "datetime",
                    "other": "NOT NULL"
                }, {
                    "name": "outtime",
                    "type": "datetime",
                    "other": ""
                }, {
                    "name": "rounds",
                    "type": "tinyint",
                    "other": "NOT NULL"
                }
            ]
        }, {
            "name": "cmch_patient",
            "fields": [{
                    "name": "pname",
                    "type": "varchar(50)",
                    "other": "NOT NULL"
                }, {
                    "name": "pid",
                    "type": "char(6)",
                    "other": "UNIQUE NOT NULL"
                }, {
                    "name": "pgender",
                    "type": "tinyint",
                    "other": "NOT NULL DEFAULT 0"
                },{
                    "name": "pmaritalstatus",
                    "type": "tinyint",
                    "other": "NOT NULL DEFAULT 0"
                }, {
                    "name": "pmobile",
                    "type": "varchar(30)",
                    "other": "NOT NULL"
                }, {
                    "name": "paadhaar",
                    "type": "varchar(20)",
                    "other": ""
                }, {
                    "name": "pyob",
                    "type": "int",
                    "other": "NOT NULL"
                }, {
                    "name": "pemail",
                    "type": "varchar(30)",
                    "other": "NOT NULL"
                }, {
                    "name": "pguardian",
                    "type": "varchar(30)",
                    "other": "NOT NULL"
                }, {
                    "name": "pward",
                    "type": "varchar(30)",
                    "other": "NOT NULL"
                }, {
                    "name": "pcity",
                    "type": "varchar(30)",
                    "other": "NOT NULL"
                }, {
                    "name": "pdistrict",
                    "type": "varchar(30)",
                    "other": "NOT NULL"
                }, {
                    "name": "pstate",
                    "type": "varchar(30)",
                    "other": "NOT NULL"
                }, {
                    "name": "pememobile1",
                    "type": "varchar(30)",
                    "other": "NOT NULL"

                }, {
                    "name": "pememobile2",
                    "type": "varchar(30)",
                    "other": "NOT NULL"
                }
            ]
        }, {
            "name": "cmch_appointment",
            "fields": [{
                    "name": "pid",
                    "type": "char(6)",
                    "other": "NOT NULL"
                }, {
                    "name": "pcase",
                    "type": "varchar(20)",
                    "other": "NOT NULL"
                }, {
                    "name": "pdate",
                    "type": "datetime",
                    "other": "NOT NULL"
                }, {
                    "name": "doctor",
                    "type": "char(36)",
                    "other": "NOT NULL"
                }, {
                    "name": "status",
                    "type": "tinyint",
                    "other": "NOT NULL"
                }, {
                    "name": "nextvisit",
                    "type": "datetime",
                    "other": ""
                }
            ]
        }, {
           "name": "cmch_ip",
           "fields": [{
                   "name": "pid",
                   "type": "char(6)",
                   "other": "NOT NULL"
               }, {
                   "name": "addate",
                   "type": "datetime",
                   "other": "NOT NULL"
               }, {
                   "name": "didate",
                   "type": "datetime",
                   "other": ""
               }, {
                   "name": "ipcase",
                   "type": "varchar(20)",
                   "other": ""
               }, {
                   "name": "docid",
                   "type": "char(36)",
                   "other": ""
               }, {
                   "name": "nurid",
                   "type": "char(36)",
                   "other": ""
               }, {
                   "name": "ward",
                   "type": "char(36)",
                   "other": ""
               }, {
                   "name": "bed",
                   "type": "varchar(20)",
                   "other": ""
               }, {
                   "name": "diagnosis",
                   "type": "varchar(300)",
                   "other": ""
               }, {
                   "name": "details",
                   "type": "varchar(500)",
                   "other": ""
               },{
                   "name": "cause",
                   "type": "varchar(500)",
                   "other": ""
               },{
                   "name": "labreport",
                   "type": "varchar(6000)",
                   "other": ""
               },{
                   "name": "treatmentdetails",
                   "type": "varchar(2000)",
                   "other": ""
               },{
                   "name": "dischargenotes",
                   "type": "varchar(2000)",
                   "other": ""
               },{
                   "name": "advice",
                   "type": "varchar(2000)",
                   "other": ""
               },{
                   "name": "issuefollowup",
                   "type": "varchar(1000)",
                   "other": ""
               },{
                   "name": "nextdate",
                   "type": "datetime",
                   "other": "NOT NULL"
               }
           ]
       }, {
            "name": "cmch_wardmaster",
            "fields": [{
                    "name": "wardname",
                    "type": "varchar(50)",
                    "other": "NOT NULL"
                }, {
                    "name": "abbreviation",
                    "type": "varchar(10)",
                    "other": "NOT NULL  UNIQUE"
                }, {
                    "name": "maxcapacity",
                    "type": "tinyint",
                    "other": "NOT NULL default 1"
                }

            ]
        }, {
            "name": "cmch_clinicaldetails",
            "fields": [{
                    "name": "pid",
                    "type": "char(36)",
                    "other": "NOT NULL"
                }, {
                    "name": "cdate",
                    "type": "datetime",
                    "required": 1
                }, {
                    "name": "bp",
                    "type": "varchar(10)",
                    "other": " "
                }, {
                    "name": "pulse",
                    "type": "varchar(10)",
                    "other": " "
                }, {
                    "name": "temperature",
                    "type": "varchar(10)",
                    "other": " "
                }, {
                    "name": "spo2",
                    "type": "varchar(10)",
                    "other": "NOT NULL"
                }, {
                    "name": "sugar",
                    "type": "varchar(10)",
                    "other": "NOT NULL"
                }, {
                    "name": "ecg",
                    "type": "varchar(30)",
                    "other": "NOT NULL"

                }

            ]
        }, {
            "name": "cmch_bill",
            "fields": [{
                    "name": "bdate",
                    "type": "datetime",
                    "other": "NOT NULL"
                }, {
                    "name": "pid",
                    "type": "char(36)",
                    "other": "NOT NULL"
                }, {
                    "name": "billno",
                    "type": "int"

                }, {
                    "name": "item",
                    "type": "varchar(50)",
                    "other": "NOT NULL"
                }, {
                    "name": "category",
                    "type": "varchar(20)",
                    "other": "NOT NULL"
                },
                {
                    "name": "rate",
                    "type": "float",
                    "other": "NOT NULL"
                }, {
                    "name": "quatity",
                    "type": "float",
                    "other": "NOT NULL"
                }, {
                    "name": "discount",
                    "type": "float",
                    "other": "NOT NULL"
                }, {
                    "name": "total",
                    "type": "float",
                    "other": "NOT NULL"
                }

            ]
        }, {
            "name": "cmch_item",
            "fields": [{
                    "name": "item",
                    "type": "varchar(50)",
                    "other": "NOT NULL UNIQUE"
                }, {
                    "name": "rate",
                    "type": "float",
                    "other": "NOT NULL"
                }, {
                    "name": "category",
                    "type": "varchar(20)",
                    "other": "NOT NULL"
                }

            ]
        }, {
            "name": "cmch_printbill",
            "fields": [{
                    "name": "billno",
                    "type": "int",
                    "other": ""
                }, {
                    "name": "paystatus",
                    "type": "varchar(20)",
                    "other": ""
                }, {
                    "name": "pid",
                    "type": "char(36)",
                    "other": "NOT NULL"
                }, {
                    "name": "appid",
                    "type": "char(36)",
                    "other": "NOT NULL"
                }

            ]

        }, {
            "name": "cmch_xray",
            "fields": [{
                    "name": "billno",
                    "type": "int"
                }, {
                    "name": "item",
                    "type": "varchar(50)"
                }, {
                    "name": "xray",
                    "type": "varchar(400)"
                },
                {
                    "name": "xdatetime",
                    "type": "datetime",
                    "other": "Not Null"
                }
            ]
        }, {
            "name": "cmch_lab",
            "fields": [{
                    "name": "billno",
                    "type": "int"
                }, {
                    "name": "item",
                    "type": "varchar(50)"
                }, {
                    "name": "status",
                    "type": "tinyint",
                    "other": "NOT NULL"
                },{
                    "name": "collectiontime",
                    "type": "datetime",
                    "other": "NULL"
                },{
                    "name": "reportingtime",
                    "type": "datetime",
                    "other": "NULL"
                },{
                    "name": "comment",
                    "type": "varchar(50)",
                    "other": "NULL"
                }
            ]
        }, {
            "name": "cmch_labresult",
            "fields": [{
                    "name": "pid",
                    "type": "char(36)"
                }, {
                    "name": "labid",
                    "type": "char(36)"
                }, {
                    "name": "parameterid",
                    "type": "char(36)"
                }, {
                    "name": "result",
                    "type": "varchar(20)"
                }, {
                    "name": "date",
                    "type": "datetime"
                }
            ]
        }, {
            "name": "cmch_labparameters",
            "fields": [{
                    "name": "parametername",
                    "type": "varchar(30)"
                }, {
                    "name": "lrange",
                    "type": "float",
                    "other": ""
                }, {
                    "name": "unit",
                    "type": "varchar(20)",
                    "other": ""
                }, {
                    "name": "itemid",
                    "type": "char(36)",
                    "other": ""
                }, {
                    "name": "porder",
                    "type": "int",
                    "other": ""
                }, {
                    "name": "preset",
                    "type": "varchar(20)",
                    "other": ""
                }, {
                    "name": "prefil",
                    "type": "varchar(20)",
                    "other": ""
                }, {
                    "name": "lowerrange",
                    "type": "float",
                    "other": ""
                }, {
                    "name": "upperrange",
                    "type": "float",
                    "other": ""
                }, {
                    "name": "strcomparision",
                    "type": "varchar(20)",
                    "other": ""
                }, {
                    "name": "referencerange",
                    "type": "varchar(300)",
                    "other": ""
                }
            ]
        }, {
            "name": "cmch_advance",
            "fields": [{
                    "name": "pid",
                    "type": "char(36)"
                }, {
                    "name": "advance",
                    "type": "float"
                },{
					"name":"paymentmethod",
					"type":"varchar(30)"
				},
				{
                    "name": "balance",
                    "type": "float"
                }
            ]
        }, {
            "name": "cmch_refund",
            "fields": [
				{
                    "name": "rfnum",
                    "type": "int"
                },{
                    "name": "pid",
                    "type": "char(36)"
                }, 
				{
                    "name": "refund",
                    "type": "float"
                },
				{
                    "name": "remark",
                    "type": "varchar(100)"
                }
            ]
        }, 
		{
            "name": "cmch_iplifecycle",
            "fields": [{
                    "name": "ipid",
                    "type": "char(36)",
                    "other": "NOT NULL"
                }, {
                    "name": "lcname",
                    "type": "varchar(50)",
                    "other": "NOT NULL"
                }, {
                    "name": "details",
                    "type": "varchar(50)"
                }
            ]
        }, {
            "name": "cmch_payment",
            "fields": [{
                    "name": "billno",
                    "type": "int"
                }, {
                    "name": "paymentmethod",
                    "type": "varchar(30)"
                }, {
                    "name": "amount",
                    "type": "float"
                }, {
                    "name": "advanceid",
                    "type": "char(36)"
                }
            ]
        }

    ],
    "sqlcommands_oninstall": [],

    "form": [{
            "name": "doctors_data",
            "formtype": "Default",
            "title": "Doctor's Details",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "savdoc",
            "getrecordcustomid": "getdoc",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [{
                    "name": "doctors_name",
                    "label": "Name Of Doctor",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "Yes",
                    "maxlength": "50"
                }, {
                    "name": "qualification",
                    "label": "Highest Qualification",
                    "fieldtype": "s",
                    "type": "textarea",
                    "required": "Yes",
                    "maxlength": "100"
                }, {
                    "name": "specialization",
                    "label": "Specialization",
                    "fieldtype": "s",
                    "type": "textarea",
                    "required": "Yes",
                    "maxlength": "100"
                }, {
                    "name": "daystime",
                    "label": "Visit Days & Time",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "Yes",
                    "maxlength": "100"
                }, {
                    "name": "mobilenum",
                    "label": "Mobile Number",
                    "fieldtype": "s",
                    "type": "number",
                    "required": "Yes",
                    "maxlength": "10"
                }, {
                    "name": "email",
                    "label": "Email",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "Yes",
                    "maxlength": "30"
                }, {
                    "name": "mbbscertficate",
                    "label": "MBBS Certificate",
                    "fieldtype": "s",
                    "type": "file",
                    "maxsize": "1mb",
                    "uploadstmt": "6upim"
                }, {
                    "name": "mcireg",
                    "label": "MCI Reg.Cert.",
                    "fieldtype": "s",
                    "type": "file",
                    "maxsize": "1mb",
                    "uploadstmt": "6upim"
                }, {
                    "name": "othercert1",
                    "label": "Other Certificate1",
                    "fieldtype": "s",
                    "type": "file",
                    "maxsize": "1mb",
                    "uploadstmt": "6upim"
                }, {
                    "name": "othercert2",
                    "label": "Other Certificate2",
                    "fieldtype": "s",
                    "type": "file",

                    "maxsize": "1mb",
                    "uploadstmt": "6upim"
                }, {
                    "name": "availability",
                    "label": "Available for Rounds",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "0:No,1:Yes"
                }, {
                    "name": "image",
                    "label": "Photo",
                    "fieldtype": "s",
                    "type": "file",
                    "maxsize": "200kb",
                    "uploadstmt": "6upim"
                }
            ]
        }, {
            "name": "doctorsattendance",
            "formtype": "Default",
            "title": "Doctor's Attendance",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "sdocat",
            "getrecordcustomid": "gdocat",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [{
                    "name": "docid",
                    "label": "Doctor's Name",
                    "fieldtype": "u",
                    "type": "select",
                    "option": "select id,name from cmch_doctors where recordstatus=1",
                    "required": 1,
                    "maxlength": "50"
                }, {
                    "name": "intime",
                    "label": "Attendance Date",
                    "fieldtype": "datetime",
                    "type": "datetime",
                    "required": 1
                }, {
                    "name": "outtime",
                    "label": "In time",
                    "fieldtype": "datetime",
                    "type": "datetime"
                }, {
                    "name": "rounds",
                    "label": "Rounds",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "0:No,1:Yes",
                    "required": 1

                }

            ]
        }, {
            "name": "patient",
            "formtype": "Horizontal",
            "title": "Patient",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "svpat",
            "getrecordcustomid": "gtpat",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [{
                    "name": "pname",
                    "label": "Name Of Patient",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "Yes",
                    "maxlength": "50"
                }, {
                    "name": "pcode",
                    "label": "Patient Code",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "Yes",
                    "maxlength": "50"
                }, {
                    "name": "pgender",
                    "label": "Gender",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "0:Male,1:Female",
                    "required": 1
                },{
                    "name": "pmaritalstatus",
                    "label": "Marital Status",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "0:[Select],1:Single,2:Married,3:Widowed,4:Divorced"                  
                }, {
                    "name": "pmobile",
                    "label": "Mobile Number",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "Yes",
                    "maxlength": "10"
                }, {
                    "name": "paadhaar",
                    "label": "Aadhaar Number",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "11"
                }, {
                    "name": "page",
                    "label": "Age",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "Yes",
                    "maxlength": "10",
                    "jsevent": "onblur",
                    "jsfun": "let yr=new Date();yr=yr.getFullYear();$(&apos;input[name=pyob]&apos;).val(yr-parseInt($(this).val()))"
                }, {
                    "name": "pyob",
                    "label": "Year of Birth",
                    "fieldtype": "n",
                    "type": "number",
                    "maxlength": "30"
                }, {
                    "name": "pemail",
                    "label": "Email",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "30"
                }, {
                    "name": "pguardian",
                    "label": "Father/Guardian Name",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "Yes",
                    "maxlength": "50"
                }, {
                    "name": "pward",
                    "label": "Ward",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "50"
                }, {
                    "name": "pcity",
                    "label": "City/ Village/Town",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "50"
                }, {
                    "name": "pdistrict",
                    "label": "District",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "50"
                }, {
                    "name": "pstate",
                    "label": "State",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "50"
                }, {
                    "name": "pememobile1",
                    "label": "Emergency Mobile Num.1",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "50"
                }, {
                    "name": "pememobile2",
                    "label": "Emergency Mobile Num.2",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "50"
                }

            ]
        }, {
            "name": "pappointment",
            "formtype": "Horizontal",
            "title": "Patient's Appointment",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "svpapp",
            "getrecordcustomid": "4gtapp",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [{
                    "name": "pid",
                    "label": "Patient ID<span id='pidnm'></span>",
                    "fieldtype": "u",
                    "type": "text",
                    "required": 1,
                    "maxlength": "50",
                    "jsevent": "onblur",
                    "jsfun": "Eirene.runStmt(&apos;4gtpnm&apos;,{pid:$(this).val()})"
                }, {
                    "name": "pcase",
                    "label": "Case",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "Medical,Surgical,Dental,Covid,Other",
                    "required": 1
                }, {
                    "name": "pdate",
                    "label": "Appointment Date",
                    "fieldtype": "datetime",
                    "default": "NOW()",
                    "type": "datetime",
                    "required": 1
                },
                {
                    "name": "doctor",
                    "label": "Doctor",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "select id,name from cmch_doctors where recordstatus=1",
                    "required": "Yes",
                    "maxlength": "50"
                },
                {
                    "name": "nextvisit",
                    "label": "Next Visit",
                    "fieldtype": "datetime",
                    "type": "datetime",
                    "maxlength": "30"
                }

            ]
        }, {
            "name": "ip",
            "formtype": "Horizontal",
            "title": "In Patient",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "svip",
            "getrecordcustomid": "gtip",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [{
                    "name": "pid",
                    "label": "Patient ID",
                    "fieldtype": "u",
                    "type": "text",
                    "required": 1,
                    "maxlength": "10"

                }, {
                    "name": "addate",
                    "label": "Admission Date",
                    "fieldtype": "datetime",
                    "type": "datetime",
                    "required": 1
                }, {
                    "name": "didate",
                    "label": "Discharge Date",
                    "fieldtype": "datetime",
                    "type": "datetime"
                }, {
                    "name": "ipcase",
                    "label": "Case",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "Medical,Surgical,Dental,Covid,Other"
                }, {
                    "name": "docid",
                    "label": " Admitting Doctor",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "select id,name from cmch_doctors where recordstatus=1",
                    "maxlength": "50"
                }, {
                    "name": "nurid",
                    "label": "Recieved by(Nurse)",
                    "fieldtype": "s",
                    "type": "select",
                    "option": ""

                }, {
                    "name": "ward",
                    "label": "Ward",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "select id,wardname from cmch_wardmaster where recordstatus=1"

                }, {
                    "name": "bed",
                    "label": "Bed No.",
                    "fieldtype": "s",
                    "type": "text"

                }
            ]
        },{
            "name": "discharge",
            "formtype": "Horizontal",
            "title": "In Patient",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "15svdi",
            "getrecordcustomid": "15gtip",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [{
                    "name": "pid",
                    "label": "Patient ID",
                    "fieldtype": "u",
                    "type": "text",
                    "required": 1                   

                },{
                    "name": "diagnosis",
                    "label": "Diagnosis",
                    "fieldtype": "s",
                    "type": "textarea"
                   
                }, {
                    "name": "details",
                    "label": "Details at Presentation",
                    "fieldtype": "s",
                    "type": "textarea"
                   
                }, {
                    "name": "cause",
                    "label": "Cause for Admission",
                    "fieldtype": "s",
                    "type": "textarea"
                }, {
                    "name": "labreport",
                    "label": "Lab Report",
                    "fieldtype": "s",
                    "type": "textarea"                    
                }, 
				{
                    "name": "treatmentdetails",
                    "label": "Treatment Details",
                    "fieldtype": "s",
                    "type": "textarea"                    
                }, {
                    "name": "dischargenotes",
                    "label": "Discharge Details",
                    "fieldtype": "s",
                    "type": "textarea"                    
                },{
                    "name": "advice",
                    "label":"Advice at Discharge",
                    "fieldtype": "s",
                    "type": "textarea"                    
                },{
                    "name": "issuefollowup",
                    "label": "Issues to Addresse at follow up",
                    "fieldtype": "s",
                    "type": "textarea"                    
                }, {
                    "name": "nextdate",
                    "label": "Next Follow Up Date",
                   	"fieldtype": "datetime",
                    "type": "datetime"                    
                }

            ]
        }, {
            "name": "wardmaster",
            "formtype": "Default",
            "title": "Ward Master",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "6svwm",
            "getrecordcustomid": "6gtwm",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [
                {
                    "name": "wardname",
                    "label": "Ward Name",
                    "fieldtype": "s",
                    "type": "text",
                    "required": 1,
                    "maxlength": "50"
                }, {
                    "name": "abbreviation",
                    "label": "Abbreviation",
                    "fieldtype": "s",
                    "type": "text",
                    "required": 1
                }, {
                    "name": "maxcapacity",
                    "label": "Max. Capacity",
                    "fieldtype": "n",
                    "type": "number",
                    "required": 1
                }
            ]
        }, {
            "name": "clinicaldetails",
            "formtype": "Horizontal",
            "title": "Clinical Details",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "7savcd",
            "getrecordcustomid": "7getcd",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [{
                    "name": "pid",
                    "label": "Patient ID<span id='pidnm'></span>",
                    "fieldtype": "u",
                    "type": "text",
                    "required": 1,
                    "maxlength": "50",
                    "jsevent": "onblur",
                    "jsfun": "Eirene.runStmt(&apos;4gtpnm&apos;,{pid:$(this).val()})"
                }, {
                    "name": "cdate",
                    "label": "Date",
                    "fieldtype": "datetime",
                    "type": "datetime",
                    "required": 1
                }, {
                    "name": "bp",
                    "label": "BP",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "10"
                },
                {
                    "name": "pulse",
                    "label": "Pulse",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "10"
                }, {
                    "name": "temperature",
                    "label": "Temperature",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "10"
                }, {
                    "name": "spo2",
                    "label": "SpO2",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "10"
                }, {
                    "name": "sugar",
                    "label": "Sugar",
                    "fieldtype": "s",
                    "type": "text",
                    "maxlength": "10"
                }, {
                    "name": "ecg",
                    "label": "ECG",
                    "fieldtype": "s",
                    "type": "file",
                    "maxsize": "200kb"
                }
            ]
        }, {
            "name": "billing",
            "formtype": "Horizontal",
            "title": "Billing",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "8svbl",
            "getrecordcustomid": "8gtbl",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [
                {
                    "name": "pid",
                    "label": "Patient ID<span id='pidnm'></span>",
                    "fieldtype": "s",
                    "type": "text",
                    "required": 1,
                    "maxlength": "50",
                    "jsevent": "onblur",
                    "jsfun": "Eirene.runStmt(&apos;4gtpnm&apos;,{pid:$(this).val()});"
                }, {
                    "name": "item",
                    "label": "Item",
					"style":"width:300px",
                    "fieldtype": "u",
                    "required": 1,
                    "type": "select",
                    "option": "select item,concat(item,':',rate,':',category) from cmch_item where recordstatus=1",
                    "jsevent": "onchange",
                    "jsfun": "let a=$(&apos;select[name=item] option:selected&apos;).text();a=a.split(&apos;:&apos;);if(a.length<2) return false;$(&apos;input[name=rate]&apos;).val(a[1]);$(&apos;input[name=category]&apos;).val(a[2]);$(&apos;#quatity&apos;).val(1);$(&apos;#total&apos;).val(a[1]);$(&apos;#discount&apos;).val(0);"

                }, {
                    "name": "rate",
                    "label": "Rate",
                    "fieldtype": "n",
                    "required": 1,
                    "type": "number"
                }, {
                    "name": "category",
                    "label": "Category",
                    "fieldtype": "s",
                    "required": 1,
                    "type": "hidden"
                }, {
                    "name": "quatity",
                    "label": "Quantity",
                    "fieldtype": "n",
                    "required": 1,
                    "type": "number",
                    "jsevent": "onblur",
                    "jsfun": "let to= $(this).val()*$(&apos;input[name=rate]&apos;).val(); $(&apos;input[name=total]&apos;).val(to);$(&apos;input[name=discount]&apos;).val(0);"
                }, {
                    "name": "discount",
                    "label": "Discount",
                    "fieldtype": "n",
                    "type": "number",
                    "jsevent": "onblur",
                    "jsfun": "let to= ($(&apos;input[name=quatity]&apos;).val()*$(&apos;input[name=rate]&apos;).val())-(($(this).val()*$(&apos;input[name=quatity]&apos;).val()*$(&apos;input[name=rate]&apos;).val())/100); $(&apos;input[name=total]&apos;).val(to);$(this).val(($(this).val()*$(&apos;input[name=quatity]&apos;).val()*$(&apos;input[name=rate]&apos;).val())/100);"
                }, {
                    "name": "total",
                    "label": "Total",
                    "fieldtype": "n",
                    "required": 1,
                    "type": "number"

                }
            ]
        }, {
            "name": "item",
            "formtype": "Horizontal",
            "title": "Items List",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "9svit",
            "getrecordcustomid": "9gtit",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [
                {
                    "name": "item",
                    "label": "Item Name",
                    "fieldtype": "s",
                    "type": "text",
                    "required": 1,
                    "maxlength": "50"
                }, {
                    "name": "rate",
                    "label": "Rate",
                    "fieldtype": "n",
                    "type": "number",
                    "required": 1
                }, {
                    "name": "category",
                    "label": "Category",
                    "fieldtype": "s",
                    "type": "text",
                    "required": 1
                }
            ]
        }, {
            "name": "xray",
            "formtype": "Horizontal",
            "title": "xray",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "11svxr",
            "getrecordcustomid": "11gtxr",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [
                {
                    "name": "xray",
                    "label": "X-Ray Image",
                    "type": "file",				
                    "fieldtype": "s",					
                    "maxsize": "600kb",
                    "uploadstmt": "33"
                }
            ]
        }, {
            "name": "lab",
            "formtype": "Default",
            "title": "lab",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "12svlb",
            "getrecordcustomid": "12gtlb",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [
                {
                    "name": "status",
                    "label": "Work Status",
                    "type": "select",
                    "option": "Incomplete,Complete"

                }
            ]
        }, {
            "name": "labparameters",
            "formtype": "Horizontal",
            "title": "Lap Parameters",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "12svlp",
            "getrecordcustomid": "12gtlp",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [{
                    "name": "itemid",
                    "label": "Item Name",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "select id,item from cmch_item"
                }, {
                    "name": "parametername",
                    "label": "Paremeter Name",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "1"

                }, {
                    "name": "lrange",
                    "label": "Range",
                    "fieldtype": "n",
                    "type": "number"

                }, {
                    "name": "unit",
                    "label": "Unit",
                    "fieldtype": "s",
                    "type": "text"

                }, {
                    "name": "porder",
                    "label": "Print Order",
                    "fieldtype": "n",
                    "type": "number"
                }, {
                    "name": "preset",
                    "label": "Preset",
                    "fieldtype": "s",
                    "type": "text"
                }, {
                    "name": "prefil",
                    "label": "Prefil",
                    "fieldtype": "s",
                    "type": "text"
                }, {
                    "name": "lowerrange",
                    "label": "Lower Range",
                    "fieldtype": "n",
                    "type": "number"
                }, {
                    "name": "upperrange",
                    "label": "Upper Range",
                    "fieldtype": "n",
                    "type": "number"
                }, {
                    "name": "strcomparision",
                    "label": "String Comparision",
                    "fieldtype": "s",
                    "type": "text"
                }, {
                    "name": "referencerange",
                    "label": "Refererence Range",
                    "fieldtype": "n",
                    "type": "number"
                }
            ]

        }, {
            "name": "parameter",
            "formtype": "Horizontal",
            "title": "Parameter",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "13svlp",
            "getrecordcustomid": "13gtlp",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [
                {
                    "name": "itemid",
                    "label": "Item Name",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "select id,item from cmch_item"
                }, {
                    "name": "parametername",
                    "label": "Paremeter Name",
                    "fieldtype": "s",
                    "type": "text",
                    "required": "1"

                }

            ]
        },
        {
            "name": "printbill",
            "formtype": "Default",
            "title": "Print Billing",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "10svpb",
            "getrecordcustomid": "10gtpb",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [
                {
                    "name": "billno",
                    "label": "Bill Num.",
                    "fieldtype": "n",
                    "required": 1,
                    "type": "number"
                }, {
                    "name": "totalamt",
                    "label": "Total Amount",
                    "fieldtype": "n",
                    "required": 1,
                    "type": "number"
                }, {
                    "name": "paymode",
                    "label": "Paymode",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "0:Cash,1:CC,2:DC,3:Online,4:POS,5:GPI,6:Others"
                }, {
                    "name": "totaldis",
                    "label": "Total Discount",
                    "fieldtype": "n",
                    "type": "number",
                    "jsevent": "onblur",
                    "jsfun": "let to= ($(&apos;input[name=quatity]&apos;).val()*$(&apos;input[name=rate]&apos;).val())-(($(this).val()*$(&apos;input[name=quatity]&apos;).val()*$(&apos;input[name=rate]&apos;).val())/100); $(&apos;input[name=total]&apos;).val(to);$(this).val(($(this).val()*$(&apos;input[name=quatity]&apos;).val()*$(&apos;input[name=rate]&apos;).val())/100);"
                }, {
                    "name": "netpay",
                    "label": "NetPay",
                    "fieldtype": "n",
                    "required": 1,
                    "type": "number"
                }, {
                    "name": "paystatus",
                    "label": "Pay Status",
                    "fieldtype": "s",
                    "type": "select",
                    "option": "1:Paid,2:Pending"
                }, {
                    "name": "pid",
                    "label": "P ID",
                    "fieldtype": "s",
                    "type": "text",
                    "required": 1
                }, {
                    "name": "bdatetime",
                    "label": "Date & Time",
                    "fieldtype": "datetime",
                    "type": "datetime",
                    "required": 1
                }

            ]
        }, {
            "name": "advance",
            "formtype": "Horizontal",
            "title": "Advance",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "svadv",
            "getrecordcustomid": "gtadv",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [
                {
                    "name": "pid",
                    "label": "Patient ID<span id='pidnm'></span>",
                    "fieldtype": "s",
                    "type": "text",
                    "required": 1,
                    "maxlength": "50",
                    "jsevent": "onblur",
                    "jsfun": "Eirene.runStmt(&apos;4gtpnm&apos;,{pid:$(this).val()})"
                }, {
                    "name": "paymentmethod",
                    "label": "Payment Method",
                    "fieldtype": "s",
                    "required": 1,
                    "type": "select",
					"option":"Cash,Card,POS,InternetBanking,UPI"
                }
				, {
                    "name": "advance",
                    "label": "Advance",
                    "fieldtype": "n",
                    "required": 1,
                    "type": "number"
                }

            ]
        },
		{
            "name": "refund",
            "formtype": "Horizontal",
            "title": "Refund",
            "icon": "mif-delicious",
            "saveButton": "1",
            "savecustomid": "svref",
            "getrecordcustomid": "gtref",
            "cancelButton": "1",
            "flex_row": "true",
            "flex_justify": "start",
            "field": [
                {
                    "name": "pid",
                    "label": "Patient ID<span id='pidnm'></span>",
                    "fieldtype": "s",
                    "type": "text",
                    "required": 1,
                    "maxlength": "50",
                    "jsevent": "onblur",
                    "jsfun": "Eirene.runStmt(&apos;4gtpnm&apos;,{pid:$(this).val()})"
                }, {
                    "name": "refund",
                    "label": "Refund Amount",
                    "fieldtype": "n",
                    "required": 1,
                    "type": "number"
                },
				{
                    "name": "remark",
                    "label": "Remarks",
                    "fieldtype": "n",
                    "required": 1,
                    "type": "text"
                }

            ]
        }


    ],

    "form_html": "",
    "navbutton": [{
            "customid": "1",
            "caption": "CMCH",
            "icon": "mif-delicious",
            "btntype": "ribbon-button",
            "btngroup": "Others",
            "btntab": "Developer",
            "btnorder": "1",
            "onclick": "initializePlugin()"
			
        }
    ],
    "script": "",
    "formbuttons": [{
            "name": "doctors",
            "caption": "Doctors",
            "icon": "mif-delicious fg-red",
            "onclick": "Eirene.runStmt('1')"
        }, {
            "name": "nurse",
            "caption": "Nurses",
            "icon": "mif-delicious fg-red",
            "onclick": ""
        }, {
            "name": "patient",
            "caption": "Patient",
            "icon": "mif-delicious fg-red",
            "onclick": "Eirene.runStmt('3-3ft')"
        }, {
            "name": "Appointment",
            "caption": "Appointment",
            "icon": "mif-delicious fg-red",
            "onclick": "Eirene.runStmt('4gtwrd-4-4btn-4apflt')"
        }, {
            "name": "IP",
            "caption": "IP",
            "icon": "mif-delicious fg-red",
            "onclick": "Eirene.runStmt('6a')"
        },
        {
            "name": "clinicaldetails",
            "caption": "Clinical Details",
            "icon": "mif-delicious fg-red",
            "onclick": "Eirene.runStmt('7-6flt')"
        },
        {
            "name": "billing",
            "caption": "Billing",
            "icon": "mif-delicious fg-red",
            "onclick": "Eirene.runStmt('8-10bft')"
        },
        {
            "name": "xray",
            "caption": "X-RAY",
            "icon": "mif-delicious fg-red",
            "onclick": "Eirene.runStmt('11-11ft')"
        },
        {
            "name": "lab",
            "caption": "Lab",
            "icon": "mif-delicious fg-red",
            "onclick": "Eirene.runStmt('12-12ft')"
        }
    ],
    "sqlstatement": [{
            "id": "1",
            "name": "List Doctor",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "doctors_data",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_doctors",
                "outputfilter": "fltbtn",
                "button": [{
                        "name": "f1",
                        "type": "buttonspan",
                        "class": "mif-plus fg-red",
                        "caption": "",
                        "onclick": "showNewForm(\\\"doctors_data\\\")",
                        "title": "Add Doctor"
                    }, {
                        "name": "f2",
                        "type": "buttonspan",
                        "class": "mif-plus fg-blue",
                        "caption": "Attendance",
                        "displaynone": 1,
                        "onclick": "showNewForm(\\\"doctorsattendance\\\")",
                        "title": "Add Doctor"
                    }, {
                        "name": "f3",
                        "caption": "List Of Doctors",
                        "onclick": "Eirene.runStmt(\\\"1\\\")",
                        "title": "List of Doctor"
                    }, {
                        "name": "f4",
                        "caption": "Doctors Attendance Details",
                        "onclick": "Eirene.runStmt(\\\"2a-2-2flt\\\")",
                        "title": "Doctors Attendance"
                    }
                ],
                "fld": "name,qualification,specialization,daystime,mobilenum,IF(in_out_status=0,CONCAT('<input type=\\\"checkbox\\\" data-role=\\\"switch\\\" onchange=\\\"let stmt;if($(this).prop(&apos;checked&apos;)){stmt=&apos;docat1&apos;}else{stmt=&apos;docat2&apos;;} Eirene.runStmt(stmt,{doctorid:&apos;',id,'&apos;})\\\"  data-on=\\\"IN\\\" data-off=\\\"OUT\\\">'),CONCAT('<input type=\\\"checkbox\\\" checked data-role=\\\"switch\\\" onchange=\\\"let stmt;if($(this).prop(&apos;checked&apos;)){stmt=&apos;docat1&apos;}else{stmt=&apos;docat2&apos;;} Eirene.runStmt(stmt,{doctorid:&apos;',id,'&apos;})\\\"  data-on=\\\"IN\\\" data-off=\\\"OUT\\\">'))",
                "delstmt": "deldoc",
                "header": "Doctor,Qualification,Specialization,Days_Time,Mobile,IN/OUT",
                "whr": "recordstatus=1",
                "onsuccess": "cmd:dom,fun:html;#workareaFilter;||fltbtn||-cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:hide;#workareaFilter1;slow-cmd:dom,fun:hide;#workareaAppendix;slow"

            },

            "edit_record": 1,
            "delete_record": 1
        }, 
		{
			"id": "2a",
			"name": "Doctors id-name dropdown",
			"sql": {
				"action": "Get Dropdown",
				"validate": "users status>0",
				"outputto": "html",
				"output": "docs",
				"fld": "id,name",
				"tbl": "cmch_doctors",
				"whr": "recordstatus>0",
				"default": ""
			}
		},
		{
            "id": "getdoc",
            "name": "Get Doctor",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_doctors",
                "fld": "id,name as doctors_name,qualification,specialization,daystime,mobilenum,email,mbbscertficate,mcireg,othercert1,othercert2,availability,image",
                "whr": "id='||ID||'",
				"function":"edit1"

            }
        }, {
            "id": "savdoc",
            "name": "Save Doctor",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_doctors",
                "fld": "name,qualification,specialization,daystime,mobilenum,email,mbbscertficate,mcireg,othercert1,othercert2,availability,image",
                "value": "||doctors_name||,||qualification||,||specialization||,||daystime||,||mobilenum||,||email||,||mbbscertficate||,||mcireg||,||othercert1||,||othercert2||,||availability||,||image||",
                "fldtype": "s,s,s,s,s,s,s,s,s,s,s,s",
                "command": "insertorupdate",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=doctors_name];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "deldoc",
            "name": "Delete Doc",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_doctors",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        }, {
            "id": "sdocat",
            "name": "Save Doctor's Attendance",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_doctorsattendance",
                "fld": "docid,intime,outtime,rounds",
                "value": "||docid||,||intime||,||outtime||,||rounds||",
                "fldtype": "s,s,s,n",
                "command": "insertorupdate",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=attendancedate];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "2",
            "name": "Doctors Attendance Details",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "doctorsattendance",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_doctorsattendance a",
                "fld": "b.name,a.intime,a.outtime,a.rounds",
                "join": "INNER JOIN cmch_doctors b ON a.docid=b.id",
                "delstmt": "dedoat",
                "header": "Doctor,In time,Out time,Rounds",
                "whr": "a.recordstatus=1 and (DATE(a.intime)=CURDATE() or a.outtime IS NULL or DATE(a.outtime)=CURDATE())",
                "limit": "200",
                "button": [{
                        "name": "f7",
                        "displaynone": 1,
                        "whr": [
                            "a.recordstatus=1", {
                                "if": "||docid||",
                                "op": "!=",
                                "value": "BLANK",
                                "then": " and a.docid='||docid||'"
                            }, {
                                "if": "||appdtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||appdtto||",
                                "andop": "!=",
                                "andvalue": "BLANK",
                                "then": " and DATE(a.intime)>='||appdtfrom||' and DATE(a.intime)<='||appdtto||'"
                            }, {
                                "if": "||appdtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||appdtto||",
                                "andop": "=",
                                "andvalue": "BLANK",
                                "then": " and DATE(a.intime)='||appdtfrom||'"
                            }

                        ]
                    }
                ]

            },
            "edit_record": 1,
            "delete_record": 1
        },
        
		{
            "id": "2flt",
            "name": "Appointment List Filter",
            "sql": {
                "action": "Return",
                "validate": "users",
                "outputto": "php",
                "output": "flt",
                "value": "",
                "outputfilter": "#workareaFilter1",
                "button": [{
                        "name": "f1",
                        "id": "docid",
                        "caption": "Doctor ",
                        "type": "select",
                        "option": "SELECT '','' UNION ALL(SELECT id,name FROM cmch_doctors WHERE recordstatus=1)"
                    }, {
                        "name": "f2",
                        "id": "appdtfrom",
                        "caption": "Date From: ",
                        "type": "datepicker",
                        "value": "||CURDATE||"
                    }, {
                        "name": "f3",
                        "id": "appdtto",
                        "caption": "Date To: ",
                        "type": "datepicker",
                        "value": "||CURDATE||"
                    }, {
                        "name": "f4",
                        "caption": "Get",
                        "class": "button secondary",
                        "onclick": "Eirene.runStmt('2',{filtertable:'f7',docid:$('#docid').val(),appdtfrom:$('#appdtfrom').val(),appdtto:$('#appdtto').val()})"
                    },
					{
                        "name": "f5",
                        "caption": "Summary",
                        "class": "button secondary",
                        "onclick": "Eirene.runStmt('2dasum',{appdtfrom:$('#appdtfrom').val(),appdtto:$('#appdtto').val()})"
                    }
					
                ],
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;slow"
            }
        },
		
		{
            "id": "2dasum",
            "name": "Doctors Attendance Summary",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_doctors a",
                "fld": "a.name,b.visit,c.round",
                "join": "LEFT JOIN (SELECT docid,count(*)as visit from cmch_doctorsattendance where rounds=0 and recordstatus=1 and DATE(intime)>='||attfromdate||' and DATE(intime)<='||atttodate||') b on b.docid=a.id LEFT JOIN (SELECT docid,count(*)as round from cmch_doctorsattendance where rounds=1 and recordstatus=1 and DATE(intime)>='||attfromdate||' and DATE(intime)<='||atttodate||') c on c.docid=a.id",
                "whr": "a.recordstatus=1",
                "header": "Doctor,Visit Count,Round Count"
            }

        },
        {
            "id": "dedoat",
            "name": "Delete Attendance",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_doctorsattendance",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        }, {
            "id": "gdocat",
            "name": "Get Doctors Attendance",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_doctorsattendance",
                "fld": "id,docid,intime,outtime,rounds",
                "whr": "id='||ID||'",
				"function":"edit1"

            }
        }, {
            "id": "docat1",
            "name": "Doctor Attendance-IN",
            "sql": {
                "action": "Save Row",
                "validate": "users status>0",
                "outputto": "php",
                "tbl": "cmch_doctorsattendance",
                "fld": "docid,intime",
                "value": "||doctorid||,NOW()",
                "fldtype": "u,n",
                "command": "insert",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-docat3",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }

        }, {
            "id": "docat2",
            "name": "Doctor Attendance-OUT",
            "sql": {
                "action": "Save Row",
                "validate": "users status>0",
                "outputto": "php",
                "tbl": "cmch_doctorsattendance",
                "fld": "outtime",
                "value": "NOW()",
                "fldtype": "n",
                "command": "update",
                "whr": "docid='||doctorid||' and (outtime IS NULL or outtime = '00:00:00')",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-docat4",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }

        }, {
            "id": "docat3",
            "name": "Doctor Attendance-IN",
            "sql": {
                "action": "Save Row",
                "validate": "users status>0",
                "outputto": "php",
                "tbl": "cmch_doctors",
                "fld": "in_out_status",
                "value": "1",
                "fldtype": "n",
                "command": "update",
                "whr": "id='||doctorid||'"
            }
        }, {
            "id": "docat4",
            "name": "Doctor Attendance-OUT",
            "sql": {
                "action": "Save Row",
                "validate": "users status>0",
                "outputto": "php",
                "tbl": "cmch_doctors",
                "fld": "in_out_status",
                "value": "0",
                "fldtype": "n",
                "whr": "id='||doctorid||'",
                "command": "update"
            }
        }, {
            "id": "filatt",
            "name": "Attendance of a doctor",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "doctorsattendance",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_doctorsattendance",
                "fld": "attendancedate,intime,outtime,rounds",
                "header": "Attendancedate,In time,Out time,Rounds"

            }
        }, {
            "id": "3",
            "name": "List Patient",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "patient",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_patient",
                "limit": 200,
                "outputfilter": "fltbtn",
                "button": [{
                        "name": "f1",
                        "type": "buttonspan",
                        "class": "mif-plus fg-red",
                        "caption": "",
                        "onclick": "showNewForm(\\\"patient\\\")",
                        "title": "Add Patient"
                    }, {
                        "name": "f2",
                        "type": "buttonspan",
                        "class": "mif-plus fg-blue",
                        "caption": "Appointment",
                        "displaynone": 1,
                        "onclick": "showNewForm(\\\"pappointment\\\")",
                        "title": "Add Appointment"
                    }, {
                        "name": "f3",
                        "type": "buttonspan",
                        "class": "mif-plus fg-blue",
                        "displaynone": 1,
                        "caption": "Clinical Details",
                        "onclick": "",
                        "title": "Add Clinical Details"
                    }, {
                        "name": "f4",
                        "caption": "Patients List",
                        "onclick": "Eirene.runStmt(\\\"3\\\")",
                        "title": "List of Patient"
                    }, {
                        "name": "f5",
                        "caption": "Appointment",
                        "displaynone": 1,
                        "onclick": "Eirene.runStmt(\\\"4\\\")",
                        "title": "Appointment Details"
                    }, {
                        "name": "f6",
                        "caption": "Clinical Details",
                        "onclick": "",
                        "displaynone": 1,
                        "title": "Clinical Details"
                    }, {
                        "name": "f7",
                        "caption": "Treatment Protocol",
                        "onclick": "",
                        "displaynone": 1,
                        "title": "Treatment Protocol"
                    }, {
                        "name": "f8",
                        "caption": "",
                        "displaynone": 1,
                        "whr": "pcode='||pcode||'"
                    }, {
                        "name": "f9",
                        "caption": "",
                        "displaynone": 1,
                        "whr": "pid = '||fpid||' or pmobile like '%||fpid||%' or pname like '%||fpid||%' or paadhaar like '%||fpid||%'"
                    }

                ],
                "fld": "pname,pid,pgender,pmobile,(YEAR(CURDATE())-pyob) as page,pememobile1",
                "delstmt": "delpat",
                "header": "Patient Name,Patient ID,Gender,Mobile,Age,Emergency Num",
                "whr": "recordstatus=1",
                "onsuccess": "cmd:dom,fun:html;#workareaFilter;||fltbtn||-cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:hide;#workareaAppendix;slow"

            },

            "edit_record": 1,
            "delete_record": 1
        }, {
            "id": "3ft",
            "name": "Filter patients",
            "sql": {
                "action": "Return",
                "output": "#workareaFilter1",
                "value": "<div class='inline-form'><input type='text' placeholder='Search' class='metro-input ml-2' id='fpid'></input><button type='button' class='button secondary ml-2' onclick='Eirene.runStmt(&apos;3&apos;,{filtertable:&apos;f9&apos;,fpid:$(&apos;#fpid&apos;).val()})'>Get</button></div>",
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;slow"
            }
        }, {
            "id": "svpat",
            "name": "Save Patient Details",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_patient",
                "fld": "pname,pid,pgender,pmobile,paadhaar,pyob,pemail,pguardian,pward,pcity,pdistrict,pstate,pememobile1,pememobile2",
                "value": "||pname||,||pcode||,||pgender||,||pmobile||,||paadhaar||,||pyob||,||pemail||,||pguardian||,||pward||,||pcity||,||pdistrict||,||pstate||,||pememobile1||,||pememobile2||",
                "fldtype": "s,s,n,s,s,n,s,s,s,s,s,s,s,s",
                "command": "insertorupdate",
                "whr": "id='||ID||'",				
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=pname];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "gtpat",
            "name": "Get Patient Details",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_patient",
                "fld": "id,pname,pid as pcode,pgender,pmobile,paadhaar,pyob,(YEAR(CURDATE())-pyob) as page,pemail,pguardian,pward,pcity,pdistrict,pstate,pememobile1,pememobile2",
                "whr": "id='||ID||'",
				"function":"edit1"

            }
        }, {
            "id": "delpat",
            "name": "Delete Patient",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_patient",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        }, {
            "id": "svpapp",
            "name": "Save Patient Appointment",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_appointment",
                "fld": "pid,pcase,pdate,doctor,nextvisit",
                "value": "||pid||,||pcase||,||pdate||,||doctor||,||nextvisit||",
                "fldtype": "s,s,s,s,s",
                "command": "insertorupdate",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=pid];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "4",
            "name": "Appointment List",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "pappointment",
                "outputto": "html",
                "output": "table",
                "outputfilter": "#workareaFilter",
                "tbl": "cmch_appointment a",
                "fld": "b.pid,b.pname,a.pcase,a.pdate,c.name,a.nextvisit",
                "functionfield": [{
                        "if": "a.status=0",
                        "type": "button",
                        "value": "Visit",
                        "onclick": "Eirene.runStmt('4visi',{pid:'<b.pid>'},$(this).hide())"
                    }, {
                        "if": "a.status=1",
                        "type": "icon",
                        "value": "Visited"
                    }, {
                        "type": "select",
                        "value": "",
                        "class": "select1",
                        "name": "appward"
                    }, {
                        "if": "a.status!=2",
                        "type": "button",
                        "value": "Admit",
                        "onclick": "Eirene.runStmt('4admi-svip1',{pid:'<b.pid>',ward:$(this).parent().parent().find('select[name=appward]').val(),docid:'<c.id>'},$(this).hide())"
                    }, {
                        "if": "a.status=2",
                        "type": "icon",
                        "value": "Admitted"
                    }
                ],
                "join": "INNER JOIN cmch_patient b ON a.pid=b.pid LEFT JOIN cmch_doctors c ON c.id=a.doctor",
                "delstmt": "depapp",
                "header": "Patient ID,Patient,Case,Appointment Date,Doctor,Next Visit",
                "whr": "a.recordstatus=1 and DATE(a.pdate)=CURDATE() and a.status=0",
                "append": "<script>$('#workareaTablebox select.select1').html(\\\"||GET_drp||\\\");</script>",
                "mergebutton": "4btn",
                "prepend": "<div><button onclick='Eirene.runStmt(&apos;4gtwrd-4&apos;)'>Not visited</button><button onclick='Eirene.runStmt(&apos;4gtwrd-4&apos;,{filtertable:&apos;f5&apos;})'>Visited</button><button onclick='Eirene.runStmt(&apos;4gtwrd-4&apos;,{filtertable:&apos;f6&apos;})'>Admitted</button></div>",
                "onsuccess": "cmd:dom,fun:function;convertSelect;#workareaTablebox-cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:show;#workareaFilter1;slow-cmd:dom,fun:hide;#workareaAppendix;slow"

            },
            "edit_record": 1,
            "delete_record": 1
        }, {
            "id": "4btn",
            "name": "Appointment Button",
            "sql": {
                "action": "Return",
                "outputto": "php",
                "output": "demo",
                "value": "",
                "outputfilter": "#workareaFilter",
                "button": [{
                        "name": "f1",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and DATE(a.pdate)=DATE('||pdate||')"
                    }, {
                        "name": "f2",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and a.doctor='||docid||' and DATE(a.pdate)>='||df||' and DATE(a.pdate)<='||dt||'"
                    },{
                        "name": "f3",
                        "caption": "",
                        "type": "buttonspan",
						"title":"Add Appointment",
                        "class": "mif-plus fg-red",
                        "onclick": "showNewForm(&apos;pappointment&apos;)"
                    },{
                        "name": "f3a",
                        "caption": "<span class='mif-user'><span>",
                        "type": "buttonspan",
						"title":"Add Patient",
                        "class": "mif-plus fg-green",
                        "onclick": "showWindowInDialog(&apos;patient&apos;)"
                    }, {
                        "name": "f4",
                        "caption": "Appointments",
                        "type": "buttonspan",
                        "class": "mif-calendar fg-blue",
                        "onclick": "Eirene.runStmt(&apos;4gtwrd-4&apos;)"
                    }, {
                        "name": "f5",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and DATE(a.pdate)=CURDATE() and a.status=1"
                    }, {
                        "name": "f6",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and DATE(a.pdate)=CURDATE() and a.status=2"
                    }, {
                        "name": "f7",
                        "displaynone": 1,
                        "whr": [
                            "a.recordstatus=1", {
                                "if": "||docid||",
                                "op": "!=",
                                "value": "BLANK",
                                "then": " and c.id='||docid||'"
                            }, {
                                "if": "||appdtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||appdtto||",
                                "andop": "!=",
                                "andvalue": "BLANK",
                                "then": " and DATE(a.pdate)>='||appdtfrom||' and DATE(a.pdate)<='||appdtto||'"
                            }, {
                                "if": "||appdtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||appdtto||",
                                "andop": "=",
                                "andvalue": "BLANK",
                                "then": " and DATE(a.pdate)='||appdtfrom||'"
                            }

                        ]
                    }

                ],
                "onsuccess": "cmd:dom,fun:show;#workareaFilter;fast"
            }
        },
        {

            "id": "4visi",
            "name": "Save Visited(Appointment)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "tbl": "cmch_appointment",
                "fld": "status",
                "value": "1",
                "fldtype": "n",
                "command": "update",
                "whr": "pid= '||pid||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {

            "id": "4admi",
            "name": "Save Admit staus(Appointment)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "tbl": "cmch_appointment",
                "fld": "status",
                "value": "2",
                "fldtype": "n",
                "command": "update",
                "whr": "pid= '||pid||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "4gtwrd",
            "name": "Get Ward Dropdown",
            "sql": {
                "action": "Get Dropdown",
                "outputto": "php",
                "output": "drp",
                "tbl": "cmch_wardmaster",
                "fld": "id,abbreviation",
                "whr": "recordstatus=1"

            }
        }, {
            "id": "4gtapp",
            "name": "Get Appointment",
            "sql": {
                "action": "Get Row",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_appointment",
                "fld": "pid,pcase,pdate,doctor,nextvisit",
                "whr": "id='||ID||'",
				"function":"edit1"
            }
        }, {
            "id": "4gtpnm",
            "name": "Get Patient Name",
            "sql": {
                "action": "Get Value",
                "outputto": "php",
                "output": "nm",
                "tbl": "cmch_patient",
                "fld": "CONCAT(' (',pname,') ')",
                "whr": "pid='||pid||'",
                "onsuccess": "cmd:dom,fun:html;#pidnm;||GET_nm||"
            }

        }, {
            "id": "4apflt",
            "name": "Appointment List Filter",
            "sql": {
                "action": "Return",
                "validate": "users",
                "outputto": "php",
                "output": "flt",
                "value": "",
                "outputfilter": "#workareaFilter1",
                "button": [{
                        "name": "f1",
                        "id": "docid",
                        "caption": "Doctor ",
                        "type": "select",
                        "option": "SELECT '','' UNION ALL(SELECT id,name FROM cmch_doctors WHERE recordstatus=1)"
                    }, {
                        "name": "f2",
                        "id": "appdtfrom",
                        "caption": "Date From: ",
                        "type": "datepicker",
                        "value": "||CURDATE||"
                    }, {
                        "name": "f3",
                        "id": "appdtto",
                        "caption": "Date To: ",
                        "type": "datepicker",
                        "value": "||CURDATE||"
                    }, {
                        "name": "f4",
                        "caption": "Get",
                        "class": "button secondary",
                        "onclick": "Eirene.runStmt('4',{filtertable:'f7',docid:$('#docid').val(),appdtfrom:$('#appdtfrom').val(),appdtto:$('#appdtto').val()})"
                    }
                ],
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;slow"
            }
        }, {
            "id": "4svapp",
            "name": "Save Appointment",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "tbl": "cmch_appointment",
                "fld": "pid,pcase,pdate,doctor",
                "fldtype": "s,s,s,u",
                "command": "insertorupdate",
                "whr": "pid='||pcode||' and pcase='||pcase||' and pdate='||pdate||'",
                "value": "||pcode||,||pcase||,||pdate||,||pdoc||",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "depapp",
            "name": "Delete Appointment",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_appointment",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        },
        {
            "id": "5",
            "name": "List IP Patient",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "ip",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_ip a",
                "outputfilter": "#workareaFilter",
                "button": [{
                        "name": "f1",
                        "caption": "IP List",
                        "onclick": "Eirene.runStmt(\\\"4gtwrd-5-5flt\\\")",
                        "title": "List of Patient"
                    }, {
                        "name": "f2",
                        "caption": "Ward",
                        "onclick": "Eirene.runStmt(\\\"6a\\\")",
                        "title": "Ward Details"

                    }, {
                        "name": "f5",
                        "displaynone": 1,
                        "whr": [
                            "a.recordstatus=1", {
                                "if": "||ward||",
                                "op": "!=",
                                "value": "BLANK",
                                "then": " and a.ward='||ward||'"
                            }, {
                                "if": "||dtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||dtto||",
                                "andop": "!=",
                                "andvalue": "BLANK",
                                "then": " and DATE(a.addate)>='||dtfrom||' and DATE(a.addate)<='||dtto||'"
                            }, {
                                "if": "||dtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||dtto||",
                                "andop": "=",
                                "andvalue": "BLANK",
                                "then": " and DATE(a.addate)='||dtfrom||'"
                            }

                        ]
                    }
                ],
                "append": "<script>convertSelect('#workareaTablebox');</script>",
				"fld": "CONCAT('<a onclick=\\\"edit(&apos;patient&apos;,&apos;',d.id,'&apos;,true)\\\">',a.pid,'</a>')as pid,d.pname,a.addate,a.ipcase,c.name,b.wardname",
                "functionfield": [
					{					
                        "type": "text",
                        "value": "<bed>",
                        "caption": "Bed",
                        "onblur": "Eirene.runStmt('5svbed-5lcba',{pid:'<a.pid>',ID:'<a.id>',bed:$(this).val()})"
                    }, {
                        "type": "select",
                        "value": "<IF(f.details is null,&apos&&apos&,f.details)>",
                        "class": "select0",
						"values":":[select],Very Sick,Sick,Improving,Stable,Improved,Start Discharge",
                        "caption": "Patient Status",
                        "name": "mark",
                        "onchange": "Eirene.runStmt('5lcdm',{ipid:'<a.id>',mark:$(this).parent().parent().find('select[name=mark]').val()})"
                    }, 
					{
						"type":"group",
						"caption":"Action",
						"grp":[
						{
							"type": "icon",
							"class": "mif-injection fg-blue  mif-2x",
							"title": "Add Clinical Detail",
							"onclick": "showWindowInDialog('clinicaldetails');$('input[name=pid]').val('<a.pid>')"
						}, {
							"type": "icon",
							"class": "mif-search fg-blue",
							"title": "View Clinical Details",
							"onclick": "Eirene.runStmt('7cd',{pid:'<a.pid>',addate:'<a.addate>'})"
						}, {
							"type": "icon",
							"class": "mif-profile fg-blue mif-2x",
							"title": "View IP_Lifeycle",
							"onclick": "Eirene.runStmt('5lc',{ipid:'<a.id>'})"
						},{
							"type": "icon",
							"class":"mif-exit fg-blue",
							"title": "Add Discharge Summary",
							"onclick": "edit('discharge','<a.id>')"
						},{
							"type": "switch",
							"dataon": "IN",
							"dataoff": "OUT",
							"value": 1,
							"caption": "Admit",
							"onclick": "let stmt='';if(this.checked){stmt='5cdis-5lcdic';}else{stmt='5svdis-5lcdi';}Eirene.runStmt(stmt,{pid:'<a.pid>',ID:'<a.id>'})"
						},{
							"type":"icon",
							"class":"mif-pencil fg-blue",
							"title":"Edit",
							"onclick":"edit('ip','<a.id>')"
						},{
							"type":"icon",
							"class":"mif-cross fg-red",
							"title":"Delete",
							"onclick":"Eirene.runStmt2('delip','ID','<a.id>')"
						}
					]
				}
					
				
                ],
                "srt": "b.wardname,a.addate",
                "join":[
					"LEFT JOIN cmch_wardmaster b ON a.ward=b.id",
					"LEFT JOIN cmch_doctors c ON c.id=a.docid",
					"LEFT JOIN cmch_patient d ON d.pid=a.pid",					
					"LEFT JOIN (SELECT ipid,details FROM cmch_iplifecycle WHERE lcname='Patient Status') f ON f.ipid=a.id"
				],
                "delstmt": "delip",
                "header": "Patient ID,Patient Name,Admission Date,Case,Admitting Physician,Ward",
                "whr": "a.recordstatus=1 and (a.didate is NULL or a.didate='0000-00-00 00:00:00')",
                "onsuccess": "cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:hide;#workareaAppendix;slow"

            }
        }, {
            "id": "5flt",
            "name": "IP Filter",
            "sql": {
                "action": "Return",
                "outputto": "php",
                "output": "demo",
                "value": "",
                "outputfilter": "#workareaFilter1",
                "button": [{
                        "name": "f1",
                        "id": "5fltward",
                        "type": "select",
                        "option": "SELECT '','' UNION ALL (SELECT id,wardname FROM cmch_wardmaster WHERE recordstatus=1)"
                    }, {
                        "name": "f2",
                        "id": "5fltdtfrom",
                        "caption": "Date From: ",
                        "type": "datepicker"
                    }, {
                        "name": "f3",
                        "id": "5fltdtto",
                        "caption": "Date To: ",
                        "type": "datepicker"
                    }, {
                        "name": "f4",
                        "caption": "IP Record",
                        "class": "button secondary",
                        "onclick": "Eirene.runStmt('5ipr',{filtertable:'f7',ward:$('#5fltward').val(),dtfrom:$('#5fltdtfrom').val(),dtto:$('#5fltdtto').val()})"
                    }, {
                        "name": "f5",
                        "caption": "In Patient",
                        "class": "button secondary",
                        "onclick": "Eirene.runStmt('5',{filtertable:'f5',ward:$('#5fltward').val(),dtfrom:$('#5fltdtfrom').val(),dtto:$('#5fltdtto').val()})"
                    }

                ],
                "value": "<div class='inline-form'>Ward:<select id='ward'><option value=''>[Select]</option>||GET_drp||</select><span>Date From</span><input type='date' class='ml-2' id='attfromdate'/><span class='ml-2'>Date To</span><input type='date' class='ml-2' id='atttodate'><button type='button' class='button secondary ml-2' onclick='let df=$(\\\"#attfromdate\\\").val();let dt=$(\\\"#atttodate\\\").val();let wd=$(\\\"#ward\\\").val();let flt=\\\"\\\";if(df && dt){flt=\\\"f3\\\"}else if(df){flt=\\\"f4\\\"}else if(wd){flt=\\\"f5\\\"}else if(wd && df && dt){flt=\\\"f6\\\"}else{return false;};Eirene.runStmt(\\\"4gtwrd-5ipr\\\",{filtertable:flt,attfromdate:df,atttodate:dt,ward:wd})' >IP Records</button><button type='button' class='button secondary ml-2' onclick='let df=$(\\\"#attfromdate\\\").val();let dt=$(\\\"#atttodate\\\").val();let flt=\\\"\\\";if(df && dt){flt=\\\"f3\\\"}else if(df){flt=\\\"f4\\\"}else{return false;};Eirene.runStmt(\\\"4gtwrd-5\\\",{filtertable:flt,attfromdate:df,atttodate:dt})' >In-Patient</button></div>",
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;slow"
            }
        }, {

            "id": "5lc",
            "name": "show Life Cycle",
            "sql": {
                "action": "Get Table",
                "formname": "s",
                "outputto": "html",
                "output": "app",
                "tbl": "cmch_iplifecycle",
                "fld": "lcname,details,createdon",
                "header": "Lifecycle Name, Details, Date&Time",
                "whr": "ipid='||ipid||'",
                "srt": "createdon ASC",
                "onsuccess": "cmd:dom,fun:show;#workareaAppendix;slow-cmd:dom,fun:html;#workareaAppendix;||app||-cmd:dom,fun:function;datatable;#workareaAppendix;"
            }
        }, {
            "id": "5lcdm",
            "name": "Save Discharge Mark(Lifecycle)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "tbl": "cmch_iplifecycle",
                "fld": "ipid,lcname,details,createdby",
                "value": "||ipid||,Patient Status,||mark||,||USERID||",
                "fldtype": "s,s,s,s",
                "command": "insertorupdate",
                "whr": "ipid='||ipid||' and lcname='Patient Status'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "5lcba",
            "name": "Save Bed Allotted(Lifecycle)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "tbl": "cmch_iplifecycle",
                "fld": "ipid,lcname,details,createdby",
                "value": "||ID||,Bed Allotted,||bed||,||USERID||",
                "fldtype": "s,s,s,s",
                "command": "insertorupdate",
                "whr": "ipid='||ID||' and lcname='Bed Allotted'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "5lcdi",
            "name": "Save Discharge(Lifecycle)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "tbl": "cmch_iplifecycle",
                "fld": "ipid,lcname,createdby",
                "value": "||ID||,Discharged,||USERID||",
                "fldtype": "s,s,s",
                "command": "insertorupdate",
                "whr": "ipid='||ID||' and lcname='Discharged'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "5lcdic",
            "name": "Delete Discharge(LifeCycle)",
            "sql": {
                "action": "Delete Row Permanently",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_iplifecycle",
                "whr": "ipid='||ID||' and lcname='Discharged'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        },
        {
            "id": "5ipr",
            "name": "List IP Record(Filter)",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "ip",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_ip a",
                "outputfilter": "fltbtn",
                "button": [
                    {
                        "name": "f3",
                        "sqlid": "7",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and DATE(a.addate)>='||attfromdate||' and DATE(a.addate)<='||atttodate||'"
                    }, {
                        "name": "f4",
                        "sqlid": "7",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and DATE(a.addate)='||attfromdate||'"
                    }, {
                        "name": "f5",
                        "sqlid": "7",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and ward='||a.ward||'"
                    }, {
                        "name": "f6",
                        "sqlid": "7",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and DATE(a.addate)>='||attfromdate||' and DATE(a.addate)<='||atttodate||' and ward='||a.ward||'"
                    }, {
                        "name": "f7",
                        "displaynone": 1,
                        "whr": [
                            "a.recordstatus=1", {
                                "if": "||ward||",
                                "op": "!=",
                                "value": "BLANK",
                                "then": " and a.ward='||ward||'"
                            }, {
                                "if": "||dtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||dtto||",
                                "andop": "!=",
                                "andvalue": "BLANK",
                                "then": " and DATE(a.addate)>='||dtfrom||' and DATE(a.addate)<='||dtto||'"
                            }, {
                                "if": "||dtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||dtto||",
                                "andop": "=",
                                "andvalue": "BLANK",
                                "then": " and DATE(a.addate)='||dtfrom||'"
                            }

                        ]
                    }

                ],

                "fld": "a.pid,a.addate,a.didate,a.ipcase,c.name,b.wardname,a.bed,IF(DATE(a.didate)>=DATE_ADD(CURDATE(),INTERVAL -1 DAY),CONCAT('<span class=\\\"mif-undo fg-blue\\\" title=\\\"Back to IP\\\"onclick=Eirene.runStmt(&apos;5cdis-5lcdic&apos;,{ID:&apos;',a.id,'&apos;,pid:&apos;',a.pid,'&apos;},$(this).hide())></span>'),'')",
                "join": "INNER JOIN cmch_wardmaster b ON a.ward=b.id LEFT JOIN cmch_doctors c ON c.id=a.docid",
                "delstmt": "delip",
                "header": "Patient ID,Admission Date,Discharge Date,Case,Admitting Physician,Ward,Bed",
                "whr": "a.recordstatus=1",
                "onsuccess": "cmd:dom,fun:html;#workareaAppendix;||fltbtn||-cmd:dom,fun:show;#workareaFilter;slow"

            },

            "edit_record": 1,
            "delete_record": 1
        },
        {
            "id": "gtip",
            "name": "Get IP Patient Details",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_ip",
                "fld": "id,pid,addate,didate,ipcase,docid,nurid,ward,bed,adremarks,diremarks",
                "whr": "id='||ID||'",
				"function":"edit1"

            }
        }, {
            "id": "svip",
            "name": "Save IP Patient",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_ip",
                "fld": "pid,addate,didate,ipcase,docid,nurid,ward,bed,adremarks,diremarks",
                "value": "||pid||,||addate||,||didate||,||ipcase||,||docid||,||nurid||,||ward||,||bed||,||adremarks||,||diremarks||",
                "fldtype": "s,s,s,s,u,u,u,s,s,s",
                "command": "insertorupdate",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=pid];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "svip1",
            "name": "Save IP Patient(Admit)",
            "sql": {
                "action": "MULTISTMT",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "multistmt": [{
                        "action": "Save Row",
                        "tbl": "cmch_ip",
                        "fld": "pid,addate,ward,recordstatus,ipcase,docid,bed",
                        "value": "||pid||,NOW(),||ward||,1,Medical,||docid||,0",
                        "fldtype": "s,n,u,n,s,u,s",
                        "command": "insert",
                        "whr": "pid='||pid||' and DATE(addate)=CURDATE()",
                        "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                        "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
                    }, {
                        "action": "Run",
                        "stmt": "INSERT INTO cmch_iplifecycle (id,createdby,ipid,lcname,details,createdon) values (UUID(),'||USERID||','||LASTINSERTID||','Admission','',NOW()),(UUID(),'||USERID||','||LASTINSERTID||','Room Allotted',(SELECT wardname FROM cmch_wardmaster WHERE id='||ward||'),NOW())"
                    }
                ]
            }
        }, {
            "id": "5svdis",
            "name": "Save Discharge(ip)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_ip",
                "fld": "didate",
                "value": "NOW()",
                "fldtype": "n",
                "command": "update",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"

            }
        }, {
            "id": "5svbed",
            "name": "Save Bed (IP)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_ip",
                "fld": "bed",
                "value": "||bed||",
                "fldtype": "s",
                "command": "update",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"

            }
        }, {

            "id": "5cdis",
            "name": "Cancel Discharge(ip)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_ip",
                "fld": "didate",
                "value": "'0000-00-00 00:00:00'",
                "fldtype": "n",
                "command": "update",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"

            }
        },
        {
            "id": "delip",
            "name": "Delete IP Patient",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_ip",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        }, {
            "id": "6",
            "name": "Ward Details",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "wardmaster",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_wardmaster a",
                "fld": "a.wardname,a.abbreviation,a.maxcapacity",
                "delstmt": "6delwd",
                "header": "Ward Name,Abbreviation,Max.Capacity",
                "whr": "recordstatus=1"
            },
            "edit_record": 1,
            "delete_record": 1
        }, {
            "id": "6flt1",
            "name": "Ward Details",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "wardmaster",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_wardmaster a",
                "outputfilter": "fltbtn",
                "button": [{
                        "name": "f3",
                        "sqlid": "6",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and a.id='||ward||'"
                    }
                ],

                "fld": "a.abbreviation,IF(b.cnt is null,0,b.cnt) as cnt, a.maxcapacity",
                "functionfield": [{
                        "type": "donut",
                        "value": "<cnt/maxcapacity * 100>",
                        "bgclr": "bg-gray"
                    }
                ],
                "join": "LEFT JOIN(SELECT ward,count(*) as cnt FROM cmch_ip WHERE (didate is null or didate='0000-00-00 00:00:00') GROUP BY ward) b on b.ward= a.id",
                "delstmt": "6delwd",
                "header": "Abbreviation,Occupied,Max.Capacity",
                "whr": "recordstatus=1",
                "onsuccess": "cmd:dom,fun:html;#workareaFilter;||fltbtn||-cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:hide;#workareaFilter1;slow-cmd:dom,fun:hide;#workareaAppendix;slow"

            },

            "edit_record": 1,
            "delete_record": 1

        }, {
            "id": "6a",
            "name": "Ward Details",
            "sql": {
                "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "table",
                "outputfilter": "fltbtn",
                "button": [{
                        "name": "f4",
                        "caption": "IP List",
                        "onclick": "Eirene.runStmt(\\\"4gtwrd-5-5flt\\\")",
                        "title": "List of Patient"
                    }, {
                        "name": "f5",
                        "caption": "Ward",
                        "onclick": "Eirene.runStmt(\\\"4gtwrd-5-5flt\\\")",
                        "title": "Ward Details"
                    }, {
                        "name": "f1",
                        "type": "buttonspan",
                        "class": "mif-plus fg-red",
                        "caption": "",
                        "onclick": "showNewForm(\\\"wardmaster\\\")",
                        "title": "Add Ward"
                    }, {
                        "name": "f2",
                        "caption": "Ward Details",
                        "sqlid": "6",
                        "title": "Ward Details"
                    }, {
                        "name": "f3",
                        "sqlid": "6",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and a.id='||ward||'"
                    }
                ],
                "tbl": "cmch_wardmaster a",
                "parent": "div class='d-flex flex-wrap flex-justify-around'",
                "template": [
                    "<div class='cell'>",
                    "<div class='icon-box border bd-default' style='height:100px;'>",
                    "<div class='bg-cyan fg-white'>||Donut||</div>",
                    "<div class='content p-4'>",
                    "<div class='text-upper'>||wardname||</div>",
                    "<div class='text-upper text-bold text-lead'>||cnt||/||maxcapacity||</div>",
                    "</div>",
                    "</div></div>"
                ],

                "fld": "a.wardname,a.abbreviation,IF(b.cnt is null,0,b.cnt) as cnt, a.maxcapacity",
                "functionfield": [{
                        "type": "donut",
                        "value": "<cnt/maxcapacity * 100>",
                        "bgclr": "bg-gray",
                        "caption": "Donut"

                    }
                ],
                "join": "LEFT JOIN(SELECT ward,count(*) as cnt FROM cmch_ip WHERE (didate is null or didate='0000-00-00 00:00:00') GROUP BY ward) b on b.ward= a.id",
                "whr": "recordstatus=1",
                "onsuccess": "cmd:dom,fun:html;#workareaFilter;||fltbtn||-cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:hide;#workareaFilter1;slow-cmd:dom,fun:hide;#workareaAppendix;slow"

            }
        },
        {
            "id": "6gtwm",
            "name": "Get Ward Details",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_wardmaster",
                "fld": "id,wardname,abbreviation,maxcapacity",
                "whr": "id='||ID||'",
				"function":"edit1"

            }
        }, {
            "id": "6svwm",
            "name": "Save Ward Details",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_wardmaster",
                "fld": "wardname,abbreviation,maxcapacity",
                "value": "||wardname||,||abbreviation||,||maxcapacity||",
                "fldtype": "s,s,n",
                "command": "insertorupdate",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=wardname];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "6delwd",
            "name": "Delete Ward",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_wardmaster",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        }, {
            "id": "7",
            "name": "Clinical Details",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "clinicaldetails",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_clinicaldetails a",
                "outputfilter": "fltbtn",
                "button": [{
                        "name": "f1",
                        "type": "buttonspan",
                        "class": "mif-plus fg-red",
                        "caption": "",
                        "onclick": "showNewForm(\\\"clinicaldetails\\\")",
                        "title": "Add Clinical Details"
                    }, {
                        "name": "f2",
                        "caption": "Clinical Details",
                        "onclick": "Eirene.runStmt(\\\"7\\\")",
                        "title": "Clinical Details"
                    },
                    {
                        "name": "f3",
                        "sqlid": "7",
                        "displaynone": 1,
                        "whr": "a.pid='||pid||' and a.recordstatus=1 and DATE(a.cdate)>='||attfromdate||' and DATE(a.cdate)<='||atttodate||'"
                    }, {
                        "name": "f4",
                        "sqlid": "7",
                        "displaynone": 1,
                        "whr": "a.pid='||pid||' and a.recordstatus=1 and DATE(a.cdate)='||attfromdate||'"
                    }

                ],
                "fld": "b.pname,a.cdate,a.bp,a.pulse,a.temperature,a.spo2,a.sugar,a.ecg",
                "join": "LEFT JOIN cmch_patient b ON b.pid=a.pid",
                "delstmt": "7delcd",
                "header": "Patient Name,Date,BP,Pulse,Temperature,spo2,Sugar,ECG",
                "whr": "a.recordstatus=1",

                "onsuccess": "cmd:dom,fun:html;#workareaFilter;||fltbtn||-cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:hide;#workareaAppendix;slow"

            },
            "edit_record": 1,
            "delete_record": 1
        }, {
            "id": "6flt",
            "name": "Clinical Details Filter",
            "sql": {
                "action": "Return",
                "output": "#workareaFilter1",
                "value": "<div class='d-flex flex-justify-around'>Patient ID<input type='text' id='fpid'></input>Date From<input type='date' id='attfromdate'></input>Date To<input type='date' id='atttodate'></input><button type='button' onclick='let df=$(\\\"#attfromdate\\\").val();let dt=$(\\\"#atttodate\\\").val();let flt=\\\"\\\";if(df && dt){flt=\\\"f3\\\"}else if(df){flt=\\\"f4\\\"}else{return false;};Eirene.runStmt(\\\"7\\\",{filtertable:flt,pid:$(&apos;#fpid&apos;).val(),attfromdate:df,atttodate:dt})' >Get</button></div>",
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;slow"
            }
        }, {
            "id": "7getcd",
            "name": "Get Clinical Details",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_clinicaldetails",
                "fld": "id,pid,cdate,bp,pulse,temperature,spo2,sugar,ecg",
                "whr": "id='||ID||'",
				"function":"edit1"

            }
        }, {
            "id": "7savcd",
            "name": "Save Clinical Details",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_clinicaldetails",
                "fld": "pid,cdate,bp,pulse,temperature,spo2,sugar,ecg",
                "value": "||pid||,||cdate||,||bp||,||pulse||,||temperature||,||spo2||,||sugar||,||ecg||",
                "fldtype": "s,s,s,s,s,s,s,s",
                "command": "insertorupdate",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=pid];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        }, {
            "id": "7svcd1",
            "name": "Save Clinical Details(ip)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_clinicaldetails",
                "fld": "pid,cdate",
                "value": "||pid||,NOW()",
                "fldtype": "s,n",
                "command": "insertorupdate",
                "whr": "pid=||pid||",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"

            }
        }, {
            "id": "7delcd",
            "name": "Delete Clinical Details",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_clinicaldetails",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        }, {

            "id": "7cd",
            "name": "Clinical Details(Selected)",
            "sql": {
                "action": "Get Table",
                "formname": "clinicaldetails",
                "outputto": "html",
                "output": "app",
                "tbl": "cmch_clinicaldetails",
                "fld": "pid,cdate,bp,pulse,temperature,spo2,sugar,ecg",
                "delstmt": "7delcd",
                "header": "PatientID,Date,BP,Pulse,Temperature,spo2,Sugar,ECG",
                "whr": "recordstatus=1 and pid='||pid||' and '||addate||'<= NOW()",
                "srt": "createdon DESC",
                "limit": 200,
                "onsuccess": "cmd:dom,fun:show;#workareaAppendix;slow-cmd:dom,fun:html;#workareaAppendix;||app||-cmd:dom,fun:function;datatable;#workareaAppendix;"

            },
            "edit_record": 1,
            "delete_record": 1

        }, {
            "id": "8",
            "name": "Billing",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "billing",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_bill a",
                "outputfilter": "fltbtn",
                "button": [{
                        "name": "f1",
                        "type": "buttonspan",
                        "class": "mif-plus fg-red",
                        "caption": "Item Bill",
                        "onclick": "showNewForm(\\\"billing\\\");Eirene.runStmt(\\\"10bft\\\")",
                        "title": "New Bill"
                    }, {
                        "name": "f12",
                        "caption": "Receipts",
                        "onclick": "Eirene.runStmt(\\\"10phft-10ph\\\")",
                        "title": "Bills of Today"
                    }, {
                        "name": "f3",
                        "sqlid": "7",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and DATE(a.bdate)>='||attfromdate||' and DATE(a.bdate)<='||atttodate||'"
                    }, {
                        "name": "f4",
                        "sqlid": "7",
                        "displaynone": 1,
                        "whr": "a.recordstatus=1 and DATE(a.bdate)='||attfromdate||'"
                    }, {
                        "name": "f8",
                        "caption": "Items",
                        "onclick": "Eirene.runStmt(\\\"9-8ftcat\\\")",
                        "title": "Show Item List"
                    }, {
                        "name": "f9",
                        "caption": "",
                        "displaynone": 1,
                        "whr": "b.category= '||fcat||'"
                    },{
                        "name": "f10",
                        "caption": "Bill Records",
                        "onclick": "Eirene.runStmt(\\\"10brec-10brft\\\")",
                        "title": "Records of Bill"
                    }, {
                        "name": "f11",
                        "caption": "Advance",
                        "onclick": "showNewForm('advance');Eirene.runStmt('13adft')",
                        "title": "Advance"
                    },
					{
                        "name": "f12",
                        "caption": "Refund",
                        "onclick": "showNewForm('refund');Eirene.runStmt('14rfft')",
                        "title": "Refund"
                    },
					{
                        "name": "f13",
                        "caption": "Bill Summary",
                        "onclick": "Eirene.runStmt('8sum-8sumft',{dt:''})",
                        "title": "Summary"
                    }

                ],
                "fld": "a.bdate,c.pname,b.item,a.rate,a.quatity,a.discount,a.total",
				 "functionfield": [
					{
						"type":"group",
						"grp":[
							{
								"if": "a.billno IS NULL",
								"type":"icon",
								"class":"mif-pencil fg-blue mr-3",
								"onclick":"edit('billing','<a.id>')"                        
							},{
								"if": "a.billno IS NULL",
								"type":"icon",
								"class":"mif-cross fg-red",
								"onclick":"Eirene.runStmt2('ditem','ID','<a.id>')"                        
							}
						]
					}
				],
				
                "join": "LEFT JOIN cmch_item b ON b.item=a.item LEFT JOIN cmch_patient c ON a.pid=c.pid",
                "header": "Date,Patient Name,Item,Rate,Quantity,Discount,Total",
                "whr": "a.recordstatus=1 and Date(a.bdate)= CURDATE()",
                "delstmt": "ditem",
                "prepend": "<div class='d-flex flex-justify-around'>Date From<input type='date' id='attfromdate'></input>Date To<input type='date' id='atttodate'></input><button type='button' onclick='let df=$(\\\"#attfromdate\\\").val();let dt=$(\\\"#atttodate\\\").val();let flt=\\\"\\\";if(df && dt){flt=\\\"f3\\\"}else if(df){flt=\\\"f4\\\"}else{return false;};Eirene.runStmt(\\\"8\\\",{filtertable:flt,attfromdate:df,atttodate:dt})' >Get</button></div>",
                "onsuccess": "cmd:dom,fun:html;#workareaFilter;||fltbtn||-cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:hide;#workareaAppendix;slow"

            }
        },{
			"id":"8sum",
			"name":"Bill Summary",
			"sql":{
				"action":"MULTISTMT",
				"outputto":"php",
				"output":"res",
				"multistmt":[
					{
						"action":"Return","output":"#workareaTablebox","value":"<div><button class='no-print button secondary' onclick='printHTML(&apos;workareaTablebox&apos;)'>Print</button></div>"
					},
					{"action":"Get Table","output":"#workareaTablebox","appendoutput":true,
						"tbl":"cmch_payment",
						"fld":"paymentmethod,SUM(amount)",
						"whr":[
							{"if":"||dt||","value":"BLANK","then":"DATE(createdon)=CURDATE()","else":"DATE(createdon)='||dt||'"}
						],
						"grp":"paymentmethod",
						"header":"Mode,Amount",
						"union":[
								" UNION ALL SELECT '<b>Total</b>',SUM(amount)",
								"FROM cmch_payment WHERE",								
								{"if":"||dt||","value":"BLANK","then":"DATE(createdon)=CURDATE()","else":"DATE(createdon)='||dt||'"},
								" UNION all SELECT '<b>Total (Non Cash)</b>',SUM(amount)",
								"FROM cmch_payment WHERE paymentmethod <>'Cash' and ",								
								{"if":"||dt||","value":"BLANK","then":"DATE(createdon)=CURDATE()","else":"DATE(createdon)='||dt||'"}
							],
						"prepend":"<h2>Receipts</h2>",
						"class":"eirene-table dataTable"
					},{
						"action":"Get Matrix","output":"#workareaTablebox","appendoutput":true,
						"row":"paystatus",
						"col":"category",
						"val":"tot",
						"horizontalsum":1,
						"verticalsum":1,
						"matrixtableclass":"eirene-table dataTable",
						"tbl":"cmch_printbill a",
						"join":"INNER JOIN cmch_bill b ON a.billno=b.billno",
						"fld":"a.paystatus,b.category,SUM(b.total) as tot",
						"whr":[
							{"if":"||dt||","value":"BLANK","then":"DATE(a.createdon)=CURDATE()","else":"DATE(a.createdon)='||dt||'"}
						],
						"grp":"a.paystatus,b.category",						
						"prepend":"<h2 class='mt-3'>Bills</h2>",
						"header":"Status,Amount",
						"class":"eirene-table dataTable"
						
					},{
						"action":"Get Table","output":"#workareaTablebox","appendoutput":true,
						"tbl":"cmch_advance",
						"fld":"paymentmethod,SUM(advance)",
						"grp":"paymentmethod",
						"vsum":"2",
						"whr":[
							{"if":"||dt||","value":"BLANK","then":"DATE(createdon)=CURDATE()","else":"DATE(createdon)='||dt||'"}
						],						
						"header":",",
						"prepend":"<h2 class='mt-3'>Advance</h2>",
						"class":"eirene-table dataTable"
					},{
						"action":"Get Table","output":"#workareaTablebox","appendoutput":true,
						"tbl":"cmch_refund",
						"fld":"'Refund',SUM(refund)",
						"whr":[
							{"if":"||dt||","value":"BLANK","then":"DATE(createdon)=CURDATE()","else":"DATE(createdon)='||dt||'"}
						],
						"header":",",
						"prepend":"<h2 class='mt-3'>Refund</h2>",
						"class":"eirene-table dataTable"
					}					
				]
			}
			
		},{
			"id":"8sumft",
			"name":"Billing Summary Filter",
			"sql":{
				"action":"Return","outputto":"php","output":"demo",
				"value":"",
				"outputfilter":"#workareaFilter1",
				"button":[
					{"name":"f1","type":"datepicker","id":"8sumftdt"},
					{"name":"f2","type":"button","class":"button secondary","caption":"Get","onclick":"Eirene.runStmt('8sum',{dt:$('#8sumftdt').val()})"}					
				],
				"onsuccess":"cmd:dom,fun:show;#workareaAppendix1;fast"
			}
			
		}, {
            "id": "8gtbl",
            "name": "Get bill item Item",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_bill",
                "fld": "id,billno,bdate,pid,item,category,rate,quatity,discount,total",
                "whr": "id='||ID||'",
				"function":"edit1"

            }

        }, {
            "id": "ditem",
            "name": "Delete bill Item",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_bill",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        }, {
            "id": "8svbl",
            "name": "Save Bill",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_bill",
                "fld": "bdate,pid,item,category,rate,quatity,discount,total",
                "value": "NOW(),||pid||,||item||,||category||,||rate||,||quatity||,||discount||,||total||",
                "fldtype": "n,s,s,s,n,n,n,n",
                "command": "insertorupdate",
                "whr": "id='||ID||'",
				"additionalstmt":"8svbla",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=total];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
            }
        },
		{
            "id": "8svbla",
            "name": "Billing",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaAppendix",
                "tbl": "cmch_bill", 
				"fld":"item,rate,quatity,discount,total",                
                "header": "Item,Rate,Quantity,Discount,Total",
                "whr": "pid='||pid||' and billno IS NULL", 
				"srt":"createdon DESC",
				"union":"SELECT '','','','<b>Total</b>',SUM(total) FROM cmch_bill WHERE pid='||pid||' and billno IS NULL",
                "onsuccess": "cmd:dom,fun:show;#workareaAppendix;slow",
				"class":"eirene-table dataTable"

            }
        },
		
        {
            "id": "8ftcat",
            "name": "Filter Item(Category)",
            "sql": {
                "action": "Return",
                "validate": "users",
                "outputto": "php",
                "output": "demo",
				"value":"",
				"outputfilter":"#workareaFilter1",
				"button":[
					{"name":"f0","type":"buttonspan","class":"mif-plus fg-blue mr-2","caption":" Item","onclick":"showWindowInDialog('item')"},
					{"name":"f1","type":"select","option":"SELECT DISTINCT category FROM cmch_item WHERE recordstatus=1","id":"catft"},
					{"name":"f2","type":"button","class":"button secondary","caption":"Get","onclick":"Eirene.runStmt('9',{filtertable:'f9',fcat:$('#catft').val()})"}
				],
                
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"
            }
        }, {
            "id": "8gens1",
            "name": "Create PrintBill Record",
            "sql": {
                "action": "MULTISTMT",
                "outputto": "php",
                "multistmt": [{
                        "action": "Save Row",
                        "command": "insert",
                        "tbl": "cmch_printbill",
                        "fld": "pid,paystatus,appid,department",
                        "value": "||pid||,||paystatus||,||appid||,||department||",
                        "fldtype": "s,s,s,s",
                        "onsuccess": "cmd:dom,fun:showtoast;success;Bill Generated-cmd:dom,fun:empty;#workareaTablebox;fast"
						
                    }, {
                        "action": "Get Value",
                        "outputto": "html",
                        "output": "billno",
                        "tbl": "cmch_printbill",
                        "fld": "billno",
                        "whr": "id='||LASTINSERTID||'"
                    }, {
                        "action": "Save Row",
                        "outputto": "php",
                        "output": "res",
                        "command": "update",
                        "tbl": "cmch_bill",
                        "fld": "billno",
                        "value": "||GET_billno||",
                        "fldtype": "n",
                        "whr": "id IN (||IDS||)"
                    }, {
                        "action": "Get Value",
                        "outputto": "php",
                        "output": "pname",
                        "tbl": "cmch_patient",
                        "fld": "pname",
                        "whr": "pid='||pid||'"

                    }, {
                        "action": "Run",
                        "outputto": "php",
                        "output": "res",
                        "stmt": "INSERT INTO cmch_xray (id,billno,item,createdby) SELECT UUID(),billno,item,'||USERID||' FROM cmch_bill WHERE category='Radiology' and billno=||GET_billno||",
                        "onfailure": "cmd:dom,fun:showtoast;alert;X Ray record generation failed"
                    }, {
                        "action": "Run",
                        "outputto": "php",
                        "output": "res",
                        "stmt": "INSERT INTO cmch_lab (id,billno,item,createdby) SELECT UUID(),billno,item,'||USERID||' FROM cmch_bill WHERE (category='Lab' or category ='Thyrocare Lab') and billno=||GET_billno||",
                        "onfailure": "cmd:dom,fun:showtoast;alert;Lab record generation failed"
                    }, {
                        "action": "Return",
                        "outputto": "html",
                        "output": "#workareaAppendix",
                        "value": [
                            "<div id='printbill_1'></div>",
                            "<div id='printbill_2'></div>",
                            "<div id='printbill_3'></div>"
                        ],
						"additionalstmt":"10-10a-10pd-10prt-10e-10tot"
                    }
                ]
            }
        },
		{
			"id":"10prbl",
			"name":"Print Bil(Record)",
			"sql":{
                        "action": "Return",
                        "outputto": "html",
                        "output": "#workareaAppendix",
                        "value": [
                            "<div id='printbill_1'></div>",
                            "<div id='printbill_2'></div>",
                            "<div id='printbill_3'></div>"
                        ],
						"additionalstmt":"10-10a-10pd-10prt-10e-10tot"
                    }
		},
        {
            "id": "9",
            "name": "Item List",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "item",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_item",
                "delstmt": "9delit",
				"outputfilter":"workareaAppendix",
				"button":[
					{
						"name": "f9",
						"caption": "",
						"displaynone": 1,
						"whr": "category='||fcat||'"
					}
				],
                "fld": "item,rate,category",
                "header": "Item,Rate,Category",
                "whr": "recordstatus=1"

            },
            "edit_record": 1,
            "delete_record": 1
        }, {
            "id": "9svit",
            "name": "Save Item List",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_item",
                "fld": "item,rate,category",
                "value": "||item||,||rate||,||category||",
                "fldtype": "s,n,s",
                "command": "insertorupdate",
                "whr": "id='||id||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=item];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"

            }
        }, {
            "id": "9gtit",
            "name": "Get Item",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_item",
                "fld": "id,item,rate,category",
                "whr": "id='||ID||'",
				"function":"edit1"

            }

        }, {
            "id": "9delit",
            "name": "Delete Item",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_item",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        },
        {
            "id": "10",
            "name": "Get Bill - HTML",
            "sql": {
                "action": "MULTISTMT",
                "validate": "users",
                "outputto": "html",                
                "multistmt":[
					{"action":"Get Row","outputto":"php","output":"patient","tbl":"cmch_patient","fld":"pname,pmobile","whr":"pid='||pid||'"},
					{"action":"Get Row","outputto":"php","output":"bill","tbl":"cmch_printbill","fld":"DATE_FORMAT(createdon,'%d-%m-%Y') as billdate,department,appid",
						"whr":[
							{"if":"||GET_billno||","op":">","value":"0","then":"billno='||GET_billno||'","else":"billno='||billno||'"}							
						]
					},
					{"action":"Get Value","outputto":"php","output":"appcnt","stmt":"SELECT count(*) FROM cmch_appointment WHERE id='||GET_bill_appid||'"},
					{"precheck":[{"if":"||GET_appcnt||","op":"=","value":"1"}], "action":"Get Row","outputto":"php","output":"appointment","tbl":"cmch_appointment a","fld":"a.pcase,b.name","join":"LEFT JOIN cmch_doctors b ON a.doctor=b.id","whr":"a.id='||GET_bill_appid||'"},
					{"precheck":[{"if":"||GET_appcnt||","op":"=","value":"0"}], "action":"Get Row","outputto":"php","output":"appointment","stmt":"SELECT '' pcase,'' name FROM cmch_appointment LIMIT 1"},
					{"action":"Return","outputto":"html","output":"#printbill_2",
						"value":[
							"<center><img src='resource/image/cmch_logo1.png' width='500' height='70'>",
							"<div>Bill No. :",
							{"if":"||GET_billno||","op":">","value":"0","then":"||GET_billno||","else":"||billno||"},							
							"</div></center><center>",
							"<table style='border:1px solid black;border-collapse:collapse;margin-left:auto;margin-right:auto;font-size:0.7em'>",
							"<tr><td style='border:1px solid black' class='p-1'><b>Patient ID</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||pid||</td><td style='border:1px solid black' class='p-1'><b>Name</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||GET_patient_pname||</td></tr>",
							"<tr><td style='border:1px solid black' class='p-1'><b>Date</b></td><td style='border:1px solid black' class='p-1'>||GET_bill_billdate||</td><td style='border:1px solid black' class='p-1'><b>Mobile No.</b></td><td style='border:1px solid black' class='p-1'>||GET_patient_pmobile||</td></tr>",
							"<tr><td style='border:1px solid black' class='p-1'><b>Case Type</b></td><td style='border:1px solid black' class='p-1'>||GET_appointment_pcase||</td><td style='border:1px solid black' class='p-1'><b>Doctor</b></td><td style='border:1px solid black' class='p-1'>||GET_appointment_name||</td></tr>",
							"<tr><td style='border:1px solid black' class='p-1'><b>Department</b></td><td style='border:1px solid black' class='p-1'>||GET_bill_department||</td><td style='border:1px solid black' class='p-1'></td><td style='border:1px solid black' class='p-1'></td></tr>",
							"</table>"
						],
						"onsuccess":"cmd:dom,fun:show;#workareaAppendix;fast"
					}
				]
            }
        },{
			"id":"10est",
			"name":"Get Estimate Bill",
			"sql":{
				"action":"MULTISTMT","output":"#workareaAppendix",
				"multistmt":[
					{"action":"Get Row","outputto":"php","output":"patient","tbl":"cmch_patient","fld":"pname,pmobile","whr":"pid='||pid||'"},
					{"action":"Return","output":"#workareaAppendix","value":"<button class='mif-printer fg-blue no-print' onclick='printHTML(&apos;workareaAppendix&apos;)'></button><div><center><img src='resource/image/cmch_logo1.png' width='600' height='70'></center></div>"},
					{
						"action": "Get Table",						
						"outputto": "html",
						"output": "#workareaAppendix","appendoutput":true,
						"tbl": "cmch_bill a",                
						"fld": "a.item,a.bdate,a.quatity,a.total",
						"header":"Item,Date,Quantity,Amount",
						"class":"eirene-table dataTable mt-3",
						"vsum":"4",
						"append":"<h3>Bill Item</h3>",
						"join": "LEFT JOIN cmch_printbill b ON b.billno=a.billno",
						"whr": "a.recordstatus=1 and a.billno is null and a.pid='||pid||'",
						"onsuccess":"cmd:dom,fun:show;#workareaAppendix;fast",
						"prepend":"<table class='eirene-table dataTable'><tr><td>||pid||</td><td>||GET_patient_pname||</td><td>Mob. ||GET_patient_pmobile||</td></tr></table>"						
					},{
						"action": "Get Table",					
						"outputto": "html",
						"output": "#workareaAppendix","appendoutput":true,
						"tbl": "cmch_advance a",
						"fld": "DATE(a.createdon),a.paymentmethod,a.advance,a.balance",
						"vsum":"3,4",
						"serialno":true,
						"append":"<h3>Advance Statement</h3>",
						"class":"eirene-table dataTable",
						"join": "LEFT JOIN cmch_patient b ON a.pid=b.pid",
						"header": "Date,Payment Mode,Amount,Balance",
						"whr": "a.recordstatus=1 and b.pid='||pid||' and DATE(a.createdon) between DATE_ADD(CURDATE(), INTERVAL -30 DAY) and CURDATE()"
					},{
						"action": "Get Table",						
						"outputto": "html",
						"output": "#workareaAppendix","appendoutput":true,
						"tbl":"cmch_printbill a",
						"join":[
							"INNER JOIN (select billno,SUM(total) total FROM cmch_bill GROUP BY billno) b ON b.billno=a.billno",
							"INNER JOIN cmch_patient c ON c.pid=a.pid",
							"LEFT JOIN (select billno,SUM(amount) amount FROM cmch_payment GROUP BY billno) d ON d.billno=a.billno"
						],
						"fld":"a.pid,c.pname,a.billno,a.createdon,b.total as billamt,IF(d.amount is null,0,d.amount) as paid",
						"functionfield":[
							{"name":"f1","type":"button","class":"mif-printer fg-blue","onclick":"Eirene.runStmt('10prbl',{billno:'<a.billno>',pid:'<c.pid>',paystatus:'<a.paystatus>'})"}
						],
						"whr":"a.pid='||pid||' and a.recordstatus=1 and paid<billamt",
						"limit":"3000",
						"srt":"a.billno DESC",				
						"vsum":"5,6",
						"prepend":"<h3>Pending Bills</h3>",
						"header": "Patient ID,Patient Name,BIll NO,Date,Total Bill,Total Paid", 
					}
				]
			}
		},{
            "id": "10prt",
            "name": "Print Bill Button",
            "sql": {
                "action": "Return",
                "output": "#printbill_1",
                "outputto": "html",
                "value": "<button style='margin-right:128px' type='buttonspan' class='mif-printer fg-blue' onclick='printHTML(&apos;printbill_2&apos;)'></button>"

            }
        },
        {
            "id": "10pd",
            "name": "Get Paid Details - HTML",
            "sql": {
                "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#printbill_2",
				"appendoutput":true,				
                "tbl": "cmch_payment",
                "fld": "createdon,paymentmethod,amount",
				"union":"UNION ALL SELECT '','<b>Total</b>', CONCAT('<span id=\\\"10pdpaidtotal\\\"><b>',SUM(amount),'</b></span>') FROM cmch_payment WHERE recordstatus=1 and billno='||billno||'",
				"parent": "TABLE style='margin-left: auto;margin-right:auto;margin-top:0.5cm;width:80%;font-size:0.7em'><thead><tr><TH style='text-align:left;'>Date</TH><TH style='text-align:left;'>Payment mode</TH><TH style='text-align:left;'>Amount</TH></TR",
                "template": "<TR><TD style='text-align:left;'> ||createdon||</TD><TD style='text-align:left;'> ||paymentmethod||</TD><TD style='text-align:left;'>||amount||</TD></TR>",
                "style":"margin-left: auto;margin-right:auto;margin-top:0.5cm;width:80%;font-size:0.7em",                
                "whr": "recordstatus=1 and billno='||billno||'"	,
				"append":"<div class='row mt-4' style='font-size:0.7em'><div class='cell'>Prepared By</div><div class='cell'>Checked By</div></div>"
            }
        },
        {
            "id": "10a",
            "name": "Get item Bill - HTML",
            "sql": {
                "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#printbill_2", 
				"appendoutput":true,
                "tbl": "cmch_bill",
                "fld": "item,rate,quatity,(rate*quatity) as amount,discount,total",				
                "union":[
						"SELECT '','','','','<b>Grand Total<b>',CONCAT('<div id=10abilltotal >',sum(total),'</div>') ",
						"FROM cmch_bill ",
						"WHERE recordstatus=1 and ",
						{"if":"||GET_billno||","op":">","value":"0","then":"billno='||GET_billno||'","else":"billno='||billno||'"}
					],
                "parent": "TABLE style='margin-left: auto;margin-right:auto;margin-top:0.5cm;font-size:0.7em;width:80%;'><thead><tr><TH style='text-align:left;'>Item</TH><TH style='text-align:left;'>Rate</TH><TH style='text-align:left;'>Quantity</TH><TH style='text-align:left;'>Amount</TH><TH style='text-align:left;'>Discount</TH><TH style='text-align:left;'>Net</TH></TR",
                "template": "<TR><TD style='text-align:left;'> ||item||</TD><TD style='text-align:left;'> ||rate||</TD><TD style='text-align:left;'>||quatity||</TD><TD style='text-align:left;'> ||amount||</TD><TD style='text-align:left;'> ||discount||</TD><TD style='text-align:left;'>||total||</TD></TR>",
                "whr":[
					"recordstatus=1",
					{"if":"||GET_billno||","op":">","value":"0","then":" and billno='||GET_billno||'","else":" and billno='||billno||'"}
				],
				"append":"<div style='text-align:left;font-size:0.7em'><span><b>Figure: </b></span><span id='10abilltotfigure'></span></div><script>$('#10abilltotfigure').html(ConvertNumberToWords($('#10abilltotal').text()));</script>"
                
            }
        }, {
            "id": "10c",
            "name": "Delegate for BillNo",
            "sql": {
                "action": "Return",
                "outputto": "php",
                "output": "billno",
                "value": "||billno||"
            }
        }, {
            "id": "10d",
            "name": "Delegate for Paystatus",
            "sql": {
                "action": "Get Value",
                "outputto": "php",
                "output": "paystatus",
                "tbl":"cmch_printbill",
				"fld":"paystatus",
				"whr":"billno=||GET_billno||"
            }
        },{
			"id": "10e",
			"name":"Advance balance",
			"sql":{
					"action": "Get Row",
					"outputto": "html",
					"output": "advbalance",					
					"tbl": "cmch_advance",
					"fld": "id,balance",
					"whr": "pid='||pid||' and balance>0 or (pid='||Get_pid||' and balance>0)",
					"srt":"createdon DESC",
					"limit":"1"
            }		
		},
		{
            "id": "10f",
            "name": "Delegate for pid",
            "sql": {
                "action": "Get Value",
                "outputto": "php",
                "output": "pid",
                "tbl":"cmch_printbill",
				"fld":"pid",
				"whr":"billno=||billno||"
            }
        },
		{
            "id": "10dept",
            "name": "Get department",
            "sql": {
                "action": "Get Value",
                "outputto": "php",
                "output": "dept",
                "tbl": "meta",
                "fld": "pdata",                
                "whr": "recordstatus=1 and pname='CMCH Department (Bills)'"
            }
        },
        {
            "id": "10gb",
            "name": "Generate Patient(Bill)",
            "sql": {
                "action": "Return",
                "validate": "users",
                "outputto": "php",
                "output": "demo",
				"outputfilter":"#workareaFilter1",
				"button":[
					{"name":"f1","type":"text","class":"metro-input","id":"pid","value":"||pid||","placeholder":"PID"},
					{"name":"f2","type":"button","class":"button secondary mr-2","caption":"Get", "onclick":"Eirene.runStmt('10tb-10apd-10dept-10gb',{filtertable:'f9',pid:$('#pid').val()})"},
					{"name":"f3","type":"select","class":" mr-2","id":"appdate","option":"SELECT id,DATE(pdate) FROM cmch_appointment WHERE pid='||pid||' ORDER BY pdate DESC LIMIT 5"},
					{"name":"f4","type":"select","id":"paystatus","class":" mr-2","option":"Pay,Pending"},
					{"name":"f5","type":"select","id":"department","class":" mr-2","option":"SELECT pdata FROM meta WHERE pname='CMCH Department (Bills)'","commaseperatedvalue":true},
					{"name":"f6","type":"button","class":"button secondary","caption":"Generate Bill", "onclick":"let ids=[];$('#workareaTablebox table tbody input[type=checkbox]:checked').each(function(i,x){ids[i]=$(this).attr('id')});ids=ids.join();if(!ids){showToast('Select Bill Items','alert',5000);return false;} Eirene.runStmt(&apos;8gens1&apos;,{pid:$(&apos;#pid&apos;).val(),IDS:ids,paystatus:$(&apos;#paystatus&apos;).val(),appid:$(&apos;#appdate&apos;).val(),department:$(&apos;#department&apos;).val()},$(this).hide())"},
					{"name":"f7","type":"button","class":"button secondary","caption":"Estimate", "onclick":"Eirene.runStmt('10est',{pid:$('#pid').val()})"}
				],
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"

            }
        },		
		{
            "id": "10tb",
            "name": "Total Bill",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_bill a",                
                "fld": "CONCAT('<input type=\\\"checkbox\\\" data-role=\\\"check\\\" name=\\\"fldchk\\\" value=\\\"',a.total,'\\\" id=\\\"&apos;',a.id,'&apos;\\\" onclick=\\\"let sum=0;$(&apos;input[type=checkbox][name=fldchk]:checked&apos;).each(function(){sum+=parseInt($(this).attr(&apos;value&apos;));});showToast(&apos;Total: &apos;+sum,&apos;warning&apos;,5000);\\\" />') as chk,a.item,a.bdate,a.quatity,a.total",
                "header": [
                    "<input type=\\\"checkbox\\\" data-role=\\\"check\\\" name=\\\"chk\\\" id=\\\"fld\\\" onclick=\\\"let chk=this.checked;if(chk){$(this).parent().parent().parent().parent().find('tbody input[type=checkbox]').prop('checked',true);}else{$(this).parent().parent().parent().parent().find('tbody input[type=checkbox]').prop('checked',false);} let sum=0;$(&apos;input[type=checkbox][name=fldchk]:checked&apos;).each(function(){sum+=parseInt($(this).attr(&apos;value&apos;));});showToast(&apos;Total: &apos;+sum,&apos;warning&apos;,5000);\\\" />",
                    "Item", "Date", "Quantity", "Amount","Action"
                ],
				"functionfield":[
					{"type":"group","caption":"Action","grp":[
							{"type":"icon","class":"mif-pencil fg-blue mr-2","onclick":"edit('billing','<a.id>')"},
							{"type":"icon","class":"mif-cross fg-red","onclick":"Eirene.runStmt2('10del','ID','<a.id>')"}
						]
					}
				],
				"vsum":"5",
                "join": "LEFT JOIN cmch_printbill b ON b.billno=a.billno",
                "whr": "a.recordstatus=1 and a.billno is null and a.pid='||pid||'",
                "onsuccess":"cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:show;#workareaAppendix;slow-cmd:dom,fun:html;#workareaAppendix;BLANK"
            }

        },{
			"id": "10del",
			"name": "Delete Bill Item (Permanently)",
			"sql": {
				"action": "Delete Row Permanently","outputto":"php",
				"tbl": "cmch_bill",
				"whr":"id='||ID||'",
				"onsuccess":"cmd:dom,fun:showtoast;success;Deleted Sucessfully",
				"onfailure":"cmd:dom,fun:showtoast;alert;Delete Failed"
			}			
		}, {
            "id": "10bft",
            "name": "Filter Patient(Bill)",
            "sql": {
                "action": "Return",
                "validate": "users",
                "outputto": "php",
                "output": "demo","value":"",
				"outputfilter":"#workareaFilter1",
				"button": [
					{"name":"f1","type":"text","id":"pid", "class":"mr-2"},
					{"name":"f2","type":"button","class":"button secondary","caption":"Get","onclick":"Eirene.runStmt('10tb-10apd-10dept-10gb',{filtertable:'f9',pid:$('#pid').val()})"}
				],                
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"
            }
        }, {
            "id": "10brec",
            "name": "Bill Records",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "outputto": "html",
                "output": "table",
                "tbl": "cmch_printbill a",                
                "button": [{
                        "name": "f5",                        
						"displaynone":1,
                        "whr": [
							"a.recordstatus=1",
							{"if":"||fromdate||","value":"BLANK","and":"||todate||","andvalue":"BLANK","then":" and DATE(a.createdon)=CURDATE()"},
							{"if":"||fromdate||","op":"!=","value":"BLANK","and":"||todate||","andvalue":"BLANK","then":" and DATE(a.createdon)='||fromdate||'"},
							{"if":"||fromdate||","op":"=","value":"BLANK","and":"||todate||","andop":"!=","andvalue":"BLANK","then":" and DATE(a.createdon)='||todate||'"},
							{"if":"||fromdate||","op":"!=","value":"BLANK","and":"||todate||","andop":"!=","andvalue":"BLANK","then":" and DATE(a.createdon)>='||fromdate||' and DATE(a.createdon)<='||todate||'"},
                            {"if":"||pid||","op":"!=","value":"BLANK","then": " and a.pid='||pid||'"},
                            {"if":"||paystatus||","op":"=","value":"Pending","then": " and paid<billamt"}
                        ]
                    }
                ],
				"tbl":"cmch_printbill a",
				"join":[
					"INNER JOIN (select billno,SUM(total) total FROM cmch_bill GROUP BY billno) b ON b.billno=a.billno",
					"INNER JOIN cmch_patient c ON c.pid=a.pid",
					"LEFT JOIN (select billno,SUM(amount) amount FROM cmch_payment GROUP BY billno) d ON d.billno=a.billno"
				],
				"fld":"a.pid,c.pname,a.billno,a.createdon,b.total as billamt,IF(d.amount is null,0,d.amount) as paid",
				"functionfield":[
					{"name":"f1","type":"button","class":"mif-printer fg-blue","onclick":"Eirene.runStmt('10prbl',{billno:'<a.billno>',pid:'<c.pid>',paystatus:'<a.paystatus>'})"}
				],				
				"limit":"3000",
				"srt":"a.billno DESC",				
				"vsum":"5,6",                
                "header": "Patient ID,Patient Name,BIll NO,Date,Total Bill,Total Paid,",                
                "onsuccess": "cmd:dom,fun:hide;#workareaAppendix;slow"
            }
        }, {
            "id": "10brft",
            "name": "Filter Record(Bill)",
            "sql": {
                "action": "Return",
                "validate": "users",
                "outputto": "php","output":"demo","value":"",
                "outputfilter": "#workareaFilter1",
				"button":[
					{"name":"f1","type":"text","class":"mr-2","id":"pid","placeholder":"Patient ID"},
					{"name":"f2","type":"select","class":"mr-2","id":"paystatus","title":"Pay Status","option":"SELECT '' UNION ALL SELECT DISTINCT paystatus from cmch_printbill"},
					{"name":"f2","type":"select","class":"mr-2","title":"Department","id":"deptbrec","option":"SELECT '' UNION ALL SELECT DISTINCT department from cmch_printbill"},
					{"name":"f3","type":"datepicker","class":"mr-2", "id":"fromdate"},
					{"name":"f4","type":"datepicker","class":"mr-2","id":"todate"},
					{"name":"f5","type":"button","class":"button secondary","caption":"Get","onclick":"let dept=$('#deptbrec').val();let pid=$('#pid').val();let paystatus=$('#paystatus').val();let df=$('#fromdate').val();let dt=$('#todate').val();Eirene.runStmt('10brec',{filtertable:'f5',pid:pid,fromdate:df,todate:dt,paystatus:paystatus,dept:dept})"}
				],                
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"
            }
        }, {
            "id": "10apd",
            "name": "Get Appoinment Date(Printbill)",
            "sql": {
                "action": "Get Dropdown",
                "outputto": "php",
                "output": "appdate",
                "tbl": "cmch_appointment",
                "fld": "id,DATE(pdate)",
                "srt": "createdon DESC",
                "limit": "5",
                "whr": "recordstatus=1 and pid='||pid||'"
            }
        }, {
            "id": "10tot",
            "name": "Total Amount(WorkareaAppendix)",
            "sql": {                
                "action": "Return",
                "outputto": "html",
                "output": "#printbill_3",				
                "value": ["<div class='row' id='billpaymode'>",
                    "<div class='cell'>Cash:</div>",
                    "<div class='cell'><input type='text' id='cash' placeholder='Amount'/></div>",
                    "<div class='cell'><button onclick='let sum=$(&apos;#10abilltotal&apos;).text();let paid=$(&apos;#10pdpaidtotal&apos;).text();if(!paid) paid=0;sum=parseFloat(sum)-parseFloat(paid);let pay=$(&apos;#cash&apos;).val();if(!pay){showToast(&apos;Empty Value&apos;,&apos;alert&apos;,5000);return false;}if(parseFloat(pay)>parseFloat(sum)){showToast(&apos;Payment more than bill&apos;,&apos;alert&apos;,5000);return false;}Eirene.runStmt(&apos;10f-10pay-10c-10d-10-10a-10pd-10e-10tot&apos;,{pid:&apos;||pid||&apos;,paymentmethod:&apos;Cash&apos;,amount:$(&apos;#cash&apos;).val(),billno:&apos;",
						{"if":"||GET_billno||","op":">","value":"0","then":"||GET_billno||","else":"||billno||"},
					"&apos;})'>Pay</button></div>",					
                    
					
                    "</div><div class='row'>",					
					{"if":"||GET_advbalance_balance||","op":">","value":"0","and":"||billno||","andop":">","andvalue":"0","then":"<div class='cell'>Advance: (Balance:||GET_advbalance_balance||)</div><div class='cell'><input type='number' id='advance' max='||GET_advbalance_balance||' placeholder= Max:||GET_advbalance_balance||></div><div class='cell'><button onclick='let sum=$(&apos;#10abilltotal&apos;).text();let paid=$(&apos;#10pdpaidtotal&apos;).text();if(!paid) paid=0;sum=parseFloat(sum)-parseFloat(paid);let pay=$(&apos;#advance&apos;).val();if(parseFloat(pay)>parseFloat(sum)){showToast(&apos;Payment more than bill&apos;,&apos;alert&apos;,5000);return false;}if(parseFloat(pay)>||GET_advbalance_balance||){showToast(&apos;Payment more than CMCHWallet&apos;,&apos;alert&apos;,5000);return false;}Eirene.runStmt(&apos;10f-10pay1-10paya-10c-10d-10-10a-10pd-10e-10tot&apos;,{pid:&apos;||pid||&apos;,paymentmethod:&apos;CMCHWallet&apos;,amount:$(&apos;#advance&apos;).val(),billno:&apos;||billno||&apos;,advanceid:&apos;||GET_advbalance_id||&apos;,balance:&apos;||GET_advbalance_balance||&apos;})'>Pay</button></div>"},
					"</div>",
					
					"<div class='row'>",
                    "<div class='cell'>POS:</div>",
                    "<div class='cell'><input type='text' id='pos' placeholder='Amount'/></div>",
                    "<div class='cell'><button onclick='let sum=$(&apos;#10abilltotal&apos;).text();let paid=$(&apos;#10pdpaidtotal&apos;).text();if(!paid) paid=0;sum=parseFloat(sum)-parseFloat(paid);let pay=$(&apos;#pos&apos;).val();if(!pay){showToast(&apos;Empty Value&apos;,&apos;alert&apos;,5000);return false;}if(parseFloat(pay)>parseFloat(sum)){showToast(&apos;Payment more than bill&apos;,&apos;alert&apos;,5000);return false;}Eirene.runStmt(&apos;10f-10pay-10c-10d-10-10a-10pd-10e-10tot&apos;,{pid:&apos;||pid||&apos;,paymentmethod:&apos;POS&apos;,amount:$(&apos;#pos&apos;).val(),billno:&apos;",
					{"if":"||GET_billno||","op":">","value":"0","then":"||GET_billno||","else":"||billno||"},
					"&apos;})'>Pay</button></div>",
					
                    "</div><div class='row'>",
                    "<div class='cell'>InternetBanking</div>",
                    "<div class='cell'><input type='text' id='internetbanking' placeholder='Amount'/></div>",
                    "<div class='cell'><button onclick='let sum=$(&apos;#10abilltotal&apos;).text();let paid=$(&apos;#10pdpaidtotal&apos;).text();if(!paid) paid=0;sum=parseFloat(sum)-parseFloat(paid);let pay=$(&apos;#internetbanking&apos;).val();if(!pay){showToast(&apos;Empty Value&apos;,&apos;alert&apos;,5000);return false;}if(parseFloat(pay)>parseFloat(sum)){showToast(&apos;Payment more than bill&apos;,&apos;alert&apos;,5000);return false;}Eirene.runStmt(&apos;10f-10pay-10c-10d-10-10a-10pd-10e-10tot&apos;,{pid:&apos;||pid||&apos;,paymentmethod:&apos;InternetBanking&apos;,amount:$(&apos;#internetbanking&apos;).val(),billno:&apos;",
					{"if":"||GET_billno||","op":">","value":"0","then":"||GET_billno||","else":"||billno||"},
					"&apos;})'>Pay</button></div>",
					
                    "</div><div class='row'>", 
                    "<div class='cell'>UPI:</div>",
                    "<div class='cell'><input type='text' id='UPI' placeholder='Amount'/></div>",
                    "<div class='cell'><button onclick='let sum=$(&apos;#10abilltotal&apos;).text();let paid=$(&apos;#10pdpaidtotal&apos;).text();if(!paid) paid=0;sum=parseFloat(sum)-parseFloat(paid);let pay=$(&apos;#UPI&apos;).val();if(!pay){showToast(&apos;Empty Value&apos;,&apos;alert&apos;,5000);return false;}if(parseFloat(pay)>parseFloat(sum)){showToast(&apos;Payment more than bill&apos;,&apos;alert&apos;,5000);return false;}Eirene.runStmt(&apos;10f-10pay-10c-10d-10-10a-10pd-10e-10tot&apos;,{pid:&apos;||pid||&apos;,paymentmethod:&apos;UPI&apos;,amount:$(&apos;#UPI&apos;).val(),billno:&apos;",
					{"if":"||GET_billno||","op":">","value":"0","then":"||GET_billno||","else":"||billno||"},
					"&apos;})'>Pay</button></div>",
						
					"</div><div class='row'>",
                    "<div class='cell'>DC/CC:</div>",
                    "<div class='cell'><input type='text' id='card' placeholder='Amount'/></div>",
                    "<div class='cell'><button onclick='let sum=$(&apos;#10abilltotal&apos;).text();let paid=$(&apos;#10pdpaidtotal&apos;).text();if(!paid) paid=0;sum=parseFloat(sum)-parseFloat(paid);let pay=$(&apos;#card&apos;).val();if(!pay){showToast(&apos;Empty Value&apos;,&apos;alert&apos;,5000);return false;}if(parseFloat(pay)>parseFloat(sum)){showToast(&apos;Payment more than bill&apos;,&apos;alert&apos;,5000);return false;}Eirene.runStmt(&apos;10f-10pay-10c-10d-10-10a-10pd-10e-10tot&apos;,{pid:&apos;||pid||&apos;,paymentmethod:&apos;Card&apos;,amount:$(&apos;#card&apos;).val(),billno:&apos;",
					{"if":"||GET_billno||","op":">","value":"0","then":"||GET_billno||","else":"||billno||"},
					"&apos;})'>Pay</button></div>",
					
                    "</div>"
                ]
            }
        },
		
		{
            "id": "10pay",
            "name": "Save payment details",
            "sql": {			
						"precheck":[
							{"if":"||amount||","op":">","value":"0"}
						],
						"action": "Save Row",
						"validate": "users",
						"outputto": "php",
						"output": "res",						
						"tbl": "cmch_payment",
						"fld": "billno,paymentmethod,amount,createdby",
						"value": "||billno||,||paymentmethod||,||amount||,||USERID||",
						"fldtype": "n,s,n,s",
						"command": "insert",						
						"onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
						"onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed-DO_NOT_PROCEED"
					}			
        },
		{
            "id": "10pay1",
            "name": "Save advance payment details",
            "sql": {			
						"action": "Save Row",
						"validate": "users",
						"outputto": "php",
						"output": "res",						
						"tbl": "cmch_payment",
						"fld": "billno,paymentmethod,amount,advanceid,createdby",
						"value": "||billno||,||paymentmethod||,||amount||,||advanceid||,||USERID||",
						"fldtype": "n,s,n,s,s",
						"command": "insert",						
						"onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
						"onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
					}			
        },
		{
					"id": "10paya",
					"name": "Save payment details",
					"sql": {
						"action": "Save Row",
						"validate": "users",
						"outputto": "php",
						"output": "res",						
						"tbl": "cmch_advance",
						"fld": "balance",
						"value": "(||balance||-||amount||)",
						"fldtype": "n",
						"command": "update",
						"whr": "id='||advanceid||'"
					}			
					
		},
        {

            "id": "10tot1",
            "name": "Total Amount(WorkareaAppendix)",
            "sql": {
                "action": "Get Table",
                "outputto": "html",
                "output": "app",
                "append": "App Date:<select id='appdate'>||GET_appdate||</select><br><br>",
                "tbl": "cmch_bill a",
                "fld": "sum(a.total),b.advance",
                "header": "Total Amount:,Advance:",
                "join": "LEFT JOIN cmch_advance b ON b.pid=a.pid",
                "whr": "a.recordstatus=1 and a.pid='||pid||' and billno IS NULL",
                "onsuccess": "cmd:dom,fun:show;#workareaAppendix;fast-cmd:dom,fun:html;#workareaAppendix;||app||"

            }

        }, 
		
		{
            "id": "svadv",
            "name": "Save Advance Details",
            "sql": {
				"action": "MULTISTMT",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "multistmt": [
				{
					"action": "Save Row",               
					"tbl": "cmch_advance",
					"fld": "pid,advance,balance,paymentmethod",
					"value": "||pid||,||advance||,||advance||,||paymentmethod||",
					"fldtype": "s,n,n,s",
					"command": "insert",
					"onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=pid];BLANK",
					"onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
				}	
				
				]                
            }
        }, 
		
            {
           "id": "10ph",
           "name": "Payment Details",
           "sql": {
               "action": "Get Table",
               "validate": "users",
               "outputto": "html",
               "output": "table",
               "outputfilter": "#workareaTablebox",
               "button": [{
                       "name": "f8",
                       "displaynone": 1,
                       "whr": [
                           "a.recordstatus=1", {
                               "if": "||mode||",
                               "op": "!=",
                               "value": "BLANK",
                               "then": " and a.paymentmethod='||mode||'"
                           }, {
                               "if": "||dfdate||",
                               "op": "!=",
                               "value": "BLANK",
                               "and": "||dtdate||",
                               "andop": "!=",
                               "andvalue": "BLANK",
                               "then": " and (DATE(a.createdon)>='||dfdate||' and DATE(a.createdon)<='||dtdate||')"
                           }, {
                               "if": "||dfdate||",
                               "op": "!=",
                               "value": "BLANK",
                               "and": "||dtdate||",
                               "andop": "=",
                               "andvalue": "BLANK",
                               "then": " and (DATE(a.createdon)='||dfdate||')"
                           }, {
                               "if": "||pid||",
                               "op": "!=",
                               "value": "BLANK",
                               "then": " and b.pid='||pid||'"
                           }
						]
					}
					],
					"tbl": "cmch_payment a",
					"fld": "DATE(a.createdon),a.billno,c.pid,c.pname,a.paymentmethod,a.amount",
					"join": [ 
							"INNER JOIN cmch_printbill b ON a.billno=b.billno",
							"INNER JOIN cmch_patient c ON b.pid=c.pid"
							],
					"vsum":"6",
					"header": "Date,Bill No,Patient ID,Patient Name,Paymode,Amount",
					"whr": "a.recordstatus=1 and DATE(a.createdon)=CURDATE()",
					"datefield": "b.bdate"
				}
			},
			{
            "id": "10phft",
            "name": "Filter Payments",
            "sql": {
                "action": "Return",
                "outputto": "php",
                "output": "demo",
                "value": "",
                "outputfilter": "#workareaFilter1",
                "button": [{
                        "name": "mode",
                        "id": "10phmode",
                        "type": "select",
                        "class": " mr-2",
                        "option": ",Cash,Card,CMCHWallet,POS,InternetBanking,UPI"
                    }, {
                        "name": "dfdate",
                        "id": "10phdfdate",
                        "type": "datepicker",
                        "caption": "Date From",
                        "class": "ml-2 mr-2"
                    }, {
                        "name": "dtdate",
                        "id": "10phdtdate",
                        "type": "datepicker",
                        "caption": "Date to",
                        "class": "ml-2 mr-2"
                    }, {
                        "name": "pid",
                        "id": "10phpid",
                        "type": "text",
                        "placeholder": "PatientID",
                        "class": "ml-2 mr-2"
                    }, {
                        "name": "bt",
                        "caption": "Get",
                        "class": "ml-2 mr-2",
                        "value": "Get",
                        "class": "button secondary",
                        "onclick": "Eirene.runStmt('10ph',{filtertable:'f8',mode:$('#10phmode').val(),dfdate:$('#10phdfdate').val(),dtdate:$('#10phdtdate').val(),pid:$('#10phpid').val()})"
                    }
                ],
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"
            }
        }, {
            "id": "11",
            "name": "Xray Details",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "xray",
                "outputto": "html",
                "output": "table",
                "outputfilter": "fltbtn",
                "button": [{
                        "name": "f1",
                        "sqlid": "11",
                        "whr": [
							"a.recordstatus=1",
							{"if":"||fromdate||","op":"!=","value":"BLANK","and":"||todate||","andop":"!=","andvalue":"BLANK","then":" and DATE(a.createdon)>='||fromdate||' and DATE(a.createdon)<='||todate||'"},
							{"if":"||fromdate||","op":"=","value":"BLANK","and":"||todate||","andop":"=","andvalue":"BLANK","then":" and DATE(a.createdon)=CURDATE()"},
							{"if":"||fromdate||","op":"!=","value":"BLANK","and":"||todate||","andop":"=","andvalue":"BLANK","then":" and DATE(a.createdon)='||fromdate||'"},
							{"if":"||fromdate||","op":"=","value":"BLANK","and":"||todate||","andop":"!=","andvalue":"BLANK","then":" and DATE(a.createdon)='||todate||'"},
							{"if":"||pid||","op":"!=","value":"BLANK","then":" and b.pid='||pid||'"}

                        ]
                    }
                ],
                "tbl": "cmch_xray a",
                "fld": "b.pid,c.pname,a.billno,a.item",
				"functionfield":[{
                        "type": "link",
						"href":"<a.xray>",
						"value":"Link",                        
						"otherattr":"target",
						"otherattrvalue":"_blank"
                    }
				],
                "join": "LEFT JOIN cmch_printbill b ON a.billno=b.billno LEFT JOIN cmch_patient c ON b.pid=c.pid",
                "header": "Patient ID,Patient Name,Bill No,Item",
                "whr": "a.recordstatus=1 and DATE(a.createdon)=CURDATE()",
                "onsuccess": "cmd:dom,fun:empty;#workareaFilter;slow-cmd:dom,fun:empty;#workareaAppendix;slow"

            },

            "edit_record": 1

        }, {
            "id": "11ft",
            "name": "Filter Record(xray)",
            "sql": {
                "action": "Return",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaFilter1",
                "value": "<div class='row'><div class='cell'><input type='text' id='pid' placeholder='Patient ID'/></div><div class='cell'>Date From</div><div class='cell'><input type='date' id='fromdate'/></div><div class='cell'>Date To</div><div class='cell'><input type='date' id='todate'/></div><div class='cell'><button class='button secondary' type='button' onclick='let pid=$(\\\"#pid\\\").val();let df=$(\\\"#fromdate\\\").val();let dt=$(\\\"#todate\\\").val();Eirene.runStmt(\\\"11\\\",{filtertable:\\\"f1\\\",pid:pid,fromdate:df,todate:dt})'>Get</button></div></div>",
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"
            }
        },
		

		{
            "id": "11svxr",
            "name": "Save xray",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_xray",
                "fld": "xray,xdatetime",
                "value": "||xray||,NOW()",
                "fldtype": "s,n",
                "command": "update",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"

            }
        }, {
            "id": "11gtxr",
            "name": "Get Xray",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_xray",
                "fld": "id,xray",
                "whr": "id='||ID||'",
				"function":"edit1"

            }

        }, {
            "id": "12",
            "name": "Lab Details",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "lab",
                "outputto": "html",
                "output": "table",
                "outputfilter": "fltbtn",
                "button": [{
                        "name": "f1",
                        "sqlid": "12",
                        "displaynone": "1",
                        "whr": [
							"a.recordstatus=1",
							{"if":"||fromdate||","op":"!=","value":"BLANK", "and":"||todate||","andop":"!=","andvalue":"BLANK","then":" and DATE(a.createdon)>='||fromdate||' and DATE(a.createdon)<='||todate||'"},
							{"if":"||fromdate||","op":"=","value":"BLANK", "and":"||todate||","andop":"=","andvalue":"BLANK","then":" and DATE(a.createdon)=CURDATE()"},
							{"if":"||fromdate||","op":"!=","value":"BLANK", "and":"||todate||","andop":"=","andvalue":"BLANK","then":" and DATE(a.createdon)='||fromdate||'"},
							{"if":"||fromdate||","op":"=","value":"BLANK", "and":"||todate||","andop":"!=","andvalue":"BLANK","then":" and DATE(a.createdon)='||todate||'"},                            
							{"if":"||pid||","op":"!=","value":"BLANK", "then":" and b.pid='||pid||'"}
                        ]
                    }, {
                        "name": "f2",
                        "type": "buttonspan",
                        "class": "mif-plus fg-red",
                        "caption": "Parameters",
                        "onclick": "showNewForm(\\\"labparameters\\\")",
                        "title": "Add Parameters"
                    }, {
                        "name": "f3",
                        "caption": "List Parameters",
                        "onclick": "Eirene.runStmt(\\\"12a-12aft\\\")",
                        "title": "List Parameters"
                    }
					

                ],
                "tbl": "cmch_lab a",
                "fld": "b.pid,d.pname,a.billno,a.item",
                "functionfield": [
				{
					"type":"group","caption":"Functions",
						"grp":[
							{								
								"name":"ct",
								"type": "button",								
								"title":"Add Collection Time",
								"otherattr":"status",
								"otherattrvalue":"<a.status>",
								"value":"",
								"class":"mif-lab fg-blue mr-3 lab-function",
								"onclick": "Eirene.runStmt('12st1-12ct',{pid:'<b.pid>',id:'<a.id>'});$(this).hide();$(this).parent().find('.lab-function[name=ap]').removeClass('no-visible')"

							},{
								"name":"ap",
								"type": "button",
								"otherattr":"status",
								"otherattrvalue":"<a.status>",
								"value":"",
								"title":"Add Parameters",
								"class":"mif-plus fg-blue mr-3 lab-function",
								"onclick": "Eirene.runStmt('12st1-12gp',{pid:'<b.pid>',billno:'<a.billno>',item:'<a.item>',id:'<a.id>'});$(this).hide();$(this).parent().find('.lab-function[name=ep],.lab-function[name=pp]').removeClass('no-visible');"

							},{								
								"name":"ep",
								"type": "button",
								"otherattr":"status",
								"otherattrvalue":"<a.status>",
								"value":"",
								"title":"Add or edit Value",
								"class":"mif-pencil fg-blue mr-3 lab-function",
								"onclick": "Eirene.runStmt('12aval',{id:'<a.id>'})"
							},
							 {
								"name":"pp",
								"type": "button",
								"value":"",
								"class":"mif-printer fg-blue lab-function",
								"otherattr":"status",
								"otherattrvalue":"<a.status>",								
								"title":"Patinet Report",
								"onclick": "Eirene.runStmt('12rt-12pr',{id:'<a.id>',billno:'<a.billno>',item:'<a.item>',comment:'<a.comment>'})"
							}
							
					]
				}
                ],
                "join": [
						"LEFT JOIN cmch_printbill b ON a.billno= b.billno",
						"LEFT JOIN cmch_patient d ON b.pid=d.pid"
						],
                "header": "Patient ID,Patient Name,Bill No,Item",
                "whr": "a.recordstatus=1 and DATE(a.createdon)=CURDATE()",
				"srt": "a.createdon DESC",
				"append":"<script>$('.lab-function').toggleClass('no-visible');$('.lab-function[status=0][name=ct]').toggleClass('no-visible');$('.lab-function[status=1][name=ap]').toggleClass('no-visible');$('.lab-function[status=2][name=ep],.lab-function[status=2][name=pp]').toggleClass('no-visible');</script>",
                "onsuccess": "cmd:dom,fun:html;#workareaFilter;||fltbtn||-cmd:dom,fun:show;#workareaFilter;slow-cmd:dom,fun:empty;#workareaAppendix;slow"
            }
        },
        {
            "id": "12pr",
            "name": "Get Report HTML(Lab Patient details)",
            "sql": {
                 "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaAppendix",               
                "prepend": [
					"<button class='mif-printer fg-blue' onclick='printHTML(&apos;workareaAppendix&apos;)'></button>",
                    "<center><img src='resource/image/cmch_logo1.png' width='400' height='60'></center>"
				],
                "template": [
					"<table style='border:1px solid black;border-collapse:collapse;margin-left:auto;margin-right:auto;margin-top:10px;font-size:0.7em'>",
                    "<tr><td style='border:1px solid black' class='pl-2'><b>Patient ID</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||pid||</td><td style='border:1px solid black' class='p-1'><b>Name</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||pname||</td></tr>",
                    "<tr><td style='border:1px solid black' class='p-1'><b>BIll NO:</b></td><td style='border:1px solid black' class='p-1'>||billno||</td><td style='border:1px solid black' class='p-1'><b>Bill Date</b></td><td style='border:1px solid black' class='p-1'>||createdon||</td></tr>",
                    "<tr><td style='border:1px solid black' class='p-1'><b>Age/Gender</b></td>",
					{"if":"||pgender||","op":"=","value":"0","then":"<td style='border:1px solid black' class='p-1'>||age||/Male</td>","else":"<td style='border:1px solid black' class='p-1'>||age||/Female</td>"},
					"<td style='border:1px solid black' class='p-1'><b>Marital Status</b></td>",
					{"if":"||pmaritalstatus||","op":"=","value":"0","then":"<td style='border:1px solid black' class='p-1'></td></tr>"},
					{"if":"||pmaritalstatus||","op":"=","value":"1","then":"<td style='border:1px solid black' class='p-1'>Single</td></tr>"},
					{"if":"||pmaritalstatus||","op":"=","value":"2","then":"<td style='border:1px solid black' class='p-1'>Married</td></tr>"},
					{"if":"||pmaritalstatus||","op":"=","value":"3","then":"<td style='border:1px solid black' class='p-1'>Widowed</td></tr>"},
					{"if":"||pmaritalstatus||","op":"=","value":"4","then":"<td style='border:1px solid black' class='p-1'>Divorced</td></tr>"},
                    "<tr><td style='border:1px solid black' class='p-1'><b>Collection Time</b></td><td style='border:1px solid black' class='p-1'>||collectiontime||</td><td style='border:1px solid black' class='p-1'><b>Reporting Time</b></td><td style='border:1px solid black' class='p-1'>||reportingtime||</td></tr>",
                    "</table>"					
				],
				"tbl": "cmch_lab a",
                "fld": "b.pid,d.pname,a.billno,a.item,a.reportingtime,a.collectiontime,a.createdon,d.pgender,d.pmaritalstatus,(YEAR(CURDATE())-d.pyob) as age",
				 "join": [
						"LEFT JOIN cmch_printbill b ON a.billno= b.billno",
						"LEFT JOIN cmch_patient d ON b.pid=d.pid"
						],
				"whr":"a.id='||id||'",
				"additionalstmt":[{"if":"||item||","op":"=","value":"Widal Test","then":"12prw","else":"12pre"}],
				"onsuccess":"cmd:dom,fun:show;#workareaAppendix;fast"
            }
        },
		 {
            "id": "12pre",
            "name": "Get Lab Result - HTML",
            "sql": {
                "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaAppendix",
				"appendoutput":true,
                "tbl": "cmch_labresult a",
                "fld": "b.parametername,a.result,b.unit,b.lrange,b.upperrange,b.lowerrange,b.referencerange", 
				"join": [
							"LEFT JOIN cmch_labparameters b ON a.parameterid=b.id",
							"LEFT JOIN cmch_lab c ON c.id=a.labid"
						],	
                "parent": "TABLE style='margin-left: auto;margin-right:auto;margin-top:0.5cm;width:80%;font-size:0.8em;'><thead><tr><TH style='text-align:left;'>Parameter</TH><TH style='text-align:left;'>Result</TH><TH style='text-align:left;'>Unit</TH><TH style='text-align:left;'>Range</TH></TR",
                "template": 
					["<TR><TD style='text-align:left;'>||parametername||",
					{"if":"||referencerange||","op":"!=","value":"BLANK","and":"||referencerange||","andop":"!=","andvalue":"0","then":"<br><span style='font-size:0.7em'>||referencerange||</span>"},
					"</TD>",
					{"if":"||result||","op":">","value":"||upperrange||","or":"||result||","orop":"<","orvalue":"||lowerrange||","then":"<TD style='text-align:left;'><b>||result||</b></TD>","else":"<TD style='text-align:left;'>||result||</TD>"},
					"<TD style='text-align:left;'>||unit||</TD>",
					"<TD style='text-align:left;'> ||lrange||</TD>",
					"</TR>"					
					],
                "whr": "c.item='||item||' and c.billno='||billno||'",
				"srt":"b.porder",
				"prepend":"<DIV style='text-align:center; margin-top:15px'><b>||item||</b></DIV>",
				"append":[
							{"if":"||comment||","op":"!=","value":"BLANK","then":"<div style='text-align:center'>Comment:<b>||comment||</b></div>"},
							"<div style='margin-left:20px;'>",
								"<div class='row' style='width:80%'><DIV class='cell'><img src='resource/image/sign.png' width='60' height='40'></DIV>",
								"<DIV class='cell'></DIV></div>",
								"<div class='row' style='width:80%'><DIV class='cell'>CMCH Lab</DIV>",
								"<DIV class='cell'><div style='text-align:right'>Lab Assistant</div></DIV></div>",
							"</div>"
						]
				   
            }
        },
		
		{
            "id": "12prw",
            "name": "Get Report HTML(Widal Test)",
            "sql": {
                 "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaAppendix",
				"appendoutput":true,
                "tbl": "cmch_labresult a",
				"fld": "b.parametername,a.result,b.porder", 
				"join": [
							"LEFT JOIN cmch_labparameters b ON a.parameterid=b.id",
							"LEFT JOIN cmch_lab c ON c.id=a.labid"
						],
				"parent": "TABLE style='border:1px solid black;border-collapse:collapse;margin-left: auto;margin-right:auto;margin-top:0.5cm;width:80%;'><thead><tr><TH style='text-align:left;'>&nbsp;</TH><TH style='text-align:left;'>1:20</TH><TH style='text-align:left;'>1:40</TH><TH style='text-align:left;'>1:80</TH><TH style='text-align:left;'>1:160</TH><TH style='text-align:left;'>1:320</TH><TH style='text-align:left;'>1:640</TH></TR",
				"template": 
				[					
					{"if":"||porder||","op":"=","value":"1","then":"</TR><TD style='border:1px solid black' class='p-1'>SalmonellaTyphi O</TD>"},
					{"if":"||porder||","op":"=","value":"7","then":"</TR><TD style='border:1px solid black' class='p-1'>SalmonellaTyphi H</TD>"},
					{"if":"||porder||","op":"=","value":"13","then":"</TR><TD style='border:1px solid black' class='p-1'>SalmonellaParaTyphi AH</TD>"},
					{"if":"||porder||","op":"=","value":"19","then":"</TR><TD style='border:1px solid black' class='p-1'>SalmonellaTyphi BH</TD>"},
					"<TD style='border:1px solid black;text-align:center' class='p-1'>||result||</TD>"
				],
				"srt":"b.porder ASC",
				"whr": "c.item='||item||' and c.billno='||billno||'",
				"prepend":"<DIV style='text-align:center; margin-top:15px'><b>||item||</b></DIV>",
				"append":[
							{"if":"||comment||","op":"!=","value":"BLANK","then":"<div style='text-align:center'>Comment:<b>||comment||</b></div>"},
							"<div style='margin-left:20px;'>",
								"<div class='row' style='width:80%'><DIV class='cell'><img src='resource/image/sign.png' width='60' height='40'></DIV>",
								"<DIV class='cell'></DIV></div>",
								"<div class='row' style='width:80%'><DIV class='cell'>CMCH Lab</DIV>",
								"<DIV class='cell'><div style='text-align:right'>Lab Assistant</div></DIV></div>",
							"</div>"
						]
				
            }
        },
        {
            "id": "12alp",
            "name": "List Parameters",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "outputto": "html",
                "output": "para",
                "tbl": "cmch_labparameters a",
                "functionfield": [{

                        "type": "button",
                        "value": "Select",
                        "onclick": "Eirene.runStmt('12gp',{pid:'||pid||',parameterid:'<a.id>',itemid:'<a.itemid>'},$(this).hide())"
                    }

                ],
                "fld": "a.parametername",
                "join": "LEFT JOIN cmch_item b ON b.id=a.itemid",
                "header": "Parameter Name",
                "whr": "a.recordstatus=1 and b.item='||item||'",
                "onsuccess": "cmd:dom,fun:show;#workareaAppendix;slow-cmd:dom,fun:html;#workareaAppendix;||para||-cmd:dom,fun:function;datatable;#workareaAppendix;"
            }
        }, {
            "id": "12gp",
            "name": "Save Lab Result(Add Parameters with blank)",
            "sql": {
                "action": "Run",
                "outputto": "php",
                "output": "res",
                "stmt": "INSERT INTO cmch_labresult (id,labid,pid,parameterid,result,createdby) SELECT UUID(),'||id||','||pid||', c.id,'0','||USERID||' FROM cmch_lab a INNER JOIN cmch_item b ON a.item=b.item INNER JOIN cmch_labparameters c ON b.id=c.itemid  WHERE a.item='||item||' and a.billno=||billno||",
                "onfailure": "cmd:dom,fun:showtoast;alert;Adding Failed",
                "onsuccess": "cmd:dom,fun:showtoast;success;Parameter Added"

            }
        }, {
            "id": "12ct",
            "name": "Status Change(Lab)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_lab",
                "fld": "collectiontime",
                "value": "NOW()",
                "fldtype": "n",
                "command": "update",
                "whr": "id='||id||'"


            }
		},
		{
            "id": "12rt",
            "name": "Update lab Reporting time",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_lab",
                "fld": "reportingtime",
                "value": "NOW()",
                "fldtype": "n",
                "command": "update",
                "whr": "id='||id||' and reportingtime IS NULL"


            }
		},
		{
            "id": "12st1",
            "name": "Status Change(Add Parameters)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_lab",
                "fld": "status",
                "value": "status+1",
                "fldtype": "n",
                "command": "update",
                "whr": "id='||id||'"

            }
        }, {
            "id": "12st2",
            "name": "Status Chnage(Add Values)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_lab",
                "fld": "status",
                "value": "2",
                "fldtype": "n",
                "command": "update",
                "whr": "id='||id||'"

            }
        }, {
            "id": "12aval",
            "name": "List Parameters",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "outputto": "html",
                "output": "para",
                "tbl": "cmch_labparameters a",
                "functionfield": [{

                        "type": "text",
                        "value": "<result>",
                        "caption": "Value",
                        "onblur": "Eirene.runStmt('12sval',{ID:'<a.id>',value:$(this).val()})"
                    }

                ],
				"append": "<div class='d-flex flex-justify-around'>Comment:<input type='text' onblur='Eirene.runStmt(&apos;12comm&apos;,{ID:&apos;||id||&apos;,value:$(this).val()})'/></div>",
                "fld": "a.parametername",
                "header": "Parameter Name",				
                "join": "LEFT JOIN cmch_labresult b ON a.id=b.parameterid",
				"srt": "a.porder",
                "whr": "a.recordstatus=1 and b.labid='||id||'",
                "onsuccess": "cmd:dom,fun:show;#workareaAppendix;slow-cmd:dom,fun:html;#workareaAppendix;||para||-cmd:dom,fun:function;datatable;#workareaAppendix;"
            }
        }, {
            "id": "12sval",
            "name": "Save values (Lab)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_labresult",
                "fld": "result",
                "value": "||value||",
                "fldtype": "s",
                "command": "update",
                "whr": "parameterid='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"

            }
        },
		{
            "id": "12comm",
            "name": "Save Comment (Lab)",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_lab",
                "fld": "comment",
                "value": "||value||",
                "fldtype": "s",
                "command": "update",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"

            }
        },
		{
			"id": "12ft",
			"name": "Filter Record(Lab)",
			"sql": {
				"action": "Return",
				"validate": "users",
				"outputto": "html",
				"output": "#workareaFilter1",
				"value": "<div class='row'><div class='cell'><input type='text' id='pid' placeholder='Patient ID'/></div><div class='cell'>Date From</div><div class='cell'><input type='date' id='fromdate'/></div><div class='cell'>Date To</div><div class='cell'><input type='date' id='todate'/></div><div class='cell'><button class='button secondary' type='button' onclick='let pid=$(\\\"#pid\\\").val();let df=$(\\\"#fromdate\\\").val();let dt=$(\\\"#todate\\\").val();Eirene.runStmt(\\\"12\\\",{filtertable:\\\"f1\\\",pid:pid,fromdate:df,todate:dt})'>Get</button></div></div>",
				"onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"
			}
		},		 {
            "id": "12svlr",
            "name": "Save Lab Result",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_labresult",
                "fld": "pid,itemid,date,createdby",
                "value": "||pid||,||itemid||,NOW(),||USERID||",
                "fldtype": "s,s,n,s",
                "command": "insert"

            }
        }, {
            "id": "12svlp",
            "name": "Save Lab Details",
            "sql": {
                "action": "Save Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_labparameters",
                "fld": "itemid,parametername,lrange,unit,porder,preset,prefil,lowerrange,upperrange,strcomparision,referencerange",
                "value": "||itemid||,||parametername||,||lrange||,||unit||,||porder||,||preset||,||prefil||,||lowerrange||,||upperrange||,||strcomparision||,||referencerange||",
                "fldtype": "s,s,n,s,n,s,s,n,n,s,s",
                "command": "insertorupdate",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=parametername];BLANK",
                "onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"

            }
        }, {
            "id": "12a",
            "name": "List Parameters",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "formname": "labparameters",
                "outputto": "html",
                "output": "table",
                "button": [{
                        "name": "f1",                        
                        "displaynone": "1",
                        "whr": "b.id='||item||'"
                    }
                ],
                "tbl": "cmch_labparameters a",
                "fld": "b.item,a.parametername,a.lrange,a.unit,a.preset,a.prefil,a.lowerrange,a.upperrange,a.strcomparision,a.referencerange",
                "header": "Item,Parameter Name,Range,Unit,Preset,Prefil,Lower Range,Upper Range,Str Comparision,Refererence Range",
                "join": "LEFT JOIN cmch_item b ON a.itemid=b.id",
				"functionfield":[
					{"type":"text","value":"<a.porder>","caption":"POrder","onblur":"Eirene.runStmt('12ap',{porder:$(this).val(),ID:'<a.id>'})"}
				],
                "delstmt": "12dlp",
                "whr": "a.recordstatus=1",
                "onsuccess": "cmd:dom,fun:hide;#workareaAppendix;slow"
            },
            "edit_record": 1,
            "delete_record": 1
        },{
			"id":"12ap",
			"name":"Save Lab Parameter Order",
			"sql":{
				"action":"Save Row","outputto":"php",
				"command":"update",
				"tbl":"cmch_labparameters",
				"fld":"porder",
				"fldtype":"n",
				"value":"||porder||",
				"whr":"id='||ID||'",
				"onsuccess":"cmd:dom,fun:showtoast;success;Saving Successful",
				"onfailure":"cmd:dom,fun:showtoast;alert;Saving Failed"
			}
		},
		{
            "id": "12aft",
            "name": "Filter by Item(Lab Parameters)",
            "sql": {
                "action": "Return","outputto":"php","output":"demo",                
                "outputfilter": "#workareaFilter1",
                "value": "",
				"button":[
					{"name":"f1","type":"select","id":"labpsel","class":"metro-input mr-2","option":"SELECT id,item FROM cmch_item WHERE category like '%lab%' ORDER BY item"},
					{"name":"f2","type":"button","caption":"Get","class":"button secondary","onclick":"Eirene.runStmt('12a',{filtertable:'f1',item:$('#labpsel').val()})"}
				],
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"
            }
        },
        {
            "id": "12gtlp",
            "name": "Get Item",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_labparameters a",
                "fld": "a.id,b.item,a.parametername,a.lrange,a.unit,a.porder,a.preset,a.prefil,a.lowerrange,a.upperrange,a.strcomparision,a.referencerange",
                "join": "LEFT JOIN cmch_item b ON a.itemid=b.id",
                "whr": "a.id='||ID||'",
				"function":"edit1"

            }

        }, {
            "id": "12dlp",
            "name": "Delete Item",
            "sql": {
                "action": "Delete Row",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "tbl": "cmch_labparameters",
                "whr": "id='||ID||'",
                "onsuccess": "cmd:dom,fun:showtoast;success;Delete Successful",
                "onfailure": "cmd:dom,fun:showtoast;alert;Delete Failed"
            }
        },
        {
            "id": "12gtlb",
            "name": "Get Lab",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_lab",
                "fld": "id,status",
                "whr": "id='||ID||'",
				"function":"edit1"

            }

        },
		{
			"id":"33",
			"name":"Upload Xray",
			"sql":{
				"action":"Upload File",
				"validate":"users",
				"outputto":"html",
				"output":"upload",				
				"directory":"xray",
				"maxsize":"600kb",
				"filetype":"jpg,jpeg,png",
				"path":"resource/media/",
				"onsuccess":"cmd:dom,elem:a,fun:showtoast;success;Upload Successful-cmd:dom,elem:input[name=||elemname||],fun:val,val:||GET_uploadedfilename||",
				"onfailure":"cmd:dom,fun:showtoast;alert;Upload Failed"
				}
		},
		{
			"id":"13",		
			"name":"Advance Details",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "outputto": "html",
                "output": "table",                
                "button": [{
                        "name": "f1",
                        "displaynone": 1,
                        "whr": [
                            "a.recordstatus=1",
                              {
                                "if": "||dtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||dtto||",
                                "andop": "!=",
                                "andvalue": "BLANK",
                                "then": " and (DATE(a.createdon)>='||dtfrom||' and DATE(a.createdon)<='||dtto||')"
                            }, {
                                "if": "||dtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||dtto||",
                                "andop": "=",
                                "andvalue": "BLANK",
                                "then": " and (DATE(a.createdon)='||dtfrom||')"
                            }, {
                                "if": "||pid||",
                                "op": "!=",
                                "value": "BLANK",
                                "then": " and b.pid='||pid||'"
                            }
                        ]
                    }

                ],
                "tbl": "cmch_advance a",
                "fld": "a.pid,b.pname,a.paymentmethod,a.advance,a.balance,DATE(a.createdon)",
				"functionfield":[
					{
						"name":"ad",
						"type":"button",
						"class":"mif-printer fg-blue",
						"caption":"prt",
						"onclick":"Eirene.runStmt('13ap-13a',{ID:'<a.id>',pid:'<a.pid>'})"
					}
				],"vsum":"4,5",
                "join": "LEFT JOIN cmch_patient b ON a.pid=b.pid",
                "header": "Patient ID, Patient Name,Payment Mode,Amount,Balance,Date",
                "whr": "a.recordstatus=1 and DATE(a.createdon)=CURDATE()"
                
            }
			
			
		},
		{
            "id": "13ap",
            "name": "Get Advance Print - HTML",
            "sql": {
                "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaAppendix",                
                "tbl": "cmch_advance a",
                "fld": "b.pname,b.pmobile,c.pcase",
                "join": "INNER JOIN cmch_patient b ON a.pid=b.pid LEFT JOIN (SELECT pcase,pid FROM cmch_appointment WHERE pdate<'||date||' ORDER BY pdate DESC LIMIT 1) c ON c.pid=b.pid",
                "parent": "TABLE style='border:1px solid black;border-collapse:collapse;margin-left:auto;margin-right:auto;font-size:0.7em'",
                "prepend": [
					"<div><button class='button secondary no-print' onclick='printHTML(&apos;workareaAppendix&apos;)'>Print</button></div>",
                    "<center><img src='resource/image/cmch_logo1.png' width='500' height='70'>",
                    "<div>Advance Receipt</div></center><center>"
                ],
                "template": [
                    "<tr><td style='border:1px solid black' class='p-1'><b>Patient ID</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||pid||</td><td style='border:1px solid black' class='p-1'><b>Name</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||pname||</td></tr>",
                    "<tr><td style='border:1px solid black' class='p-1'><b>Date</b></td><td style='border:1px solid black' class='p-1'>||CURDATE_D_M_Y||</td><td style='border:1px solid black' class='p-1'><b>Mobile No.</b></td><td style='border:1px solid black' class='p-1'>||pmobile||</td></tr>",
                    "<tr><td style='border:1px solid black' class='p-1'><b>Case Type</b></td><td style='border:1px solid black' class='p-1'>||pcase||</td><td style='border:1px solid black' class='p-1'><b>Department:</b></td><td style='border:1px solid black' class='p-1'></td></tr>"
                    
                ],                
                "whr": "a.recordstatus=1 and a.id='||ID||'",
                "onsuccess": "cmd:dom,fun:show;#workareaAppendix;slow"

            }
        },
		{
            "id": "13a",
            "name": "Get advance details - HTML",
            "sql": {
                "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaAppendix", 
				"appendoutput":true,
                "tbl": "cmch_advance",
                "fld": "'Advance Received' as remark,advance",	                
                "parent": "TABLE style='margin-left: auto;margin-right:auto;margin-top:0.5cm;font-size:0.7em;width:80%;'><thead><tr><TH style='text-align:left;'>Reamrk</TH><TH style='text-align:left;'>Amount</TH></TR",
                "template": "<TR><TD style='text-align:left;'> ||remark||</TD><TD style='text-align:left;'> ||advance||</TD></TR>",
                "whr": "recordstatus=1 and id='||ID||'",
				"append":[
							"<div style='text-align:left;font-size:0.7em'>",
								"<span><b>Figure: </b></span>",
								"<span id='14rftotfigure'></span>",
							"</div>",
							"<script>$('#14rftotfigure').html(ConvertNumberToWords($('#14rftotal').text()));</script>",
							"<div class='row mt-4' style='font-size:0.7em'><div class='cell'>Prepared by</div><div class='cell'>Checked By</div></div>"
						]
            }
        },
		{
			"id": "13adft",
            "name": "Filter Advance",
            "sql": {
				"action": "Return",
                "outputto": "php",
                "output": "demo",
                "value": "",
                "outputfilter": "#workareaFilter1",
				 "button": [{
                        "name": "f1",
                        "id": "13ftpid",
                        "caption": "PID: ",
                        "type": "text",
                        "value": ""
                    },{
                        "name": "f2",
                        "id": "13ftdtfrom",
                        "caption": "Date From: ",
                        "type": "datepicker", "value":"||CURDATE||"                        
                    },{
                        "name": "f3",
                        "id": "13ftdtto",
                        "caption": "Date From: ",
                        "type": "datepicker", "value":"||CURDATE||"
                    },{
                        "name": "f4",
                        "caption": "Get",
                        "class": "button secondary",
                        "onclick": "Eirene.runStmt('13',{filtertable:'f1',pid:$('#13ftpid').val(),dtfrom:$('#13ftdtfrom').val(),dtto:$('#13ftdtto').val()})"
                    }
				],                
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"
            }
		},
		{
			"id":"14",		
			"name":"Refund Details",
            "sql": {
                "action": "Get Table",
                "validate": "users",
                "outputto": "html",
                "output": "table",
                "outputfilter": "#workareaTablebox",
                "button": [{
                        "name": "f1",
                        "displaynone": 1,
                        "whr": [
                            "a.recordstatus=1",
                              {
                                "if": "||dtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||dtto||",
                                "andop": "!=",
                                "andvalue": "BLANK",
                                "then": " and (DATE(a.createdon)>='||dtfrom||' and DATE(a.createdon)<='||dtto||')"
                            }, {
                                "if": "||dtfrom||",
                                "op": "!=",
                                "value": "BLANK",
                                "and": "||dtto||",
                                "andop": "=",
                                "andvalue": "BLANK",
                                "then": " and (DATE(a.createdon)='||dtfrom||')"
                            }, {
                                "if": "||pid||",
                                "op": "!=",
                                "value": "BLANK",
                                "then": " and b.pid='||pid||'"
                            }
                        ]
                    }
                ],
                "tbl": "cmch_refund a",
                "fld": "rfnum,a.pid,b.pname,a.remark,DATE(a.createdon),a.refund",
				"vsum":"6",
                "functionfield": [{
                        "type": "icon",
                        "class": "mif-printer fg-blue",
                        "caption": "Print",
                        "title": "Print Bill",
                        "onclick": "Eirene.runStmt(&apos;14rg-14a&apos;,{rfnum:'<a.rfnum>',pid:'<a.pid>',date:'<a.createdon>',remark:'<a.remark>'})"
                    }
                ],
                "join": "LEFT JOIN cmch_patient b ON a.pid=b.pid",
                "header": "Refund No.,Patient ID, Name,Remark,Date,Refund Amount",
				"srt": "a.createdon DESC",
                "whr": "a.recordstatus=1 and DATE(a.createdon)=CURDATE()"
                
            }			
		},
		
		{
            "id": "14rg",
            "name": "Get Refund Bill - HTML",
            "sql": {
                "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaAppendix",                
                "tbl": "cmch_refund a",
                "fld": "b.pname,b.pmobile,c.pcase",
                "join": "INNER JOIN cmch_patient b ON a.pid=b.pid LEFT JOIN (SELECT pcase,pid FROM cmch_appointment WHERE pdate<'||date||' ORDER BY pdate DESC LIMIT 1) c ON c.pid=b.pid",
                "parent": "TABLE style='border:1px solid black;border-collapse:collapse;margin-left:auto;margin-right:auto;font-size:0.7em'",
                "prepend": [
					"<div><button class='button secondary no-print' onclick='printHTML(&apos;workareaAppendix&apos;)'>Print</button></div>",
                    "<center><img src='resource/image/cmch_logo1.png' width='500' height='70'>",
                    "<div>Refund No. : ||rfnum||</div></center><center>"
                ],
                "template": [
                    "<tr><td style='border:1px solid black' class='p-1'><b>Patient ID</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||pid||</td><td style='border:1px solid black' class='p-1'><b>Name</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||pname||</td></tr>",
                    "<tr><td style='border:1px solid black' class='p-1'><b>Date</b></td><td style='border:1px solid black' class='p-1'>||CURDATE_D_M_Y||</td><td style='border:1px solid black' class='p-1'><b>Mobile No.</b></td><td style='border:1px solid black' class='p-1'>||pmobile||</td></tr>",
                    "<tr><td style='border:1px solid black' class='p-1'><b>Case Type</b></td><td style='border:1px solid black' class='p-1'>||pcase||</td><td style='border:1px solid black' class='p-1'><b>Department:</b></td><td style='border:1px solid black' class='p-1'></td></tr>"
                    
                ],                
                "whr": "a.recordstatus=1 and a.rfnum=||rfnum||",
                "onsuccess": "cmd:dom,fun:function;convertSelect;#workareaTablebox-cmd:dom,fun:show;#workareaFilter1;slow-cmd:dom,fun:show;#workareaAppendix;slow"

            }
        },
		{
            "id": "14a",
            "name": "Get refund details - HTML",
            "sql": {
                "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaAppendix", 
				"appendoutput":true,
                "tbl": "cmch_refund",
                "fld": "remark,refund",				
                "union": "SELECT '<b>Grand Total<b>',CONCAT('<div id=14rftotal >',sum(refund),'</div>') FROM cmch_refund WHERE recordstatus=1 and rfnum='||rfnum||'",
                "parent": "TABLE style='margin-left: auto;margin-right:auto;margin-top:0.5cm;font-size:0.7em;width:80%;'><thead><tr><TH style='text-align:left;'>Reamrk</TH><TH style='text-align:left;'>Amount</TH></TR",
                "template": "<TR><TD style='text-align:left;'> ||remark||</TD><TD style='text-align:left;'> ||refund||</TD></TR>",
                "whr": "recordstatus=1 and rfnum='||rfnum||'",
				"append":[
							"<div style='text-align:left;font-size:0.7em'>",
								"<span><b>Figure: </b></span>",
								"<span id='14rftotfigure'></span>",
							"</div>",
							"<script>$('#14rftotfigure').html(ConvertNumberToWords($('#14rftotal').text()));</script>",
							"<div class='row mt-4' style='font-size:0.7em;'><div class='cell'>Prepared by</div><div class='cell'>Checked By</div></div>"
						]
            }
        },
		{
            "id": "svref",
            "name": "Save Refund Details",
            "sql": {
				"action": "MULTISTMT",
                "validate": "users",
                "outputto": "php",
                "output": "res",
                "multistmt": [
				{
					"action": "Save Row",               
					"tbl": "cmch_refund",
					"fld": "pid,refund,remark",
					"value": "||pid||,||refund||,||remark||",
					"fldtype": "s,n,s",
					"command": "insert",
					"onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful-cmd:dom,fun:val;input[name=pid];BLANK",
					"onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
				}
				
				
				]                
            }
        }, 
		{
			"id": "14rfft",
            "name": "Filter Advance",
            "sql": {
				"action": "Return",
                "outputto": "php",
                "output": "demo",
                "value": "",
                "outputfilter": "#workareaFilter1",
				 "button": [{
                        "name": "f1",
                        "id": "14ftpid",
                        "caption": "PID: ",
                        "type": "text",
                        "value": ""
                    },{
                        "name": "f2",
                        "id": "14ftdtfrom",
                        "caption": "Date From: ",
                        "type": "datepicker", "value":"||CURDATE||"                        
                    },{
                        "name": "f3",
                        "id": "14ftdtto",
                        "caption": "Date From: ",
                        "type": "datepicker", "value":"||CURDATE||"
                    },{
                        "name": "f4",
                        "caption": "Get",
                        "class": "button secondary",
                        "onclick": "Eirene.runStmt('14',{filtertable:'f1',pid:$('#14ftpid').val(),dtfrom:$('#14ftdtfrom').val(),dtto:$('#14ftdtto').val()})"
                    }
				],                
                "onsuccess": "cmd:dom,fun:show;#workareaFilter1;fast"
            }
		},
		{
            "id": "15svdi",
            "name": "Save Discharge Summary",
            "sql": {
				"action": "Save Row", 
                "validate": "users",
                "outputto": "php",
                "output": "res",  
				"tbl": "cmch_ip",
				"fld": "diagnosis,details,cause,labreport,treatmentdetails,dischargenotes,advice,issuefollowup,nextdate",
				"value": "||diagnosis||,||details||,||cause||,||labreport||,||treatmentdetails||,||dischargenotes||,||advice||,||issuefollowup||,||nextdate||",
				"fldtype": "s,s,s,s,s,s,s,s,s",
				"command": "update",
				"whr": "id='||ID||'",
				"onsuccess": "cmd:dom,fun:showtoast;success;Saving Successful",
				"onfailure": "cmd:dom,fun:showtoast;alert;Saving Failed"
			}
        },
		{
            "id": "15gtip",
            "name": "Get Discharge Details",
            "sql": {
                "action": "Get Row",
                "validate": "users",
                "outputto": "html",
                "output": "edit",
                "tbl": "cmch_ip",
                "fld": "id,pid,diagnosis,details,cause,labreport,treatmentdetails,dischargenotes,advice,issuefollowup,nextdate",
                "whr": "id='||ID||'",
				"function":"edit1"
            }
        },{
            "id": "15pr",
            "name": "Get Discharge HTML(Patient details)",
            "sql": {
                 "action": "Get HTML",
                "validate": "users",
                "outputto": "html",
                "output": "#workareaAppendix",               
                "prepend": [
					"<button class='mif-printer fg-blue' onclick='printHTML(&apos;workareaAppendix&apos;)'></button>",
                    "<center><img src='resource/image/cmch_logo1.png' width='400' height='60'></center>"
				],
                "template": [
					"<table style='border:1px solid black;border-collapse:collapse;margin-left:auto;margin-right:auto;margin-top:10px;font-size:0.7em'>",
                    "<tr><td style='border:1px solid black' class='pl-2'><b>Patient ID</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||pid||</td><td style='border:1px solid black' class='p-1'><b>Name</b></td><td style='border:1px solid black;width:5cm' class='p-1'>||pname||</td></tr>",
                    "<tr><td style='border:1px solid black' class='p-1'><b>BIll NO:</b></td><td style='border:1px solid black' class='p-1'>||billno||</td><td style='border:1px solid black' class='p-1'><b>Bill Date</b></td><td style='border:1px solid black' class='p-1'>||createdon||</td></tr>",
                    "<tr><td style='border:1px solid black' class='p-1'><b>Age/Gender</b></td>",
					{"if":"||pgender||","op":"=","value":"0","then":"<td style='border:1px solid black' class='p-1'>||age||/Male</td>","else":"<td style='border:1px solid black' class='p-1'>||age||/Female</td>"},
					"<td style='border:1px solid black' class='p-1'><b>Marital Status</b></td>",
					{"if":"||pmaritalstatus||","op":"=","value":"0","then":"<td style='border:1px solid black' class='p-1'></td></tr>"},
					{"if":"||pmaritalstatus||","op":"=","value":"1","then":"<td style='border:1px solid black' class='p-1'>Single</td></tr>"},
					{"if":"||pmaritalstatus||","op":"=","value":"2","then":"<td style='border:1px solid black' class='p-1'>Married</td></tr>"},
					{"if":"||pmaritalstatus||","op":"=","value":"3","then":"<td style='border:1px solid black' class='p-1'>Widowed</td></tr>"},
					{"if":"||pmaritalstatus||","op":"=","value":"4","then":"<td style='border:1px solid black' class='p-1'>Divorced</td></tr>"},
                    "</table>"					
				],
				"tbl": "cmch_ip a",
                "fld": "a.pid,b.pname,(YEAR(CURDATE())-b.pyob) as age",
				 "join": [
						"LEFT JOIN cmch_patient b ON a.pid= b.pid",
						"LEFT JOIN cmch_doctors c ON a.docid=c.id"
						],
				"whr":"a.id='||id||'",
				"additionalstmt":"",
				"onsuccess":"cmd:dom,fun:show;#workareaAppendix;fast"
            }
        }		
    ]
}
