<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohamed Hossam</title>
    <description>The latest articles on DEV Community by Mohamed Hossam (@mohamedhossam).</description>
    <link>https://dev.to/mohamedhossam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F671057%2F59216084-4a52-46b3-8f42-79b33cc0256d.jpeg</url>
      <title>DEV Community: Mohamed Hossam</title>
      <link>https://dev.to/mohamedhossam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohamedhossam"/>
    <language>en</language>
    <item>
      <title>Diseases Prediction Based On Medications Using Indexing In MongoDB</title>
      <dc:creator>Mohamed Hossam</dc:creator>
      <pubDate>Thu, 29 Jul 2021 23:28:46 +0000</pubDate>
      <link>https://dev.to/mohamedhossam/diseases-prediction-based-on-medications-using-indexing-in-mongodb-22e7</link>
      <guid>https://dev.to/mohamedhossam/diseases-prediction-based-on-medications-using-indexing-in-mongodb-22e7</guid>
      <description>&lt;p&gt;In this article, we will discuss a feature in &lt;strong&gt;DOCTOR-Y&lt;/strong&gt; to predict the current patients' medical conditions based on their regular medications, using a dataset containing medicines and their corresponding medical conditions.&lt;br&gt;&lt;br&gt;
And this is done using searching techniques provided from the &lt;a href="https://docs.mongodb.com/"&gt;MongoDB&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;If you don't know what is &lt;strong&gt;DOCTOR-Y&lt;/strong&gt; check this &lt;a href="https://www.linkedin.com/feed/update/urn:li:activity:6826664589346779136/"&gt;post&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Objective
&lt;/h2&gt;

&lt;p&gt;Our goal is to generate a chart that shows the patients' conditions in a form of percentages, which are calculated based on all the medications they have taken during a specific period.&lt;/p&gt;

&lt;h6&gt;
  
  
  For example
&lt;/h6&gt;

&lt;p&gt;A patient that is prescribed with 3 medicines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Actemra&lt;/li&gt;
&lt;li&gt;Duexis&lt;/li&gt;
&lt;li&gt;Indocin&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The results should be something like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y9iIwTUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2bw0k1s02jiwxe0o73u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y9iIwTUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2bw0k1s02jiwxe0o73u.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dataset
&lt;/h2&gt;

&lt;p&gt;The dataset consists of 1224 records; each record contains the drug name, its corresponding condition, and the weight of this condition. It is derived from the Medication guide offered by the &lt;a href="https://www.accessdata.fda.gov/scripts/cder/daf/index.cfm?event=medguide.page"&gt;FDA&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
This dataset is uploaded on DOCTOR-Y's database, so it can be used by the application server.&lt;/p&gt;

&lt;h6&gt;
  
  
  A sample from the dataset
&lt;/h6&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;Abilify &lt;/td&gt;
&lt;td&gt;Schizophrenia&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;td&gt;Abilify &lt;/td&gt;
&lt;td&gt;Bipolar I Disorder&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;tr&gt;
&lt;td&gt;Abilify &lt;/td&gt;
&lt;td&gt;Major Depressive Disorder (MDD)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Abilify &lt;/td&gt;
&lt;td&gt;Irritability&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Abilify &lt;/td&gt;
&lt;td&gt;Tourette's Disorder&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Abilify Maintena Kit&lt;/td&gt;
&lt;td&gt;Schizophrenia&lt;/td&gt;
&lt;td&gt;0.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Abilify Maintena Kit&lt;/td&gt;
&lt;td&gt;Bipolar I Disorder&lt;/td&gt;
&lt;td&gt;0.5&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Applied Search Method
&lt;/h2&gt;

&lt;p&gt;In order to traverse the collection, we can use the default search method in the MongoDB which is the collection scan of complexity O(n). &lt;br&gt;&lt;br&gt;
However, we opted to use indexing, single field indexing to be exact which is a searching method that uses B-tree data structure, thus having a complexity of O(log n) which offers better performance than a collection scan.&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Mechanism
&lt;/h2&gt;

&lt;p&gt;Each record has a drug name, condition and weight, the following steps are taken to get percentage of occurrence of each condition.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;A search is conducted for each medicine taken by the user in the drug name field and the matching records are retrieved. &lt;br&gt;For example a patient is prescribed with {Actemra, Duexis, Indocin}&lt;/p&gt;
&lt;h6&gt;
  
  
  The following records were retrieved.
&lt;/h6&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Drug name&lt;/th&gt;
&lt;th&gt;Condition&lt;/th&gt;
&lt;th&gt;Weight&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Actemra&lt;/td&gt;
&lt;td&gt;Rheumatoid Arthritis (RA)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Actemra&lt;/td&gt;
&lt;td&gt;Giant Cell Arteritis (GCA)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Actemra&lt;/td&gt;
&lt;td&gt;Polyarticular Juvenile Idiopathic Arthritis (PJIA)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Actemra&lt;/td&gt;
&lt;td&gt;Systemic Juvenile Idiopathic Arthritis (SJIA)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Actemra&lt;/td&gt;
&lt;td&gt;Cytokine Release Syndrome (CRS)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Duexis&lt;/td&gt;
&lt;td&gt;upper gastrointestinal ulcers&lt;/td&gt;
&lt;td&gt;0.33&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Duexis&lt;/td&gt;
&lt;td&gt;Osteoarthritis&lt;/td&gt;
&lt;td&gt;0.33&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Duexis&lt;/td&gt;
&lt;td&gt;Rheumatoid Arthritis (RA)&lt;/td&gt;
&lt;td&gt;0.33&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indocin&lt;/td&gt;
&lt;td&gt;Rheumatoid Arthritis (RA)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indocin&lt;/td&gt;
&lt;td&gt;Ankylosing spondylitis (AS)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indocin&lt;/td&gt;
&lt;td&gt;Osteoarthritis&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indocin&lt;/td&gt;
&lt;td&gt;Acute painful shoulder&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Indocin&lt;/td&gt;
&lt;td&gt;Acute gouty arthritis&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;An iteration is done through the retrieved records while putting each new condition into a hash table with the key being the condition and the value being the weight. &lt;br&gt;&lt;br&gt;If a condition already exists in the hash table, we add its weight to the existing weight in the hash table.&lt;br&gt;&lt;br&gt; Now we have a table of patient conditions with their corresponding weights.&lt;/p&gt;
&lt;h6&gt;
  
  
  Moving on with the previous example we get the following hash table.
&lt;/h6&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key (Condition)&lt;/th&gt;
&lt;th&gt;Value (Weight)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rheumatoid Arthritis (RA)&lt;/td&gt;
&lt;td&gt;0.73&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Osteoarthritis&lt;/td&gt;
&lt;td&gt;0.53&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;upper gastrointestinal ulcers&lt;/td&gt;
&lt;td&gt;0.33&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Giant Cell Arteritis (GCA)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Polyarticular Juvenile Idiopathic Arthritis (PJIA)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Systemic Juvenile Idiopathic Arthritis (SJIA)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cytokine Release Syndrome (CRS)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ankylosing spondylitis (AS)&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Acute painful shoulder&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Acute gouty arthritis&lt;/td&gt;
&lt;td&gt;0.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total&lt;/td&gt;
&lt;td&gt;2.99&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We divided each weight by the total sum of weights and multiplied it by 100 to get the percentage of occurrence of each condition.&lt;/p&gt;
&lt;h6&gt;
  
  
  From the previous example we get the following results.
&lt;/h6&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key (Condition)&lt;/th&gt;
&lt;th&gt;Value (Weight)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rheumatoid Arthritis (RA)&lt;/td&gt;
&lt;td&gt;24.4%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Osteoarthritis&lt;/td&gt;
&lt;td&gt;17.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;upper gastrointestinal ulcers&lt;/td&gt;
&lt;td&gt;11%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Giant Cell Arteritis (GCA)&lt;/td&gt;
&lt;td&gt;6.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Polyarticular Juvenile Idiopathic Arthritis (PJIA)&lt;/td&gt;
&lt;td&gt;6.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Systemic Juvenile Idiopathic Arthritis (SJIA)&lt;/td&gt;
&lt;td&gt;6.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cytokine Release Syndrome (CRS)&lt;/td&gt;
&lt;td&gt;6.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ankylosing spondylitis (AS)&lt;/td&gt;
&lt;td&gt;6.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Acute painful shoulder&lt;/td&gt;
&lt;td&gt;6.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Acute gouty arthritis&lt;/td&gt;
&lt;td&gt;6.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Integration With DOCTOR-Y
&lt;/h2&gt;

&lt;p&gt;The final diseases and their percentages are sent to the system server, which sends them to the client-side to be represented on a chart as shown in the figure below.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vG53xKRE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbsb0q7kppte1eeawrqe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vG53xKRE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbsb0q7kppte1eeawrqe.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>mongodb</category>
      <category>healthcare</category>
      <category>indexing</category>
    </item>
  </channel>
</rss>
