Skip to content

Commit

Permalink
update spec
Browse files Browse the repository at this point in the history
Signed-off-by: Vanessa Fotso <[email protected]>
  • Loading branch information
vanessuniq committed Jan 7, 2025
1 parent c108c31 commit 006b3b3
Show file tree
Hide file tree
Showing 5 changed files with 666 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ class DTRQuestionnaireResponsePrePopulationTest < Inferno::Test
questionnaires = extract_questionnaires_from_bundles(scratch[:static_questionnaire_bundles])
questionnaires.find { |q| questionnaire_response.questionnaire.end_with?(q.id) }
end

skip_if questionnaire.blank?,
"Couldn't find Questionnaire #{questionnaire_response.questionnaire} to check the QuestionnaireResponse"
"Couldn't find Questionnaire `#{questionnaire_response.questionnaire}` in the provided
custom questionnaire package to validate the QuestionnaireResponse."

expected_overrides = ['PBD.2'] if scratch[:static_questionnaire_bundles].present?
expected_overrides = ['PBD.2'] if scratch[:static_questionnaire_bundles].blank?
scratch[:static_questionnaire_bundles] = nil
end

Expand Down
26 changes: 15 additions & 11 deletions spec/davinci_dtr_test_kit/dtr_questionnaire_response_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,31 @@ def run(runnable, test_session, inputs = {})
end
end
let(:request_body) do
File.read(File.join(__dir__, '..', 'fixtures', 'questionnaire_response_conformant.json'))
File.read(File.join(__dir__, '..', 'fixtures', 'dinner_questionnaire_response_conformant.json'))
end
let(:incorrect_request_body) do
File.read(File.join(__dir__, '..', 'fixtures', 'dinner_questionnaire_response_missing_answers.json'))
end
let(:package_bundle) do
File.read(File.join(__dir__, '..', 'fixtures', 'dinner_questionnaire_package.json'))
end

it 'passes if questionnaire response pre-population is conformant' do
allow_any_instance_of(DaVinciDTRTestKit::DTRQuestionnaireResponseValidation).to(
receive(:validate_questionnaire_pre_population).and_return(nil)
)
before do
allow_any_instance_of(runnable).to receive(:scratch)
.and_return({ static_questionnaire_bundles: [FHIR.from_contents(package_bundle)] })
end

it 'passes if questionnaire response pre-population is conformant and all requred questions are answered' do
repo_create(:request, name: 'questionnaire_response_save', url: questionnaire_response_url,
request_body:, test_session_id: test_session.id)

result = run(runnable, test_session)
expect(result.result).to eq('pass'), result.result_message
end

it 'fails if questionnaire response input parameters are nonconformant' do
allow_any_instance_of(DaVinciDTRTestKit::DTRQuestionnaireResponseValidation).to(
receive(:validate_questionnaire_pre_population).and_raise(Inferno::Exceptions::AssertionException)
)

repo_create(:request, name: 'questionnaire_response_save', request_body:, test_session_id: test_session.id)
it 'fails if not all required questions are answered or an origin.source is missing' do
repo_create(:request, name: 'questionnaire_response_save', url: questionnaire_response_url,
request_body: incorrect_request_body, test_session_id: test_session.id)

result = run(runnable, test_session)
expect(result.result).to eq('fail')
Expand Down
283 changes: 283 additions & 0 deletions spec/fixtures/dinner_questionnaire_package.json

Large diffs are not rendered by default.

206 changes: 206 additions & 0 deletions spec/fixtures/dinner_questionnaire_response_conformant.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
{
"resourceType": "QuestionnaireResponse",
"meta": {
"profile": [
"http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-questionnaireresponse-r4"
],
"tag": [
{
"code": "lformsVersion: 29.3.1"
}
]
},
"status": "completed",
"authored": "2024-05-08T12:35:38.748Z",
"item": [
{
"linkId": "PBD",
"text": "Patient Information",
"item": [
{
"linkId": "PBD.1",
"text": "Last Name:",
"answer": [
{
"valueString": "Oster",
"extension": [
{
"url": "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/information-origin",
"extension": [
{
"url": "source",
"valueCode": "auto"
}
]
}
]
}
]
},
{
"linkId": "PBD.2",
"text": "First Name:",
"answer": [
{
"valueString": "William",
"extension": [
{
"url": "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/information-origin",
"extension": [
{
"url": "source",
"valueCode": "override"
}
]
}
]
}
]
}
]
},
{
"linkId": "LOC",
"text": "Patient's Location",
"item": [
{
"linkId": "LOC.1",
"text": "Location",
"answer": [
{
"valueString": "Observation2c",
"extension": [
{
"url": "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/information-origin",
"extension": [
{
"url": "source",
"valueCode": "override"
},
{
"url": "author",
"extension": [
{
"url": "practitioner",
"valueReference": {
"reference": "Practitioner/pra1234"
}
}
]
}
]
}
]
}
]
}
]
},
{
"linkId": "3",
"text": "Dinner Order",
"item": [
{
"linkId": "3.1",
"text": "What would you like for dinner?",
"answer": [
{
"valueCoding": {
"code": "Hamburger",
"display": "Hamburger"
},
"extension": [
{
"url": "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/information-origin",
"extension": [
{
"url": "source",
"valueCode": "manual"
},
{
"url": "author",
"extension": [
{
"url": "practitioner",
"valueReference": {
"reference": "Practitioner/pra1234"
}
}
]
}
]
}
]
}
]
},
{
"linkId": "3.3",
"text": "Any special requests?",
"answer": [
{
"valueString": "toasted bun",
"extension": [
{
"url": "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/information-origin",
"extension": [
{
"url": "source",
"valueCode": "manual"
},
{
"url": "author",
"extension": [
{
"url": "practitioner",
"valueReference": {
"reference": "Practitioner/pra1234"
}
}
]
}
]
}
]
}
]
}
]
}
],
"author": {
"reference": "Practitioner/pra1234"
},
"subject": {
"reference": "Patient/pat015"
},
"questionnaire": "http://localhost:4567/custom/dtr_payer_server/fhir/Questionnaire/DinnerOrderStatic",
"extension": [
{
"url": "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/qr-context",
"valueReference": {
"reference": "DeviceRequest/devreq015",
"type": "DeviceRequest"
}
},
{
"url": "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/qr-context",
"valueReference": {
"reference": "Coverage/cov015",
"type": "Coverage"
}
},
{
"url": "http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/intendedUse",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/us/davinci-crd/CodeSystem/temp",
"code": "withorder",
"display": "Include with order"
}
]
}
}
]
}
Loading

0 comments on commit 006b3b3

Please sign in to comment.