示例#1
0
        public PrestazioneDTO RetrievePres(string presid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            PrestazioneDTO pres = null;

            pres = bll.GetPrestazioneById(presid);

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(pres);
        }
示例#2
0
        public PrestazioneDTO ChangeHL7StatusAndMessagePrestazione(string presidid, string hl7_stato, string hl7_msg = null)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            PrestazioneDTO updated = new PrestazioneDTO();

            log.Info(string.Format("Starting ..."));

            string msg_ = "Status updating with 'hl7_stato'-> " + hl7_stato;

            if (hl7_msg != null)
            {
                msg_ += " and 'hl7_msg'-> " + hl7_msg;
            }
            log.Info(string.Format(msg_));

            log.Info(string.Format("Updating PRES ..."));

            PrestazioneDTO got = GetPrestazioneById(presidid);

            got.hl7_stato = hl7_stato;
            got.hl7_msg   = hl7_msg != null ? hl7_msg : got.hl7_msg;
            updated       = UpdatePrestazione(got);

            int res = 0;

            if (updated != null)
            {
                res++;
            }
            else
            {
                log.Info(string.Format("An Error occurred. Record not updated! PRESIDID: {0}", got.presidid));
            }
            log.Info(string.Format("Updated {0}/{1} record!", res, 1));

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(updated);
        }
示例#3
0
        public bool ValidatePres(PrestazioneDTO pres, ref string errorString)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            bool validate = true;

            if (errorString == null)
            {
                errorString = "";
            }

            if (pres.preseven == null)
            {
                string msg = "PRESEVEN is Null!";
                validate = false;
                if (errorString != "")
                {
                    errorString += "\r\n" + "PRES error: " + msg;
                }
                else
                {
                    errorString += "PRES error: " + msg;
                }
            }

            if (errorString == "")
            {
                errorString = null;
            }

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(validate);
        }
示例#4
0
        public int ChangeHL7StatusAndMessageAll(string richidid, string presidid, string hl7_stato, string hl7_msg = null)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            int res = 0;

            log.Info(string.Format("Starting ..."));

            string msg_ = "Status updating with 'hl7_stato'-> " + hl7_stato;

            if (hl7_msg != null)
            {
                msg_ += " and 'hl7_msg'-> " + hl7_msg;
            }
            log.Info(string.Format(msg_));
            log.Info(string.Format("Updating ESAM ..."));

            RichiestaLISDTO got = GetRichiestaLISById(richidid);

            got.hl7_stato = hl7_stato;
            got.hl7_msg   = hl7_msg != null ? hl7_msg : got.hl7_msg;
            RichiestaLISDTO updt = UpdateRichiestaLIS(got);

            int esamres = 0;

            if (updt != null)
            {
                esamres++;
            }
            else
            {
                log.Info(string.Format("An Error occurred. Record not updated! ESAMIDID: {0}", got.esamidid));
            }
            res += esamres;

            log.Info(string.Format("Updated {0}/{1} record!", esamres, 1));

            log.Info(string.Format("Updating PRES ..."));

            PrestazioneDTO got2 = GetPrestazioneById(presidid);

            got2.hl7_stato = hl7_stato;
            got2.hl7_msg   = hl7_msg != null ? hl7_msg : got2.hl7_msg;
            PrestazioneDTO updt1 = UpdatePrestazione(got2);

            int presres = 0;

            if (updt1 != null)
            {
                presres++;
            }
            else
            {
                log.Info(string.Format("An Error occurred. Record not updated! PRESIDID: {0}", got2.presidid));
            }
            res += presres;

            log.Info(string.Format("Updated {0}/{1} record!", presres, 1));

            log.Info(string.Format("Updating ANAL ..."));
            List <AnalisiDTO> gots = GetAnalisisByRichiesta(richidid);

            gots.ForEach(p => { p.hl7_stato = hl7_stato; p.hl7_msg = hl7_msg != null ? hl7_msg : p.hl7_msg; });
            int analsres = 0;

            foreach (AnalisiDTO got_ in gots)
            {
                AnalisiDTO updt_ = UpdateAnalisi(got_);
                if (updt_ != null)
                {
                    analsres++;
                }
                else
                {
                    log.Info(string.Format("An Error occurred. Record not updated! ANALIDID: {0}", got_.analidid));
                }
            }
            res += analsres;
            log.Info(string.Format("Updated {0}/{1} record!", analsres, gots.Count));

            log.Info(string.Format("Updated {0} record overall!", res));

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(res);
        }
