# frozen_string_literal: true require 'spec_helper' describe 'Fetching A19 from EPIC' do describe 'the patient Jan Fictief' do before { load_fixture 'epic_test_client', '7767853' } subject { Roqua::Healthy::A19.fetch("7767853") } it { expect(subject[:status]).to eq('SUCCESS') } it { expect(subject[:error]).to be_nil } it { expect(subject[:source]).to eq('CLOVDMZP') } it { expect(subject[:identities]).to eq([{ident: '7767853', authority: 'PI'}]) } it { expect(subject[:firstname]).to eq('Jan') } it { expect(subject[:initials]).to eq('J A B') } it { expect(subject[:lastname]).to eq('Fictief') } it { expect(subject[:display_name]).to be_nil } it { expect(subject[:nickname]).to be_nil } it { expect(subject[:email]).to eq('test@example.com') } it { expect(subject[:address_type]).to eq('P') } it { expect(subject[:street]).to eq('hanzeplein 1') } it { expect(subject[:city]).to eq('GRONINGEN') } it { expect(subject[:zipcode]).to eq('9713GZ') } it { expect(subject[:country]).to eq('NLD') } it { expect(subject[:birthdate]).to eq('19800101') } it { expect(subject[:gender]).to eq('M') } it { expect(subject[:phone_cell]).to eq('0612345679') } it { expect(subject[:deceased]).to eq(false) } end describe 'epd example: a patient with no PID 8.1 (gender) field' do before { load_fixture 'epic_no_gender', '2001111' } subject { Roqua::Healthy::A19.fetch('2001111') } it { expect(subject[:status]).to eq('SUCCESS') } it { expect(subject[:error]).to be_nil } it { expect(subject[:source]).to eq('CLOVDMZP') } it { expect(subject[:identities]).to eq([{ident: "2001111", authority: "PI"}]) } it { expect(subject[:firstname]).to eq('H') } it { expect(subject[:initials]).to eq('H') } it { expect(subject[:lastname]).to eq("CLINT\u00C9N") } it { expect(subject[:display_name]).to eq(nil) } it { expect(subject[:email]).to eq(nil) } it { expect(subject[:address_type]).to eq('M') } it { expect(subject[:street]).to eq(nil) } it { expect(subject[:city]).to eq(nil) } it { expect(subject[:zipcode]).to eq(nil) } it { expect(subject[:country]).to eq('NLD') } it { expect(subject[:birthdate]).to eq('20011003') } it { expect(subject[:gender]).to eq(nil) } it { expect(subject[:phone_cell]).to eq(nil) } it { expect(subject[:deceased]).to eq(false) } end describe 'example of compounded last name and prefix' do before { load_fixture 'epic_lastname', '12345678' } subject { Roqua::Healthy::A19.fetch('12345678') } it { expect(subject[:status]).to eq('SUCCESS') } it { expect(subject[:error]).to be_nil } it { expect(subject[:source]).to eq('CLOVDMZP') } it do expect(subject[:identities]).to eq([{ident: "12345678", authority: "PI"}, {ident: "111000111", authority: "NNNLD"}]) end it { expect(subject[:firstname]).to eq('Voornaam') } it { expect(subject[:initials]).to eq('V') } it { expect(subject[:lastname]).to eq("Samen-Gesteld van de") } it { expect(subject[:display_name]).to eq(nil) } it { expect(subject[:email]).to eq('email@example.com') } it { expect(subject[:address_type]).to eq('P') } it { expect(subject[:street]).to eq('WEGWEG 10') } it { expect(subject[:city]).to eq('GRONINGEN') } it { expect(subject[:zipcode]).to eq('9714AA') } it { expect(subject[:country]).to eq('NLD') } it { expect(subject[:birthdate]).to eq('1990101') } it { expect(subject[:gender]).to eq('F') } it { expect(subject[:phone_cell]).to eq('0612345678') } it { expect(subject[:deceased]).to eq(false) } end describe 'patient not found' do before { load_fixture 'epic_not_found', '1234unknown' } subject { Roqua::Healthy::A19.fetch("1234unknown") } it 'raises PatientNotFound' do expect { subject }.to raise_error(Roqua::Healthy::PatientNotFound) end end end