/// <summary> /// Get drug allergy interactions. /// </summary> /// <param name="genericDrugIds">The generic drug ids.</param> /// <param name="allergyClassIds">The allergy class ids.</param> /// <param name="testDrugId">The test drug identifier.</param> /// <param name="passKey">The pass key.</param> /// <returns>List<DrugAllergyInterResult>.</returns> public List <DrugAllergyInterResult> rx_GetDrugAllergyInteractions(string[] genericDrugIds, int[] allergyClassIds, string testDrugId, string passKey) { if (!ValidationAndEncryptDecrypt.ValidateKey(passKey)) { return(null); } SqlConnection dbConn = new SqlConnection(); GenericDAL myDal = null; ScreeningContext sc = null; try { dbConn = OpenLexidataConnection(); myDal = GetLexidataDAL(dbConn); sc = new ScreeningContext(); foreach (string gdi in genericDrugIds) { GenericDrug drugAllergen = myDal.GetGenericDrug(gdi); sc.Allergies.Add(drugAllergen); } AllergyClass classAllergen = myDal.GetAllergyClass(3); sc.Allergies.Add(classAllergen); GenericDrug drug1 = myDal.GetGenericDrug(testDrugId); sc.Drugs.Add(drug1); List <DrugAllergyResult> results = myDal.GetDrugAllergyInteractions(sc, false); List <DrugAllergyInterResult> r = new List <DrugAllergyInterResult>(); foreach (DrugAllergyResult ir in results) { DrugAllergyInterResult newR = new DrugAllergyInterResult { Drug1 = { GenDrugId = ir.Drug.GenDrugID, GenericName = ir.Drug.GenericName }, Allergen1 = { AllergySeverity = ir.Allergen.AllergySeverity, ConceptType = ir.Allergen.ConceptType.ToString(), Reaction = ir.Allergen.Reaction }, AllergyMessage = ir.AllergyMessage, AllergySeverity = ir.AllergySeverity, AllergyXrGroupDescription = ir.AllergyXRGroupDescription, AllergyXrGroupId = ir.AllergyXRGroupID, ClassDescription = ir.ClassDescription, ClassDescriptionPlural = ir.ClassDescriptionPlural, ClassId = ir.ClassID, MatchTypeDescription = ir.MatchTypeDescription, MatchTypeId = ir.MatchTypeID, Reaction = ir.Reaction }; r.Add(newR); } return(r); } catch (Exception e) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Method: rx_GetDrugAllergyInteractions"); if (genericDrugIds == null) { sb.AppendLine("genericDrugIds array is null"); } else { foreach (string gdi in genericDrugIds) { sb.AppendLine(gdi == null ? "genericDrugId is null" : "genericDrugId: " + gdi); } } if (allergyClassIds == null) { sb.AppendLine("allergyClassIds array is null"); } else { foreach (int adi in allergyClassIds) { sb.AppendLine(adi == 0 ? "allergyClassId is zero" : "allergyClassId: " + adi); } } sb.AppendLine(testDrugId == null ? "testDrugId is null" : "DrugId: " + testDrugId); sb.AppendLine(""); sb.AppendLine(e.ExceptionToString()); WriteEventLogEntry(sb.ToString()); sb.Clear(); sb.Destroy(); throw; } finally { sc.Destroy(); myDal.Destroy(); CloseConnection(dbConn); } }