示例#5
0
 private void AggiungiRiga(DSReport ds, PrestazioneDTO p)
 {
     ds.PrestazioniDTO.AddPrestazioniDTORow(p.Id.ToString(), p.DataRegistrazione, p.DataDocumento, p.Utente, p.TipoPrestazione, p.Referente);
 }
示例#6
0
        static void Main(string[] args)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            EventoDTO even = new EventoDTO()
            {
                evenepis = 112986,
                evenreri = 17,
                eventipo = 1,
                evenperi = 306,
                evenrees = 22,
                evendata = Convert.ToDateTime("2017-01-01T00:10:34"),
                evenrepp = 0,
                evendaef = Convert.ToDateTime("2017-01-01T02:45:01"),
            };

            PrestazioneDTO pres = new PrestazioneDTO()
            {
                presstat = 0,
                prestipo = 217,
                presurge = true,
                prespren = Convert.ToDateTime("2017-01-06T18:00:00"),
                presrico = 6,
                presflcc = 0,
                prespers = "MARTELLA LUCIANO",
                preserog = 0,
                presannu = 0,
            };

            RichiestaLISDTO esam = new RichiestaLISDTO()
            {
                esamtipo = 0,
                esampren = DateTime.Now,
            };

            List <AnalisiDTO> anals = new List <AnalisiDTO>()
            {
                new AnalisiDTO()
                {
                    analcodi = "EMO",
                    analnome = "EMOCROMO",
                    analflro = 0,
                    analinvi = 0,
                    analextb = "235",
                },
                new AnalisiDTO()
                {
                    analcodi = "AMI",
                    analnome = "AMILASI",
                    analflro = 0,
                    analinvi = 0,
                    analextb = "273",
                },
                new AnalisiDTO()
                {
                    analcodi = "BIF",
                    analnome = "BILIRUBINA DIRETTA",
                    analflro = 0,
                    analinvi = 0,
                    analextb = "281",
                },
            };

            string errs = null;

            LISPlugin.LIS lis = new LISPlugin.LIS();

            string richid = lis.ScheduleNewRequest(even, pres, esam, anals, ref errs);
            //string richid = "8682285";

            MirthResponseDTO resp = lis.SubmitNewRequest(richid, ref errs);

            //PrestazioneDTO pres_ = lis.RetrievePresByEven("2182273");

            //PazienteDTO pazi = lis.RetrievePazi("571010");

            List <RisultatoDTO> riss = lis.RetrieveResults(richid, ref errs, true);

            /*
             * string evenid = "2182265";
             * string richid = "8682284";
             * string analid1 = "4645449";
             * string analid2 = "4645450";
             * string analid3 = "4645451";
             */

            //List<RichiestaLISDTO> richs = lis.Check4Exams(evenid);
            //List<AnalisiDTO> anals_ = lis.Check4Analysis(richid);

            //MirthResponseDTO resp = lis.SubmitNewRequest(richid, ref errs);
            //List<LabelDTO> labes = lis.Check4Labels(richid);

            //List<RisultatoDTO> riss = lis.RetrieveResults(richid, ref errs);

            //List<RisultatoDTO> riss = lis.Check4Results(analid1);

            //bool cnl = lis.CheckIfCancelingIsAllowed(richid, ref errs);

            /*
             * List<int> red = null;
             *
             * int r = 0;
             * if (red != null && red.Count > 0)
             *  r = 1;
             */

            //RefertoDTO refe = lis.Check4Report(richid);

            sw.Stop();

            Console.WriteLine("ElapsedTime {0}\n\n", sw.Elapsed);

            Console.WriteLine("Press a key to Close!");
            Console.ReadKey();
        }
