From cf9f579b5f748073f472b68d88508182b3554552 Mon Sep 17 00:00:00 2001 From: Kris Pethtel Date: Mon, 8 Apr 2024 18:11:36 -0500 Subject: [PATCH] 8189 appointments index schema corrections (#16245) * 8189: corrections to appointments index schema --- .../vaos/app/schemas/appointments_index.json | 112 +++++++++++++----- .../services/vaos/v2/appointments_service.rb | 8 +- 2 files changed, 87 insertions(+), 33 deletions(-) diff --git a/modules/vaos/app/schemas/appointments_index.json b/modules/vaos/app/schemas/appointments_index.json index 725e3c22c71..4db0c3b8974 100644 --- a/modules/vaos/app/schemas/appointments_index.json +++ b/modules/vaos/app/schemas/appointments_index.json @@ -91,25 +91,22 @@ } }, "reason_code": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "coding": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "system": { "type": "string" }, - "code": { "type": "string" }, - "display": { "type": "string" } - } + "type": "object", + "additionalProperties": false, + "properties": { + "coding": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "system": { "type": "string" }, + "code": { "type": "string" }, + "display": { "type": "string" } } - }, - "text": { "type": "string" } - } + } + }, + "text": { "type": "string" } } }, "description": { "type": "string" }, @@ -135,7 +132,8 @@ "practitioners": { "type": "array", "items": { - "type": "array", + "type": "object", + "additionalProperties": false, "properties": { "identifier": { "type": "array", @@ -160,7 +158,7 @@ } } }, - "practiceName": { "type": "string" }, + "practice_name": { "type": "string" }, "address": { "type": "object", "additionalProperties": false, @@ -175,13 +173,13 @@ }, "city": { "type": "string" }, "state": { "type": "string" }, - "postalCode": { "type": "string" }, + "postal_code": { "type": "string" }, "country": { "type": "string" }, "text": { "type": "string" } } }, - "firstName": { "type": "string" }, - "lastName": { "type": "string" } + "first_name": { "type": "string" }, + "last_name": { "type": "string" } } } }, @@ -290,20 +288,20 @@ "type": "object", "additionalProperties": false, "properties": { - "sitecode": { "type": "string" }, - "confirmationCode": { "type": "string" }, + "site_code": { "type": "string" }, + "confirmation_code": { "type": "string" }, "address": { "type": "object", "additionalProperties": false, "properties": { - "streetAddress": { "type": "string" }, + "street_address": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" }, - "zipCode": { "type": "string" }, + "zip_code": { "type": "string" }, "country": { "type": "string" }, - "latitude": { "type": "number" }, + "latitutde": { "type": "number" }, "longitude": { "type": "number" }, - "additionalDetails": { "type": "string" } + "additional_details": { "type": "string" } } } } @@ -316,7 +314,10 @@ "type": "object", "additionalProperties": false, "properties": { - "ccLocation": { + "desired_date": { + "type": "string" + }, + "cc_location": { "type": "object", "additionalProperties": false, "properties": { @@ -334,7 +335,7 @@ }, "city": { "type": "string" }, "state": { "type": "string" }, - "postalCode": { "type": "string" }, + "postal_code": { "type": "string" }, "country": { "type": "string" }, "text": { "type": "string" } } @@ -353,7 +354,54 @@ } } }, - "practiceName": { "type": "string" } + "practice_name": { "type": "string" } + } + }, + "cc_requested_cancellation": { "type": "boolean" }, + "hsrm_tast_id": { "type": "string" }, + "hsrm_consult_id": { "type": "string" }, + "vista_status": { + "type": "array", + "items": { "type": "string" } + }, + "cc_treating_specialty": { "type": "string" }, + "modality": { "type": "string" }, + "patient_has_mobile_gfe": { "type": "boolean" }, + "pre_checkin_allowed": { "type": "boolean" }, + "e_checkin_allowed": { "type": "boolean" }, + "clinic": { + "type": "object", + "additionalProperties": false, + "properties": { + "vista_site": { + "type": "integer", + "maxLength": 3, + "minLength": 3 + }, + "id": { "type": "string" }, + "service_name": { "type": "string" }, + "physical_location": { "type": "string" }, + "phone_number": { "type": "string" }, + "station_id": { "type": "string" }, + "station_name": { "type": "string" }, + "primary_stop_code": { + "type": "integer", + "maxLength": 3, + "minLength": 3 + }, + "primary_stop_code_name": { "type": "string" }, + "secondary_stop_code": { + "type": "integer", + "maxLength": 3, + "minLength": 3 + }, + "secondary_stop_code_name": { "type": "string" }, + "patient_direct_scheduling": { "type": "boolean" }, + "patient_display": { "type": "boolean" }, + "char4": { "type": "string" }, + "active": { "type": "boolean" }, + "non_count": { "type": "boolean" }, + "future_booking_maximum_days": { "type": "integer" } } } } diff --git a/modules/vaos/app/services/vaos/v2/appointments_service.rb b/modules/vaos/app/services/vaos/v2/appointments_service.rb index 3fcadb28f69..fda329d27f4 100644 --- a/modules/vaos/app/services/vaos/v2/appointments_service.rb +++ b/modules/vaos/app/services/vaos/v2/appointments_service.rb @@ -31,7 +31,7 @@ def get_appointments(start_date, end_date, statuses = nil, pagination_params = { with_monitoring do response = perform(:get, appointments_base_path, params, headers) - SchemaContract::ValidationInitiator.call(user:, response:, contract_name: 'appointments_index') + validate_response_schema(response, 'appointments_index') response.body[:data].each do |appt| # for CnP and covid appointments set cancellable to false per GH#57824, GH#58690 set_cancellable_false(appt) if cnp?(appt) || covid?(appt) @@ -538,6 +538,12 @@ def update_appointment_vaos(appt_id, status) params = VAOS::V2::UpdateAppointmentForm.new(status:).params perform(:put, url_path, params, headers) end + + def validate_response_schema(response, contract_name) + return unless response.success? && response.body[:data].present? + + SchemaContract::ValidationInitiator.call(user:, response:, contract_name:) + end end end end