private QueryResponse ExecuteQuery(string query) { if (string.IsNullOrWhiteSpace(query)) { throw new ArgumentException("message", nameof(query)); } var headerParams = Expressions.Constants.HeaderDefault.Headers; var serviceConfig = _integrationServicesConfiguration.GetConfigurationService(IntegrationServicesConfiguration.ConfigurationServicesName.SNOWSTORM); var endpoint = serviceConfig.GetEndPoint(IntegrationService.ConfigurationEndPointName.SNOWSTORM_FIND_CONCEPTS); var urlFriendly = $"{endpoint.FriendlyURL}?{query}"; var url = $"{endpoint.URL}?{query}"; var client = new HttpConsumer.SnowstormRequest(headerParams); var ret = client.Get <QueryResponse>(url); var activityLog = new ActivityLog { ActivityRequest = $"{url}", ActivityRequestUI = $"{urlFriendly}", ActivityTypeDescriptorId = (int)Entities.Activity.ActivityType.SNOWSTORM_FIND_CONCEPTS, ActivityResponse = $"Conceptos obtenidos Limite:{ret.Limit} sobre un Total de:{ret.Total}", RequestIsURL = true }; _currentContext.RegisterActivityLog(activityLog); return(ret); }
public FederarPacienteResponse FederarPaciente(Model.Request.FederarPacienteRequest request) { var patientIdentifierDNI = new Hl7.Fhir.Model.Identifier { Use = Hl7.Fhir.Model.Identifier.IdentifierUse.Usual, System = Common.Constants.DomainName.RenaperDniDomain.Value, Value = request.DNI.ToString() }; var patientIdentifierLocal = new Hl7.Fhir.Model.Identifier { Use = Hl7.Fhir.Model.Identifier.IdentifierUse.Usual, System = Common.Constants.DomainName.LocalDomain.Value, Value = request.LocalId }; var patientName = new Hl7.Fhir.Model.HumanName { Use = Hl7.Fhir.Model.HumanName.NameUse.Official, Text = $"{request.PrimerNombre} {request.PrimerApellido}", Family = $"{request.PrimerApellido}", Given = new string[] { request.PrimerNombre, request.OtrosNombres }, }; patientName.FamilyElement.Extension.Add( new Hl7.Fhir.Model.Extension { Url = "http://hl7.org/fhir/StructureDefinition/humanname-fathers-family", Value = new Hl7.Fhir.Model.FhirString($"{request.PrimerApellido}") }); var patient = new Hl7.Fhir.Model.Patient { Id = null, //INPORTANTE IdElement = null, //INPORTANTE Name = new List <Hl7.Fhir.Model.HumanName> { patientName }, Identifier = new List <Hl7.Fhir.Model.Identifier> { patientIdentifierLocal, patientIdentifierDNI }, BirthDate = request.FechaNacimiento.ToString("yyyy-MM-dd"), Gender = (request.Sexo == Common.Constants.Sexo.Femenido) ? Hl7.Fhir.Model.AdministrativeGender.Female : Hl7.Fhir.Model.AdministrativeGender.Male }; var serviceUrl = _integrationServicesConfiguration.GetConfigurationService(IntegrationServicesConfiguration.ConfigurationServicesName.BUS); //var patientCreateUrl = serviceUrl.GetEndPoint(IntegrationService.ConfigurationEndPointName.PATIENT_POST_CREATE); var client = new FhirClient(serviceUrl.BaseURL) { PreferredFormat = ResourceFormat.Json }; var activity = new ActivityLog { ActivityTypeDescriptorId = (int)Entities.Activity.ActivityType.FEDERAR_PACIENTE_EN_BUS }; client.OnBeforeRequest += (object sender, BeforeRequestEventArgs e) => { if (e.Body != null) { var requestAdderss = e.RawRequest.Address.ToString(); var requestBody = Encoding.UTF8.GetString(e.Body, 0, e.Body.Length); //Prettify !!! requestBody = JToken.Parse(requestBody).ToString(); activity.RequestIsJson = true; activity.ActivityRequestUI = requestAdderss; activity.ActivityRequestBody = requestBody; _logger.LogInformation($"Send Request Address:{requestAdderss}"); _logger.LogInformation($"Send Request Body:{requestBody}"); } }; client.OnAfterResponse += (object sender, AfterResponseEventArgs e) => { if (e.Body != null) { var responseBody = Encoding.UTF8.GetString(e.Body, 0, e.Body.Length); //Prettify !!! responseBody = JToken.Parse(responseBody).ToString(); activity.ResponseIsJson = true; activity.ActivityResponse = $"Status: {e.RawResponse.StatusCode}"; activity.ActivityResponseBody = responseBody; _logger.LogInformation($"Received response with status: {e.RawResponse.StatusCode}"); _logger.LogInformation($"Received response with body: {responseBody}"); } }; var patientRet = client.Create(patient); var identifierBus = patient.Identifier.Where(x => x.System == Msn.InteropDemo.Common.Constants.DomainName.FederadorPatientDomain.Value).FirstOrDefault(); var resp = new Model.Response.FederarPacienteResponse(); if (identifierBus != null) { resp.Id = int.Parse(identifierBus.Value); } _currentContext.RegisterActivityLog(activity); return(resp); }
/// <summary> /// Registra una vacuna en Nomivac basandose en el ejemplo de: /// https://simplifier.net/saluddigital.ar/immunization-example /// </summary> /// <param name="request">Model con los datos para el registro</param> public RegistrarImmunizationResponse RegistrarAplicacionVacuna(Model.Request.RegistrarInmunizationRequest request) { var immu = GenerateImmunization(request); var service = _integrationServicesConfiguration.GetConfigurationService(IntegrationServicesConfiguration.ConfigurationServicesName.IMMUNIZATION); var client = new FhirClient(service.BaseURL) { PreferredFormat = ResourceFormat.Json }; var activity = new ActivityLog { ActivityTypeDescriptorId = (int)Entities.Activity.ActivityType.IMMUNIZATION_POST_VACUNA_NOMIVAC }; client.OnBeforeRequest += (object sender, BeforeRequestEventArgs e) => { if (e.Body != null) { var requestAdderss = e.RawRequest.Address.ToString(); var requestBody = Encoding.UTF8.GetString(e.Body, 0, e.Body.Length); //Prettify !!! requestBody = JToken.Parse(requestBody).ToString(); activity.RequestIsJson = true; activity.ActivityRequestUI = requestAdderss; activity.ActivityRequestBody = requestBody; _logger.LogInformation($"Send Request Address:{requestAdderss}"); _logger.LogInformation($"Send Request Body:{requestBody}"); } }; client.OnAfterResponse += (object sender, AfterResponseEventArgs e) => { if (e.Body != null) { var responseBody = Encoding.UTF8.GetString(e.Body, 0, e.Body.Length); //Prettify !!! responseBody = JToken.Parse(responseBody).ToString(); activity.ResponseIsJson = true; activity.ActivityResponse = $"Status: {e.RawResponse.StatusCode}"; activity.ActivityResponseBody = responseBody; _logger.LogInformation($"Received response with status: {e.RawResponse.StatusCode}"); _logger.LogInformation($"Received response with body: {responseBody}"); } }; var immuResp = client.Create(immu); var ret = new RegistrarImmunizationResponse { Id = immuResp.Id }; _currentContext.RegisterActivityLog(activity); return(ret); }