forked from project-rhex/patient-data-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of barrel.mitre.org:hdata-patient-server/hdata…
…-patient-server into develop
- Loading branch information
Showing
7 changed files
with
111 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'section_registry' | ||
|
||
############################################################## | ||
# Register all the sections we will use in the web application | ||
############################################################## | ||
sr = SectionRegistry.instance | ||
|
||
sr.add_section('allergies', 'http://projecthdata.org/hdata/schemas/2009/06/allergy', 'Allergies') | ||
sr.add_section('care_goals', 'http://projecthdata.org/hdata/schemas/2009/06/care_goal', 'Care Goals') | ||
sr.add_section('conditions', 'http://projecthdata.org/hdata/schemas/2009/06/condition', 'Conditions') | ||
sr.add_section('encounters', 'http://projecthdata.org/hdata/schemas/2009/06/encounter', 'Encounters') | ||
sr.add_section('immunizations', 'http://projecthdata.org/hdata/schemas/2009/06/immunization', 'Immunizations') | ||
sr.add_section('medical_equipment', 'http://projecthdata.org/hdata/schemas/2009/06/medical_equipment', 'Medical Equipment') | ||
sr.add_section('medications', 'http://projecthdata.org/hdata/schemas/2009/06/medication', 'Medications') | ||
sr.add_section('procedures', 'http://projecthdata.org/hdata/schemas/2009/06/procedure', 'Procedures') | ||
sr.add_section('results', 'http://projecthdata.org/hdata/schemas/2009/06/result', 'Lab Results') do |importers, exporters| | ||
importers['application/xml'] = HealthDataStandards::Import::GreenCda::ResultImporter.instance | ||
exporters['application/xml'] = HealthDataStandards::Export::GreenCda::ExportGenerator.create_exporter_for(:result) | ||
end | ||
sr.add_section('social_history', 'http://projecthdata.org/hdata/schemas/2009/06/social_history', 'Social History') | ||
sr.add_section('vital_signs', 'http://projecthdata.org/hdata/schemas/2009/06/result', 'Vital Signs') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'test_helper' | ||
|
||
class EntriesControllerTest < ActionController::TestCase | ||
setup do | ||
@record = FactoryGirl.create(:record, :with_lab_results) | ||
end | ||
|
||
test "get a result as xml" do | ||
request.env['HTTP_ACCEPT'] = Mime::XML | ||
get :show, {record_id: @record.medical_record_number, section: 'results', id: @record.results.first.id} | ||
doc = Nokogiri::XML::Document.parse(response.body) | ||
assert_response :success | ||
assert_equal "result", doc.children.first.name | ||
end | ||
|
||
test "get a result as JSON" do | ||
request.env['HTTP_ACCEPT'] = Mime::JSON | ||
get :show, {record_id: @record.medical_record_number, section: 'results', id: @record.results.first.id} | ||
doc = JSON.parse(response.body) | ||
assert_response :success | ||
assert_equal "LDL Cholesterol", doc['description'] | ||
end | ||
|
||
test "get a section that doesn't exist" do | ||
request.env['HTTP_ACCEPT'] = Mime::XML | ||
get :show, {record_id: @record.medical_record_number, section: 'bacon', id: @record.results.first.id} | ||
assert_response :missing | ||
end | ||
|
||
test "get section Atom feed" do | ||
request.env['HTTP_ACCEPT'] = 'application/atom+xml' | ||
get :index, {record_id: @record.medical_record_number, section: 'results'} | ||
assert_response :success | ||
rss = Feedzirra::Feed.parse(@response.body) | ||
assert_not_nil(rss.entries) | ||
assert_equal(1, rss.entries.size) | ||
assert rss.entries[0].links[0].include? "/records/#{@record.medical_record_number}/results/#{@record.results.first.id}" | ||
end | ||
|
||
test "get a document that doesn't exist" do | ||
request.env['HTTP_ACCEPT'] = Mime::XML | ||
get :show, {record_id: @record.medical_record_number, section: 'results', id: 'bacon'} | ||
assert_response 400 | ||
|
||
get :show, {record_id: @record.medical_record_number, section: 'results', id: ('0' * 24)} | ||
assert_response :missing | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters