/// <summary> /// Get generic drug from product identifier. /// </summary> /// <param name="productId">The product identifier.</param> /// <param name="passKey">The pass key.</param> /// <returns>LexiData.GenericDrug.</returns> public GenericDrug rx_GetGenericDrugFromProductId(int productId, string passKey) { if (!ValidationAndEncryptDecrypt.ValidateKey(passKey)) { return(null); } SqlConnection dbConn = new SqlConnection(); GenericDAL myDal = null; try { dbConn = OpenLexidataConnection(); myDal = GetLexidataDAL(dbConn); GenericDrug gd = myDal.GetGenericDrug((myDal.GetGenericProduct(productId)).GenDrugID); return(gd); } catch (Exception e) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Method: rx_GetGenericDrugFromProductId"); sb.AppendLine(productId == 0 ? "ProductId is null" : "ProductId: " + productId); sb.AppendLine(""); sb.AppendLine(e.ExceptionToString()); WriteEventLogEntry(sb.ToString()); sb.Clear(); sb.Destroy(); throw; } finally { myDal.Destroy(); CloseConnection(dbConn); } }
/// <summary> /// Get drug 2 drug interactions. /// </summary> /// <param name="productId">The product identifier.</param> /// <param name="genDrugId">The gen drug identifier.</param> /// <param name="passKey">The pass key.</param> /// <returns>List<DrugDrugInterResult>.</returns> public List <DrugDrugInterResult> rx_GetDrugDrugInteractions(int productId, string genDrugId, string passKey) { if (!ValidationAndEncryptDecrypt.ValidateKey(passKey)) { return(null); } if (productId == 0) { return(null); } SqlConnection dbConn = new SqlConnection(); GenericDAL myDal = null; try { dbConn = OpenLexidataConnection(); myDal = GetLexidataDAL(dbConn); ScreeningContext screen = new ScreeningContext(); GenericDrug gd = myDal.GetGenericDrug((myDal.GetGenericProduct(productId)).GenDrugID); if (gd != null) { screen.Drugs.Add(gd); } GenericDrug newGd = myDal.GetGenericDrug(genDrugId); if (gd != null) { screen.Drugs.Add(newGd); } var drugInteractions = myDal.GetDrugDrugInteractions(screen, false, 0); List <DrugDrugInterResult> r = new List <DrugDrugInterResult>(); foreach (DrugDrugInteractionResult ir in drugInteractions) { DrugDrugInterResult newR = new DrugDrugInterResult { Drug1 = { GenDrugId = ir.Drug1.GenDrugID, GenericName = ir.Drug1.GenericName }, Drug2 = { GenDrugId = ir.Drug2.GenDrugID, GenericName = ir.Drug2.GenericName }, InteractionDescription = ir.InteractionDescription, SeverityDescription = ir.SeverityDescription }; r.Add(newR); } return(r); } catch (Exception e) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Method: rx_GetDrugDrugInteractions"); sb.AppendLine("ProductId: " + productId); sb.AppendLine(genDrugId == null ? "genDrugId is null" : "genDrugId: " + genDrugId); sb.AppendLine(""); sb.AppendLine(e.ExceptionToString()); WriteEventLogEntry(sb.ToString()); sb.Clear(); sb.Destroy(); throw; } finally { myDal.Destroy(); CloseConnection(dbConn); } }
/// <summary> /// The rx_GetDrugInteractions. /// </summary> /// <param name="patientId">The patientId<see cref="int"/>.</param> /// <param name="genDrugId">The genDrugId<see cref="string"/>.</param> /// <param name="passKey">The passKey<see cref="string"/>.</param> /// <returns>The <see cref="List{DrugDrugInterResult}"/>.</returns> public List <DrugDrugInterResult> rx_GetDrugInteractions(int patientId, string genDrugId, string passKey) { if (!ValidationAndEncryptDecrypt.ValidateKey(passKey)) { return(null); } if (patientId == 0) { return(null); } SqlConnection dbConn = new SqlConnection(); GenericDAL myDal = null; try { dbConn = OpenLexidataConnection(); myDal = GetLexidataDAL(dbConn); ScreeningContext interactionScreening = new ScreeningContext(); // add existing drugs SqlCommand cmd = XSql1.CreateStoredProcedureCommand("rx_SelectPatientInteractionData"); cmd.AddParameter("@PatientId", patientId); DataSet interactDs = XSql1.GetDataSet(cmd); foreach (DataRow row in interactDs.Tables[0].Rows) { int productId = row["RootProductId"].ToString().ToInt(0); if (productId > 0) { GenericDrug gd = myDal.GetGenericDrug((myDal.GetGenericProduct(productId)).GenDrugID); if (gd != null) { interactionScreening.Drugs.Add(gd); } } } // Add new drug GenericDrug newGd = myDal.GetGenericDrug(genDrugId); if (newGd != null) { interactionScreening.Drugs.Add(newGd); } var drugInteractions = myDal.GetDrugDrugInteractions(interactionScreening, false, 0); List <DrugDrugInterResult> ddirList = new List <DrugDrugInterResult>(); foreach (DrugDrugInteractionResult ddir in drugInteractions) { DrugDrugInterResult newDdir = new DrugDrugInterResult { Drug1 = { GenDrugId = ddir.Drug1.GenDrugID, GenericName = ddir.Drug1.GenericName }, Drug2 = { GenDrugId = ddir.Drug2.GenDrugID, GenericName = ddir.Drug2.GenericName }, InteractionDescription = ddir.InteractionDescription, SeverityDescription = ddir.SeverityDescription }; ddirList.Add(newDdir); } return(ddirList); } catch (Exception e) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Method: rx_GetDrugInteractions"); sb.AppendLine("PatientId: " + patientId); sb.AppendLine(genDrugId == null ? "genDrugId is null" : "genDrugId: " + genDrugId); sb.AppendLine(""); sb.AppendLine(e.ExceptionToString()); WriteEventLogEntry(sb.ToString()); sb.Clear(); sb.Destroy(); throw; } finally { myDal.Destroy(); CloseConnection(dbConn); } }
/// <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); } }