Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CC Referral Appointments - Draft Appointment Submit #20323

Merged
merged 7 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions config/settings/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,3 @@ va_notify:

accredited_representative_portal:
pilot_user_email_poa_codes:

vaos:
eps:
key_path: modules/health_quest/config/rsa/sandbox_rsa
Comment on lines -448 to -451
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just approved a PR that added this. Please confirm this deletion

Copy link
Member

@randomsync randomsync Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there were 2 PRs that were merged that both included this change in different places of the test.yml, which caused this to be duped in final merge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is correct - it also got added and merged in another PR and this is removing one of them

67 changes: 67 additions & 0 deletions modules/vaos/app/controllers/vaos/v2/appointments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ def update
render json: { data: serialized }
end

def submit_referral_appointment
params = submit_params
appointment = eps_appointment_service.submit_appointment(
params[:id],
{ referral_number: params[:referral_number],
network_id: params[:network_id],
provider_service_id: params[:provider_service_id],
slot_ids: [params[:slot_id]],
additional_patient_attributes: patient_attributes(params) }
)

render json: Eps::DraftAppointmentSerializer.new(appointment), status: :created
end

private

def set_facility_error_msg(appointment)
Expand Down Expand Up @@ -368,6 +382,59 @@ def create_method_logging_name
end
end

def submit_params
devin-mccurdy marked this conversation as resolved.
Show resolved Hide resolved
params.require(%i[id network_id provider_service_id slot_id referral_number])
params.permit(
:id,
:network_id,
:provider_service_id,
:slot_id,
:referral_number,
:birth_date,
:email,
:phone_number,
:gender,
address: submit_address_params,
name: [
:family,
{ given: [] }
]
)
end

def submit_address_params
[
:type,
{ line: [] },
:city,
:state,
:postal_code,
:country,
:text
]
end

def patient_attributes(params)
{
name: {
family: params.dig(:name, :family),
given: params.dig(:name, :given)
},
phone: params[:phone_number],
email: params[:email],
birthDate: params[:birth_date],
gender: params[:gender],
address: {
line: params.dig(:address, :line),
city: params.dig(:address, :city),
state: params.dig(:address, :state),
country: params.dig(:address, :country),
postalCode: params.dig(:address, :postal_code),
type: params.dig(:address, :type)
}
}
end

