© 2018 Capita Business Services Ltd. All rights reserved.

Capita Education Software Solutions is a trading name of Capita Business Services Ltd. Our Registered office is 30 Berners Street, London, W1T 3LR and our registered number is 02299747. Further information about Capita plc can be found in our legal statement.

SIMS 7 - Generic Lookup Extract

Lookups may be exported in 2 parts:

  • Get a list of all of the Lookup tables.
  • Get a list of all the Lookup Codes for each table.

Lookups vary in type, some of the tables are completely defined by government and others are user defined in the school. TI's need to take care if they assume that any values are comparable between schools.  For example, the code HE for illness category (Staff) might be Heart Condition in one school and Heat Stroke in another.  The use of the description is more likely to be meaningful as a human readable value but could be H/Stroke in school A and Heat Stroke in school B.  Lookups may also have a linked category, where the code is school defined but links to an externally recognisable category

A lookup table is of the form

public class dLookupTable
{
    public string Name { get; set; }
    public string Area { get; set; }    
    public string Mode { get; set; }
    public List<dLookupEntry> TableEntries = new List<dLookupEntry>();
}

A lookup entry is of the form

public class dLookupEntry
{
    public int? ID { get; set; }
    public string Code { get; set; }
    public string Description { get; set; }
    public bool Active { get; set; }
    public string Category { get; set; }
    public string CatDes { get; set; }  
}

We can use the Maintain Lookups browse to get the set of tables.  Note that we have 2 types of lookup - True Lookup and Group Type lookups which need to be processed separately.

List<dLookupTable> lU_Tables = new List<dLookupTable>();
//GetStaffLookups(ref lU_Tables);
          
SIMS.Processes.LookupTypeBrowser lutb = new SIMS.Processes.LookupTypeBrowser();
SIMS.Entities.LookupArea lua = new SIMS.Entities.LookupArea();

foreach (var v in lutb.Browse("%", lutb.LookupAreaAny))
{
    if (v is SIMS.Entities.TrueLookupTypeSummary)
    {
    //..
    }
    else if (v is SIMS.Entities.GroupLookupTypeSummary)
    {
    //..
    }
    

True Lookups


TrueLookupTypeSummary t = (TrueLookupTypeSummary)v;
dLookupTable table = new dLookupTable();
table.Name = t.Description;
table.Area = null;
if (t.LookupArea != null)
{
    table.Area = t.LookupArea.Description;
}
table.Mode = null;
if (t.LookupMode != null)
{
    table.Mode  = t.LookupMode.Description; 
}

 and then need to load the lookup entries for the table.


SIMS.Processes.LookupTypeDetail lutd = new SIMS.Processes.LookupTypeDetail();

lutd.Load(t);
SIMS.Entities.TrueLookupType trueLookupType = new TrueLookupType();
trueLookupType = (TrueLookupType)lutd.LookupType;

foreach (SIMS.Entities.TrueLookupValue lookupValue in trueLookupType.LookupValues.Value)
{
    dLookupEntry e = new dLookupEntry();
    e.Code = lookupValue.Code;
    e.ID = lookupValue.LookupValueID;
    if (lookupValue.Category != null)
    {

        e.Category = lookupValue.Category.Code;
        e.CatDes = lookupValue.Category.Description;

    }
    e.Description = lookupValue.Description;
    e.Active = lookupValue.Active;
    table.TableEntries.Add(e);
    }
    lU_Tables.Add(table);

And for group type

GroupLookupTypeSummary t = (GroupLookupTypeSummary)v;
dLookupTable table = new dLookupTable();
table.Name = t.Description;
table.Area = null;
if (t.LookupArea != null)
{
    table.Area = t.LookupArea.Description;
}
table.Mode = null;
if (t.LookupMode != null)
{
    table.Mode  = t.LookupMode.Description; 
}
SIMS.Processes.LookupTypeDetail lutd = new SIMS.Processes.LookupTypeDetail();
lutd.Load(t);
SIMS.Entities.GroupLookupType trueLookupType = new GroupLookupType();
trueLookupType = (GroupLookupType)lutd.LookupType;

and then the entries

foreach (SIMS.Entities.GroupLookupValue lookupValue in trueLookupType.LookupValues.Value)
{
    dLookupEntry e = new dLookupEntry();
    e.Code = lookupValue.Code;
    e.Description = lookupValue.Description;
    if (lookupValue.Category != null)
    {
        e.Category = lookupValue.Category.Code;
        e.CatDes = lookupValue.Category.Description;

    }
    e.Active = lookupValue.Active;
    table.TableEntries.Add(e);
}

then add them to the list of looks that you require.

This would serialise to:

  {
    "TableEntries": [
      {
        "ID": 1,
        "Code": "Y",
        "Description": "Yes",
        "Active": true,
        "Category": null,
        "CatDes": null
      },
      {
        "ID": 2,
        "Code": "N",
        "Description": "No",
        "Active": true,
        "Category": null,
        "CatDes": null
      },
      {
        "ID": 3,
        "Code": "U",
        "Description": "Unknown",
        "Active": true,
        "Category": null,
        "CatDes": null
      },
      {
        "ID": 4,
        "Code": "R",
        "Description": "Refused",
        "Active": true,
        "Category": null,
        "CatDes": null
      }
    ],
    "Name": "Service Children in Education",
    "Area": "Students",
    "Mode": "Statutory (Fixed)"
  }