Thoughts on creating a medical calculator in Phoenix?

Hello, I’m looking to create something similar to https://reference.medscape.com/guide/medical-calculators for my school project using phoenix. So for every calculator, there will be a set of questions which the user has to answer, and based from these answers the user gets diagnosed with something or recommended something. Don’t worry about the medicinal side, I’ll take care of that :). I wanted to gather your thoughts on the best & easiest approaches to create something like that (backend side of course). Do you think I’ll have to utilize the Database for this?

My deadline is by the end of this month, so any & all help will be appreciated.

If the questions are fixed and they always come in the same order - you may not need database. You can just put them in code like maps or load from json files in priv/calculators folder.

defmodule Calculator do
  def audit_questionaire() do
    %{
       "title" => "Alcohol Use Disorders Identification Test (AUDIT)",
       "about" => "<... about text ...>",
       "references" => "<... references text ...>",
       "more_info" => "<... more info text  ...>",
       "questions" => [
          %{
            "id" => 1,
            "question" => "How often do you have a drink containing alcohol?"
            "options" => [
               %{"id" => 1, "text" => "Never"},
               %{"id" => 2, "text" => "Monthly or less"},
               %{"id" => 3, "text" => "<..>"},
               <.. more options ..>
            ]    
          },
         <.. more questions ..>
        ]
    }
  end
end

or store all the questions as json files in priv/calculators folder and load them using a function.

defmodule Calculator do
   def get_questionaire(name) do
     definition = 
        :code.priv_dir(:your_app_name)
        |> Path.join("calculators/#{name}.json")
        |> File.read!()
     Jason.decode!(definition)
   end
end

# load questionaire as below
Calculator.get_questionaire("audit")

Do start your app if you want to build it and keep posting questions. Community will help complete it.

You will learn more if you do some research/google or refer to docs and share it along questions that you tried x, y, z and they did not work - how can I achieve this.

1 Like

Thank you so much. I am doing some research on google, and checking out the docs, I came here because I couldn’t find anything useful for me.

1 Like

You are welcome, I was talking more about when you are building your app and if you have questions (I was not clear in my previous post).

This question has no textbook answer - if you want to build without database, there is a way and if you want to build with database, there is a way too.

1 Like

If you want a simple database with no fancy features I can recommend CubDB.
It’s like storing in plain text files but with the basic features of a database with the bonus of not corrupting your text file if a failure happens at write time.
https://hexdocs.pm/cubdb/CubDB.html

2 Likes

Thanks, I’ll check it out.

1 Like

Retex (alpha) is a rules system based on rete, and shows a simple example for medical diagnosis here: GitHub - lorenzosinisi/retex: A boilerplate/proof-of-concept for a Rete Algorithm implementation in Elixir

A recent discussion about rules systems (including retex) here: Design of an Elixir based rules system with multiple rules-bases

I’m checking it out right now, thanks.