Exemple #1
0
        public async Task <DetectEntitiesV2Response> DetectEntities(string text)
        {
            var request = new DetectEntitiesV2Request
            {
                Text = text
            };
            DetectEntitiesV2Response result = await comprehendMedicalClient.DetectEntitiesV2Async(request);

            return(result);
        }
        private async Task <DetectEntitiesV2Response> LoadEntityFromFile()
        {
            DetectEntitiesV2Response result = null;
            // var fileName = GetFilePath("Data/MedicationCategory_sample1.json");
            var fileName = GetFilePath("Data/All_sample1.json");

            using (StreamReader r = new StreamReader(fileName))
            {
                string json = await r.ReadToEndAsync();

                result = JsonConvert.DeserializeObject <DetectEntitiesV2Response>(json);
            }
            return(result);
        }
Exemple #3
0
        public async Task <MedicalEntityResponse> ExtractMedicalEntitiesAsync(string clinicalNotes)
        {
            MedicalEntityResponse    response = new MedicalEntityResponse();
            DetectEntitiesV2Response result   = null;

            try
            {
                if (_rootConfiguration.AWSAIServiceEnabled)
                {
                    result = await ExtractMedicalEntitiesAWS(clinicalNotes);
                }
                else
                {
                    result = await ExtractMedicalEntitiesMock(clinicalNotes);
                }
                //
                if (result.HttpStatusCode != HttpStatusCode.OK)
                {
                    response.IsError    = true;
                    response.StatusCode = (int)result.HttpStatusCode;
                    return(response);
                }

                ParseEntities(result.Entities, response);

                return(response);
            }
            catch (Exception)
            {
                throw;
            }

            // var result = await ExtractMedicalEntitiesAWS(clinicalNotes);
            //var result = await ExtractMedicalEntitiesMock(clinicalNotes);
            //if (result.StatusCode != 200)
            //{
            //    return result;
            //}
            ////parse the response and convert into custom entity model
            //result.Medications = result.Medications ?? new List<MedicationEntity>();
            //result.Medications = GetMeidcationEntities(result)
            //return result;
        }
Exemple #4
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DetectEntitiesV2Response response = new DetectEntitiesV2Response();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Entities", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Entity, EntityUnmarshaller>(EntityUnmarshaller.Instance);
                    response.Entities = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ModelVersion", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ModelVersion = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("PaginationToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.PaginationToken = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("UnmappedAttributes", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <UnmappedAttribute, UnmappedAttributeUnmarshaller>(UnmappedAttributeUnmarshaller.Instance);
                    response.UnmappedAttributes = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }