diff --git a/lib/medical_records/bb_internal/client.rb b/lib/medical_records/bb_internal/client.rb index ca80ab2060e..95478a5490e 100644 --- a/lib/medical_records/bb_internal/client.rb +++ b/lib/medical_records/bb_internal/client.rb @@ -98,6 +98,26 @@ def get_dicom(study_id, header_callback, yielder) end ## + # @param icn - user icn + # @param last_name - user last name + # @return JSON [{ dateGenerated, status, patientId }] + # + def get_generate_ccd(icn, last_name) + response = perform(:get, "bluebutton/healthsummary/#{icn}/#{last_name}/xml", nil, token_headers) + response.body + end + + ## + # @param date - receieved from get_generate_ccd call property dateGenerated (e.g. 2024-10-18T09:55:58.000-0400) + # @return - Continuity of Care Document in XML format + # + def get_download_ccd(date) + token_headers['Accept'] = 'application/xml' + + response = perform(:get, "bluebutton/healthsummary/#{date}/fileFormat/XML/ccdType/XML", nil, token_headers) + response.body + end + # check the status of a study job # @return [Array] - [{ status: "COMPLETE", studyIdUrn: "111-1234567" percentComplete: 100, fileSize: "1.01 MB", # startDate: 1729777818853, endDate}] diff --git a/modules/my_health/app/controllers/my_health/v1/medical_records/ccd_controller.rb b/modules/my_health/app/controllers/my_health/v1/medical_records/ccd_controller.rb new file mode 100644 index 00000000000..94edee21206 --- /dev/null +++ b/modules/my_health/app/controllers/my_health/v1/medical_records/ccd_controller.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module MyHealth + module V1 + module MedicalRecords + class CcdController < MrController + # Generates a CCD + # @return [Array] of objects with CCDs generated date and status (COMPLETE or not) + def generate + resource = bb_client.get_generate_ccd(@current_user.icn, @current_user.last_name) + render json: resource.to_json + end + + # Downloads the CCD once it has been generated + # @param generated_datetime [String] date receieved from get_generate_ccd call property dateGenerated + # @return [XML] Continuity of Care Document + def download + resource = bb_client.get_download_ccd(generated_datetime) + send_data resource, type: 'application/xml' + end + end + end + end +end diff --git a/modules/my_health/config/routes.rb b/modules/my_health/config/routes.rb index 74c9fa004e4..7f83bb5bc49 100644 --- a/modules/my_health/config/routes.rb +++ b/modules/my_health/config/routes.rb @@ -17,6 +17,12 @@ resources :session, only: %i[create], controller: 'mr_session', defaults: { format: :json } do get :status, on: :collection end + resources :ccd, only: [] do + collection do + get :generate, to: 'ccd#generate' + get :download, to: 'ccd#download' + end + end resources :imaging, only: %i[index], defaults: { format: :json } do get 'request', on: :member, action: :request_download get :status, on: :collection, action: :request_status diff --git a/spec/lib/medical_records/bb_internal/client_spec.rb b/spec/lib/medical_records/bb_internal/client_spec.rb index 0b69fcefad7..d5329777510 100644 --- a/spec/lib/medical_records/bb_internal/client_spec.rb +++ b/spec/lib/medical_records/bb_internal/client_spec.rb @@ -88,6 +88,36 @@ end end + describe '#get_generate_ccd' do + it 'requests a CCD be generated and returns the correct structure' do + VCR.use_cassette 'mr_client/bb_internal/generate_ccd' do + ccd_list = client.get_generate_ccd(client.session.icn, 'DOE') + + expect(ccd_list).to be_an(Array) + expect(ccd_list).not_to be_empty + + first_ccd = ccd_list.first + expect(first_ccd).to be_a(Hash) + expect(first_ccd).to have_key('dateGenerated') + expect(first_ccd['dateGenerated']).to be_a(String) + + expect(first_ccd).to have_key('status') + expect(first_ccd['status']).to be_a(String) + end + end + end + + describe '#get_download_ccd' do + it 'retrieves a previously generated CCD as XML' do + VCR.use_cassette 'mr_client/bb_internal/download_ccd' do + ccd = client.get_download_ccd('2024-10-23T12:42:48.000-0400') + + expect(ccd).to be_a(String) + expect(ccd).to include('/mhvapi/v1/bluebutton/healthsummary/2024-10-23T12:42:48.000-0400/fileFormat/XML/ccdType/XML" + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/xml + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Token: "" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: '' + headers: + Date: + - Wed, 23 Oct 2024 20:20:59 GMT + Content-Type: + - text/xml + Content-Length: + - '32663' + Expires: + - "-1" + Cache-Control: + - no-cache + Content-Disposition: + - attachment; filename=mhv_VA_CCD_IPOACEVEDA_20241023_1242.xml + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: "\n\nVA Continuity of Care Document (CCD)4002 + Crutchfield StRichmondVA23225-4755IPOACEVEDADEWAYNEDEANMMarriedNazareneDeclined to AnswerNot Hispanic or LatinoDepartment of + Veterans Affairs (VA)Department + of Veterans Affairs (VA)810 + Vermont Avenue NWWashingtonDC20420USPrimary Care ProviderWVDIXSON, + JESSIPOTEST 1
Insurance Providers: All on record + at VANo Data Provided for This Section
Advance Directives: All on record + at VANo Data Provided + for This Section
Allergies and Adverse Reactions (ADRs): + All on record at VANo Data + Provided for This Section
Encounters: + Outpatient Encounters with NotesNo Data Provided for This Section
Functional Status: Functional Independence + Measurement (FIM) ScoresNo Data Provided for This Section
Medications: VA Dispensed and Non-VA Documented + (Obtained Outside VA)No + Data Provided for This Section
Immunizations: All on record at VANo Data Provided + for This Section
Procedures: + Surgical Procedures with NotesNo + Data Provided for This Section
Plan of + Treatment: Future Appointments and Active/Pending OrdersNo Data + Provided for This Section
Problems (Conditions): All on record at VANo Data Provided for This Section
Results: Chemistry and HematologyNo Data Provided + for This Section
Social History: All on record at VANo + Data Provided for This Section
Vital Signs\n The + included list of inpatient and outpatient Vital Signs is from the last 12 + months and includes a maximum of the 5 most recent sets of vital sign values. + If more than one set of vitals was taken on the same date, only the most recent + set is populated for that date. The data comes from all VA treatment facilities. + Vital Sign information from the new VA electronic health record is not included.\n\t\t\t\t\t\t\t\t\t\t\t
Date/TimeTemperaturePulseBlood + PressureRespiratory RateSP02PainHeightWeightBody + Mass IndexSource
Aug 29, 2024 12:57 + PM99 77 22 CHEYENNE VAMC
Vital + Sign Observation Text Not Available
TEMPERATUREPULSERESPIRATION
Consult NotesConsult + Notes\n The + included Consult Notes are from the last 18 months, are available thirty-six + (36) hours after completion, and include a maximum of the 5 most recent notes. + The data comes from all VA treatment facilities. Note that Compensation & + Pension Notes are available 30 days after completion. Consult Notes (including + Compensation and Pension exam notes) from the new VA electronic health record + are not included.\n\t\t\t\t\t\t\t\t\t\t
Date/TimeConsult + Note with TextProviderSource
Aug 21, 2024 12:00 PMEDUCATION:
LOCAL TITLE: NUTRITION CLASS - SATP EDUCATION CONSULT REPORT
STANDARD + TITLE: NUTRITION EDUCATION NOTE
DATE OF NOTE: + AUG 21, 2024@12:00 ENTRY DATE: AUG 21, 2024@14:38:20
AUTHOR: + GOODMAN,KEOLA EXP COSIGNER:
URGENCY: + \ STATUS: COMPLETED

