Unverified Commit b320f40b authored by pom421's avatar pom421 Committed by GitHub
Browse files

Dev (#70)

* fix: better management of date pickers in declaration and statistics

* feat: add message on landing page from new table messages

* feat(test): add unit test for login page

* feat: add seed example for messages table

* feat(knex): add del for messages table

* feat(knex): seed for messages table in dev env

* feat: change color of welcome message

* feat: check that some hospitals can't do post mortem
parent 0453a0e2
Pipeline #54457 failed with stages
in 7 minutes and 47 seconds
......@@ -5,6 +5,7 @@ Array [
Object {
"addr1": "2 BD TONNELLE",
"addr2": "",
"canDoPostMortem": true,
"depCode": "37",
"finesseNumber": "370000481",
"id": 1,
......
......@@ -10,6 +10,7 @@ describe("", () => {
"email": "acte@tours.fr",
"firstName": "Utilisateur de Tours",
"hospital": Object {
"canDoPostMortem": true,
"id": 1,
"name": "CHRU de Tours",
},
......@@ -29,6 +30,7 @@ describe("", () => {
"email": "acte@tours.fr",
"firstName": "Utilisateur de Tours",
"hospital": Object {
"canDoPostMortem": true,
"id": 1,
"name": "CHRU de Tours",
},
......
......@@ -6,7 +6,10 @@ import { Col, Row } from "reactstrap"
import { periodOfDayValues, getSituationDate } from "../../utils/actsConstants"
import ColumnAct from "../../components/ColumnAct"
const DeceasedEdit = ({ dispatch, state, errors }) => {
const examinationsUMJ = ["Examen externe", "Levée de corps"]
const examinationsIML = [...examinationsUMJ, "Autopsie", "Anthropologie", "Odontologie"]
const DeceasedEdit = ({ dispatch, state, errors, hospital }) => {
const situationDate = getSituationDate(state.examinationDate)
const periods = periodOfDayValues[situationDate].period.map((elt) => ({ title: elt.title, subTitle: elt.subTitle }))
......@@ -15,7 +18,7 @@ const DeceasedEdit = ({ dispatch, state, errors }) => {
<ActBlock
type="examinationTypes"
title="Type(s) d'acte"
values={["Examen externe", "Levée de corps", "Autopsie", "Anthropologie", "Odontologie"]}
values={hospital?.canDoPostMortem ? examinationsIML : examinationsUMJ}
mode="toggleMultiple"
dispatch={dispatch}
state={state.examinationTypes || []}
......@@ -132,6 +135,7 @@ DeceasedEdit.propTypes = {
dispatch: PropTypes.func.isRequired,
state: PropTypes.object.isRequired,
errors: PropTypes.object,
hospital: PropTypes.object,
}
export default {
......
......@@ -12,7 +12,7 @@ exports.seed = function (knex) {
town: "Tours",
dep_code: "37",
postal_code: "37044",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 2,
......@@ -23,7 +23,7 @@ exports.seed = function (knex) {
town: "Orléans",
dep_code: "45",
postal_code: "45067",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 3,
......@@ -34,7 +34,7 @@ exports.seed = function (knex) {
town: "Nantes",
dep_code: "44",
postal_code: "44093",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 4,
......@@ -45,7 +45,7 @@ exports.seed = function (knex) {
town: "Angers",
dep_code: "49",
postal_code: "49933",
extra_data: null,
extra_data: '{"canDoPostMortem": false}',
},
{
id: 5,
......@@ -56,7 +56,7 @@ exports.seed = function (knex) {
town: "Créteil",
dep_code: "94",
postal_code: "94010",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 6,
......@@ -67,7 +67,7 @@ exports.seed = function (knex) {
town: "Lille",
dep_code: "59",
postal_code: "59037",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 7,
......@@ -78,7 +78,7 @@ exports.seed = function (knex) {
town: "Paris",
dep_code: "75",
postal_code: "75181",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 8,
......@@ -89,7 +89,7 @@ exports.seed = function (knex) {
town: "Pointe-à-Pitre",
dep_code: "970",
postal_code: "97004",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 10,
......@@ -100,7 +100,7 @@ exports.seed = function (knex) {
town: "Fort-de-France",
dep_code: "972",
postal_code: "97261",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 13,
......@@ -111,7 +111,7 @@ exports.seed = function (knex) {
town: "Saint-Denis",
dep_code: "974",
postal_code: "97400",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 14,
......@@ -122,7 +122,7 @@ exports.seed = function (knex) {
town: "Rennes",
dep_code: "35",
postal_code: "35000",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 15,
......@@ -133,7 +133,7 @@ exports.seed = function (knex) {
town: "Montpellier",
dep_code: "34",
postal_code: "34090",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 11,
......
......@@ -12,7 +12,7 @@ exports.seed = function (knex) {
town: "Tours",
dep_code: "37",
postal_code: "37044",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 2,
......@@ -23,7 +23,7 @@ exports.seed = function (knex) {
town: "Orléans",
dep_code: "45",
postal_code: "45067",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 3,
......@@ -34,7 +34,7 @@ exports.seed = function (knex) {
town: "Nantes",
dep_code: "44",
postal_code: "44093",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 4,
......@@ -45,7 +45,7 @@ exports.seed = function (knex) {
town: "Angers",
dep_code: "49",
postal_code: "49933",
extra_data: null,
extra_data: '{"canDoPostMortem": false}',
},
{
id: 5,
......@@ -56,7 +56,7 @@ exports.seed = function (knex) {
town: "Créteil",
dep_code: "94",
postal_code: "94010",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 6,
......@@ -67,7 +67,7 @@ exports.seed = function (knex) {
town: "Lille",
dep_code: "59",
postal_code: "59037",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 7,
......@@ -78,7 +78,7 @@ exports.seed = function (knex) {
town: "Paris",
dep_code: "75",
postal_code: "75181",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 8,
......@@ -89,7 +89,7 @@ exports.seed = function (knex) {
town: "Pointe-à-Pitre",
dep_code: "970",
postal_code: "97004",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 10,
......@@ -100,7 +100,7 @@ exports.seed = function (knex) {
town: "Fort-de-France",
dep_code: "972",
postal_code: "97261",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 13,
......@@ -111,7 +111,7 @@ exports.seed = function (knex) {
town: "Saint-Denis",
dep_code: "974",
postal_code: "97400",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 14,
......@@ -122,7 +122,7 @@ exports.seed = function (knex) {
town: "Rennes",
dep_code: "35",
postal_code: "35000",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 15,
......@@ -133,7 +133,7 @@ exports.seed = function (knex) {
town: "Montpellier",
dep_code: "34",
postal_code: "34090",
extra_data: null,
extra_data: '{"canDoPostMortem": true}',
},
{
id: 11,
......
......@@ -19,6 +19,7 @@ export const transform = (knexData) => {
: {
id: knexData.hospital_id,
name: knexData.hospital_name || "",
...knexData.hospital_extra_data,
},
}
}
......
......@@ -201,7 +201,7 @@ const ActDeclaration = ({ act, currentUser }) => {
)
const getProfiledRender = ({ profile }) => {
return profiles[profile].edit({ dispatch, state, errors })
return profiles[profile].edit({ dispatch, state, errors, hospital })
}
const validAndSubmitAct = async () => {
......
......@@ -4,7 +4,11 @@ import { APIError } from "../../utils/errors"
import { untransform } from "../../models/acts"
const examinationsOnlyIML = ["Autopsie", "Anthropologie", "Odontologie"]
export const create = async (data, currentUser) => {
console.log("create -> currentUser", currentUser)
console.log("create -> data", data)
if (!data || !data.hospitalId) {
throw new APIError({
status: STATUS_400_BAD_REQUEST,
......@@ -12,6 +16,18 @@ export const create = async (data, currentUser) => {
})
}
// examinations are limited for UMJ structures for deceased profile
if (data?.profile === "Personne décédée" && !currentUser?.hospital?.canDoPostMortem) {
data?.examinationTypes.forEach((elt) => {
if (examinationsOnlyIML.includes(elt)) {
throw new APIError({
status: STATUS_400_BAD_REQUEST,
message: "Bad request",
})
}
})
}
if (data.hospitalId !== (currentUser.hospital && currentUser.hospital.id)) {
throw new APIError({
status: STATUS_401_UNAUTHORIZED,
......
......@@ -32,6 +32,7 @@ export const authenticate = async (email, password) => {
"users.role",
"users.hospital_id",
"hospitals.name as hospital_name",
"hospitals.extra_data as hospital_extra_data",
"users.scope"
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment