How to automatically select a categorical variable based on calculated number in REDCap? - redcap

I am creating a REDCap tool which gives patients a numerical acuity score based on their medical history. Each numerical score also corresponds to a color code (Green 1-3, Yellow 4-6, Red 7+) that nurses use. Is there a way to automatically display the name of the color code based on the acuity score?
I wanted to use something like a calculated field but it apparently cannot return text answers.

If you are on a sufficiently recent version, you can use the #CALCTEXT action tag to return the colour code based on the value:
#CALCTEXT(if([acuity]<=3,'Green',if([acuity]<=6,'Yellow','Red')))
Another way (or if you don't have #CALCTEXT) is to have a calculated 'helper' field and use its value in a #DEFAULT action tag. So, a field [acuity_code] would have the calculation:
if([acuity]<=3,1,if([acuity]<=6,2,3))
Them, a field [acuity_colourcode] could have these options:
1, Green
2, Yellow
3, Red
And an action tag:
#DEFAULT='[acuity_code]'
[acuity_colourcode] must be on a different form or page, as piping into #DEFAULT requires that the value exists in the database on page load; it's not dynamic or performed in-browser like branching logic or a calculation. So [acuity] and [acuity_code] would be on one page, and [acuity_colourcode] would be on a subsequent page.

Related

Indicators in a matrix

I'm trying to add some indicators into a matrix to show an increase or decrease from the previous year
This is my design view
And this is how it's viewed in the report
I would obviously like my up and down arrows to appear in the currently empty columns. Also I'm wondering if there is a way of deleting the first empty column after 2014/15 as there is no year to compare it to.
SSRS supports a function called Previous, which will be useful in your scenario. Assuming that the name of your column group is "Fiscal", the difference of two years can be calculated as
=Count(Fields!IDNUMBER.Value) - Previous(Count(Fields!IDNUMBER.Value), "Fiscal")
Because you can't know the range of the numbers in advance, I suggest to use a "numeric" expression like
=Sign(Count(Fields!IDNUMBER.Value) - Previous(Count(Fields!IDNUMBER.Value), "Fiscal"))
for the indicator, so the ranges can be defined by single values -1, 0 and 1:
To hide the first indicator column, right-click the column header in design view and click Column Visibility..., then in the cnfiguration dialog specify to hide based on an expression like
=IsNothing(Previous(Fields!Fiscal.Value, "Fiscal"))
Here's a screenshot of my design view:

SSRS Scope with Row and Column groups issues

I'm trying to get percentage calculated for my tablix and have problem on very last column, which is outside of Column Group, can't make it work, I can't use Dataset as I have a filter on tablix level. Pic below illustrates all my setup. I Understand if you stay inside the box then you have all right scopes, curious if I can do any right click and see what scope is ??)
I need somehow to get value =1837 to use in pink boxes.
I tried to digest error message and tried all combo but not helps
Is this doable?
You can refer to your very last column which is outside the groups and the deatils with the following expression. Lets say your Total from YTD is in Textbox1. Then you can refer to this textbox (because its outside the detail rows):
=ReportItems!Textbox1.Value 'Result: 1837
But a better way to calculate the percentage in the pink boxes would be the following expression (this expression comes in the pink box):
=Sum(Fields!YTDDetail.Value, "TurnDays") / Sum(Fields!YTDDetail.Value, "Dataset")
This way you are dividing the grouped sum with the whole sum, which should result in your percentage if you format the output of the texbox as Number > Percentage.

Calculate length, width and height of a product

I have the following problem. I want to get the product price calculated through the lengt, width and height.
The length and width are calculated through a csv-file, but not the height. The height should be priced for each 5cm( till 10cm +0€, till 15cm +5€, till 20cm +10€ etc.).
I have tried some different things, but never reached my goal. My next idea is, that the height is calculated by two areas: the first would be a dropdown menu, where the customer can select ranges like in the example above. The second would be a text field, where the customer can write the wanted cm value. The problem is, that the customer can select e.g. "till 10cm +0€" in the dropdown and then writes e.g. 25cm. So he would get the wanted value for free.
My question: Is there a way to connect those two areas and limit the text field to the chosen dropdown range (e.g. dropdown: till 20cm +10€ -> text field limit: customer can write anything between 16 and 20cm). Or are there any better and simpler?
I thank you very much in advance for your answers.
Best Regards,
The idea would be to use options of product.
A configuration part must be done in back office for each product where you want to set the height. In my idea there are two options : the exact height (if you need it for order) and a dropdown that will not be displayed but that contains the prices range. For this dropdown, you use a pattern like you said (till 20cm or <20 as it would not be display I would use a pattern easy to parse with JS).
On front, you hide this select and when a client enters a value for the height, you set the undisplayed select with the correct values range and retrieve the price to display to the user all in JavaScript.

Data validation on the result of a formula

I'm looking for a way to default a cell value with data validation applied, but allow the user to overwrite the value to one of the valid values allowed.
I have a demo spreadsheet here.
And visually:
I have data validation on column D that provides a list of possible markup percentages from column G, however, I want a default value in there so I have written a formula to work this out (based on there being a value in an adjacent cost cell).
I enter the item, I enter a cost and the markup defaults. All good.
But, when I click the dropdown I don't get any values popup. the formula is shown instead.
I have tried conditional formatting based on making the cell text and background white, but this is sub-optimal for my real world (significantly more complex) scenario.
How can I achieve what I am after - a default value of 50% if there is a cost value, but selectable from the drop-down.
The only way to add a "default" value based on a condition is to use on edit (simple or installable) script.
Example:
The following is an simple on edit trigger. If a cell from column C below the first row is edited, then the cell to the right will be 50% (assuming that the cell format is set to display %)
function onEdit(e){
if(e.range.columnStart === 3 && e.range.rowStart > 1){
e.range.offset(0,1).setValue(0.5);
}
}
Resources
https://developers.google.com/apps-script/guides/sheets
https://developers.google.com/apps-script/guides/triggers

Magento Attribute Options - Group same store value option with different admin value

in our admin we use the color option set as "dropdown"
we break down our colors very detail. For example in the "admin option values" we have
blue
blue lace
blue-green
blue-green
but on the front end "store view" we want the filter to just have 1 option "blue"
so in the "Manage Options (values of your attribute)" > "Default Store View" we put for all of those "blue"
but on our web site there ends up being 4 separate blue filters.
is there a way on the front end to only see 1 option "blue" with all the products added up?
Exploratory solution:
You need do some custom coding in a class with a name something like the Mage_Catalog_Model_Layer_Filter , there should be a function there called getItems().
The function itself just calls another function which creates a Zend query which grabs the information from the database.
You should explore until you find that Zend query builder and add a group by to the query.
Alternatively you could just take the array of items and modify it before returning it.
Counter argument:
Removing the second, third etc. links from the getItems list should be fairly simple and you'll basically leave only the first link.
But when the user will click on the link the URL will be filtering by the first attribute the results of filtering by the second, third etc. attributes will not be shown.
You'll have to manipulate that logic as well.
Counter proposal:
You can create an additional attribute such as "color_detail" which you can setup to not be visible in the front end or filterable or sortable etc. so none of the users can see it. BAM! Mission completed.
Another approach -- less intuitive -- if you're not already using and displaying product tags you could use those to tag the object with that particular color detail.
Another approach -- more intuitive especially if you want to keep track of stocks and/or allow the user to choose from the list of color details -- is using product options which can be configured to have their own SKU as well as their own stock inventory and can affect the product price and weight.

Resources