示例#7
0
        public MirthResponseDTO CancelRequest(string richid, ref string errorString)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            MirthResponseDTO data = null;

            try
            {
                // 0. Check if richid is a numeric Value
                int richid_int = 0;
                if (!int.TryParse(richid, out richid_int))
                {
                    string msg = string.Format("ID of the riquest is not an integer string. {0} is not a valid ID for this context!", richid);
                    errorString = msg;
                    log.Info(msg);
                    log.Error(msg);
                    throw new Exception(msg);
                }

                // 1. Check if Canceling is allowed
                if (CheckIfCancelingIsAllowed(richid, ref errorString))
                {
                    string msg = string.Format("Canceling of the request with id {0} is denied! errorString: {1}", richid, errorString);
                    log.Info(msg);
                    log.Error(msg);
                    throw new Exception(msg);
                }

                // 2. Check if ESAM and ANAL exist
                RichiestaLISDTO   chkEsam  = bll.GetRichiestaLISById(richid);
                List <AnalisiDTO> chkAnals = bll.GetAnalisisByRichiesta(richid);
                if (chkEsam == null || chkAnals == null || (chkAnals != null && chkAnals.Count == 0))
                {
                    string msg = "Error! No Esam or Anal records found referring to EsamID " + richid + "! A request must be Scheduled first!";
                    errorString = msg;
                    log.Info(msg);
                    log.Error(msg);
                    return(null);
                }

                // 3. Check if PRES exists
                if (!chkEsam.esameven.HasValue)
                {
                    string msg = "Error! Found an EsamEven NULL referring to EsamID " + richid + "!";
                    errorString = msg;
                    log.Info(msg);
                    log.Error(msg);
                    return(null);
                }
                PrestazioneDTO chkPres = bll.GetPrestazioneByEvento(chkEsam.esameven.Value.ToString());
                if (chkPres == null)
                {
                    string msg = "Error! No Pres record found referring to EvenID " + chkEsam.esameven.Value.ToString() + "! A request must be Scheduled first!";
                    errorString = msg;
                    log.Info(msg);
                    log.Error(msg);
                    return(null);
                }
                string presidid = chkPres.presidid.Value.ToString();

                // 4. Settare Stato a "DELETNG"
                int res = bll.ChangeHL7StatusAndMessageAll(richid, presidid, IBLL.HL7StatesRichiestaLIS.Deleting);

                // 5. Invio a Mirth
                string hl7orl = bll.SendMirthRequest(richid);
                if (hl7orl == null)
                {
                    string msg = "Mirth Returned an Error!";
                    errorString = msg;
                    // 4.e1 Cambiare stato in errato
                    int err = bll.ChangeHL7StatusAndMessageAll(richid, presidid, IBLL.HL7StatesRichiestaLIS.Errored, msg);
                    // 4.e2 Restituire null
                    return(null);
                }

                // 6. Estrarre i dati dalla risposta di Mirth
                data = bll.ORLParser(hl7orl);

                // 7. Settare Stato a seconda della risposta
                string status = IBLL.HL7StatesRichiestaLIS.Deleted;
                if (data.ACKCode != "AA")
                {
                    status = IBLL.HL7StatesRichiestaLIS.Errored;
                }
                RichiestaLISDTO RichUpdt = bll.ChangeHL7StatusAndMessageRichiestaLIS(richid, status, data.ACKDesc);
                PrestazioneDTO  PresUpdt = bll.ChangeHL7StatusAndMessagePrestazione(presidid, status, data.ACKDesc);

                List <ORCStatus> orcs = data.ORCStatus;
                if (orcs != null)
                {
                    foreach (ORCStatus orc in orcs)
                    {
                        string            desc      = orc.Description;
                        string            stat      = orc.Status;
                        string            analid    = orc.AnalID;
                        List <AnalisiDTO> AnalUpdts = bll.ChangeHL7StatusAndMessageAnalisis(new List <string>()
                        {
                            analid
                        }, stat, desc);
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(data);
        }
示例#8
0
        public string ScheduleNewRequest(EventoDTO even, PrestazioneDTO pres, RichiestaLISDTO esam, List <AnalisiDTO> anals, ref string errorString)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            string hl7_stato = IBLL.HL7StatesRichiestaLIS.Idle;
            string evenIdStr = null;
            string esamIdStr = null;
            string presIdStr = null;

            EventoDTO         evenInserted  = null;
            PrestazioneDTO    presInserted  = null;
            RichiestaLISDTO   esamInserted  = null;
            List <AnalisiDTO> analsInserted = null;

            if (errorString == null)
            {
                errorString = "";
            }

            try
            {
                if (even == null || esam == null || anals == null || (anals != null && anals.Count == 0))
                {
                    throw new Exception("Error! Request a null or void insertion of EVEN and/or ESAM and/or ANAL.");
                }

                // Validation Even!!!!
                if (!bll.ValidateEven(even, ref errorString))
                {
                    string msg = "Validation Even Failure! Check the error string for figuring out the issue!";
                    log.Info(msg + "\r\n" + errorString);
                    log.Error(msg + "\r\n" + errorString);
                    throw new Exception(msg);
                }

                // Check if Epis exists!!!!
                log.Info(string.Format("Checking EPIS '{0}' exists ...", even.evenepis));
                EpisodioDTO epis = bll.GetEpisodioById(even.evenepis.ToString());
                if (epis == null)
                {
                    string msg = string.Format("EPIS Checking Failure! EPIS '{0}' not Found!", even.evenepis);
                    log.Info(msg);
                    log.Error(msg);
                    throw new Exception(msg);
                }
                epis = null;
                log.Info(string.Format("Checking EPIS '{0}' succeded!", even.evenepis));

                // Create Even
                log.Info(string.Format("EVEN Insertion ..."));
                even.evenidid = null;
                evenInserted  = bll.AddEvento(even);
                if (evenInserted == null)
                {
                    throw new Exception("Error during EVEN writing into the DB.");
                }
                log.Info(string.Format("EVEN Inserted. Got {0} EVENIDID!", evenInserted.evenidid));

                evenIdStr = evenInserted.evenidid.ToString();

                pres.preseven = evenInserted.evenidid;
                log.Info(string.Format("PRES foreign key PRESEVEN updated!"));
                // Validation Pres!!!!
                if (!bll.ValidatePres(pres, ref errorString))
                {
                    string msg = "Validation Pres Failure! Check the error string for figuring out the issue!";
                    log.Info(msg + "\r\n" + errorString);
                    log.Error(msg + "\r\n" + errorString);
                    throw new Exception(msg);
                }

                pres.hl7_stato = hl7_stato;

                // Create Pres
                log.Info(string.Format("PRES Insertion ..."));
                presInserted = bll.AddPrestazione(pres);
                if (presInserted == null)
                {
                    throw new Exception("Error during PRES writing into the DB.");
                }
                log.Info(string.Format("PRES Inserted. Got {0} PRESIDID!", presInserted.presidid));

                presIdStr = presInserted.presidid.ToString();

                esam.esameven = evenInserted.evenidid;
                // Validation Esam!!!!
                if (!bll.ValidateEsam(esam, ref errorString))
                {
                    string msg = "Validation Esam Failure! Check the error string for figuring out the issue!";
                    log.Info(msg + "\r\n" + errorString);
                    log.Error(msg + "\r\n" + errorString);
                    throw new Exception(msg);
                }

                log.Info(string.Format("ESAM foreign key ESAMEVEN updated!"));
                esam.hl7_stato = hl7_stato;

                // Create Esam
                log.Info(string.Format("ESAM Insertion ..."));
                esamInserted = bll.AddRichiestaLIS(esam);
                if (esamInserted == null)
                {
                    throw new Exception("Error during ESAM writing into the DB.");
                }
                log.Info(string.Format("ESAM Inserted. Got {0} ESAMIDID!", esamInserted.esamidid));

                esamIdStr = esamInserted.esamidid.ToString();

                anals.ForEach(p => { p.analesam = int.Parse(esamIdStr); p.hl7_stato = hl7_stato; });

                // Validation Anals!!!!
                if (!bll.ValidateAnals(anals, ref errorString))
                {
                    string msg = "Validation Anals Failure! Check the error string for figuring out the issue!";
                    log.Info(msg + "\r\n" + errorString);
                    log.Error(msg + "\r\n" + errorString);
                    throw new Exception(msg);
                }

                // Create Anals
                log.Info(string.Format("Insertion of {0} ANAL requested. Processing ...", anals.Count));
                analsInserted = bll.AddAnalisis(anals);
                if ((analsInserted == null) || (analsInserted != null && analsInserted.Count != anals.Count))
                {
                    throw new Exception("Error during ANALs writing into the DB.");
                }
                log.Info(string.Format("Inserted {0} ANAL successfully!", analsInserted.Count));

                // Log Total Number Of Records Inserted! 1 for Esam, 1 for PRES and n for ANAL(s)
                log.Info(string.Format("Inserted {0} records successfully!", analsInserted.Count + 1 + 1));
            }
            catch (Exception ex)
            {
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);

                if (errorString == "")
                {
                    errorString = msg + "\r\n" + ex.Message;
                }
                else
                {
                    errorString += "\r\n" + msg + "\r\n" + ex.Message;
                }

                int evenRB  = 0;
                int presRB  = 0;
                int esamRB  = 0;
                int analsRB = 0;

                log.Info(string.Format("Rolling Back of the Insertions due an error occured ..."));
                // Rolling Back
                if (evenIdStr != null)
                {
                    evenRB = bll.DeleteEventoById(evenIdStr);
                    log.Info(string.Format("Rolled Back {0} EVEN record. EVENIDID was {1}!", evenRB, evenIdStr));
                }
                if (presIdStr != null)
                {
                    presRB = bll.DeletePrestazioneById(presIdStr);
                    log.Info(string.Format("Rolled Back {0} PRES record. PRESIDID was {1}!", presRB, presIdStr));
                }
                if (esamIdStr != null)
                {
                    esamRB = bll.DeleteRichiestaLISById(esamIdStr);
                    log.Info(string.Format("Rolled Back {0} ESAM record. ESAMIDID was {1}!", esamRB, esamIdStr));
                    analsRB = bll.DeleteAnalisiByRichiesta(esamIdStr);
                    log.Info(string.Format("Rolled Back {0} ANAL records. ANALESAM was {1}!", analsRB, esamIdStr));
                }

                log.Info(string.Format("Rolled Back {0} records of {1} requested!", evenRB + presRB + esamRB + analsRB, anals.Count + 1 + 1 + 1));
                esamIdStr = null;
            }

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            if (errorString == "")
            {
                errorString = null;
            }

            return(esamIdStr);
        }
