diff --git a/src/data/test-data.ts b/src/data/test-data.ts index 62358a2..6e4947d 100644 --- a/src/data/test-data.ts +++ b/src/data/test-data.ts @@ -1,8 +1,8 @@ import { AIRLINES } from './constants'; import { faker } from '@faker-js/faker'; -import type { FlightRequestData } from '../interfaces/flight-request.interface'; -import type { PassengerData } from '../interfaces/passenger.interface'; -import type { FlightLegData } from '../interfaces/flight-leg.interface'; +import type { FlightRequestData } from '../interfaces/requests/flight-request.interface'; +import type { PassengerData } from '../interfaces/passenger/passenger.interface'; +import type { FlightLegData } from '../interfaces/legs/flight-leg.interface'; /** * Creates a test passenger data object with random data diff --git a/src/interfaces/flight-leg.interface.ts b/src/interfaces/legs/flight-leg.interface.ts similarity index 100% rename from src/interfaces/flight-leg.interface.ts rename to src/interfaces/legs/flight-leg.interface.ts diff --git a/src/interfaces/legs/trimmed-flight-leg.interface.ts b/src/interfaces/legs/trimmed-flight-leg.interface.ts new file mode 100644 index 0000000..d057aaa --- /dev/null +++ b/src/interfaces/legs/trimmed-flight-leg.interface.ts @@ -0,0 +1,27 @@ +export interface TrimmedFlightLeg { + id: string; + createdTime: string; + Status: string; + Airline: string; + 'Departure Date/Time': string; + 'Arrival Date/Time': string; + 'Nautical Miles': number; + Passengers: string[]; + 'Departure Airport': string; + 'Arrival Airport': string; + 'Leg ID': string; + 'Leg Type': string; + 'Total Miles': number; + 'Passenger Names': string | string[]; + 'Total Cost': number; + 'AirTable Record ID': string; + 'Request AirTable Record ID': string[]; + 'Passenger AirTable Record IDs': string | string[]; + 'Log Airline Credit': { + label: string; + url: string; + }; + 'Patient Name': string[]; + 'Patient Latest Trip': string[]; + 'Is Latest Trip': string; +} diff --git a/src/interfaces/passenger.interface.ts b/src/interfaces/passenger/passenger.interface.ts similarity index 100% rename from src/interfaces/passenger.interface.ts rename to src/interfaces/passenger/passenger.interface.ts diff --git a/src/interfaces/passenger/trimmed-passenger.interface.ts b/src/interfaces/passenger/trimmed-passenger.interface.ts new file mode 100644 index 0000000..25a6d11 --- /dev/null +++ b/src/interfaces/passenger/trimmed-passenger.interface.ts @@ -0,0 +1,27 @@ +export interface TrimmedPassenger { + id: string; + createdTime: string; + Type: string; + 'First Name': string; + 'Last Name': string; + 'Date of Birth': string; + Gender: string; + Street: string; + Country: string; + Email: string; + 'Household Income': number; + 'Household Size': number; + Ethnicity: string[]; + 'Military Service': string; + 'Military Member': string[]; + 'How did you hear about us': string[]; + 'All Flight Legs': string[]; + Diagnosis: string[]; + 'AirTable Record ID': string; + '# of Flight Legs': number; + '# of Booked Flight Requests': number; + 'Birth Month': string; + 'Full Name': string; + Age: number; + 'Latest Trip': string; +} diff --git a/src/interfaces/flight-request.interface.ts b/src/interfaces/requests/flight-request.interface.ts similarity index 100% rename from src/interfaces/flight-request.interface.ts rename to src/interfaces/requests/flight-request.interface.ts diff --git a/src/interfaces/requests/trimmed-flight-request.interface.ts b/src/interfaces/requests/trimmed-flight-request.interface.ts new file mode 100644 index 0000000..30f04a3 --- /dev/null +++ b/src/interfaces/requests/trimmed-flight-request.interface.ts @@ -0,0 +1,56 @@ +export interface TrimmedFlightRequest { + id: string; + createdTime: string; + 'Submission ID': string; + 'Trip Type': string; + 'Departure Date': string; + 'Request Type': string; + 'Household Size': number; + 'Passenger 2 Approval Status': string; + Diagnosis: string; + 'Passenger 3': string[]; + 'Patient Type': string; + Ethnicity: string[]; + 'Treatment City': string; + Education: string; + 'Treatment Phone': string; + 'Submission Date': string; + 'Alt Destination Airport': string; + 'Primary Treatment Doctor': string; + 'Wheelchair?': string; + 'Flight Specialist': string; + 'Appt Date': string; + 'Passenger 3 Approval Status': string; + 'First Request': string; + 'Type of Treatment': string; + 'Passenger 3 Reason': string; + 'Flight Legs': string[]; + Status: string; + 'Oxygen?': string; + 'Origin Airport': string; + 'Treatment Fax': string; + 'Passenger 3 Different Return': string; + Patient: string[]; + 'Passenger 2': string[]; + 'Return Date': string; + 'Treatment Site': string; + 'Treatment State': string; + 'Passenger 3 Return Date': string; + 'Patient Age': number; + 'Passenger 2 Different Return': string; + + 'Destination Airport': string; + 'Alt. Origin Airport': string; + 'AirTable Record ID': string; + 'Patient AirTable Record ID': string[]; + 'Passenger 2 AirTable Record ID': string[]; + + 'Passenger 3 AirTable Record ID': string[]; + 'Passenger AirTable Record IDs': string; + + 'Existing Diagnoses': string[]; + 'Total Nautical Miles': number; + '# of Legs': number; + 'Total # of Legs': number; + 'Request ID': string; +} diff --git a/src/util/trimming/__tests__/Trimming.test.ts b/src/util/trimming/__tests__/Trimming.test.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/util/trimming/flight-legs.ts b/src/util/trimming/flight-legs.ts new file mode 100644 index 0000000..98b5262 --- /dev/null +++ b/src/util/trimming/flight-legs.ts @@ -0,0 +1,38 @@ +import type { FlightLegData } from '../../interfaces/legs/flight-leg.interface'; +import type { TrimmedFlightLeg } from '../../interfaces/legs/trimmed-flight-leg.interface'; + +export const trimRequest = (request: FlightLegData): TrimmedFlightLeg => { + const { id, createdTime, fields } = request; + + const { Status, Airline, Passengers } = fields; + + const trimmedLeg: TrimmedFlightLeg = { + id: id, + createdTime: createdTime, + Status: Status, + Airline: Airline, + 'Departure Date/Time': fields['Departure Date/Time'], + 'Arrival Date/Time': fields['Arrival Date/Time'], + 'Nautical Miles': fields['Nautical Miles'], + Passengers: Passengers, + 'Departure Airport': fields['Departure Airport'], + 'Arrival Airport': fields['Arrival Airport'], + 'Leg ID': fields['Leg ID'], + 'Leg Type': fields['Leg Type'], + 'Total Miles': fields['Total Miles'], + 'Passenger Names': fields['Passenger Names'], + 'Total Cost': fields['Total Cost'], + 'AirTable Record ID': fields['AirTable Record ID'], + 'Request AirTable Record ID': fields['Request AirTable Record ID'], + 'Passenger AirTable Record IDs': fields['Passenger AirTable Record IDs'], + 'Log Airline Credit': { + label: fields['Log Airline Credit'].label, + url: fields['Log Airline Credit'].url, + }, + 'Patient Name': fields['Patient Name'], + 'Patient Latest Trip': fields['Patient Latest Trip'], + 'Is Latest Trip': fields['Is Latest Trip'], + }; + + return trimmedLeg; +}; diff --git a/src/util/trimming/flight-requests.ts b/src/util/trimming/flight-requests.ts new file mode 100644 index 0000000..13d0a60 --- /dev/null +++ b/src/util/trimming/flight-requests.ts @@ -0,0 +1,64 @@ +import type { FlightRequestData } from '../../interfaces/requests/flight-request.interface'; +import type { TrimmedFlightRequest } from '../../interfaces/requests/trimmed-flight-request.interface'; + +export const trimRequest = (request: FlightRequestData): TrimmedFlightRequest => { + const { id, createdTime, fields } = request; + + const { Diagnosis, Ethnicity, Education, Status, Patient } = fields; + + const trimmedRequest: TrimmedFlightRequest = { + id: id, + createdTime: createdTime, + 'Submission ID': fields['Submission ID'], + 'Trip Type': fields['Trip Type'], + 'Departure Date': fields['Departure Date'], + 'Request Type': fields['Request Type'], + 'Household Size': fields['Household Size'], + 'Passenger 2 Approval Status': fields['Passenger 2 Approval Status'], + Diagnosis: Diagnosis, + 'Passenger 3': fields['Passenger 3'], + 'Patient Type': fields['Patient Type'], + Ethnicity: Ethnicity, + 'Treatment City': fields['Treatment City'], + Education: Education, + 'Treatment Phone': fields['Treatment Phone'], + 'Submission Date': fields['Submission Date'], + 'Alt Destination Airport': fields['Alt Destination Airport'], + 'Primary Treatment Doctor': fields['Primary Treatment Doctor'], + 'Wheelchair?': fields['Wheelchair?'], + 'Flight Specialist': fields['Flight Specialist'], + 'Appt Date': fields['Appt Date'], + 'Passenger 3 Approval Status': fields['Passenger 3 Approval Status'], + 'First Request': fields['First Request'], + 'Type of Treatment': fields['Type of Treatment'], + 'Passenger 3 Reason': fields['Passenger 3 Reason'], + 'Flight Legs': fields['Flight Legs'], + Status: Status, + 'Oxygen?': fields['Oxygen?'], + 'Origin Airport': fields['Origin Airport'], + 'Treatment Fax': fields['Treatment Fax'], + 'Passenger 3 Different Return': fields['Passenger 3 Different Return'], + Patient: Patient, + 'Passenger 2': fields['Passenger 2'], + 'Return Date': fields['Return Date'], + 'Treatment Site': fields['Treatment Site'], + 'Treatment State': fields['Treatment State'], + 'Passenger 3 Return Date': fields['Passenger 3 Return Date'], + 'Patient Age': fields['Patient Age'], + 'Passenger 2 Different Return': fields['Passenger 2 Different Return'], + 'Destination Airport': fields['Destination Airport'], + 'Alt. Origin Airport': fields['Alt. Origin Airport'], + 'AirTable Record ID': fields['AirTable Record ID'], + 'Patient AirTable Record ID': fields['Patient AirTable Record ID'], + 'Passenger 2 AirTable Record ID': fields['Passenger 2 AirTable Record ID'], + 'Passenger 3 AirTable Record ID': fields['Passenger 3 AirTable Record ID'], + 'Passenger AirTable Record IDs': fields['Passenger AirTable Record IDs'], + 'Existing Diagnoses': fields['Existing Diagnoses'], + 'Total Nautical Miles': fields['Total Nautical Miles'], + '# of Legs': fields['# of Legs'], + 'Total # of Legs': fields['Total # of Legs'], + 'Request ID': fields['Request ID'], + }; + + return trimmedRequest; +}; diff --git a/src/util/trimming/passengers.ts b/src/util/trimming/passengers.ts new file mode 100644 index 0000000..e101c63 --- /dev/null +++ b/src/util/trimming/passengers.ts @@ -0,0 +1,39 @@ +import type { PassengerData } from '../../interfaces/passenger/passenger.interface'; +import type { TrimmedPassenger } from '../../interfaces/passenger/trimmed-passenger.interface'; + +export const trimPassenger = (passenger: PassengerData): TrimmedPassenger => { + const { id, createdTime, fields } = passenger; + + const { Type, Gender, Street, Country, Email, Ethnicity, Diagnosis, Age } = + fields; + + const trimmedPassenger: TrimmedPassenger = { + id: id, + createdTime: createdTime, + Type: Type, + 'First Name': fields['First Name'], + 'Last Name': fields['Last Name'], + 'Date of Birth': fields['Date of Birth'], + Gender: Gender, + Street: Street, + Country: Country, + Email: Email, + 'Household Income': fields['Household Income'], + 'Household Size': fields['Household Size'], + Ethnicity: Ethnicity, + 'Military Service': fields['Military Service'], + 'Military Member': fields['Military Member'], + 'How did you hear about us': fields['How did you hear about us'], + 'All Flight Legs': fields['All Flight Legs'], + Diagnosis: Diagnosis, + 'AirTable Record ID': fields['AirTable Record ID'], + '# of Flight Legs': fields['# of Flight Legs'], + '# of Booked Flight Requests': fields['# of Booked Flight Requests'], + 'Birth Month': fields['Birth Month'], + 'Full Name': fields['Full Name'], + Age: Age, + 'Latest Trip': fields['Latest Trip'], + }; + + return trimmedPassenger; +};