AI Classifier Treating List as a Single Value

Certified Associate Developer

Hi Team,

I'm using the Document Classifier to distinguish between Medical Certificates and other document types (e.g., doctor prescriptions, blood reports, etc.). My goal is to extract data only from Medical Certificates after classification.

I am using the AI Classifier Skill, which returns a list of classified documents in the following format:  The output of this is a list  say : [classifiedItem=325673, type=Medical Certificate, confidenceScore=94, errorMessage=],[classifiedItem=325672, type=Medical Certificate, confidenceScore=95, errorMessage=] 

To process the classification result, I wrote the following expression to match each classified document with the corresponding uploaded document and then extract data only from Medical Certificates:

However, I have noticed that even when the classification result contains multiple values, Appian is treating the entire list as one single value, instead of iterating over each item properly. (Screenshot below)

a!localVariables(
local!document : ri!document,
local!classificationResult: a!forEach(
items: ri!AboveThreshold,
expression: a!localVariables(
local!appianDocId: index(
ri!document,
'recordType!RSL Request Document.appianDocId',
null
),

if(
and(a!isNotNullOrEmpty(local!appianDocId) ,
tointeger(fv!item.classifiedItem) = tointeger(local!appianDocId)),
fv!item,
null
)
)
),

local!classificationResult
)

Question: How can I modify my expression rule to correctly process each classified document separately and extract data only from Medical Certificates? Alternatively, is there a better approach to achieve this in Appian?

Here is my process model

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    1. Can you please share the result of AI classifier.

    2. Seems the rule input value you gave fro AboveThreshold is taking first item. You should keep the list as below.

    {

    {classifiedItem=325673, type=Medical Certificate, confidenceScore=94, errorMessage=},

    {classifiedItem=325672, type=Medical Certificate, confidenceScore=95, errorMessage=}

    }

    3. You can't apply index for record fields. you can simpe read record fields as below

       recordType[recordType.fields.field]

Reply
  • 0
    Certified Senior Developer

    1. Can you please share the result of AI classifier.

    2. Seems the rule input value you gave fro AboveThreshold is taking first item. You should keep the list as below.

    {

    {classifiedItem=325673, type=Medical Certificate, confidenceScore=94, errorMessage=},

    {classifiedItem=325672, type=Medical Certificate, confidenceScore=95, errorMessage=}

    }

    3. You can't apply index for record fields. you can simpe read record fields as below

       recordType[recordType.fields.field]

Children
  • 0
    Certified Associate Developer
    in reply to Shivakanth Reddy P

    1) this is the classifier output : [classifiedItem=325673, type=Medical Certificate, confidenceScore=94, errorMessage=],[classifiedItem=325672, type=Medical Certificate, confidenceScore=95, errorMessage=], [classifiedItem=325672, type=Other, confidenceScore=83, errorMessage=] 

    I used this expression in the process modeller first (step : copy of current data) but noticed it wasn't working as expected, so i tried it in expression and noticed that its not treating the classificationresult as list without the {}. So the ask is advise in how to get classifier result for each doc or modified expression to achieve this result : 

    a!localVariables(
    local!document : ri!document,
    local!classificationResult: a!forEach(
    items: ri!AboveThreshold,
    expression: a!localVariables(
    local!appianDocId: index(
    ri!document,
    'recordType!RSL Request Document.appianDocId',
    null
    ),

    if(
    and(a!isNotNullOrEmpty(local!appianDocId) ,
    tointeger(fv!item.classifiedItem) = tointeger(local!appianDocId)),
    fv!item,
    null
    )
    )
    ),

    local!classificationResult
    )