示例#9
0
        public MirthResponseDTO SubmitNewRequest(string richid, ref string errorString)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            MirthResponseDTO data = null;

            if (errorString == null)
            {
                errorString = "";
            }

            try
            {
                // 0. Check if richid is a numeric Value
                int richid_int = 0;
                if (!int.TryParse(richid, out richid_int))
                {
                    string msg = string.Format("ID of the riquest is not an integer string. {0} is not a valid ID for this context!", richid);
                    errorString = msg;
                    log.Info(msg);
                    log.Error(msg);
                    throw new Exception(msg);
                }

                // 1. Check if ESAM and ANAL exist
                RichiestaLISDTO   chkEsam  = bll.GetRichiestaLISById(richid);
                List <AnalisiDTO> chkAnals = bll.GetAnalisisByRichiesta(richid);
                if (chkEsam == null || chkAnals == null || (chkAnals != null && chkAnals.Count == 0))
                {
                    string msg = "Error! No Esam or Anal records found referring to EsamID " + richid + "! A request must be Scheduled first!";
                    errorString = msg;
                    log.Info(msg);
                    log.Error(msg);
                    return(null);
                }

                // 2. Check if PRES exists
                if (!chkEsam.esameven.HasValue)
                {
                    string msg = "Error! Found an EsamEven NULL referring to EsamID " + richid + "!";
                    errorString = msg;
                    log.Info(msg);
                    log.Error(msg);
                    return(null);
                }
                PrestazioneDTO chkPres = bll.GetPrestazioneByEvento(chkEsam.esameven.Value.ToString());
                if (chkPres == null)
                {
                    string msg = "Error! No Pres record found referring to EvenID " + chkEsam.esameven.Value.ToString() + "! A request must be Scheduled first!";
                    errorString = msg;
                    log.Info(msg);
                    log.Error(msg);
                    return(null);
                }
                string presidid = chkPres.presidid.Value.ToString();

                // 3. Settare Stato a "SEDNING"
                int res = bll.ChangeHL7StatusAndMessageAll(richid, presidid, IBLL.HL7StatesRichiestaLIS.Sending, "");

                // 4. Invio a Mirth
                string hl7orl = bll.SendMirthRequest(richid);
                if (hl7orl == null)
                {
                    string msg = "Mirth Returned an Error!";
                    errorString = msg;
                    // 3.e1 Cambiare stato in errato
                    int err = bll.ChangeHL7StatusAndMessageAll(richid, presidid, IBLL.HL7StatesRichiestaLIS.Errored, msg);
                    // 3.e2 Restituire null
                    return(null);
                }
                // 4.1 Settare a SENT
                int snt = bll.ChangeHL7StatusAndMessageAll(richid, presidid, IBLL.HL7StatesRichiestaLIS.Sent, "");

                // 5. Estrarre i dati dalla risposta di Mirth
                log.Info("Mirth Data Response Extraction ...");
                data = bll.ORLParser(hl7orl);
                if (data == null)
                {
                    string emsg = "Mirth Data Response Extraction failed!";
                    if (errorString == "")
                    {
                        errorString = emsg;
                    }
                    else
                    {
                        errorString += "\n\r" + emsg;
                    }
                    log.Info(emsg);
                    log.Error(emsg);
                }
                else
                {
                    log.Info("Mirth Data Response Successfully extracted!");
                }

                // 6. Settare Stato a seconda della risposta
                string status = IBLL.HL7StatesRichiestaLIS.Sent;
                if (data.ACKCode != "AA")
                {
                    status = IBLL.HL7StatesRichiestaLIS.Errored;
                }
                else
                {
                    if (data.Labes != null)
                    {
                        status = IBLL.HL7StatesRichiestaLIS.Labelled;
                    }
                    else
                    {
                        string msg = "An Error Occurred! No Lables Retrieved By the Remote LAB!";
                        errorString = msg;
                        log.Info(msg);
                        log.Error(msg);
                        return(null);
                    }
                }
                RichiestaLISDTO RichUpdt = bll.ChangeHL7StatusAndMessageRichiestaLIS(richid, status, data.ACKDesc);
                PrestazioneDTO  PresUpdt = bll.ChangeHL7StatusAndMessagePrestazione(presidid, status, data.ACKDesc);

                List <ORCStatus> orcs = data.ORCStatus;
                if (orcs != null)
                {
                    foreach (ORCStatus orc in orcs)
                    {
                        string            desc      = orc.Description;
                        string            stat      = orc.Status;
                        string            analid    = orc.AnalID;
                        List <AnalisiDTO> AnalUpdts = bll.ChangeHL7StatusAndMessageAnalisis(new List <string>()
                        {
                            analid
                        }, stat, desc);
                    }
                }

                // 7. Scrivere Labels nel DB
                if (data.Labes != null)
                {
                    data.Labes.ForEach(p => p.labeesam = richid_int);
                    List <LabelDTO> stored = bll.StoreLabels(data.Labes);
                    if (stored == null)
                    {
                        string msg = "An Error Occurred! Labels successfully retrieved by the remote LAB, but they haven't been sotred into the local DB! The EsamIDID is " + richid;
                        errorString = msg;
                        log.Info(msg);
                        log.Error(msg);
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            if (errorString == "")
            {
                errorString = null;
            }

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            // 8. Restituire il DTO
            return(data);
        }