VistA Imaging - Scanned Document


*** + SCANNED DOCUMENT ***
SIGNATURE NOT REQUIRED


Electronically Filed: 08/21/2024
by: + KEOLA GOODMAN




GOODMAN,KEOLACHEYENNE + VAMC
History and Physical + NotesNo Data Provided for This Section
Discharge + SummariesNo Data Provided for This Section
Radiology + ReportsNo Data Provided for This Section
Pathology + ReportsNo Data Provided for This Section
Clinical + Procedure NotesNo Data Provided for This Section
\n" + recorded_at: Wed, 23 Oct 2024 20:20:59 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/support/vcr_cassettes/mr_client/bb_internal/generate_ccd.yml b/spec/support/vcr_cassettes/mr_client/bb_internal/generate_ccd.yml new file mode 100644 index 00000000000..96bb7c54d51 --- /dev/null +++ b/spec/support/vcr_cassettes/mr_client/bb_internal/generate_ccd.yml @@ -0,0 +1,36 @@ +--- +http_interactions: +- request: + method: get + uri: "/mhvapi/v1/bluebutton/healthsummary/1012740022V620959/DOE/xml" + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Token: "" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: '' + headers: + Date: + - Wed, 23 Oct 2024 20:04:00 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: '[{"dateGenerated":"2024-10-23T12:42:48.000-0400","status":"COMPLETE","patientId":"1012740022V620959"},{"dateGenerated":"2024-10-22T15:10:37.000-0400","status":"COMPLETE","patientId":"1012740022V620959"}]' + recorded_at: Wed, 23 Oct 2024 20:04:00 GMT +recorded_with: VCR 6.3.1