defmodule Api.Emailtosend do
  use Ecto.Schema
  import Ecto.Changeset

  @derive {Jason.Encoder, only: [:idemailtosend, :idstudy, :patientemail, :sent, :hasreport, :retries, :errormsg, :forcereprocess, :sentdatetime]}
  @primary_key {:idemailtosend, :id, autogenerate: true}
  schema "emailstosend" do
    field :idstudy, :integer
    field :patientemail, :string
    field :sent, :boolean
    field :hasreport, :boolean
    field :retries, :integer
    field :errormsg, :string
    field :forcereprocess, :boolean
    field :sentdatetime, :naive_datetime
    field :registered, :utc_datetime
  end

  def changeset(emailtosend, attrs) do
  emailtosend
   |> cast(attrs, [:idstudy,
                   :patientemail,
                   :sent,
                   :hasreport,
                   :retries,
                   :errormsg,
                   :forcereprocess,
                   :sentdatetime])
   |> validate_required([])
  end
end
