Class: OpenehrRails::OpenehrApi::EhrsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- OpenehrRails::OpenehrApi::EhrsController
- Defined in:
- app/controllers/openehr_rails/openehr_api/ehrs_controller.rb
Overview
openEHR REST API EHR resource (base URL:
Instance Method Summary collapse
-
#create ⇒ Object
POST /v1/ehr (server-generated ehr_id).
-
#ehr_status ⇒ Object
GET /v1/ehr/:ehr_id/ehr_status.
- #openehr_access_scope ⇒ Object
-
#show ⇒ Object
GET /v1/ehr/:ehr_id.
-
#upsert ⇒ Object
PUT /v1/ehr/:ehr_id (client-supplied ehr_id).
Instance Method Details
#create ⇒ Object
POST /v1/ehr (server-generated ehr_id)
19 20 21 22 |
# File 'app/controllers/openehr_rails/openehr_api/ehrs_controller.rb', line 19 def create ehr = OpenehrRails::Rm::Ehr.create!(ehr_attributes.merge(ehr_id: SecureRandom.uuid)) render_ehr(ehr, status: :created) end |
#ehr_status ⇒ Object
GET /v1/ehr/:ehr_id/ehr_status
40 41 42 |
# File 'app/controllers/openehr_rails/openehr_api/ehrs_controller.rb', line 40 def ehr_status render json: OpenehrRails::Rm::EhrSerializer.new(find_ehr!).ehr_status end |
#openehr_access_scope ⇒ Object
14 15 16 |
# File 'app/controllers/openehr_rails/openehr_api/ehrs_controller.rb', line 14 def openehr_access_scope :rest_api end |
#show ⇒ Object
GET /v1/ehr/:ehr_id
35 36 37 |
# File 'app/controllers/openehr_rails/openehr_api/ehrs_controller.rb', line 35 def show render_ehr(find_ehr!) end |
#upsert ⇒ Object
PUT /v1/ehr/:ehr_id (client-supplied ehr_id)
25 26 27 28 29 30 31 32 |
# File 'app/controllers/openehr_rails/openehr_api/ehrs_controller.rb', line 25 def upsert if OpenehrRails::Rm::Ehr.exists?(ehr_id: params[:ehr_id]) return render json: { error: "EHR #{params[:ehr_id]} already exists" }, status: :conflict end ehr = OpenehrRails::Rm::Ehr.create!(ehr_attributes.merge(ehr_id: params[:ehr_id])) render_ehr(ehr, status: :created) end |