Skip to main content

system.kanoa.cmms.getEnteredValueState(value, checkConfig)

Evaluates a manually entered check value (for example, a meter reading or inspection check) against the check's configuration to determine which item state the value falls into. It returns the resolved state identifier and its display name/color, so calling code can immediately react to whether an entered value is within a normal, warning, or other configured range.


Parameters

value object
checkConfig Dictionary


Returns

stateInfo Dictionary i.e. {'chkItemStateId', 'chkItemStateName', 'chkItemValueName', 'chkItemValueState', chkItemStateColor', 'msg'}


Example

#Find out an entered value's state based on what has set up for this procedure step check
procedureStepCheckId = 17
value = 87.5
checkConfig = system.kanoa.utilities.getFieldValue('checkConfig', system.kanoa.cmms.getProcedureStepChecks({'procedureStepCheckId': procedureStepCheckId}))
if checkConfig:
checkConfig = system.util.jsonDecode(checkConfig)
stateInfo = system.kanoa.cmms.getEnteredValueState(value, checkConfig)
else:
print 'Value states undefined'
stateInfo = {}

for k,v in stateInfo.items():
print k,v
>>>
msg None
chkItemValueName 87.5
chkItemStateId 3
chkItemStateName FAIL
chkItemValueState None
chkItemStateColor --kcBadContainer
>>>

#Find out an entered value's state based on what has set up for this procedure step
procedureStepId = 141
value = 52
stepConfig = system.kanoa.utilities.getFieldValue('stepConfig', system.kanoa.cmms.getProcedureSteps({'procedureStepId': procedureStepId}))
print stepConfig
if stepConfig:
stepConfig = system.util.jsonDecode(stepConfig)
stateInfo = system.kanoa.cmms.getEnteredValueState(value, stepConfig)
else:
print 'Value states undefined'
stateInfo = {}

for k,v in stateInfo.items():
print k,v

msg None
chkItemValueName 52
chkItemStateId 1
chkItemStateName PASS
chkItemValueState None
chkItemStateColor --kcGoodContainer