add business model processing

This commit is contained in:
Marcel Arndt
2024-07-15 12:53:11 +02:00
parent 8be07e1f9b
commit 53e945253c
65 changed files with 10638 additions and 6659 deletions
@@ -0,0 +1,4 @@
export enum AttendanceRegistrationEvents {
ClockedIn = 'clocked in',
ClockedOut = 'clocked out',
}
@@ -0,0 +1,6 @@
export enum TraceTypes {
AnomalyAccepted = 'anomaly.accepted',
AnomalyIgnored = 'anomaly.ignored',
TourWarning = 'tour.warning',
TourCritical = 'tour.critical',
}
@@ -1 +1 @@
export const PRISMA_SERVICE_OPTIONS = 'PRISMA_SERVICE_OPTIONS';
export const PRISMA_SERVICE_OPTIONS = 'PRISMA_SERVICE_OPTIONS';
@@ -0,0 +1,19 @@
import { DynamicModule, Global, Module, Provider } from '@nestjs/common';
import { KyselyConfig } from 'kysely';
import { createKyselyProvider } from './kysely-client.factory';
export const KYSELY_CLIENT_PROVIDER_TOKEN = 'KyselyClientProviderToken';
@Global()
@Module({})
export class DatabaseModule {
public static forRoot(config: KyselyConfig): DynamicModule {
const provider: Provider = createKyselyProvider(config);
return {
module: DatabaseModule,
exports: [provider],
providers: [provider],
};
}
}
@@ -0,0 +1,12 @@
import { Provider } from '@nestjs/common';
import { Kysely, KyselyConfig } from 'kysely';
import { KYSELY_CLIENT_PROVIDER_TOKEN } from './database.module';
export const createKyselyClient = <DB>(options: KyselyConfig): Kysely<DB> => {
return new Kysely<DB>(options);
};
export const createKyselyProvider = (options: KyselyConfig): Provider => ({
provide: KYSELY_CLIENT_PROVIDER_TOKEN,
useValue: createKyselyClient(options),
});
@@ -0,0 +1,530 @@
import type { ColumnType } from 'kysely';
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
? ColumnType<S, I | undefined, U>
: ColumnType<T, T | undefined, T>;
export type Timestamp = ColumnType<Date, Date | string, Date | string>;
export const CostTypeVariant = {
NACHTZUSCHLAG: 'NACHTZUSCHLAG',
WOCHENENDZUSCHLAG: 'WOCHENENDZUSCHLAG',
FEIERTAGSZUSCHLAG: 'FEIERTAGSZUSCHLAG',
DESINFEKTIONSZUSCHLAG: 'DESINFEKTIONSZUSCHLAG',
KILOMETERZUSCHLAG: 'KILOMETERZUSCHLAG',
FAHRZEUGZUSCHLAG: 'FAHRZEUGZUSCHLAG',
TSWDIFFERENZIERUNG: 'TSWDIFFERENZIERUNG',
GRUNDPREIS: 'GRUNDPREIS',
} as const;
export type CostTypeVariant =
(typeof CostTypeVariant)[keyof typeof CostTypeVariant];
export const TicketState = {
CREATED: 'CREATED',
APPROVAL_REQUIRED: 'APPROVAL_REQUIRED',
READY: 'READY',
DONE: 'DONE',
BILLABLE: 'BILLABLE',
ARCHIVED: 'ARCHIVED',
} as const;
export type TicketState = (typeof TicketState)[keyof typeof TicketState];
export const TicketValidationState = {
CREATED: 'CREATED',
USER_INTERACTION_REQUIRED: 'USER_INTERACTION_REQUIRED',
TD_UNCERTAIN: 'TD_UNCERTAIN',
DOCUMENTS_MISSING: 'DOCUMENTS_MISSING',
ARCHIVED: 'ARCHIVED',
} as const;
export type TicketValidationState =
(typeof TicketValidationState)[keyof typeof TicketValidationState];
export const ApprovalState = {
UNKNOWN: 'UNKNOWN',
FREE: 'FREE',
REQUIRED: 'REQUIRED',
REQUESTED: 'REQUESTED',
APPROVED: 'APPROVED',
} as const;
export type ApprovalState = (typeof ApprovalState)[keyof typeof ApprovalState];
export type Anomaly = {
id: string;
type: string;
description: string;
groupKey: string;
groupDescription: string;
workedOnBy: string;
sleepTimer: number;
sleepSince: Timestamp | null;
resolvedAt: Timestamp | null;
manuallyResolved: Generated<boolean>;
createdAt: Generated<Timestamp>;
};
export type AttendanceRegistration = {
attendanceRegistrationId: number;
employeeId: number;
personnelNumber: string;
dateTime: Timestamp;
event: string;
};
export type AttendanceRegistrationSource = {
internalId: Generated<string>;
insertedAt: Generated<Timestamp>;
jobId: string;
attendanceRegistrationId: string | null;
employeeId: string | null;
personnelNumber: string | null;
dateTime: string | null;
event: string | null;
};
export type AttendanceRegistrationStaging = {
internalId: Generated<string>;
attendanceRegistrationId: number;
employeeId: number;
dateTime: Timestamp;
event: string;
};
export type AvicennaTenant = {
id: Generated<string>;
healthInsuranceNumber: string;
name: string;
};
export type AvicennaTenantToTariffGroup = {
A: string;
B: string;
};
export type CostType = {
id: Generated<string>;
description: string;
variant: CostTypeVariant;
costAmount: number;
timeRange: string | null;
kmInclusive: number | null;
excludeCarNames: string[];
infectionType: string | null;
tariffId: string | null;
};
export type DyflexisEmployee = {
id: Generated<string>;
userId: string;
firstname: string;
surname: string;
contractStart: string;
contractEnd: string | null;
contractHoursWeek: number;
contractSalaryHour: number;
};
export type Employee = {
id: string;
name: string;
surname: string;
personnelNumber: string | null;
mobile: string | null;
qualification: string | null;
occuptationalHealthExamination: Timestamp | null;
personTransportCertificate: Timestamp | null;
};
export type EmployeeDispoLiveSource = {
internalId: Generated<string>;
insertedAt: Generated<Timestamp>;
jobId: string;
id: string | null;
pScheinAblaufDatum: string | null;
name: string | null;
surname: string | null;
persId: string | null;
importPersId: string | null;
qualifikation: string | null;
};
export type EmployeeDyflexisSource = {
internalId: Generated<string>;
insertedAt: Generated<Timestamp>;
jobId: string;
id: string | null;
firstname: string | null;
surname: string | null;
contract_id: string | null;
contract_start: string | null;
contract_end: string | null;
contract_hours_week: string | null;
contract_salary_hour: string | null;
};
export type EmployeeStaging = {
internalId: Generated<string>;
id: number;
firstname: string;
surname: string;
contractStart: Timestamp;
contractEnd: Timestamp;
contractHoursWeek: number;
contractSalaryHour: number;
personTransportCertificate: Timestamp | null;
qualification: string | null;
};
export type Patient = {
id: string;
surname: string | null;
name: string | null;
street: string | null;
zip: string | null;
city: string | null;
birthday: Timestamp | null;
healthinsuranceId: string | null;
healthinsurance: string | null;
careDegree: string | null;
disabilityMark1: string | null;
disabilityMark2: string | null;
};
export type PatientSource = {
internalId: Generated<string>;
insertedAt: Generated<Timestamp>;
jobId: string;
id: string | null;
surname: string | null;
name: string | null;
street: string | null;
zip: string | null;
city: string | null;
birthday: string | null;
kkId: string | null;
krankenkasse: string | null;
pflegestufe: string | null;
behinderung1: string | null;
behinderung2: string | null;
};
export type PatientStaging = {
internalId: Generated<string>;
id: string | null;
surname: string | null;
name: string | null;
street: string | null;
zip: string | null;
city: string | null;
birthday: Timestamp | null;
healthinsuranceId: string | null;
healthinsurance: string | null;
careDegree: string | null;
disabilityMark1: string | null;
disabilityMark2: string | null;
};
export type PlannedTime = {
id: string;
userId: string;
firstname: string | null;
surname: string | null;
startDate: Timestamp | null;
endDate: Timestamp | null;
department: string | null;
pause: number;
duration: number;
note: string | null;
};
export type PlannedTimeSource = {
internalId: Generated<string>;
insertedAt: Generated<Timestamp>;
jobId: string;
id: string | null;
user_id: string | null;
firstname: string | null;
surname: string | null;
department_id: string | null;
department_name: string | null;
start_date: string | null;
end_date: string | null;
pauze: string | null;
duration: string | null;
deleted: string | null;
mark: string | null;
};
export type PlannedTimeStaging = {
internalId: Generated<string>;
id: number;
employeeId: number;
firstname: string | null;
surname: string | null;
departmentName: string | null;
startDate: Timestamp;
endDate: Timestamp;
deleted: boolean;
mark: string | null;
};
export type SolutionTarget = {
id: Generated<string>;
name: string;
anomalyId: string | null;
};
export type SolutionTargetStep = {
id: Generated<string>;
description: string;
solutionTargetId: string | null;
};
export type Tariff = {
id: Generated<string>;
validFrom: Timestamp | null;
validTo: Timestamp | null;
tariffGroupId: string | null;
};
export type TariffGroup = {
id: Generated<string>;
description: string;
ordinanceType: string;
};
export type Ticket = {
id: Generated<string>;
currentState: TicketValidationState;
notes: string[];
errors: string[];
isUrgent: Generated<boolean>;
urgency: Generated<Timestamp>;
approvalState: ApprovalState | null;
documentInfo: Generated<unknown | null>;
createdAt: Generated<Timestamp>;
};
export type TicketStateHistory = {
id: Generated<string>;
state: TicketValidationState;
createdAt: Generated<Timestamp>;
ticketId: string;
};
export type Tour = {
id: Generated<string>;
done: boolean;
direction: string;
carName: string | null;
operationId: string;
driverId: string | null;
driverName: string | null;
codriverId: string | null;
codriverName: string | null;
patientId: string | null;
patientName: string | null;
patientSurname: string | null;
patientStreet: string | null;
patientZip: string | null;
patientCity: string | null;
healthInsurance: string | null;
healthInsuranceNumber: string | null;
type: string | null;
category: string | null;
transportType: string | null;
ordinanceType: string | null;
rangeEndDate: Timestamp | null;
startInstitution: string | null;
startStreet: string | null;
startZip: string | null;
startCity: string | null;
targetInstitution: string | null;
targetStreet: string | null;
targetZip: string | null;
targetCity: string | null;
startDate: Timestamp;
check: Generated<number>;
occupiedKm: number | null;
totalKm: number | null;
startBegin: string | null;
startEnd: string | null;
target: string | null;
targetBegin: string | null;
empty: string | null;
hasInfection: Generated<boolean>;
infectionName: string | null;
revenueDispoLive: number | null;
billDate: Timestamp | null;
billNumber: string | null;
revenue: Generated<number>;
consumptionCosts: Generated<number>;
revenueDeviation: Generated<number>;
createdAt: Timestamp | null;
deletedAt: Timestamp | null;
ticketId: string | null;
};
export type TourSource = {
internalId: Generated<string>;
insertedAt: Generated<Timestamp>;
jobId: string;
id: string | null;
check: string | null;
createTime: string | null;
empfangenVonId: string | null;
endgen: string | null;
serienId: string | null;
serienKategorName: string | null;
serienKategorie: string | null;
zadStatus: string | null;
abrDate: string | null;
abrNum: string | null;
abrTime: string | null;
ausrueckZeit: string | null;
startTime: string | null;
startDate: string | null;
date: string | null;
date_iso: string | null;
dauergenehmigung: string | null;
direction: string | null;
distanceValue: string | null;
besetztKm: string | null;
gefahren: string | null;
gesamtPreis: string | null;
infektion: string | null;
itDesc: string | null;
itKrz: string | null;
itName: string | null;
kkId: string | null;
krankenkasse: string | null;
patId: string | null;
patName: string | null;
patSurname: string | null;
patStreet: string | null;
patZip: string | null;
patCity: string | null;
startInstitution: string | null;
startStreet: string | null;
startZip: string | null;
startCity: string | null;
targetInstitution: string | null;
targetStreet: string | null;
targetZip: string | null;
targetCity: string | null;
transportKrz: string | null;
transportName: string | null;
transportart: string | null;
verordnungsId: string | null;
verordnungsName: string | null;
type: string | null;
startBegin: string | null;
startEnd: string | null;
frei: string | null;
ziel: string | null;
zielBegin: string | null;
endTime: string | null;
endDate: string | null;
einsatzNummer: string | null;
carName: string | null;
carNo: string | null;
beifahrerName: string | null;
beifahrer: string | null;
fahrerName: string | null;
fahrer: string | null;
color: string | null;
};
export type TourStaging = {
internalId: Generated<string>;
id: string | null;
done: boolean | null;
direction: string | null;
carName: string | null;
operationId: string | null;
driverId: string | null;
driverName: string | null;
codriverId: string | null;
codriverName: string | null;
patientId: string | null;
patientName: string | null;
patientSurname: string | null;
patientStreet: string | null;
patientZip: string | null;
patientCity: string | null;
healthInsurance: string | null;
healthInsuranceNumber: string | null;
type: string | null;
category: string | null;
transportType: string | null;
ordinanceType: string | null;
rangeEndDate: Timestamp | null;
startInstitution: string | null;
startStreet: string | null;
startZip: string | null;
startCity: string | null;
targetInstitution: string | null;
targetStreet: string | null;
targetZip: string | null;
targetCity: string | null;
startDate: Timestamp | null;
check: Generated<number>;
occupiedKm: number | null;
totalKm: number | null;
startBegin: string | null;
startEnd: string | null;
target: string | null;
targetBegin: string | null;
empty: string | null;
hasInfection: Generated<boolean>;
infectionName: string | null;
revenueDispoLive: number | null;
billDate: Timestamp | null;
billNumber: string | null;
revenue: Generated<number>;
revenueDeviation: Generated<number>;
consumptionCosts: Generated<number>;
createdAt: Timestamp | null;
};
export type Trace = {
id: Generated<string>;
type: string;
entityKey: string;
createdAt: Generated<Timestamp>;
};
export type WorkTime = {
id: string;
userId: string;
firstname: string;
surname: string;
startDate: Timestamp | null;
endDate: Timestamp | null;
department: string | null;
pause: number;
duration: number;
};
export type WorkTimeSource = {
internalId: Generated<string>;
insertedAt: Generated<Timestamp>;
jobId: string;
id: string | null;
user_id: string | null;
firstname: string | null;
surname: string | null;
department_id: string | null;
department_name: string | null;
start_date: string | null;
end_date: string | null;
pauze: string | null;
duration: string | null;
};
export type WorkTimeStaging = {
internalId: Generated<string>;
id: number;
employeeId: number;
firstname: string;
surname: string;
departmentName: string | null;
startDate: Timestamp;
endDate: Timestamp;
};
export type DB = {
_AvicennaTenantToTariffGroup: AvicennaTenantToTariffGroup;
Anomaly: Anomaly;
AttendanceRegistration: AttendanceRegistration;
AttendanceRegistrationSource: AttendanceRegistrationSource;
AttendanceRegistrationStaging: AttendanceRegistrationStaging;
AvicennaTenant: AvicennaTenant;
CostType: CostType;
DyflexisEmployee: DyflexisEmployee;
Employee: Employee;
EmployeeDispoLiveSource: EmployeeDispoLiveSource;
EmployeeDyflexisSource: EmployeeDyflexisSource;
EmployeeStaging: EmployeeStaging;
Patient: Patient;
PatientSource: PatientSource;
PatientStaging: PatientStaging;
PlannedTime: PlannedTime;
PlannedTimeSource: PlannedTimeSource;
PlannedTimeStaging: PlannedTimeStaging;
SolutionTarget: SolutionTarget;
SolutionTargetStep: SolutionTargetStep;
Tariff: Tariff;
TariffGroup: TariffGroup;
Ticket: Ticket;
TicketStateHistory: TicketStateHistory;
Tour: Tour;
TourSource: TourSource;
TourStaging: TourStaging;
Trace: Trace;
WorkTime: WorkTime;
WorkTimeSource: WorkTimeSource;
WorkTimeStaging: WorkTimeStaging;
};