background first: I have the following agent types: activity and pathway. pathways are agents that contain populations of activities. activities contain specific instructions given to other agents (orders). And pathways are collections of those instructions. The pathway collections are defined via a database where each row is 1 pathway agent & each column is the String ID of an activity, with the cell value being 0, 1, 2 etc depending on number of each activity allocated to that pathway.
Goal: I need to create a population of activities within the pathway agent at agent startup
What I have tried: I have created a population of activities in Main. Each pathway has an activityList which contains the string ID of all the activities. The intention is when a cell value is 1 or above, the code would pick the corresponding activity agent from main and place it into the population in pathway. Code below, I noticed from other posts an index is used to go through rows, but this does not seem to work for columns.
Problem: I cannot get the code to search the columns dynamically, based on the list of string IDs
activityIndex = 0;
// there are 115 activities in the list, the code would repeat for each one
while (activityIndex <= 114)
{
activityName = activityList.get(activityIndex);
// search below returns the cell value from row with pathway ID = agAssess
// it searches the column with string ID matching activityName
// note: error returned as the database does not contain a column named "activityName"
// in this case "activityName" in the search below would need to be replaced with the parameter's value
// error message: activityName cannot be resolved or is not a field
double value = selectFrom(activity_groups_assess).
where(activity_groups_assess.code.eq(agAssess)).
uniqueResult(activity_groups_assess.activityName);
// if the value > 0, create agent with string ID activityName
// for agents with value > 1, multiple agents with the same string ID would be created, hence while function
while (value > 0)
{
// find the agent with the same string ID
Activity newActivity = findFirst(main.activities, p -> p.code == activityName);
// add agent to population activitiesAssess
// error when adding agent: Description: The method add_activitiesAssess() in the type ClinicalPathway is not applicable for the arguments (Activity).
add_activitiesAssess( newActivity );
value--;
}
activityIndex++;
}