private DrugSuggestionInputModel PrepareDrugSuggestionInput(MedicalEntityResponse entityResponse, PatientDto patientDto) { var modelResult = new DrugSuggestionInputModel(); foreach (var item in entityResponse.MedicalConditions) { if (item.Text.Equals("fever", StringComparison.OrdinalIgnoreCase)) { modelResult.Fever = true; } if (item.Text.Equals("vomiting", StringComparison.OrdinalIgnoreCase) || item.Text.Equals("vomite", StringComparison.OrdinalIgnoreCase)) { modelResult.Vomiting = true; } if (item.Text.Equals("headache", StringComparison.OrdinalIgnoreCase) || item.Text.Equals("head ache", StringComparison.OrdinalIgnoreCase)) { modelResult.Headache = true; } if (item.Text.Equals("diarrhea", StringComparison.OrdinalIgnoreCase)) { modelResult.Diarrhea = true; } } modelResult.Age = patientDto?.Age; modelResult.Weight = patientDto?.Weight; return(modelResult); }
private MedicalEntityResponse ParseEntities(List <Entity> awsEntities, MedicalEntityResponse response) { var medicationEntities = new List <MedicationEntity>(); var medicalConditions = new List <MedicalConditionEntity>(); var anatomyList = new List <AnatomyEntity>(); foreach (var entity in awsEntities) { if (entity.Category == EntityType.MEDICAL_CONDITION) { var medicacCondition = GetMedicalConditionEntity(entity); medicalConditions.Add(medicacCondition); } else if (entity.Category == EntityType.MEDICATION) { var medicalEntity = GetMedicationEntity(entity); medicationEntities.Add(medicalEntity); } else if (entity.Category == EntityType.ANATOMY) { anatomyList.Add(GetAnatomyEntity(entity)); } } response.Medications = medicationEntities; response.MedicalConditions = medicalConditions; response.AnatomyList = anatomyList; return(response); }
public async Task <List <MedicationEntity> > GetMedicineSuggestions(string externalPatientId, MedicalEntityResponse entityResponse) { var responseEntity = new MedicalEntityResponse(); try { //get patient demographic information var patientInfo = await _patientService.Get(externalPatientId); var inputAI = PrepareDrugSuggestionInput(entityResponse, patientInfo); if (_rootConfiguration.AWSAIServiceEnabled) { var responseAI = await InvokeAIServiceAsync(inputAI); if (responseAI.IsSuccess != true) { return(null); } //convert to medicine list var(medicineList1, rawList1) = GetMedicineList(responseAI.RawResult); return(medicineList1); } else { var tempdata1 = await LoadSampleResponseFromFile(); var(medicineList1, rawList1) = GetMedicineList(tempdata1); return(medicineList1); } //----- // var tempdata = await LoadSampleResponseFromFile(); // // var tempresult = JsonConvert.DeserializeObject<MLServiceResponse>(tempdata); // var response = await InvokeAIServiceAsync(inputAI); // if (response.IsSuccess != true) return null; // //convert to medicine list //// var (medicineList, rawList) = GetMedicineList(response.RawResult); // var (medicineList, rawList) = GetMedicineList(tempdata); // return medicineList; } catch (Exception ex) { throw; } }
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; }
public async Task <MedicalEntityResponse> ExtractMedicalEntitiesV1Async(string externalPatientId, string clinicalNotes) { MedicalEntityResponse response = new MedicalEntityResponse(); try { // var result = await ExtractMedicalEntitiesAWS(clinicalNotes); var 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; }