def MakeReagentMap(InstrumentName, TestMapDIC):
    #sor.LoadConfig();
    #instrumentname = sor.instrumentna;
    reagentinfos = []
    sql = "select distinct(reagent_name),reagent_type,reagent_lot from sys_info.reagent_detail where instrument_name = '" + InstrumentName + "' and  onboard = 1 order by reagent_name"
    results = db.FetchData(sql)
    testmaphexcode = "01BF"
    for row in results:
        ReagentName = str(row[0])
        if ReagentName in TestMapDIC:
            print('1')
            id = TestMapDIC[ReagentName]
            print(id)
        else:
            id = row[2]
        testmaphexcode += str_to_hex(id + ";" + ReagentName) + "FD"
        reagenttype = row[1]
        reagenttype = str(row[1]).upper()[0:1]
        reagentcount = GetReagentCount(ReagentName, InstrumentName)
        reagentinfo = "01B5" + str_to_hex(ReagentName) + "FD01" + str_to_hex(
            row[2] + reagenttype + reagentcount + ";" + id) + "FD"
        reagentinfo = "F0" + reagentinfo + checksum(reagentinfo) + "F8"
        reagentinfos.append(reagentinfo)
    sum = checksum(testmaphexcode)
    testmaphexcode = "F0" + testmaphexcode + sum + "F8"
    return testmaphexcode, reagentinfos
def GetReagentCount(ReagentName, InstrumentName):
    sql = "select reagent_name,reagent_count from sys_info.reagent_detail where instrument_name = '" + InstrumentName + "' and  onboard = 1 and reagent_name = '" + ReagentName + "' order by reagent_name"
    results = db.FetchData(sql)
    count = 0
    for r in results:
        count += int(r[1])
    return str(count)