On call roster clasification as per sites

I have 36 hospital sites and want to assign different roster for different sites, is it possible to show my roster as per the site selection. In below screen I have 7 rosters but as per the site is selected the respective roster will only be shown Is their a way to do this?

Rosters are a "global" resource. You'd have to make different rosters for each type-of-user across each type-of-site.

What you can do instead, in the alarm notification pipeline, is use a calculated roster to retrieve roster information from a database (or anywhere else you can programmatically define this information) and build it up into a complete roster before it's sent:

You could even put everyone across all sites into their appropriate roster buckets, then in the calculated roster retrieve all users and filter it down to only the users appropriate to a given site.

2 Likes

Ok got it Thanks for the info.

Is it possible to create a customized roster system without using the Gateway, by instead managing everything through a database?
For example, maintaining a Users table (with fields like userID, name, email, phone, etc.) and a Rosters table (with rosterID and rosterName), and then assigning users to rosters directly from the database—without needing to configure or add users through the Gateway?

Yes. Use calculated roster, like Paul has mention above. The link has examples on how to do it.

1 Like

I am not able to execute the following script:

def calculateRoster(event, builder):

logger = system.util.getLogger("CalculateRoster")

try:
	rosterID = 1

    logger.info("Fetching roster: {}".format(rosterID))
    
    results = system.db.runNamedQuery("Mediclinic_UCC",
        "CalculatedRoster",
        {"rosterID": rosterID}
    )

results = system.dataset.toPyDataSet(results)

    if not results:
        logger.warn("No users found for roster: {}".format(rosterID))
        return []

    
    for row in results:

        logger.info("Adding user: {}".format(row["Name"]))

       
        builder.username(row["Name"]) \
               .email([row["Email"]] if row["Email"] else []) \
               .phone([row["Phone"]] if row["Phone"] else []) \
               .add()

    
    roster = builder.build()

    logger.info("Final roster size: {}".format(len(roster)))

    return roster

except Exception as e:
    logger.error("Roster calculation failed: {}".format(str(e)))
    return []















In namedquery I have checked it is giving correct result but in gateway logs i am getting

image

If this is your exact code, then this line:

Is unindented too far, and is closing the scope and preventing the rest of the code from doing anything.

If you don't know basic Python syntax, you won't be able to evaluate your LLM's output with any kind of rigor.

1 Like

thanks Paul, in above script indent was proper in the ignition but while pasting I did some mistake so due to that you pointed that out, but even after that same error was coming.

def calculateRoster(event, builder):

logger = system.util.getLogger("CalculateRoster")

try:
	rosterID = 1

    logger.info("Fetching roster: {}".format(rosterID))
    
    results = system.db.runNamedQuery("Mediclinic_UCC",
        "CalculatedRoster",
        {"rosterID": rosterID}
    )
    results = system.dataset.toPyDataSet(results)

    if not results:
        logger.warn("No users found for roster: {}".format(rosterID))
        return []

    
    for row in results:

        logger.info("Adding user: {}".format(row["Name"]))

       
        builder.username(row["Name"]) \
               .email([row["Email"]] if row["Email"] else []) \
               .phone([row["Phone"]] if row["Phone"] else []) \
               .add()

    
    roster = builder.build()

    logger.info("Final roster size: {}".format(len(roster)))

    return roster

except Exception as e:
    logger.error("Roster calculation failed: {}".format(str(e)))
    return []


can you plese check again this script and help where I am wrong?
also does alarm pipeline which is running in gateway is able to fetch DB data?

The code that comes after the function definition should have indendation, like this.

def calculateRoster(event, builder):

    logger = system.util.getLogger("CalculateRoster")

    try:
        rosterID = 1

        logger.info("Fetching roster: {}".format(rosterID))
        
        results = system.db.runNamedQuery("Mediclinic_UCC",
            "CalculatedRoster",
            {"rosterID": rosterID}
        )
        results = system.dataset.toPyDataSet(results)

        if not results:
            logger.warn("No users found for roster: {}".format(rosterID))
            return []

        
        for row in results:

            logger.info("Adding user: {}".format(row["Name"]))

        
            builder.username(row["Name"]).email([row["Email"]]).phone([row["Phone"]]).add()

        
        roster = builder.build()

        logger.info("Final roster size: {}".format(len(roster)))

        return roster

    except Exception as e:
        logger.error("Roster calculation failed: {}".format(str(e)))
        return []

Yes, If you have the correct named query CalculatedRoster inside the project named Mediclinic_UCC

still I am getting that error, below are my screen shoots of named query and their test which is running sucessfully in designer.

Can you expand on the error and see what it says?

But I have the project

It's says that Mediclinic_UCC project not found, you should give correct name of the project in the function, system.db.runNamedQuery()

It has double underscores. Mediclinic__UCC instead of Mediclinic_UCC

2 Likes

I was stuck on this for the past two days, and your help really made a difference. Thank you so much—I truly appreciate it!:heart_eyes:

1 Like

Hi Cose_Peter1 I have to filter the user by hospital name as well I am executing the below script and added the hospitalName as another parameter, on named query side it is running fine but in gateway side its not running (indentation is correct dont worry about it). what am I doing wrong can you help me?

def calculateRoster(event, builder):
	try:
	    rosterID = 1
	    hospitalName = "Mediclinic Bloemfontein"
	
	    logger.info("Fetching roster: {} for hospital: {}".format(rosterID, hospitalName))
	   
	    results = system.db.runNamedQuery(
	        "Mediclinic__UCC",
	        "CalculatedRoster",
	        {
	            "rosterID": rosterID,
	            "hospital": hospitalName
	        }
	    )
	
	    results = system.dataset.toPyDataSet(results)
	
	    if not results:
	        logger.warn("No users found for roster: {} and hospital: {}".format(rosterID, hospitalName))
	        return []
	
	    for row in results:
	        logger.info("Adding user: {}".format(row["Name"]))
	
	        builder.username(row["Name"])\
	               .email([row["Email"]])\
	               .phone([row["Phone"]])\
	               .add()
	
	    roster = builder.build()
	
	    logger.info("Final roster size: {}".format(len(roster)))
	
	    return roster
	
	except Exception as e:
	    logger.error("Roster calculation failed: {}".format(str(e)))
	    return []

I am getting below error on gateway.

image

Also below is my query:

Which is working perfectly.

Seems like there is no data in your DB table for the conditions provided in you sql query. Try testing it by giving rosterID = 1 and hospital = "Mediclinic Bloemfontein" directly on your named query.

1 Like

Ok Thanks.

@Cose_Peter1 is it possible to make dropdown work as bidirectional, meaning it can give selection values as well as take the values coming from database below is my example:

Like whenever I click the user as for example in Pharmacy manager roster only the fields like Name, Title, Email, cell number are getting inserted but not in dropdown as I am using it for selection of region and hospital data to be inserted in DB.
is it possible?