convert the list into array

Hi team,

i have an expression rule to get the doctors with count of patients assigned to them with the disease but i want to get the  total patience count for that particular doctor with array of disease like eg:

swift:3:{cance,Gallstones,Emotional Disorder}, Please help me to achieve this format

substitute(substitute(substitute(substitute(
  substitute(
    substitute(
      a!queryEntity(
        entity: cons!PO_MEDICALINFO,
        query: a!query(
          logicalexpression: a!queryLogicalExpression(
           operator: "AND",
          filters:  {
           a!queryFilter(
             field: "reasonForVisit", 
             operator: "in",
             value:ri!reasonForVisit 
           ),
            a!queryFilter(
              field:"appointmentDate",
              operator: "between",
              value: {
                todatetime(ri!createddatefrom),
                todatetime(ri!createddateto)
              },
              applywhen: and(
                not(rule!APN_isEmpty(ri!createddatefrom)),
                not(rule!APN_isEmpty(ri!createddateto)))
              
            ),

 
          },
          ignorefilterswithemptyvalues: true()
          
          ),
          aggregation: a!queryAggregation(
            aggregationColumns: {
              a!queryAggregationColumn(
                field: "reportingDoctor",
                isGrouping: true,
              ),
              a!queryAggregationColumn(
                field: "patientId",
                alias:"patientCount",
                aggregationFunction:"COUNT"

              ),
              a!queryAggregationColumn(
                field: "reasonForVisit",
                isGrouping: true
              )
              
              
            },

          ),
          pagingInfo: a!pagingInfo(
            startIndex: 1,
            batchSize: -1,
            sort: a!sortInfo(
              field: "patientCount",
              ascending: true()
            )
          )
        ),
        fetchTotalCount: true
      ).data,"patientCount",""),"reportingDoctor:",""),",",""),"[",""),"]",""),"reasonForVisit","")

  Discussion posts and replies are publicly visible