def fetch_provider_slots
eps_provider_service.get_provider_slots(
draft_params[:provider_id],
Expand Down
186 changes: 186 additions & 0 deletions modules/vaos/app/docs/vaos/v2/vaos_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,61 @@ paths:
$ref: "#/components/responses/ServiceUnavailable"
"504":
$ref: "#/components/responses/GatewayTimeout"
"/appointments/submit":
post:
tags:
- appointments
summary: Submit a draft appointment
operationId: submitDraftAppointment
security:
- bearerAuth: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SubmitDraftAppointmentRequest"
responses:
"201":
description: The submitted draft appointment
content:
application/json:
schema:
required:
- data
properties:
data:
required:
- id
- type
- attributes
type: object
properties:
id:
type: string
type:
type: string
attributes:
$ref: "#/components/schemas/DraftAppointment"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
"422":
$ref: "#/components/responses/Unprocessable"
"500":
$ref: "#/components/responses/InternalServerError"
"501":
$ref: "#/components/responses/NotImplemented"
"502":
$ref: "#/components/responses/BadGateway"
"503":
$ref: "#/components/responses/ServiceUnavailable"
"504":
$ref: "#/components/responses/GatewayTimeout"
"/appointments/{appointment-id}":
get:
tags:
Expand Down Expand Up @@ -1303,6 +1358,44 @@ components:
type: string
preferredLanguage:
type: string
SubmitDraftAppointmentRequest:
description: A request to create a new referral appointment.
type: object
properties:
id:
description: The EPS appointment ID
type: string
nullable: false
networkId:
description: The EPS network ID
type: string
nullable: false
providerServiceId:
description: The EPS provider service ID
type: string
nullable: false
referralNumber:
description: The appointment referral number
type: string
nullable: false
slotId:
description: The EPS slot ID
type: string
nullable: false
name:
$ref: "#/components/schemas/HumanName"
address:
$ref: '#/components/schemas/Address'
birthDate:
description: The birth date of the patient.
type: string
format: date
email:
type: string
gender:
type: string
phoneNumber:
type: string
HumanName:
type: object
properties:
Expand Down Expand Up @@ -1647,6 +1740,99 @@ components:
enrollmentCoordinator:
type: string
example: 202-555-1212
DraftAppointment:
type: object
description: 'Draft appointment'
properties:
appointment:
type: object
properties:
provider:
type: object
properties:
id:
type: string
name:
type: string
isActive:
type: boolean
individualProviders:
type: array
items:
type: string
providerOrganization:
type: string
location:
type: object
properties:
address:
type: string
networkIds:
type: array
items:
type: string
schedulingNotes:
type: string
appointmentTypes:
type: array
items:
type: object
properties:
id:
type: string
name:
type: string
isSelfSchedulable:
type: boolean
specialties:
type: array
items:
type: object
properties:
id:
type: string
name:
type: string
visitMode:
type: string
features:
type: object
properties:
isDigital:
type: boolean
slots:
type: array
items:
type: object
properties:
id:
type: string
start:
type: string
format: date-time
drivetime:
type: object
properties:
origin:
type: object
properties:
latitude:
type: number
longitude:
type: number
destination:
type: object
properties:
distanceInMiles:
type: integer
driveTimeInSecondsWithoutTraffic:
type: number
driveTimeInSecondsWithTraffic:
type: number
latitude:
type: number
longitude:
type: number
SchedulingConfiguration:
type: object
required:
Expand Down
1 change: 1 addition & 0 deletions modules/vaos/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
get '/relationships', to: 'relationships#index'
post '/appointments', to: 'appointments#create'
post '/appointments/draft', to: 'appointments#create_draft'
post '/appointments/submit', to: 'appointments#submit_referral_appointment'
end
end
65 changes: 65 additions & 0 deletions modules/vaos/spec/requests/vaos/v2/appointments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,71 @@ def stub_clinics
end
end
end

describe 'POST appointments/submit' do
context 'referral appointment' do
let(:params) do
{ referral_number: '12345',
provider_service_id: '9mN718pH',
id: 'J9BhspdR',
slot_id: '5vuTac8v-practitioner-4-role-1|2a82f6c9-e693-4091-826d' \
'-97b392958301|2024-11-04T17:00:00Z|30m0s|1732735998236|ov',
network_id: 'sandbox-network-5vuTac8v',
name: {
family: 'Smith',
given: %w[
Sarah
Elizabeth
]
},
birth_date: '1985-03-15',
email: 'sarah.smith@email.com',
gender: 'female',
phone_number: '407-555-8899',
address: {
city: 'Orlando',
country: 'USA',
line: [
'742 Sunshine Boulevard',
'Apt 15B'
],
postal_code: '32801',
state: 'FL',
type: 'both',
text: 'text'
} }
end

it 'successfully submits referral appointment' do
VCR.use_cassette('vaos/v2/eps/post_access_token',
match_requests_on: %i[method path]) do
VCR.use_cassette('vaos/v2/eps/post_submit_appointment',
match_requests_on: %i[method path body]) do
post '/vaos/v2/appointments/submit', params:, headers: inflection_header

response_obj = JSON.parse(response.body)
expect(response).to have_http_status(:created)
expect(response_obj.dig('data', 'id')).to eql('J9BhspdR')
end
end
end

it 'handles EPS error response' do
VCR.use_cassette('vaos/v2/eps/post_access_token',
match_requests_on: %i[method path]) do
VCR.use_cassette('vaos/v2/eps/post_submit_appointment_400',
match_requests_on: %i[method path]) do
post '/vaos/v2/appointments/submit', params: { ** params, phone_number: nil }, headers: inflection_header

response_obj = JSON.parse(response.body)
expect(response).to have_http_status(:bad_request)
expect(response_obj['errors'].length).to be(1)
expect(response_obj['errors'][0]['detail']).to eql('missing patient attributes: phone')
end
end
end
end
end
end

context 'for eps referrals' do
Expand Down
Loading
Loading