Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
sneko committed Oct 10, 2023
2 parents e900f33 + 5467d35 commit bda9684
Show file tree
Hide file tree
Showing 52 changed files with 1,733 additions and 258 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- CreateEnum
CREATE TYPE "CitizenRepresentation" AS ENUM ('INDIVIDUAL', 'BUSINESS', 'PUBLIC_INSTITUTION', 'AUTHORITY', 'ASSOCIATION', 'OTHER');

-- CreateEnum
CREATE TYPE "CaseOriginator" AS ENUM ('CITIZEN', 'ADMINISTRATIVE_COURT', 'INTERNAL_DEPARTMENT', 'AUTHORITY_REPRESENTATIVE', 'RIGHTS_DEFENDER', 'AGENT', 'OTHER');

-- AlterTable
ALTER TABLE "Case" ADD COLUMN "initiatedBy" "CaseOriginator";

-- AlterTable
ALTER TABLE "Citizen" ADD COLUMN "representation" "CitizenRepresentation";
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
-- Update the case analytics view manually since Prisma does not handle view update for now
-- (we have to rewrite the whole query... :p)

-- pre-delete is required since "assigned" column has been removed
DROP VIEW "CaseAnalytics";

CREATE OR REPLACE VIEW "CaseAnalytics" AS
SELECT
"Case"."humanId" as "humanId",
"Authority"."id" as "authorityId",
"Authority"."name" as "authorityName",
"Authority"."type" as "authorityType",
"Case"."createdAt" as "createdAt",
"Case"."updatedAt" as "updatedAt",
"Case"."closedAt" as "closedAt",
"Case"."status" as "status",
"Case"."initiatedFrom" as "initiatedFrom",
"Case"."initiatedBy" as "initiatedBy",
"Case"."alreadyRequestedInThePast" as "alreadyRequestedInThePast",
"Case"."gotAnswerFromPreviousRequest" as "gotAnswerFromPreviousRequest",
("Citizen"."email" IS NOT NULL) as "citizenHasEmail",
"Address"."city" as "citizenCity",
"Address"."postalCode" as "citizenPostalCode",
"Address"."countryCode" as "citizenCountryCode",
CASE
WHEN ("ParentCaseDomainItem"."id" IS NOT NULL) THEN "ParentCaseDomainItem"."name"
WHEN ("TargetedCaseDomainItem"."id" IS NOT NULL) THEN "TargetedCaseDomainItem"."name"
ELSE NULL
END as "primaryDomain",
CASE
WHEN ("ParentCaseDomainItem"."id" IS NOT NULL) THEN "TargetedCaseDomainItem"."name"
ELSE NULL
END as "secondaryDomain",
"Case"."outcome" as "outcome",
"Case"."collectiveAgreement" as "collectiveAgreement",
"Case"."administrativeCourtNext" as "administrativeCourtNext",
"Citizen"."genderIdentity" as "citizenGenderIdentity",
"Case"."termReminderAt" as "termReminderAt",
"Case"."competent" as "competent",
CASE
WHEN ("ParentCaseCompetentThirdPartyItem"."id" IS NOT NULL) THEN "ParentCaseCompetentThirdPartyItem"."name"
WHEN ("TargetedCaseCompetentThirdPartyItem"."id" IS NOT NULL) THEN "TargetedCaseCompetentThirdPartyItem"."name"
ELSE NULL
END as "primaryCompetentThirdParty",
CASE
WHEN ("ParentCaseCompetentThirdPartyItem"."id" IS NOT NULL) THEN "TargetedCaseCompetentThirdPartyItem"."name"
ELSE NULL
END as "secondaryCompetentThirdParty",
"Case"."faceToFaceMediation" as "faceToFaceMediation",
"Citizen"."representation" as "citizenRepresentation",
CASE
WHEN ("Case"."agentId" IS NOT NULL) THEN "AgentUser"."firstname" || ' ' || "AgentUser"."lastname"
ELSE NULL
END as "assignee"
FROM "Case"
LEFT JOIN "Authority"
ON "Case"."authorityId" = "Authority"."id"
LEFT JOIN "Agent"
ON "Case"."agentId" = "Agent"."id"
LEFT JOIN "User" as "AgentUser"
ON "Agent"."userId" = "AgentUser"."id"
LEFT JOIN "Citizen"
ON "Case"."citizenId" = "Citizen"."id"
LEFT JOIN "Address"
ON "Citizen"."addressId" = "Address"."id"
LEFT JOIN "CaseDomainItem" as "TargetedCaseDomainItem"
ON "Case"."domainId" = "TargetedCaseDomainItem"."id"
LEFT JOIN "CaseDomainItem" as "ParentCaseDomainItem"
ON "TargetedCaseDomainItem"."parentItemId" = "ParentCaseDomainItem"."id"
LEFT JOIN "CaseCompetentThirdPartyItem" as "TargetedCaseCompetentThirdPartyItem"
ON "Case"."domainId" = "TargetedCaseCompetentThirdPartyItem"."id"
LEFT JOIN "CaseCompetentThirdPartyItem" as "ParentCaseCompetentThirdPartyItem"
ON "TargetedCaseCompetentThirdPartyItem"."parentItemId" = "ParentCaseCompetentThirdPartyItem"."id";
34 changes: 32 additions & 2 deletions apps/main/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,29 @@ model Phone {
Citizen Citizen?
}

