Ejemplo n.º 1
0
        public async Task AddAndSaveToES(PatientDetailDto PatientDetail)
        {
            try
            {
                if (IndexExist())
                {
                    var resultresponse = await ElasticSearchClient.GetClient().IndexDocumentAsync(PatientDetail);

                    Console.WriteLine(resultresponse.IsValid.ToString());
                }
                else
                {
                    var result = await CreateIndexIfNotExist();

                    if (result)
                    {
                        var resultresponse = await ElasticSearchClient.GetClient().IndexDocumentAsync(PatientDetail);

                        Console.WriteLine(resultresponse.IsValid.ToString());
                    }
                }
            }catch (Exception ex)
            {
                Console.WriteLine("Error while adding document to elastic search");
                Console.WriteLine(ex.Message.ToString());
            }
        }
        public async Task IndexDocument(PatientDetailDto PatientDetail)
        {
            var ClientIndex = PatientDetail.ClientName.Replace(" ", string.Empty).ToLower();

            try
            {
                var result = await CreateIndexIfNotExist(ClientIndex);

                if (result)
                {
                    //var resultresponse = ElasticSearchClient.GetClient().Index(PatientDetail, i => i
                    //                                                           .Index(ClientIndex)
                    //                                                           .Id(PatientDetail.PatientVisitID));
                    var resultresponse = await ElasticSearchClient.GetClient().IndexAsync <PatientDetailDto>(PatientDetail, i => i
                                                                                                             .Index(ClientIndex)
                                                                                                             .Id(PatientDetail.PatientVisitID)
                                                                                                             .Refresh(Elasticsearch.Net.Refresh.True));

                    Console.WriteLine(resultresponse.IsValid.ToString());
                }
            }catch (Exception ex)
            {
                Console.WriteLine("Error while adding document to elastic search");
                Console.WriteLine(ex.Message.ToString());
            }
        }
 public async Task Handle(CreateUpdatePatientDetailsInESCommand notification, CancellationToken cancellationToken)
 {
     var patientDetails = new PatientDetailDto {
         AccountNumber = notification.AccountNumber, AdmitDate = notification.AdmitDate,
         AdmitType     = notification.AdmitType, ClientID = notification.ClientID,
         DOS           = notification.DOS, FinancialClass = notification.FinancialClass,
         FirstName     = notification.FirstName, HAR = notification.HAR, LastName = notification.LastName,
         MRN           = notification.MRN, PatientType = notification.PatientType, PatientVisitID = notification.PatientVisitID,
         PayerCode     = notification.PayerCode, Registrar = notification.Registrar, SSN = notification.SSN,
         Status        = notification.Status, Gender = notification.Gender
     };
     await _elasticSearchService.AddAndSaveToES(patientDetails);
 }