Ejemplo n.º 1
0
        private List <His2lis> BuildOrderRequest(PeticionEntrante ordersData)
        {
            RequestParser      messageParser      = new RequestParser();
            RequestBuilderUtil requestBuilderUtil = new RequestBuilderUtil();
            List <His2lis>     orderList          = new List <His2lis>();


            var           requestOrderMessage = ordersData;
            List <String> lastNames           = requestBuilderUtil.getLastNames(requestOrderMessage.Pid5_1_familyName);

            foreach (var orderDetail in requestOrderMessage.ListaORB)
            {
                var newOrder = new His2lis();
                newOrder.Orden          = requestBuilderUtil.compuseOrderId(requestOrderMessage.Orc4_placerGroupNumer);
                newOrder.Fsolicitud     = requestBuilderUtil.currentDateFormated();
                newOrder.Origen         = requestOrderMessage.Pv2_patientClass;
                newOrder.Servicio       = requestOrderMessage.Orc13_1_pointOfCare;
                newOrder.Doctor         = requestOrderMessage.Orc12_1_idNumber;
                newOrder.Libre          = "1";
                newOrder.Identificacion = requestOrderMessage.Pid3_1_idNumber;
                newOrder.Nombre         = requestOrderMessage.Pid5_2_givenName + " " + requestOrderMessage.Pid5_3_secondName;
                newOrder.Apell1         = lastNames[0];
                newOrder.Apell2         = lastNames[1];
                newOrder.Edad           = requestBuilderUtil.getAges(requestOrderMessage.Pid7_datetimeBirth);
                newOrder.Codigo         = orderDetail.Obr4_4_AlternateIdentifier;
                newOrder.Sexo           = requestBuilderUtil.getGender(requestOrderMessage.Pid8_AdministrativeSex);
                orderList.Add(newOrder);
            }

            return(orderList);
        }
Ejemplo n.º 2
0
        public async Task <AcceptMessage> saveOrder(string jsonMessage)
        {
            var           jsonObject    = JsonConvert.DeserializeObject <PetitionElements>(jsonMessage);
            Autentication autorizaction = new Autentication(_hl7Context);
            AcceptMessage resultMessage = new AcceptMessage();

            if (autorizaction.validateToken(jsonObject.Token))
            {
                RequestParser requestParser = new RequestParser();
                resultMessage.Estado  = true;
                resultMessage.Mensaje = "OK";
                var messageData      = requestParser.decodeOrderData(jsonObject);
                var transactionSaved = saveTransaction(messageData, jsonMessage).Result;
                if (transactionSaved)
                {
                    List <His2lis> ordersList = BuildOrderRequest(messageData);
                    foreach (His2lis itemData in ordersList)
                    {
                        _context.His2lis.Add(itemData);
                        _context.SaveChanges();
                    }
                    _context.His2lis.AddRange(ordersList);
                }
                else
                {
                    resultMessage.Estado  = false;
                    resultMessage.Mensaje = "Error";
                }
            }
            else
            {
                resultMessage.Estado  = false;
                resultMessage.Mensaje = "Token invalido";
            }
            return(resultMessage);
        }