Skip to content

Commit

Permalink
[minor] create umbrella (#1756)
Browse files Browse the repository at this point in the history
Enjoy
  • Loading branch information
AlexKovalevych authored and Troush committed Jan 22, 2018
1 parent 85cc902 commit bf5cf86
Show file tree
Hide file tree
Showing 479 changed files with 551 additions and 400 deletions.
7 changes: 2 additions & 5 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Used by "mix format"
[
inputs: [
"{config,lib,test,rel,priv}/**/*.{ex,exs}",
"mix.exs",
".formatter.exs"
],
inputs: ["mix.exs", "apps/*/mix.exs", "apps/*/{config,lib,test}/**/*.{ex,exs}"],
line_length: 120
]
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ before_install:
- sudo ./bin/ci/init-db.sh
before_script:
# Extract project name and version from mix.exs
- source ./bin/ci/release/fetch-project-environment.sh
- source ./bin/ci/rel/fetch-project-environment.sh
# Load information about new version
- source ./bin/ci/release/fetch-source-version.sh
# Load information about changelog
Expand All @@ -55,14 +55,14 @@ script:
# Run all tests except pending ones
- ./bin/mix_tests.sh || travis_terminate 1
# Build Docker container
- ./bin/ci/release/build-container.sh || travis_terminate 1
- ./bin/ci/rel/build-container.sh || travis_terminate 1
# Initialize DB for Docker container
- MIX_ENV=dev mix ecto.setup
- (cd apps/ehealth && MIX_ENV=dev mix ecto.setup)
# Run Docker container
- sudo ./bin/ci/release/start-container.sh
- sudo ./bin/ci/release/check-container.sh || travis_terminate
# Submit Docker container to Docker Hub and create GitHub Release by pushing tag with changelog
- ./bin/ci/release/push-changes.sh || travis_terminate 1
- ./bin/ci/rel/push-changes.sh || travis_terminate 1
- echo "Decrypting deploy key..."
- openssl aes-256-cbc -K $encrypted_c996ec964e08_key -iv $encrypted_c996ec964e08_iv -in eHealth-8110bd102a69.json.enc -out eHealth-8110bd102a69.json -d
- sudo ./bin/deploy.sh || travis_terminate 1
17 changes: 17 additions & 0 deletions apps/ehealth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# App artifacts
/_build
/db
/deps
/*.ez

# Generated on crash by the VM
erl_crash.dump

# Files matching config/*.secret.exs pattern contain sensitive
# data and you should not commit them into version control.
#
# Alternatively, you may comment the line below and commit the
# secrets files as long as you replace their contents by environment
# variables.
/config/*.secret.exs
/cover
19 changes: 19 additions & 0 deletions apps/ehealth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EHealth

To start your Phoenix app:

* Install dependencies with `mix deps.get`
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
* Start Phoenix endpoint with `mix phoenix.server`

Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.

Ready to run in production? Please [check our deployment guides](http://www.phoenixframework.org/docs/deployment).

## Learn more

* Official website: http://www.phoenixframework.org/
* Guides: http://phoenixframework.org/docs/overview
* Docs: https://hexdocs.pm/phoenix
* Mailing list: http://groups.google.com/group/phoenix-talk
* Source: https://github.com/phoenixframework/phoenix
251 changes: 251 additions & 0 deletions apps/ehealth/config/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
use Mix.Config

# General application configuration
config :ehealth,
env: Mix.env(),
namespace: EHealth,
ecto_repos: [EHealth.Repo, EHealth.PRMRepo, EHealth.FraudRepo, EHealth.EventManagerRepo],
run_declaration_request_terminator: true,
system_user: {:system, "EHEALTH_SYSTEM_USER", "4261eacf-8008-4e62-899f-de1e2f7065f0"}

# Configures the endpoint
config :ehealth, EHealth.Web.Endpoint,
url: [host: "localhost"],
secret_key_base: "AcugHtFljaEFhBY1d6opAasbdFYsvV8oydwW98qS0oZOv+N/a5TE5G7DPfTZcXm9",
render_errors: [view: EView.Views.PhoenixError, accepts: ~w(json)]

# Configures Digital Signature API
config :ehealth, EHealth.API.Signature,
enabled: {:system, :boolean, "DIGITAL_SIGNATURE_ENABLED", true},
endpoint: {:system, "DIGITAL_SIGNATURE_ENDPOINT"},
hackney_options: [
connect_timeout: {:system, :integer, "DIGITAL_SIGNATURE_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "DIGITAL_SIGNATURE_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "DIGITAL_SIGNATURE_REQUEST_TIMEOUT", 30_000}
]

# Configures MediaStorage API
config :ehealth, EHealth.API.MediaStorage,
endpoint: {:system, "MEDIA_STORAGE_ENDPOINT"},
legal_entity_bucket: {:system, "MEDIA_STORAGE_LEGAL_ENTITY_BUCKET"},
declaration_request_bucket: {:system, "MEDIA_STORAGE_DECLARATION_REQUEST_BUCKET"},
declaration_bucket: {:system, "MEDIA_STORAGE_DECLARATION_BUCKET"},
medication_request_request_bucket: {:system, "MEDIA_STORAGE_MEDICATION_REQUEST_REQUEST_BUCKET"},
enabled?: {:system, :boolean, "MEDIA_STORAGE_ENABLED", false},
hackney_options: [
connect_timeout: {:system, :integer, "MEDIA_STORAGE_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "MEDIA_STORAGE_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "MEDIA_STORAGE_REQUEST_TIMEOUT", 30_000}
]

# Configures PRM API
config :ehealth, EHealth.API.PRM,
endpoint: {:system, "PRM_ENDPOINT", "http://api-svc.prm/api"},
hackney_options: [
connect_timeout: {:system, :integer, "PRM_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "PRM_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "PRM_REQUEST_TIMEOUT", 30_000}
]

# Configures Legal Entities token permission
config :ehealth, EHealth.Plugs.ClientContext,
tokens_types_personal: {:system, :list, "TOKENS_TYPES_PERSONAL", ["MSP", "PHARMACY"]},
tokens_types_mis: {:system, :list, "TOKENS_TYPES_MIS", ["MIS"]},
tokens_types_admin: {:system, :list, "TOKENS_TYPES_ADMIN", ["NHS ADMIN"]}

# Configures OAuth API
config :ehealth, EHealth.API.Mithril,
endpoint: {:system, "OAUTH_ENDPOINT"},
hackney_options: [
connect_timeout: {:system, :integer, "OAUTH_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "OAUTH_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "OAUTH_REQUEST_TIMEOUT", 30_000}
]

# Configures Man API
config :ehealth, EHealth.API.Man,
endpoint: {:system, "MAN_ENDPOINT"},
hackney_options: [
connect_timeout: {:system, :integer, "MAN_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "MAN_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "MAN_REQUEST_TIMEOUT", 30_000}
]

# Configures UAddress API
config :ehealth, EHealth.API.UAddress,
endpoint: {:system, "UADDRESS_ENDPOINT"},
hackney_options: [
connect_timeout: {:system, :integer, "UADDRESS_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "UADDRESS_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "UADDRESS_REQUEST_TIMEOUT", 30_000}
]

# Configures OTP Verification API
config :ehealth, EHealth.API.OTPVerification,
endpoint: {:system, "OTP_VERIFICATION_ENDPOINT"},
hackney_options: [
connect_timeout: {:system, :integer, "OTP_VERIFICATION_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "OTP_VERIFICATION_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "OTP_VERIFICATION_REQUEST_TIMEOUT", 30_000}
]

# Configures MPI API
config :ehealth, EHealth.API.MPI,
endpoint: {:system, "MPI_ENDPOINT"},
hackney_options: [
connect_timeout: {:system, :integer, "MPI_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "MPI_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "MPI_REQUEST_TIMEOUT", 30_000}
]

# Configures OPS API
config :ehealth, EHealth.API.OPS,
endpoint: {:system, "OPS_ENDPOINT"},
hackney_options: [
connect_timeout: {:system, :integer, "OPS_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "OPS_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "OPS_REQUEST_TIMEOUT", 30_000}
]

# Configures Gandalf API
config :ehealth, EHealth.API.Gandalf,
endpoint: {:system, "GNDF_ENDPOINT"},
client_id: {:system, "GNDF_CLIENT_ID"},
client_secret: {:system, "GNDF_CLIENT_SECRET"},
application_id: {:system, "GNDF_APPLICATION_ID"},
table_id: {:system, "GNDF_TABLE_ID"},
hackney_options: [
connect_timeout: {:system, :integer, "GNDF_REQUEST_TIMEOUT", 30_000},
recv_timeout: {:system, :integer, "GNDF_REQUEST_TIMEOUT", 30_000},
timeout: {:system, :integer, "GNDF_REQUEST_TIMEOUT", 30_000}
]

# configure emails
config :ehealth, :emails,
employee_request_invitation: %{
from: {:system, "BAMBOO_EMPLOYEE_REQUEST_INVITATION_FROM", ""},
subject: {:system, "BAMBOO_EMPLOYEE_REQUEST_INVITATION_SUBJECT", ""}
},
employee_request_update_invitation: %{
from: {:system, "BAMBOO_EMPLOYEE_REQUEST_UPDATE_INVITATION_FROM", ""},
subject: {:system, "BAMBOO_EMPLOYEE_REQUEST_UPDATE_INVITATION_SUBJECT", ""}
},
hash_chain_verification_notification: %{
from: {:system, "CHAIN_VERIFICATION_FAILED_NOTIFICATION_FROM", ""},
to: {:system, "CHAIN_VERIFICATION_FAILED_NOTIFICATION_TO", ""},
subject: {:system, "CHAIN_VERIFICATION_FAILED_NOTIFICATION_SUBJECT", ""}
},
employee_created_notification: %{
from: {:system, "BAMBOO_EMPLOYEE_CREATED_NOTIFICATION_FROM", ""},
subject: {:system, "BAMBOO_EMPLOYEE_CREATED_NOTIFICATION_SUBJECT", ""}
},
credentials_recovery_request: %{
from: {:system, "BAMBOO_CREDENTIALS_RECOVERY_REQUEST_INVITATION_FROM", ""},
subject: {:system, "BAMBOO_CREDENTIALS_RECOVERY_REQUEST_INVITATION_SUBJECT", ""}
}

config :ehealth, EHealth.Man.Templates.EmployeeRequestInvitation,
id: {:system, "EMPLOYEE_REQUEST_INVITATION_TEMPLATE_ID"},
format: {:system, "EMPLOYEE_REQUEST_INVITATION_TEMPLATE_FORMAT", "text/html"},
locale: {:system, "EMPLOYEE_REQUEST_INVITATION_TEMPLATE_LOCALE", "uk_UA"}

# Configures employee request update invitation template
config :ehealth, EHealth.Man.Templates.EmployeeRequestUpdateInvitation,
id: {:system, "EMPLOYEE_REQUEST_UPDATE_INVITATION_TEMPLATE_ID"},
format: {:system, "EMPLOYEE_REQUEST_UPDATE_INVITATION_TEMPLATE_FORMAT", "text/html"},
locale: {:system, "EMPLOYEE_REQUEST_UPDATE_INVITATION_TEMPLATE_LOCALE", "uk_UA"}

config :ehealth, EHealth.Man.Templates.HashChainVerificationNotification,
id: {:system, "CHAIN_VERIFICATION_FAILED_NOTIFICATION_ID", ""},
format: {:system, "CHAIN_VERIFICATION_FAILED_NOTIFICATION_FORMAT", ""},
locale: {:system, "CHAIN_VERIFICATION_FAILED_NOTIFICATION_LOCALE", ""}

# employee created notification
# Configures employee created notification template
config :ehealth, EHealth.Man.Templates.EmployeeCreatedNotification,
id: {:system, "EMPLOYEE_CREATED_NOTIFICATION_TEMPLATE_ID"},
format: {:system, "EMPLOYEE_CREATED_NOTIFICATION_TEMPLATE_FORMAT", "text/html"},
locale: {:system, "EMPLOYEE_CREATED_NOTIFICATION_TEMPLATE_LOCALE", "uk_UA"}

config :ehealth, EHealth.Man.Templates.DeclarationRequestPrintoutForm,
id: {:system, "DECLARATION_REQUEST_PRINTOUT_FORM_TEMPLATE_ID"},
format: {:system, "DECLARATION_REQUEST_PRINTOUT_FORM_TEMPLATE_FORMAT", "text/html"},
locale: {:system, "DECLARATION_REQUEST_PRINTOUT_FORM_TEMPLATE_LOCALE", "uk_UA"}

# Template and setting for credentials recovery requests
config :ehealth, :credentials_recovery_request_ttl, {:system, :integer, "CREDENTIALS_RECOVERY_REQUEST_TTL", 1_500}

config :ehealth, EHealth.Man.Templates.CredentialsRecoveryRequest,
id: {:system, "CREDENTIALS_RECOVERY_REQUEST_INVITATION_TEMPLATE_ID"},
format: {:system, "CREDENTIALS_RECOVERY_REQUEST_INVITATION_TEMPLATE_FORMAT", "text/html"},
locale: {:system, "CREDENTIALS_RECOVERY_REQUEST_INVITATION_TEMPLATE_LOCALE", "uk_UA"}

config :ehealth, :legal_entity_employee_types,
msp: {:system, "LEGAL_ENTITY_MSP_EMPLOYEE_TYPES", ["OWNER", "HR", "DOCTOR", "ADMIN"]},
pharmacy: {:system, "LEGAL_ENTITY_PHARMACY_EMPLOYEE_TYPES", ["PHARMACY_OWNER", "PHARMACIST", "HR"]}

config :ehealth, :legal_entity_division_types,
msp: {:system, "LEGAL_ENTITY_MSP_DIVISION_TYPES", ["CLINIC", "AMBULANT_CLINIC", "FAP"]},
pharmacy: {:system, "LEGAL_ENTITY_PHARMACIST_DIVISION_TYPES", ["DRUGSTORE", "DRUGSTORE_POINT"]}

config :ehealth, :medication_request_request,
expire_in_minutes: {:system, "MEDICATION_REQUEST_REQUEST_EXPIRATION", 30},
otp_code_length: {:system, "MEDICATION_REQUEST_REQUEST_OTP_CODE_LENGTH", 4}

config :ehealth, :medication_request,
sign_template_sms:
{:system, "TEMPLATE_SMS_FOR_SIGN_MEDICATION_REQUEST",
"Ваш рецепт: <request_number>. Код підтвердження: <verification_code>"},
reject_template_sms:
{:system, "TEMPLATE_SMS_FOR_REJECT_MEDICATION_REQUEST", "Відкликано рецепт: <request_number> від <created_at>"}

config :ehealth, EHealth.Bamboo.Emails.Sender, mailer: {:system, :module, "BAMBOO_MAILER"}

# Configures bamboo
config :ehealth, EHealth.Bamboo.PostmarkMailer,
adapter: EHealth.Bamboo.PostmarkAdapter,
api_key: {:system, "POSTMARK_API_KEY", ""}

config :ehealth, EHealth.Bamboo.MailgunMailer,
adapter: EHealth.Bamboo.MailgunAdapter,
api_key: {:system, "MAILGUN_API_KEY", ""},
domain: {:system, "MAILGUN_DOMAIN", ""}

config :ehealth, EHealth.Bamboo.SMTPMailer,
adapter: EHealth.Bamboo.SMTPAdapter,
server: {:system, "BAMBOO_SMTP_SERVER", ""},
hostname: {:system, "BAMBOO_SMTP_HOSTNAME", ""},
port: {:system, "BAMBOO_SMTP_PORT", ""},
username: {:system, "BAMBOO_SMTP_USERNAME", ""},
password: {:system, "BAMBOO_SMTP_PASSWORD", ""},
tls: :if_available,
allowed_tls_versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"],
ssl: true,
retries: 1

# Configures address merger
config :ehealth, EHealth.Utils.AddressMerger, no_suffix_areas: {:system, "NO_SUFFIX_AREAS", ["М.КИЇВ", "М.СЕВАСТОПОЛЬ"]}

# Configures genral validator
config :ehealth, EHealth.LegalEntities.Validator, owner_positions: {:system, :list, "OWNER_POSITIONS", [""]}

# Configures birth date validator
config :ehealth, EHealth.Validators.BirthDate,
min_age: {:system, "MIN_AGE", 0},
max_age: {:system, "MAX_AGE", 150}

# Configures Elixir's Logger
config :logger, :console,
format: "$message\n",
handle_otp_reports: true,
level: :info

config :ehealth, EHealth.Scheduler,
declaration_request_autotermination: {:system, :string, "DECLARATION_REQUEST_AUTOTERMINATION_SCHEDULE", "* 0-4 * * *"},
employee_request_autotermination: {:system, :string, "EMPLOYEE_REQUEST_AUTOTERMINATION_SCHEDULE", "0-4 * * *"}

config :cipher,
keyphrase: System.get_env("CIPHER_KEYPHRASE") || "8()VN#U#_CU#X)*BFG(Cadsvn$&",
ivphrase: System.get_env("CIPHER_IVPHRASE") || "B((%(^(%V(CWBY(**(by(*YCBDYB#(Y(C#"

import_config "#{Mix.env()}.exs"
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions apps/ehealth/coveralls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"skip_files": [
"specs/*",
"test/*",
"lib/tasks"
],
"custom_stop_words": [
"field",
"has_one",
"has_many",
"embeds_one",
"embeds_many",
"schema",
"send"
],
"treat_no_relevant_lines_as_covered": true
}
2 changes: 0 additions & 2 deletions lib/ehealth/application.ex → apps/ehealth/lib/ehealth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ defmodule EHealth do
# Start the endpoint when the application starts
supervisor(EHealth.Web.Endpoint, []),
worker(EHealth.Scheduler, [])
# Starts a worker by calling: EHealth.Worker.start_link(arg1, arg2, arg3)
# worker(EHealth.Worker, [arg1, arg2, arg3]),
]

# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ defmodule EHealth.Web.MedicationRequestRequestView do
PersonView
|> render("show.json", %{"person" => person})
|> Map.put("age", age)
|> Map.drop(["birth_date", "addresses"])
|> Map.delete("bitrh_date")
end

defp get_age(birth_date, current_date) do
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/tasks/tasks.ex → apps/ehealth/lib/tasks/tasks.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule :ehealth_tasks do
defmodule EHealth.ReleaseTasks do
@moduledoc """
Nice way to apply migrations inside a released application.
Expand Down
Loading

0 comments on commit bf5cf86

Please sign in to comment.