/// @@Gen.model(hide: true)
enum CitizenGenderIdentity {
MALE
FEMALE
NON_BINARY
}

/// @@Gen.model(hide: true)
enum CitizenRepresentation {
INDIVIDUAL
BUSINESS
PUBLIC_INSTITUTION
AUTHORITY
ASSOCIATION
OTHER
}

/// @@Gen.model(hide: true)
model Citizen {
id String @id @default(uuid()) @db.Uuid
email String?
genderIdentity CitizenGenderIdentity?
representation CitizenRepresentation?
firstname String
lastname String
addressId String? @unique @db.Uuid
Expand Down Expand Up @@ -231,6 +243,17 @@ enum CaseInitialPlatform {
WEB
}

/// @@Gen.model(hide: true)
enum CaseOriginator {
CITIZEN
ADMINISTRATIVE_COURT
INTERNAL_DEPARTMENT
AUTHORITY_REPRESENTATIVE
RIGHTS_DEFENDER
AGENT
OTHER
}

/// @@Gen.model(hide: true)
model CaseDomainItem {
id String @id @default(uuid()) @db.Uuid
Expand Down Expand Up @@ -293,6 +316,7 @@ model Case {
emailCopyWanted Boolean
termReminderAt DateTime?
initiatedFrom CaseInitialPlatform @default(WEB)
initiatedBy CaseOriginator?
status CaseStatus
domainId String? @db.Uuid
competent Boolean?
Expand Down Expand Up @@ -513,20 +537,26 @@ view CaseAnalytics {
authorityType AuthorityType
createdAt DateTime
updatedAt DateTime
termReminderAt DateTime?
closedAt DateTime?
status CaseStatus
initiatedFrom CaseInitialPlatform
initiatedBy CaseOriginator?
primaryDomain String?
secondaryDomain String?
assigned Boolean
competent Boolean?
primaryCompetentThirdParty String?
secondaryCompetentThirdParty String?
assignee String?
alreadyRequestedInThePast Boolean?
gotAnswerFromPreviousRequest Boolean?
// faceToFaceMediation Boolean
faceToFaceMediation Boolean
outcome CaseOutcome?
collectiveAgreement Boolean?
administrativeCourtNext Boolean?
citizenHasEmail Boolean
citizenGenderIdentity CitizenGenderIdentity?
citizenRepresentation CitizenRepresentation?
citizenCity String?
citizenPostalCode String?
citizenCountryCode String?
Expand Down
75 changes: 75 additions & 0 deletions apps/main/public/assets/features/case_management.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bda9684

Please sign in to comment.