v1.1
This commit is contained in:
parent
84a94c2f6b
commit
d429adab19
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
node_modules/
|
||||
*/node_modules/
|
||||
**/node_modules/
|
||||
*/build/
|
||||
**/build/
|
||||
.DS_Store
|
||||
.env
|
||||
File diff suppressed because one or more lines are too long
@ -18,6 +18,31 @@ module.exports = class CentersDBApi {
|
||||
|
||||
name: data.name
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
address: data.address
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
city: data.city
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
state: data.state
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
country: data.country
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
gstin: data.gstin
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
@ -42,6 +67,31 @@ module.exports = class CentersDBApi {
|
||||
name: item.name
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
address: item.address
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
city: item.city
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
state: item.state
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
country: item.country
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
gstin: item.gstin
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
@ -66,6 +116,16 @@ module.exports = class CentersDBApi {
|
||||
|
||||
if (data.name !== undefined) updatePayload.name = data.name;
|
||||
|
||||
if (data.address !== undefined) updatePayload.address = data.address;
|
||||
|
||||
if (data.city !== undefined) updatePayload.city = data.city;
|
||||
|
||||
if (data.state !== undefined) updatePayload.state = data.state;
|
||||
|
||||
if (data.country !== undefined) updatePayload.country = data.country;
|
||||
|
||||
if (data.gstin !== undefined) updatePayload.gstin = data.gstin;
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await centers.update(updatePayload, {transaction});
|
||||
@ -172,6 +232,61 @@ module.exports = class CentersDBApi {
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.address) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'centers',
|
||||
'address',
|
||||
filter.address,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.city) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'centers',
|
||||
'city',
|
||||
filter.city,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.state) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'centers',
|
||||
'state',
|
||||
filter.state,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.country) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'centers',
|
||||
'country',
|
||||
filter.country,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.gstin) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'centers',
|
||||
'gstin',
|
||||
filter.gstin,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.active !== undefined) {
|
||||
where = {
|
||||
...where,
|
||||
|
||||
@ -33,6 +33,21 @@ module.exports = class MachinesDBApi {
|
||||
|
||||
year: data.year
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
subtype: data.subtype
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
softwarename: data.softwarename
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
purchaseyear: data.purchaseyear
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
@ -72,6 +87,21 @@ module.exports = class MachinesDBApi {
|
||||
year: item.year
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
subtype: item.subtype
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
softwarename: item.softwarename
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
purchaseyear: item.purchaseyear
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
@ -102,6 +132,12 @@ module.exports = class MachinesDBApi {
|
||||
|
||||
if (data.year !== undefined) updatePayload.year = data.year;
|
||||
|
||||
if (data.subtype !== undefined) updatePayload.subtype = data.subtype;
|
||||
|
||||
if (data.softwarename !== undefined) updatePayload.softwarename = data.softwarename;
|
||||
|
||||
if (data.purchaseyear !== undefined) updatePayload.purchaseyear = data.purchaseyear;
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await machines.update(updatePayload, {transaction});
|
||||
@ -230,6 +266,28 @@ module.exports = class MachinesDBApi {
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.subtype) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'machines',
|
||||
'subtype',
|
||||
filter.subtype,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.softwarename) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'machines',
|
||||
'softwarename',
|
||||
filter.softwarename,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.yearRange) {
|
||||
const [start, end] = filter.yearRange;
|
||||
|
||||
@ -254,6 +312,30 @@ module.exports = class MachinesDBApi {
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.purchaseyearRange) {
|
||||
const [start, end] = filter.purchaseyearRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
purchaseyear: {
|
||||
...where.purchaseyear,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
purchaseyear: {
|
||||
...where.purchaseyear,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.active !== undefined) {
|
||||
where = {
|
||||
...where,
|
||||
|
||||
267
backend/src/db/api/modalities.js
Normal file
267
backend/src/db/api/modalities.js
Normal file
@ -0,0 +1,267 @@
|
||||
|
||||
const db = require('../models');
|
||||
const crypto = require('crypto');
|
||||
const Utils = require('../utils');
|
||||
|
||||
const Sequelize = db.Sequelize;
|
||||
const Op = Sequelize.Op;
|
||||
|
||||
module.exports = class ModalitiesDBApi {
|
||||
|
||||
static async create(data, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const modalities = await db.modalities.create(
|
||||
{
|
||||
id: data.id || undefined,
|
||||
|
||||
type: data.type
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: data.importHash || null,
|
||||
createdById: currentUser.id,
|
||||
updatedById: currentUser.id,
|
||||
},
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
return modalities;
|
||||
}
|
||||
|
||||
static async bulkImport(data, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
// Prepare data - wrapping individual data transformations in a map() method
|
||||
const modalitiesData = data.map((item, index) => ({
|
||||
id: item.id || undefined,
|
||||
|
||||
type: item.type
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
createdById: currentUser.id,
|
||||
updatedById: currentUser.id,
|
||||
createdAt: new Date(Date.now() + index * 1000),
|
||||
}));
|
||||
|
||||
// Bulk create items
|
||||
const modalities = await db.modalities.bulkCreate(modalitiesData, { transaction });
|
||||
|
||||
return modalities;
|
||||
}
|
||||
|
||||
static async update(id, data, options) {
|
||||
const currentUser = (options && options.currentUser) || {id: null};
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const modalities = await db.modalities.findByPk(id, {}, {transaction});
|
||||
|
||||
const updatePayload = {};
|
||||
|
||||
if (data.type !== undefined) updatePayload.type = data.type;
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await modalities.update(updatePayload, {transaction});
|
||||
|
||||
return modalities;
|
||||
}
|
||||
|
||||
static async deleteByIds(ids, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const modalities = await db.modalities.findAll({
|
||||
where: {
|
||||
id: {
|
||||
[Op.in]: ids,
|
||||
},
|
||||
},
|
||||
transaction,
|
||||
});
|
||||
|
||||
await db.sequelize.transaction(async (transaction) => {
|
||||
for (const record of modalities) {
|
||||
await record.update(
|
||||
{deletedBy: currentUser.id},
|
||||
{transaction}
|
||||
);
|
||||
}
|
||||
for (const record of modalities) {
|
||||
await record.destroy({transaction});
|
||||
}
|
||||
});
|
||||
|
||||
return modalities;
|
||||
}
|
||||
|
||||
static async remove(id, options) {
|
||||
const currentUser = (options && options.currentUser) || {id: null};
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const modalities = await db.modalities.findByPk(id, options);
|
||||
|
||||
await modalities.update({
|
||||
deletedBy: currentUser.id
|
||||
}, {
|
||||
transaction,
|
||||
});
|
||||
|
||||
await modalities.destroy({
|
||||
transaction
|
||||
});
|
||||
|
||||
return modalities;
|
||||
}
|
||||
|
||||
static async findBy(where, options) {
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
const modalities = await db.modalities.findOne(
|
||||
{ where },
|
||||
{ transaction },
|
||||
);
|
||||
|
||||
if (!modalities) {
|
||||
return modalities;
|
||||
}
|
||||
|
||||
const output = modalities.get({plain: true});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static async findAll(filter, options) {
|
||||
const limit = filter.limit || 0;
|
||||
let offset = 0;
|
||||
let where = {};
|
||||
const currentPage = +filter.page;
|
||||
|
||||
const user = (options && options.currentUser) || null;
|
||||
|
||||
offset = currentPage * limit;
|
||||
|
||||
const orderBy = null;
|
||||
|
||||
const transaction = (options && options.transaction) || undefined;
|
||||
|
||||
let include = [];
|
||||
|
||||
if (filter) {
|
||||
if (filter.id) {
|
||||
where = {
|
||||
...where,
|
||||
['id']: Utils.uuid(filter.id),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.type) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'modalities',
|
||||
'type',
|
||||
filter.type,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.active !== undefined) {
|
||||
where = {
|
||||
...where,
|
||||
active: filter.active === true || filter.active === 'true'
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.createdAtRange) {
|
||||
const [start, end] = filter.createdAtRange;
|
||||
|
||||
if (start !== undefined && start !== null && start !== '') {
|
||||
where = {
|
||||
...where,
|
||||
['createdAt']: {
|
||||
...where.createdAt,
|
||||
[Op.gte]: start,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (end !== undefined && end !== null && end !== '') {
|
||||
where = {
|
||||
...where,
|
||||
['createdAt']: {
|
||||
...where.createdAt,
|
||||
[Op.lte]: end,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const queryOptions = {
|
||||
where,
|
||||
include,
|
||||
distinct: true,
|
||||
order: filter.field && filter.sort
|
||||
? [[filter.field, filter.sort]]
|
||||
: [['createdAt', 'desc']],
|
||||
transaction: options?.transaction,
|
||||
logging: console.log
|
||||
};
|
||||
|
||||
if (!options?.countOnly) {
|
||||
queryOptions.limit = limit ? Number(limit) : undefined;
|
||||
queryOptions.offset = offset ? Number(offset) : undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
const { rows, count } = await db.modalities.findAndCountAll(queryOptions);
|
||||
|
||||
return {
|
||||
rows: options?.countOnly ? [] : rows,
|
||||
count: count
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error executing query:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async findAllAutocomplete(query, limit, offset) {
|
||||
let where = {};
|
||||
|
||||
if (query) {
|
||||
where = {
|
||||
[Op.or]: [
|
||||
{ ['id']: Utils.uuid(query) },
|
||||
Utils.ilike(
|
||||
'modalities',
|
||||
'id',
|
||||
query,
|
||||
),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const records = await db.modalities.findAll({
|
||||
attributes: [ 'id', 'id' ],
|
||||
where,
|
||||
limit: limit ? Number(limit) : undefined,
|
||||
offset: offset ? Number(offset) : undefined,
|
||||
orderBy: [['id', 'ASC']],
|
||||
});
|
||||
|
||||
return records.map((record) => ({
|
||||
id: record.id,
|
||||
label: record.id,
|
||||
}));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -38,6 +38,31 @@ module.exports = class PatientsDBApi {
|
||||
|
||||
history: data.history
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
firstname: data.firstname
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
lastname: data.lastname
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
email: data.email
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
contactnumber: data.contactnumber
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
historydescription: data.historydescription
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
@ -82,6 +107,31 @@ module.exports = class PatientsDBApi {
|
||||
history: item.history
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
firstname: item.firstname
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
lastname: item.lastname
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
email: item.email
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
contactnumber: item.contactnumber
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
historydescription: item.historydescription
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
@ -114,6 +164,16 @@ module.exports = class PatientsDBApi {
|
||||
|
||||
if (data.history !== undefined) updatePayload.history = data.history;
|
||||
|
||||
if (data.firstname !== undefined) updatePayload.firstname = data.firstname;
|
||||
|
||||
if (data.lastname !== undefined) updatePayload.lastname = data.lastname;
|
||||
|
||||
if (data.email !== undefined) updatePayload.email = data.email;
|
||||
|
||||
if (data.contactnumber !== undefined) updatePayload.contactnumber = data.contactnumber;
|
||||
|
||||
if (data.historydescription !== undefined) updatePayload.historydescription = data.historydescription;
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await patients.update(updatePayload, {transaction});
|
||||
@ -242,6 +302,61 @@ module.exports = class PatientsDBApi {
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.firstname) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'patients',
|
||||
'firstname',
|
||||
filter.firstname,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.lastname) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'patients',
|
||||
'lastname',
|
||||
filter.lastname,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.email) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'patients',
|
||||
'email',
|
||||
filter.email,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.contactnumber) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'patients',
|
||||
'contactnumber',
|
||||
filter.contactnumber,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.historydescription) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'patients',
|
||||
'historydescription',
|
||||
filter.historydescription,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.ageRange) {
|
||||
const [start, end] = filter.ageRange;
|
||||
|
||||
|
||||
@ -33,6 +33,11 @@ module.exports = class ReportsDBApi {
|
||||
|
||||
ai_suggestions: data.ai_suggestions
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
aisuggestedfindings: data.aisuggestedfindings
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
@ -72,6 +77,11 @@ module.exports = class ReportsDBApi {
|
||||
ai_suggestions: item.ai_suggestions
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
aisuggestedfindings: item.aisuggestedfindings
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
@ -102,6 +112,8 @@ module.exports = class ReportsDBApi {
|
||||
|
||||
if (data.ai_suggestions !== undefined) updatePayload.ai_suggestions = data.ai_suggestions;
|
||||
|
||||
if (data.aisuggestedfindings !== undefined) updatePayload.aisuggestedfindings = data.aisuggestedfindings;
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await reports.update(updatePayload, {transaction});
|
||||
@ -230,6 +242,17 @@ module.exports = class ReportsDBApi {
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.aisuggestedfindings) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'reports',
|
||||
'aisuggestedfindings',
|
||||
filter.aisuggestedfindings,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.dateRange) {
|
||||
const [start, end] = filter.dateRange;
|
||||
|
||||
|
||||
@ -28,6 +28,11 @@ module.exports = class StudiesDBApi {
|
||||
|
||||
must_do_evaluations: data.must_do_evaluations
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
studytype: data.studytype
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
@ -62,6 +67,11 @@ module.exports = class StudiesDBApi {
|
||||
must_do_evaluations: item.must_do_evaluations
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
studytype: item.studytype
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
@ -90,6 +100,8 @@ module.exports = class StudiesDBApi {
|
||||
|
||||
if (data.must_do_evaluations !== undefined) updatePayload.must_do_evaluations = data.must_do_evaluations;
|
||||
|
||||
if (data.studytype !== undefined) updatePayload.studytype = data.studytype;
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await studies.update(updatePayload, {transaction});
|
||||
@ -218,6 +230,17 @@ module.exports = class StudiesDBApi {
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.studytype) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'studies',
|
||||
'studytype',
|
||||
filter.studytype,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.active !== undefined) {
|
||||
where = {
|
||||
...where,
|
||||
|
||||
@ -68,6 +68,10 @@ module.exports = class UsersDBApi {
|
||||
||
|
||||
null,
|
||||
|
||||
agreementtype: data.data.agreementtype
|
||||
||
|
||||
null,
|
||||
|
||||
importHash: data.data.importHash || null,
|
||||
createdById: currentUser.id,
|
||||
updatedById: currentUser.id,
|
||||
@ -146,6 +150,11 @@ module.exports = class UsersDBApi {
|
||||
provider: item.provider
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
agreementtype: item.agreementtype
|
||||
||
|
||||
null
|
||||
,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
@ -210,6 +219,8 @@ module.exports = class UsersDBApi {
|
||||
|
||||
if (data.provider !== undefined) updatePayload.provider = data.provider;
|
||||
|
||||
if (data.agreementtype !== undefined) updatePayload.agreementtype = data.agreementtype;
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
await users.update(updatePayload, {transaction});
|
||||
@ -393,6 +404,17 @@ module.exports = class UsersDBApi {
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.agreementtype) {
|
||||
where = {
|
||||
...where,
|
||||
[Op.and]: Utils.ilike(
|
||||
'users',
|
||||
'agreementtype',
|
||||
filter.agreementtype,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (filter.emailVerificationTokenExpiresAtRange) {
|
||||
const [start, end] = filter.emailVerificationTokenExpiresAtRange;
|
||||
|
||||
|
||||
38
backend/src/db/migrations/1754331079723.js
Normal file
38
backend/src/db/migrations/1754331079723.js
Normal file
@ -0,0 +1,38 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
38
backend/src/db/migrations/1754331124213.js
Normal file
38
backend/src/db/migrations/1754331124213.js
Normal file
@ -0,0 +1,38 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331176110.js
Normal file
54
backend/src/db/migrations/1754331176110.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'users',
|
||||
'agreementtype',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'users',
|
||||
'agreementtype',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331183188.js
Normal file
54
backend/src/db/migrations/1754331183188.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'centers',
|
||||
'address',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'centers',
|
||||
'address',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331202127.js
Normal file
54
backend/src/db/migrations/1754331202127.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'centers',
|
||||
'city',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'centers',
|
||||
'city',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331219661.js
Normal file
54
backend/src/db/migrations/1754331219661.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'centers',
|
||||
'state',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'centers',
|
||||
'state',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331229838.js
Normal file
54
backend/src/db/migrations/1754331229838.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'centers',
|
||||
'country',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'centers',
|
||||
'country',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331243902.js
Normal file
54
backend/src/db/migrations/1754331243902.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'centers',
|
||||
'gstin',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'centers',
|
||||
'gstin',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
38
backend/src/db/migrations/1754331251242.js
Normal file
38
backend/src/db/migrations/1754331251242.js
Normal file
@ -0,0 +1,38 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
91
backend/src/db/migrations/1754331262972.js
Normal file
91
backend/src/db/migrations/1754331262972.js
Normal file
@ -0,0 +1,91 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.createTable('modalities', {
|
||||
id: {
|
||||
type: Sequelize.DataTypes.UUID,
|
||||
defaultValue: Sequelize.DataTypes.UUIDV4,
|
||||
primaryKey: true,
|
||||
},
|
||||
createdById: {
|
||||
type: Sequelize.DataTypes.UUID,
|
||||
references: {
|
||||
key: 'id',
|
||||
model: 'users',
|
||||
},
|
||||
},
|
||||
updatedById: {
|
||||
type: Sequelize.DataTypes.UUID,
|
||||
references: {
|
||||
key: 'id',
|
||||
model: 'users',
|
||||
},
|
||||
},
|
||||
createdAt: { type: Sequelize.DataTypes.DATE },
|
||||
updatedAt: { type: Sequelize.DataTypes.DATE },
|
||||
deletedAt: { type: Sequelize.DataTypes.DATE },
|
||||
importHash: {
|
||||
type: Sequelize.DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
unique: true,
|
||||
},
|
||||
}, { transaction });
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'modalities',
|
||||
'centersId',
|
||||
{
|
||||
type: Sequelize.DataTypes.UUID,
|
||||
|
||||
references: {
|
||||
model: 'centers',
|
||||
key: 'id',
|
||||
},
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'modalities',
|
||||
'centersId',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await queryInterface.dropTable('modalities', { transaction });
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331272529.js
Normal file
54
backend/src/db/migrations/1754331272529.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'modalities',
|
||||
'type',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'modalities',
|
||||
'type',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331278922.js
Normal file
54
backend/src/db/migrations/1754331278922.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'machines',
|
||||
'subtype',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'machines',
|
||||
'subtype',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331294624.js
Normal file
54
backend/src/db/migrations/1754331294624.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'machines',
|
||||
'softwarename',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'machines',
|
||||
'softwarename',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331311845.js
Normal file
54
backend/src/db/migrations/1754331311845.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'patients',
|
||||
'firstname',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'patients',
|
||||
'firstname',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331321788.js
Normal file
54
backend/src/db/migrations/1754331321788.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'patients',
|
||||
'lastname',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'patients',
|
||||
'lastname',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331337651.js
Normal file
54
backend/src/db/migrations/1754331337651.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'patients',
|
||||
'email',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'patients',
|
||||
'email',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331354217.js
Normal file
54
backend/src/db/migrations/1754331354217.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'patients',
|
||||
'contactnumber',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'patients',
|
||||
'contactnumber',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331369993.js
Normal file
54
backend/src/db/migrations/1754331369993.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'patients',
|
||||
'historydescription',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'patients',
|
||||
'historydescription',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
38
backend/src/db/migrations/1754331388868.js
Normal file
38
backend/src/db/migrations/1754331388868.js
Normal file
@ -0,0 +1,38 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331454908.js
Normal file
54
backend/src/db/migrations/1754331454908.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'machines',
|
||||
'purchaseyear',
|
||||
{
|
||||
type: Sequelize.DataTypes.INTEGER,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'machines',
|
||||
'purchaseyear',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331467963.js
Normal file
54
backend/src/db/migrations/1754331467963.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'studies',
|
||||
'studytype',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'studies',
|
||||
'studytype',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
54
backend/src/db/migrations/1754331477066.js
Normal file
54
backend/src/db/migrations/1754331477066.js
Normal file
@ -0,0 +1,54 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.addColumn(
|
||||
'reports',
|
||||
'aisuggestedfindings',
|
||||
{
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {QueryInterface} queryInterface
|
||||
* @param {Sequelize} Sequelize
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
/**
|
||||
* @type {Transaction}
|
||||
*/
|
||||
const transaction = await queryInterface.sequelize.transaction();
|
||||
try {
|
||||
|
||||
await queryInterface.removeColumn(
|
||||
'reports',
|
||||
'aisuggestedfindings',
|
||||
{ transaction }
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (err) {
|
||||
await transaction.rollback();
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -19,6 +19,31 @@ name: {
|
||||
|
||||
},
|
||||
|
||||
address: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
city: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
state: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
country: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
gstin: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
|
||||
@ -34,6 +34,21 @@ year: {
|
||||
|
||||
},
|
||||
|
||||
subtype: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
softwarename: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
purchaseyear: {
|
||||
type: DataTypes.INTEGER,
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
|
||||
48
backend/src/db/models/modalities.js
Normal file
48
backend/src/db/models/modalities.js
Normal file
@ -0,0 +1,48 @@
|
||||
const config = require('../../config');
|
||||
const providers = config.providers;
|
||||
const crypto = require('crypto');
|
||||
const bcrypt = require('bcrypt');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = function(sequelize, DataTypes) {
|
||||
const modalities = sequelize.define(
|
||||
'modalities',
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true,
|
||||
},
|
||||
|
||||
type: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
unique: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
paranoid: true,
|
||||
freezeTableName: true,
|
||||
},
|
||||
);
|
||||
|
||||
modalities.associate = (db) => {
|
||||
|
||||
db.modalities.belongsTo(db.users, {
|
||||
as: 'createdBy',
|
||||
});
|
||||
|
||||
db.modalities.belongsTo(db.users, {
|
||||
as: 'updatedBy',
|
||||
});
|
||||
};
|
||||
|
||||
return modalities;
|
||||
};
|
||||
|
||||
@ -49,6 +49,31 @@ history: {
|
||||
|
||||
},
|
||||
|
||||
firstname: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
lastname: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
email: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
contactnumber: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
historydescription: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
|
||||
@ -34,6 +34,11 @@ ai_suggestions: {
|
||||
|
||||
},
|
||||
|
||||
aisuggestedfindings: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
|
||||
@ -29,6 +29,11 @@ must_do_evaluations: {
|
||||
|
||||
},
|
||||
|
||||
studytype: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
|
||||
@ -80,6 +80,11 @@ provider: {
|
||||
|
||||
},
|
||||
|
||||
agreementtype: {
|
||||
type: DataTypes.TEXT,
|
||||
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
|
||||
71
backend/src/db/seeders/20250804181422.js
Normal file
71
backend/src/db/seeders/20250804181422.js
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
const { v4: uuid } = require("uuid");
|
||||
const db = require('../models');
|
||||
const Sequelize = require('sequelize');
|
||||
const config = require("../../config");
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* @param{import("sequelize").QueryInterface} queryInterface
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async up(queryInterface) {
|
||||
const createdAt = new Date();
|
||||
const updatedAt = new Date();
|
||||
|
||||
/** @type {Map<string, string>} */
|
||||
const idMap = new Map();
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @return {string}
|
||||
*/
|
||||
function getId(key) {
|
||||
if (idMap.has(key)) {
|
||||
return idMap.get(key);
|
||||
}
|
||||
const id = uuid();
|
||||
idMap.set(key, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
function createPermissions(name) {
|
||||
return [
|
||||
{ id: getId(`CREATE_${name.toUpperCase()}`), createdAt, updatedAt, name: `CREATE_${name.toUpperCase()}` },
|
||||
{ id: getId(`READ_${name.toUpperCase()}`), createdAt, updatedAt, name: `READ_${name.toUpperCase()}` },
|
||||
{ id: getId(`UPDATE_${name.toUpperCase()}`), createdAt, updatedAt, name: `UPDATE_${name.toUpperCase()}` },
|
||||
{ id: getId(`DELETE_${name.toUpperCase()}`), createdAt, updatedAt, name: `DELETE_${name.toUpperCase()}` }
|
||||
];
|
||||
}
|
||||
|
||||
const entities = [
|
||||
|
||||
"modalities",
|
||||
|
||||
];
|
||||
|
||||
const createdPermissions = entities.flatMap(createPermissions);
|
||||
|
||||
// Add permissions to database
|
||||
await queryInterface.bulkInsert("permissions", createdPermissions);
|
||||
// Get permissions ids
|
||||
const permissionsIds = createdPermissions.map((p) => p.id);
|
||||
// Get admin role
|
||||
const adminRole = await db.roles.findOne({
|
||||
where: {name: config.roles.super_admin}
|
||||
});
|
||||
|
||||
if (adminRole) {
|
||||
// Add permissions to admin role if it exists
|
||||
await adminRole.addPermissions(permissionsIds);
|
||||
}
|
||||
|
||||
},
|
||||
down: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.bulkDelete("permissions", entities.flatMap(createPermissions));
|
||||
}
|
||||
};
|
||||
|
||||
@ -36,6 +36,8 @@ const permissionsRoutes = require('./routes/permissions');
|
||||
|
||||
const centersRoutes = require('./routes/centers');
|
||||
|
||||
const modalitiesRoutes = require('./routes/modalities');
|
||||
|
||||
const getBaseUrl = (url) => {
|
||||
if (!url) return '';
|
||||
return url.endsWith('/api') ? url.slice(0, -4) : url;
|
||||
@ -112,6 +114,8 @@ app.use('/api/permissions', passport.authenticate('jwt', {session: false}), perm
|
||||
|
||||
app.use('/api/centers', passport.authenticate('jwt', {session: false}), centersRoutes);
|
||||
|
||||
app.use('/api/modalities', passport.authenticate('jwt', {session: false}), modalitiesRoutes);
|
||||
|
||||
app.use(
|
||||
'/api/search',
|
||||
passport.authenticate('jwt', { session: false }),
|
||||
|
||||
@ -20,6 +20,21 @@ const { parse } = require('json2csv');
|
||||
* name:
|
||||
* type: string
|
||||
* default: name
|
||||
* address:
|
||||
* type: string
|
||||
* default: address
|
||||
* city:
|
||||
* type: string
|
||||
* default: city
|
||||
* state:
|
||||
* type: string
|
||||
* default: state
|
||||
* country:
|
||||
* type: string
|
||||
* default: country
|
||||
* gstin:
|
||||
* type: string
|
||||
* default: gstin
|
||||
|
||||
*/
|
||||
|
||||
@ -276,7 +291,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','name',
|
||||
const fields = ['id','name','address','city','state','country','gstin',
|
||||
|
||||
];
|
||||
const opts = { fields };
|
||||
|
||||
@ -26,10 +26,19 @@ const { parse } = require('json2csv');
|
||||
* software_version:
|
||||
* type: string
|
||||
* default: software_version
|
||||
* subtype:
|
||||
* type: string
|
||||
* default: subtype
|
||||
* softwarename:
|
||||
* type: string
|
||||
* default: softwarename
|
||||
|
||||
* year:
|
||||
* type: integer
|
||||
* format: int64
|
||||
* purchaseyear:
|
||||
* type: integer
|
||||
* format: int64
|
||||
|
||||
*/
|
||||
|
||||
@ -286,8 +295,8 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','name','type','software_version',
|
||||
'year',
|
||||
const fields = ['id','name','type','software_version','subtype','softwarename',
|
||||
'year','purchaseyear',
|
||||
|
||||
];
|
||||
const opts = { fields };
|
||||
|
||||
410
backend/src/routes/modalities.js
Normal file
410
backend/src/routes/modalities.js
Normal file
@ -0,0 +1,410 @@
|
||||
|
||||
const express = require('express');
|
||||
|
||||
const ModalitiesService = require('../services/modalities');
|
||||
const ModalitiesDBApi = require('../db/api/modalities');
|
||||
const wrapAsync = require('../helpers').wrapAsync;
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const { parse } = require('json2csv');
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* Modalities:
|
||||
* type: object
|
||||
* properties:
|
||||
|
||||
* type:
|
||||
* type: string
|
||||
* default: type
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Modalities
|
||||
* description: The Modalities managing API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/modalities:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Modalities]
|
||||
* summary: Add new item
|
||||
* description: Add new item
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* properties:
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The item was successfully added
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
* description: Invalid input data
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.post('/', wrapAsync(async (req, res) => {
|
||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||
const link = new URL(referer);
|
||||
await ModalitiesService.create(req.body.data, req.currentUser, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/budgets/bulk-import:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Modalities]
|
||||
* summary: Bulk import items
|
||||
* description: Bulk import items
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* properties:
|
||||
* data:
|
||||
* description: Data of the updated items
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The items were successfully imported
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 405:
|
||||
* description: Invalid input data
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*
|
||||
*/
|
||||
router.post('/bulk-import', wrapAsync(async (req, res) => {
|
||||
const referer = req.headers.referer || `${req.protocol}://${req.hostname}${req.originalUrl}`;
|
||||
const link = new URL(referer);
|
||||
await ModalitiesService.bulkImport(req, res, true, link.host);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/modalities/{id}:
|
||||
* put:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Modalities]
|
||||
* summary: Update the data of the selected item
|
||||
* description: Update the data of the selected item
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* description: Item ID to update
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* requestBody:
|
||||
* description: Set new item data
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* properties:
|
||||
* id:
|
||||
* description: ID of the updated item
|
||||
* type: string
|
||||
* data:
|
||||
* description: Data of the updated item
|
||||
* type: object
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* required:
|
||||
* - id
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The item data was successfully updated
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Item not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.put('/:id', wrapAsync(async (req, res) => {
|
||||
await ModalitiesService.update(req.body.data, req.body.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/modalities/{id}:
|
||||
* delete:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Modalities]
|
||||
* summary: Delete the selected item
|
||||
* description: Delete the selected item
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* description: Item ID to delete
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The item was successfully deleted
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Item not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.delete('/:id', wrapAsync(async (req, res) => {
|
||||
await ModalitiesService.remove(req.params.id, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/modalities/deleteByIds:
|
||||
* post:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Modalities]
|
||||
* summary: Delete the selected item list
|
||||
* description: Delete the selected item list
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* properties:
|
||||
* ids:
|
||||
* description: IDs of the updated items
|
||||
* type: array
|
||||
* responses:
|
||||
* 200:
|
||||
* description: The items was successfully deleted
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Items not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.post('/deleteByIds', wrapAsync(async (req, res) => {
|
||||
await ModalitiesService.deleteByIds(req.body.data, req.currentUser);
|
||||
const payload = true;
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/modalities:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Modalities]
|
||||
* summary: Get all modalities
|
||||
* description: Get all modalities
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Modalities list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Data not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/', wrapAsync(async (req, res) => {
|
||||
const filetype = req.query.filetype
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await ModalitiesDBApi.findAll(
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','type',
|
||||
|
||||
];
|
||||
const opts = { fields };
|
||||
try {
|
||||
const csv = parse(payload.rows, opts);
|
||||
res.status(200).attachment(csv);
|
||||
res.send(csv)
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
} else {
|
||||
res.status(200).send(payload);
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/modalities/count:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Modalities]
|
||||
* summary: Count all modalities
|
||||
* description: Count all modalities
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Modalities count successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Data not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/count', wrapAsync(async (req, res) => {
|
||||
const currentUser = req.currentUser;
|
||||
const payload = await ModalitiesDBApi.findAll(
|
||||
req.query,
|
||||
null,
|
||||
{ countOnly: true, currentUser }
|
||||
);
|
||||
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/modalities/autocomplete:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Modalities]
|
||||
* summary: Find all modalities that match search criteria
|
||||
* description: Find all modalities that match search criteria
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Modalities list successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Data not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/autocomplete', async (req, res) => {
|
||||
const payload = await ModalitiesDBApi.findAllAutocomplete(
|
||||
req.query.query,
|
||||
req.query.limit,
|
||||
req.query.offset,
|
||||
);
|
||||
|
||||
res.status(200).send(payload);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/modalities/{id}:
|
||||
* get:
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* tags: [Modalities]
|
||||
* summary: Get selected item
|
||||
* description: Get selected item
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* description: ID of item to get
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Selected item successfully received
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: "#/components/schemas/Modalities"
|
||||
* 400:
|
||||
* description: Invalid ID supplied
|
||||
* 401:
|
||||
* $ref: "#/components/responses/UnauthorizedError"
|
||||
* 404:
|
||||
* description: Item not found
|
||||
* 500:
|
||||
* description: Some server error
|
||||
*/
|
||||
router.get('/:id', wrapAsync(async (req, res) => {
|
||||
const payload = await ModalitiesDBApi.findBy(
|
||||
{ id: req.params.id },
|
||||
);
|
||||
|
||||
res.status(200).send(payload);
|
||||
}));
|
||||
|
||||
router.use('/', require('../helpers').commonErrorHandler);
|
||||
|
||||
module.exports = router;
|
||||
@ -26,6 +26,21 @@ const { parse } = require('json2csv');
|
||||
* history:
|
||||
* type: string
|
||||
* default: history
|
||||
* firstname:
|
||||
* type: string
|
||||
* default: firstname
|
||||
* lastname:
|
||||
* type: string
|
||||
* default: lastname
|
||||
* email:
|
||||
* type: string
|
||||
* default: email
|
||||
* contactnumber:
|
||||
* type: string
|
||||
* default: contactnumber
|
||||
* historydescription:
|
||||
* type: string
|
||||
* default: historydescription
|
||||
|
||||
* age:
|
||||
* type: integer
|
||||
@ -287,7 +302,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','name','contact','history',
|
||||
const fields = ['id','name','contact','history','firstname','lastname','email','contactnumber','historydescription',
|
||||
'age',
|
||||
|
||||
];
|
||||
|
||||
@ -26,6 +26,9 @@ const { parse } = require('json2csv');
|
||||
* ai_suggestions:
|
||||
* type: string
|
||||
* default: ai_suggestions
|
||||
* aisuggestedfindings:
|
||||
* type: string
|
||||
* default: aisuggestedfindings
|
||||
|
||||
*/
|
||||
|
||||
@ -282,7 +285,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','findings','impression','ai_suggestions',
|
||||
const fields = ['id','findings','impression','ai_suggestions','aisuggestedfindings',
|
||||
|
||||
'date',
|
||||
];
|
||||
|
||||
@ -26,6 +26,9 @@ const { parse } = require('json2csv');
|
||||
* must_do_evaluations:
|
||||
* type: string
|
||||
* default: must_do_evaluations
|
||||
* studytype:
|
||||
* type: string
|
||||
* default: studytype
|
||||
|
||||
*/
|
||||
|
||||
@ -282,7 +285,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','organ','technique','must_do_evaluations',
|
||||
const fields = ['id','organ','technique','must_do_evaluations','studytype',
|
||||
|
||||
];
|
||||
const opts = { fields };
|
||||
|
||||
@ -29,6 +29,9 @@ const { parse } = require('json2csv');
|
||||
* email:
|
||||
* type: string
|
||||
* default: email
|
||||
* agreementtype:
|
||||
* type: string
|
||||
* default: agreementtype
|
||||
|
||||
*/
|
||||
|
||||
@ -285,7 +288,7 @@ router.get('/', wrapAsync(async (req, res) => {
|
||||
req.query, { currentUser }
|
||||
);
|
||||
if (filetype && filetype === 'csv') {
|
||||
const fields = ['id','firstName','lastName','phoneNumber','email',
|
||||
const fields = ['id','firstName','lastName','phoneNumber','email','agreementtype',
|
||||
|
||||
];
|
||||
const opts = { fields };
|
||||
|
||||
131
backend/src/services/modalities.js
Normal file
131
backend/src/services/modalities.js
Normal file
@ -0,0 +1,131 @@
|
||||
const db = require('../db/models');
|
||||
const ModalitiesDBApi = require('../db/api/modalities');
|
||||
const processFile = require("../middlewares/upload");
|
||||
const ValidationError = require('./notifications/errors/validation');
|
||||
const csv = require('csv-parser');
|
||||
const axios = require('axios');
|
||||
const config = require('../config');
|
||||
const stream = require('stream');
|
||||
|
||||
module.exports = class ModalitiesService {
|
||||
static async create(data, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
await ModalitiesDBApi.create(
|
||||
data,
|
||||
{
|
||||
currentUser,
|
||||
transaction,
|
||||
},
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
static async bulkImport(req, res, sendInvitationEmails = true, host) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await processFile(req, res);
|
||||
const bufferStream = new stream.PassThrough();
|
||||
const results = [];
|
||||
|
||||
await bufferStream.end(Buffer.from(req.file.buffer, "utf-8")); // convert Buffer to Stream
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
bufferStream
|
||||
.pipe(csv())
|
||||
.on('data', (data) => results.push(data))
|
||||
.on('end', async () => {
|
||||
console.log('CSV results', results);
|
||||
resolve();
|
||||
})
|
||||
.on('error', (error) => reject(error));
|
||||
})
|
||||
|
||||
await ModalitiesDBApi.bulkImport(results, {
|
||||
transaction,
|
||||
ignoreDuplicates: true,
|
||||
validate: true,
|
||||
currentUser: req.currentUser
|
||||
});
|
||||
|
||||
await transaction.commit();
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async update(data, id, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
try {
|
||||
let modalities = await ModalitiesDBApi.findBy(
|
||||
{id},
|
||||
{transaction},
|
||||
);
|
||||
|
||||
if (!modalities) {
|
||||
throw new ValidationError(
|
||||
'modalitiesNotFound',
|
||||
);
|
||||
}
|
||||
|
||||
const updatedModalities = await ModalitiesDBApi.update(
|
||||
id,
|
||||
data,
|
||||
{
|
||||
currentUser,
|
||||
transaction,
|
||||
},
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
return updatedModalities;
|
||||
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
static async deleteByIds(ids, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await ModalitiesDBApi.deleteByIds(ids, {
|
||||
currentUser,
|
||||
transaction,
|
||||
});
|
||||
|
||||
await transaction.commit();
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
static async remove(id, currentUser) {
|
||||
const transaction = await db.sequelize.transaction();
|
||||
|
||||
try {
|
||||
await ModalitiesDBApi.remove(
|
||||
id,
|
||||
{
|
||||
currentUser,
|
||||
transaction,
|
||||
},
|
||||
);
|
||||
|
||||
await transaction.commit();
|
||||
} catch (error) {
|
||||
await transaction.rollback();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -53,6 +53,8 @@ module.exports = class SearchService {
|
||||
|
||||
"email",
|
||||
|
||||
"agreementtype",
|
||||
|
||||
],
|
||||
|
||||
"consulting_doctors": [
|
||||
@ -77,6 +79,10 @@ module.exports = class SearchService {
|
||||
|
||||
"software_version",
|
||||
|
||||
"subtype",
|
||||
|
||||
"softwarename",
|
||||
|
||||
],
|
||||
|
||||
"patients": [
|
||||
@ -87,6 +93,16 @@ module.exports = class SearchService {
|
||||
|
||||
"history",
|
||||
|
||||
"firstname",
|
||||
|
||||
"lastname",
|
||||
|
||||
"email",
|
||||
|
||||
"contactnumber",
|
||||
|
||||
"historydescription",
|
||||
|
||||
],
|
||||
|
||||
"reports": [
|
||||
@ -97,6 +113,8 @@ module.exports = class SearchService {
|
||||
|
||||
"ai_suggestions",
|
||||
|
||||
"aisuggestedfindings",
|
||||
|
||||
],
|
||||
|
||||
"studies": [
|
||||
@ -107,6 +125,8 @@ module.exports = class SearchService {
|
||||
|
||||
"must_do_evaluations",
|
||||
|
||||
"studytype",
|
||||
|
||||
],
|
||||
|
||||
"templates": [
|
||||
@ -121,6 +141,22 @@ module.exports = class SearchService {
|
||||
|
||||
"name",
|
||||
|
||||
"address",
|
||||
|
||||
"city",
|
||||
|
||||
"state",
|
||||
|
||||
"country",
|
||||
|
||||
"gstin",
|
||||
|
||||
],
|
||||
|
||||
"modalities": [
|
||||
|
||||
"type",
|
||||
|
||||
],
|
||||
|
||||
};
|
||||
@ -130,6 +166,8 @@ module.exports = class SearchService {
|
||||
|
||||
"year",
|
||||
|
||||
"purchaseyear",
|
||||
|
||||
],
|
||||
|
||||
"patients": [
|
||||
|
||||
14
cloudbuild.yaml
Normal file
14
cloudbuild.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
steps:
|
||||
- name: 'gcr.io/cloud-builders/docker'
|
||||
entrypoint: 'bash'
|
||||
args: ['-c', 'docker pull gcr.io/fldemo-315215/medisight-33223-dev:latest || exit 0']
|
||||
- name: 'gcr.io/cloud-builders/docker'
|
||||
args: [
|
||||
'build',
|
||||
'-t', 'gcr.io/fldemo-315215/medisight-33223-dev:latest',
|
||||
'--file', 'Dockerfile.dev',
|
||||
'--cache-from', 'gcr.io/fldemo-315215/medisight-33223-dev:latest',
|
||||
'.'
|
||||
]
|
||||
images: ['gcr.io/fldemo-315215/medisight-33223-dev:latest']
|
||||
logsBucket: 'gs://fldemo-315215-cloudbuild-logs'
|
||||
1
frontend/json/runtimeError.json
Normal file
1
frontend/json/runtimeError.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
||||
2
frontend/next-env.d.ts
vendored
2
frontend/next-env.d.ts
vendored
@ -2,4 +2,4 @@
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
|
||||
|
||||
@ -70,6 +70,60 @@ const CardCenters = ({
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Address</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.address }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>City</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.city }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>State</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.state }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Country</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.country }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Gstin</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.gstin }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Addressproof</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.addressproof }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@ -40,6 +40,36 @@ const ListCenters = ({ centers, loading, onDelete, currentPage, numPages, onPage
|
||||
<p className={'line-clamp-2'}>{ item.name }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Address</p>
|
||||
<p className={'line-clamp-2'}>{ item.address }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>City</p>
|
||||
<p className={'line-clamp-2'}>{ item.city }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>State</p>
|
||||
<p className={'line-clamp-2'}>{ item.state }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Country</p>
|
||||
<p className={'line-clamp-2'}>{ item.country }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Gstin</p>
|
||||
<p className={'line-clamp-2'}>{ item.gstin }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Addressproof</p>
|
||||
<p className={'line-clamp-2'}>{ item.addressproof }</p>
|
||||
</div>
|
||||
|
||||
</Link>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
|
||||
@ -40,6 +40,84 @@ export const loadColumns = async (
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'address',
|
||||
headerName: 'Address',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'city',
|
||||
headerName: 'City',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'state',
|
||||
headerName: 'State',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'country',
|
||||
headerName: 'Country',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'gstin',
|
||||
headerName: 'Gstin',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'addressproof',
|
||||
headerName: 'Addressproof',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'actions',
|
||||
type: 'actions',
|
||||
|
||||
@ -97,6 +97,33 @@ const CardMachines = ({
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Subtype</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.subtype }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Softwarename</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.softwarename }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Purchaseyear</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.purchaseyear }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@ -55,6 +55,21 @@ const ListMachines = ({ machines, loading, onDelete, currentPage, numPages, onPa
|
||||
<p className={'line-clamp-2'}>{ item.year }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Subtype</p>
|
||||
<p className={'line-clamp-2'}>{ item.subtype }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Softwarename</p>
|
||||
<p className={'line-clamp-2'}>{ item.softwarename }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Purchaseyear</p>
|
||||
<p className={'line-clamp-2'}>{ item.purchaseyear }</p>
|
||||
</div>
|
||||
|
||||
</Link>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
|
||||
@ -80,6 +80,46 @@ export const loadColumns = async (
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'subtype',
|
||||
headerName: 'Subtype',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'softwarename',
|
||||
headerName: 'Softwarename',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'purchaseyear',
|
||||
headerName: 'Purchaseyear',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
type: 'number',
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'actions',
|
||||
type: 'actions',
|
||||
|
||||
93
frontend/src/components/Modalities/CardModalities.tsx
Normal file
93
frontend/src/components/Modalities/CardModalities.tsx
Normal file
@ -0,0 +1,93 @@
|
||||
import React from 'react';
|
||||
import ListActionsPopover from '../ListActionsPopover';
|
||||
import { useAppSelector } from '../../stores/hooks';
|
||||
import dataFormatter from '../../helpers/dataFormatter';
|
||||
import { Pagination } from '../Pagination';
|
||||
import LoadingSpinner from "../LoadingSpinner";
|
||||
import Link from 'next/link';
|
||||
|
||||
type Props = {
|
||||
modalities: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
numPages: number;
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const CardModalities = ({
|
||||
modalities,
|
||||
loading,
|
||||
onDelete,
|
||||
currentPage,
|
||||
numPages,
|
||||
onPageChange,
|
||||
}: Props) => {
|
||||
const asideScrollbarsStyle = useAppSelector(
|
||||
(state) => state.style.asideScrollbarsStyle,
|
||||
);
|
||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
||||
const darkMode = useAppSelector((state) => state.style.darkMode);
|
||||
const corners = useAppSelector((state) => state.style.corners);
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
|
||||
return (
|
||||
<div className={'p-4'}>
|
||||
{loading && <LoadingSpinner />}
|
||||
<ul
|
||||
role='list'
|
||||
className='grid grid-cols-1 gap-x-6 gap-y-8 lg:grid-cols-3 2xl:grid-cols-4 xl:gap-x-8'
|
||||
>
|
||||
{!loading && modalities.map((item, index) => (
|
||||
<li
|
||||
key={item.id}
|
||||
className={`overflow-hidden ${corners !== 'rounded-full'? corners : 'rounded-3xl'} border ${focusRing} border-gray-200 dark:border-dark-700 ${
|
||||
darkMode ? 'aside-scrollbars-[slate]' : asideScrollbarsStyle
|
||||
}`}
|
||||
>
|
||||
<Link href={`/modalities/modalities-view/?id=${item.id}`} className='text-lg font-bold leading-6 line-clamp-1'>
|
||||
{item.id}
|
||||
</Link>
|
||||
|
||||
<div className='ml-auto'>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/modalities/modalities-edit/?id=${item.id}`}
|
||||
pathView={`/modalities/modalities-view/?id=${item.id}`}
|
||||
hasUpdatePermission={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<dl className='divide-y dark:divide-dark-700 px-6 py-4 text-sm leading-6 h-64 overflow-y-auto'>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Type</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.type }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
{!loading && modalities.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
)}
|
||||
</ul>
|
||||
<div className={'flex items-center justify-center my-6'}>
|
||||
<Pagination
|
||||
currentPage={currentPage}
|
||||
numPages={numPages}
|
||||
setCurrentPage={onPageChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CardModalities;
|
||||
72
frontend/src/components/Modalities/ListModalities.tsx
Normal file
72
frontend/src/components/Modalities/ListModalities.tsx
Normal file
@ -0,0 +1,72 @@
|
||||
import React from 'react';
|
||||
import CardBox from '../CardBox';
|
||||
import dataFormatter from '../../helpers/dataFormatter';
|
||||
import ListActionsPopover from "../ListActionsPopover";
|
||||
import {useAppSelector} from "../../stores/hooks";
|
||||
import {Pagination} from "../Pagination";
|
||||
import LoadingSpinner from "../LoadingSpinner";
|
||||
import Link from 'next/link';
|
||||
|
||||
type Props = {
|
||||
modalities: any[];
|
||||
loading: boolean;
|
||||
onDelete: (id: string) => void;
|
||||
currentPage: number;
|
||||
numPages: number;
|
||||
onPageChange: (page: number) => void;
|
||||
};
|
||||
|
||||
const ListModalities = ({ modalities, loading, onDelete, currentPage, numPages, onPageChange }: Props) => {
|
||||
const corners = useAppSelector((state) => state.style.corners);
|
||||
const bgColor = useAppSelector((state) => state.style.cardsColor);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='relative overflow-x-auto p-4 space-y-4'>
|
||||
{loading && <LoadingSpinner />}
|
||||
{!loading && modalities.map((item) => (
|
||||
<div key={item.id}>
|
||||
<CardBox hasTable isList className={'rounded shadow-none'}>
|
||||
<div className={`flex rounded dark:bg-dark-900 border items-center overflow-hidden`}>
|
||||
<Link
|
||||
href={`/modalities/modalities-view/?id=${item.id}`}
|
||||
className={
|
||||
'flex-1 px-4 py-6 h-24 flex divide-x-2 divide-stone-300 items-center overflow-hidden dark:divide-dark-700 overflow-x-auto'
|
||||
}
|
||||
>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Type</p>
|
||||
<p className={'line-clamp-2'}>{ item.type }</p>
|
||||
</div>
|
||||
|
||||
</Link>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={item.id}
|
||||
pathEdit={`/modalities/modalities-edit/?id=${item.id}`}
|
||||
pathView={`/modalities/modalities-view/?id=${item.id}`}
|
||||
hasUpdatePermission={true}
|
||||
/>
|
||||
</div>
|
||||
</CardBox>
|
||||
</div>
|
||||
))}
|
||||
{!loading && modalities.length === 0 && (
|
||||
<div className='col-span-full flex items-center justify-center h-40'>
|
||||
<p className=''>No data to display</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className={'flex items-center justify-center my-6'}>
|
||||
<Pagination
|
||||
currentPage={currentPage}
|
||||
numPages={numPages}
|
||||
setCurrentPage={onPageChange}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
};
|
||||
|
||||
export default ListModalities
|
||||
441
frontend/src/components/Modalities/TableModalities.tsx
Normal file
441
frontend/src/components/Modalities/TableModalities.tsx
Normal file
@ -0,0 +1,441 @@
|
||||
import React, { useEffect, useState, useMemo } from 'react'
|
||||
import { createPortal } from 'react-dom';
|
||||
import { ToastContainer, toast } from 'react-toastify';
|
||||
import BaseButton from '../BaseButton'
|
||||
import CardBoxModal from '../CardBoxModal'
|
||||
import CardBox from "../CardBox";
|
||||
import { fetch, update, deleteItem, setRefetch, deleteItemsByIds } from '../../stores/modalities/modalitiesSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import { Field, Form, Formik } from "formik";
|
||||
import {
|
||||
DataGrid,
|
||||
GridColDef,
|
||||
} from '@mui/x-data-grid';
|
||||
import {loadColumns} from "./configureModalitiesCols";
|
||||
import _ from 'lodash';
|
||||
import dataFormatter from '../../helpers/dataFormatter'
|
||||
import {dataGridStyles} from "../../styles";
|
||||
import axios from 'axios';
|
||||
|
||||
const perPage = 10;
|
||||
|
||||
const TableSampleModalities = ({ filterItems, setFilterItems, filters, showGrid }) => {
|
||||
const notify = (type, msg) => toast( msg, {type, position: "bottom-center"});
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
const router = useRouter();
|
||||
|
||||
const pagesList = [];
|
||||
const [id, setId] = useState(null);
|
||||
const [currentPage, setCurrentPage] = useState(0);
|
||||
const [filterRequest, setFilterRequest] = React.useState('');
|
||||
const [columns, setColumns] = useState<GridColDef[]>([]);
|
||||
const [selectedRows, setSelectedRows] = useState([]);
|
||||
const [sortModel, setSortModel] = useState([
|
||||
{
|
||||
field: '',
|
||||
sort: 'desc',
|
||||
},
|
||||
]);
|
||||
const { modalities, loading, count, notify: modalitiesNotify, refetch } = useAppSelector((state) => state.modalities)
|
||||
const { currentUser } = useAppSelector((state) => state.auth);
|
||||
const focusRing = useAppSelector((state) => state.style.focusRingColor);
|
||||
const bgColor = useAppSelector((state) => state.style.bgLayoutColor);
|
||||
const corners = useAppSelector((state) => state.style.corners);
|
||||
const numPages = Math.floor(count / perPage) === 0 ? 1 : Math.ceil(count / perPage);
|
||||
for (let i = 0; i < numPages; i++) {
|
||||
pagesList.push(i);
|
||||
}
|
||||
|
||||
const loadData = async (page = currentPage, request = filterRequest) => {
|
||||
if (page !== currentPage) setCurrentPage(page);
|
||||
if (request !== filterRequest) setFilterRequest(request);
|
||||
const { sort, field } = sortModel[0];
|
||||
|
||||
const query = `?page=${page}&limit=${perPage}${request}&sort=${sort}&field=${field}`;
|
||||
dispatch(fetch({ limit: perPage, page, query }));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (modalitiesNotify.showNotification) {
|
||||
notify(modalitiesNotify.typeNotification, modalitiesNotify.textNotification);
|
||||
}
|
||||
}, [modalitiesNotify.showNotification]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentUser) return;
|
||||
loadData();
|
||||
}, [sortModel, currentUser]);
|
||||
|
||||
useEffect(() => {
|
||||
if (refetch) {
|
||||
loadData(0);
|
||||
dispatch(setRefetch(false));
|
||||
}
|
||||
}, [refetch, dispatch]);
|
||||
|
||||
const [isModalInfoActive, setIsModalInfoActive] = useState(false)
|
||||
const [isModalTrashActive, setIsModalTrashActive] = useState(false)
|
||||
|
||||
const handleModalAction = () => {
|
||||
setIsModalInfoActive(false)
|
||||
setIsModalTrashActive(false)
|
||||
}
|
||||
|
||||
const handleDeleteModalAction = (id: string) => {
|
||||
setId(id)
|
||||
setIsModalTrashActive(true)
|
||||
}
|
||||
const handleDeleteAction = async () => {
|
||||
if (id) {
|
||||
await dispatch(deleteItem(id));
|
||||
await loadData(0);
|
||||
setIsModalTrashActive(false);
|
||||
}
|
||||
};
|
||||
|
||||
const generateFilterRequests = useMemo(() => {
|
||||
let request = '&';
|
||||
filterItems.forEach((item) => {
|
||||
const isRangeFilter = filters.find(
|
||||
(filter) =>
|
||||
filter.title === item.fields.selectedField &&
|
||||
(filter.number || filter.date),
|
||||
);
|
||||
|
||||
if (isRangeFilter) {
|
||||
const from = item.fields.filterValueFrom;
|
||||
const to = item.fields.filterValueTo;
|
||||
if (from) {
|
||||
request += `${item.fields.selectedField}Range=${from}&`;
|
||||
}
|
||||
if (to) {
|
||||
request += `${item.fields.selectedField}Range=${to}&`;
|
||||
}
|
||||
} else {
|
||||
const value = item.fields.filterValue;
|
||||
if (value) {
|
||||
request += `${item.fields.selectedField}=${value}&`;
|
||||
}
|
||||
}
|
||||
});
|
||||
return request;
|
||||
}, [filterItems, filters]);
|
||||
|
||||
const deleteFilter = (value) => {
|
||||
const newItems = filterItems.filter((item) => item.id !== value);
|
||||
|
||||
if (newItems.length) {
|
||||
setFilterItems(newItems);
|
||||
} else {
|
||||
loadData(0, '');
|
||||
setFilterItems(newItems);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
loadData(0, generateFilterRequests);
|
||||
};
|
||||
|
||||
const handleChange = (id) => (e) => {
|
||||
const value = e.target.value;
|
||||
const name = e.target.name;
|
||||
|
||||
setFilterItems(
|
||||
filterItems.map((item) => {
|
||||
if (item.id !== id) return item;
|
||||
if (name === 'selectedField') return { id, fields: { [name]: value } };
|
||||
|
||||
return { id, fields: { ...item.fields, [name]: value } }
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
setFilterItems([]);
|
||||
loadData(0, '');
|
||||
};
|
||||
|
||||
const onPageChange = (page: number) => {
|
||||
loadData(page);
|
||||
setCurrentPage(page);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadColumns(handleDeleteModalAction, `modalities`).then((newCols) =>
|
||||
setColumns(newCols),
|
||||
);
|
||||
}, []);
|
||||
|
||||
const handleTableSubmit = async (id: string, data) => {
|
||||
|
||||
if (!_.isEmpty(data)) {
|
||||
await dispatch(update({ id, data }))
|
||||
.unwrap()
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const onDeleteRows = async (selectedRows) => {
|
||||
await dispatch(deleteItemsByIds(selectedRows));
|
||||
await loadData(0);
|
||||
};
|
||||
|
||||
const controlClasses =
|
||||
'w-full py-2 px-2 my-2 border-gray-700 rounded dark:placeholder-gray-400 ' +
|
||||
` ${bgColor} ${focusRing} ${corners} ` +
|
||||
'dark:bg-slate-800 border';
|
||||
|
||||
const dataGrid = (
|
||||
<div className='relative overflow-x-auto'>
|
||||
<DataGrid
|
||||
autoHeight
|
||||
rowHeight={64}
|
||||
sx={dataGridStyles}
|
||||
className={'datagrid--table'}
|
||||
getRowClassName={() => `datagrid--row`}
|
||||
rows={modalities ?? []}
|
||||
columns={columns}
|
||||
initialState={{
|
||||
pagination: {
|
||||
paginationModel: {
|
||||
pageSize: 10,
|
||||
},
|
||||
},
|
||||
}}
|
||||
disableRowSelectionOnClick
|
||||
onProcessRowUpdateError={(params) => {
|
||||
console.log('Error', params);
|
||||
}}
|
||||
processRowUpdate={async (newRow, oldRow) => {
|
||||
const data = dataFormatter.dataGridEditFormatter(newRow);
|
||||
|
||||
try {
|
||||
await handleTableSubmit(newRow.id, data);
|
||||
return newRow;
|
||||
} catch {
|
||||
return oldRow;
|
||||
}
|
||||
}}
|
||||
sortingMode={'server'}
|
||||
checkboxSelection
|
||||
onRowSelectionModelChange={(ids) => {
|
||||
setSelectedRows(ids)
|
||||
}}
|
||||
onSortModelChange={(params) => {
|
||||
params.length
|
||||
? setSortModel(params)
|
||||
: setSortModel([{ field: '', sort: 'desc' }]);
|
||||
}}
|
||||
rowCount={count}
|
||||
pageSizeOptions={[10]}
|
||||
paginationMode={'server'}
|
||||
loading={loading}
|
||||
onPaginationModelChange={(params) => {
|
||||
onPageChange(params.page);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
{filterItems && Array.isArray( filterItems ) && filterItems.length ?
|
||||
<CardBox>
|
||||
<Formik
|
||||
initialValues={{
|
||||
checkboxes: ['lorem'],
|
||||
switches: ['lorem'],
|
||||
radio: 'lorem',
|
||||
}}
|
||||
onSubmit={() => null}
|
||||
>
|
||||
<Form>
|
||||
<>
|
||||
{filterItems && filterItems.map((filterItem) => {
|
||||
return (
|
||||
<div key={filterItem.id} className="flex mb-4">
|
||||
<div className="flex flex-col w-full mr-3">
|
||||
<div className="text-gray-500 font-bold">Filter</div>
|
||||
<Field
|
||||
className={controlClasses}
|
||||
name='selectedField'
|
||||
id='selectedField'
|
||||
component='select'
|
||||
value={filterItem?.fields?.selectedField || ''}
|
||||
onChange={handleChange(filterItem.id)}
|
||||
>
|
||||
{filters.map((selectOption) => (
|
||||
<option
|
||||
key={selectOption.title}
|
||||
value={`${selectOption.title}`}
|
||||
>
|
||||
{selectOption.label}
|
||||
</option>
|
||||
))}
|
||||
</Field>
|
||||
</div>
|
||||
{filters.find((filter) =>
|
||||
filter.title === filterItem?.fields?.selectedField
|
||||
)?.type === 'enum' ? (
|
||||
<div className="flex flex-col w-full mr-3">
|
||||
<div className="text-gray-500 font-bold">
|
||||
Value
|
||||
</div>
|
||||
<Field
|
||||
className={controlClasses}
|
||||
name="filterValue"
|
||||
id='filterValue'
|
||||
component="select"
|
||||
value={filterItem?.fields?.filterValue || ''}
|
||||
onChange={handleChange(filterItem.id)}
|
||||
>
|
||||
<option value="">Select Value</option>
|
||||
{filters.find((filter) =>
|
||||
filter.title === filterItem?.fields?.selectedField
|
||||
)?.options?.map((option) => (
|
||||
<option key={option} value={option}>
|
||||
{option}
|
||||
</option>
|
||||
))}
|
||||
</Field>
|
||||
</div>
|
||||
) : filters.find((filter) =>
|
||||
filter.title === filterItem?.fields?.selectedField
|
||||
)?.number ? (
|
||||
<div className="flex flex-row w-full mr-3">
|
||||
<div className="flex flex-col w-full mr-3">
|
||||
<div className="text-gray-500 font-bold">From</div>
|
||||
<Field
|
||||
className={controlClasses}
|
||||
name='filterValueFrom'
|
||||
placeholder='From'
|
||||
id='filterValueFrom'
|
||||
value={filterItem?.fields?.filterValueFrom || ''}
|
||||
onChange={handleChange(filterItem.id)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col w-full">
|
||||
<div className="text-gray-500 font-bold">To</div>
|
||||
<Field
|
||||
className={controlClasses}
|
||||
name='filterValueTo'
|
||||
placeholder='to'
|
||||
id='filterValueTo'
|
||||
value={filterItem?.fields?.filterValueTo || ''}
|
||||
onChange={handleChange(filterItem.id)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : filters.find(
|
||||
(filter) =>
|
||||
filter.title ===
|
||||
filterItem?.fields?.selectedField
|
||||
)?.date ? (
|
||||
<div className='flex flex-row w-full mr-3'>
|
||||
<div className='flex flex-col w-full mr-3'>
|
||||
<div className='text-gray-500 font-bold'>
|
||||
From
|
||||
</div>
|
||||
<Field
|
||||
className={controlClasses}
|
||||
name='filterValueFrom'
|
||||
placeholder='From'
|
||||
id='filterValueFrom'
|
||||
type='datetime-local'
|
||||
value={filterItem?.fields?.filterValueFrom || ''}
|
||||
onChange={handleChange(filterItem.id)}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex flex-col w-full'>
|
||||
<div className='text-gray-500 font-bold'>To</div>
|
||||
<Field
|
||||
className={controlClasses}
|
||||
name='filterValueTo'
|
||||
placeholder='to'
|
||||
id='filterValueTo'
|
||||
type='datetime-local'
|
||||
value={filterItem?.fields?.filterValueTo || ''}
|
||||
onChange={handleChange(filterItem.id)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col w-full mr-3">
|
||||
<div className="text-gray-500 font-bold">Contains</div>
|
||||
<Field
|
||||
className={controlClasses}
|
||||
name='filterValue'
|
||||
placeholder='Contained'
|
||||
id='filterValue'
|
||||
value={filterItem?.fields?.filterValue || ''}
|
||||
onChange={handleChange(filterItem.id)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex flex-col">
|
||||
<div className="text-gray-500 font-bold">Action</div>
|
||||
<BaseButton
|
||||
className="my-2"
|
||||
type='reset'
|
||||
color='danger'
|
||||
label='Delete'
|
||||
onClick={() => {
|
||||
deleteFilter(filterItem.id)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
<div className="flex">
|
||||
<BaseButton
|
||||
className="my-2 mr-3"
|
||||
color="success"
|
||||
label='Apply'
|
||||
onClick={handleSubmit}
|
||||
/>
|
||||
<BaseButton
|
||||
className="my-2"
|
||||
color='info'
|
||||
label='Cancel'
|
||||
onClick={handleReset}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
</Form>
|
||||
</Formik>
|
||||
</CardBox> : null
|
||||
}
|
||||
<CardBoxModal
|
||||
title="Please confirm"
|
||||
buttonColor="info"
|
||||
buttonLabel={loading ? 'Deleting...' : 'Confirm'}
|
||||
isActive={isModalTrashActive}
|
||||
onConfirm={handleDeleteAction}
|
||||
onCancel={handleModalAction}
|
||||
>
|
||||
<p>Are you sure you want to delete this item?</p>
|
||||
</CardBoxModal>
|
||||
{dataGrid}
|
||||
|
||||
{selectedRows.length > 0 &&
|
||||
createPortal(
|
||||
<BaseButton
|
||||
className='me-4'
|
||||
color='danger'
|
||||
label={`Delete ${selectedRows.length === 1 ? 'Row' : 'Rows'}`}
|
||||
onClick={() => onDeleteRows(selectedRows)}
|
||||
/>,
|
||||
document.getElementById('delete-rows-button'),
|
||||
)}
|
||||
<ToastContainer />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default TableSampleModalities
|
||||
@ -0,0 +1,65 @@
|
||||
import React from 'react';
|
||||
import BaseIcon from '../BaseIcon';
|
||||
import { mdiEye, mdiTrashCan, mdiPencilOutline } from '@mdi/js';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
GridActionsCellItem,
|
||||
GridRowParams,
|
||||
GridValueGetterParams,
|
||||
} from '@mui/x-data-grid';
|
||||
import dataFormatter from '../../helpers/dataFormatter'
|
||||
import DataGridMultiSelect from "../DataGridMultiSelect";
|
||||
import ListActionsPopover from '../ListActionsPopover';
|
||||
type Params = (id: string) => void;
|
||||
|
||||
export const loadColumns = async (
|
||||
onDelete: Params,
|
||||
entityName: string,
|
||||
) => {
|
||||
async function callOptionsApi(entityName: string) {
|
||||
try {
|
||||
const data = await axios(`/${entityName}/autocomplete?limit=100`);
|
||||
return data.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
return [
|
||||
|
||||
{
|
||||
field: 'type',
|
||||
headerName: 'Type',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'actions',
|
||||
type: 'actions',
|
||||
minWidth: 30,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
getActions: (params: GridRowParams) => {
|
||||
|
||||
return [
|
||||
<div key={params?.row?.id}>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
itemId={params?.row?.id}
|
||||
pathEdit={`/modalities/modalities-edit/?id=${params?.row?.id}`}
|
||||
pathView={`/modalities/modalities-view/?id=${params?.row?.id}`}
|
||||
hasUpdatePermission={true}
|
||||
/>
|
||||
</div>,
|
||||
]
|
||||
},
|
||||
},
|
||||
];
|
||||
};
|
||||
@ -106,6 +106,60 @@ const CardPatients = ({
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Firstname</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.firstname }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Lastname</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.lastname }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Email</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.email }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Contactnumber</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.contactnumber }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Historydescription</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.historydescription }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Historydocuments</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.historydocuments }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@ -60,6 +60,36 @@ const ListPatients = ({ patients, loading, onDelete, currentPage, numPages, onPa
|
||||
<p className={'line-clamp-2'}>{ item.history }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Firstname</p>
|
||||
<p className={'line-clamp-2'}>{ item.firstname }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Lastname</p>
|
||||
<p className={'line-clamp-2'}>{ item.lastname }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Email</p>
|
||||
<p className={'line-clamp-2'}>{ item.email }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Contactnumber</p>
|
||||
<p className={'line-clamp-2'}>{ item.contactnumber }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Historydescription</p>
|
||||
<p className={'line-clamp-2'}>{ item.historydescription }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Historydocuments</p>
|
||||
<p className={'line-clamp-2'}>{ item.historydocuments }</p>
|
||||
</div>
|
||||
|
||||
</Link>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
|
||||
@ -93,6 +93,84 @@ export const loadColumns = async (
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'firstname',
|
||||
headerName: 'Firstname',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'lastname',
|
||||
headerName: 'Lastname',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'email',
|
||||
headerName: 'Email',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'contactnumber',
|
||||
headerName: 'Contactnumber',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'historydescription',
|
||||
headerName: 'Historydescription',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'historydocuments',
|
||||
headerName: 'Historydocuments',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'actions',
|
||||
type: 'actions',
|
||||
|
||||
@ -115,6 +115,15 @@ const CardReports = ({
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Aisuggestedfindings</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.aisuggestedfindings }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@ -65,6 +65,11 @@ const ListReports = ({ reports, loading, onDelete, currentPage, numPages, onPage
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.patientsOneListFormatter(item.patient) }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Aisuggestedfindings</p>
|
||||
<p className={'line-clamp-2'}>{ item.aisuggestedfindings }</p>
|
||||
</div>
|
||||
|
||||
</Link>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
|
||||
@ -122,6 +122,19 @@ export const loadColumns = async (
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'aisuggestedfindings',
|
||||
headerName: 'Aisuggestedfindings',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'actions',
|
||||
type: 'actions',
|
||||
|
||||
@ -88,6 +88,15 @@ const CardStudies = ({
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Studytype</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.studytype }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@ -50,6 +50,11 @@ const ListStudies = ({ studies, loading, onDelete, currentPage, numPages, onPage
|
||||
<p className={'line-clamp-2'}>{ item.must_do_evaluations }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Studytype</p>
|
||||
<p className={'line-clamp-2'}>{ item.studytype }</p>
|
||||
</div>
|
||||
|
||||
</Link>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
|
||||
@ -66,6 +66,19 @@ export const loadColumns = async (
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'studytype',
|
||||
headerName: 'Studytype',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'actions',
|
||||
type: 'actions',
|
||||
|
||||
@ -142,6 +142,33 @@ const CardUsers = ({
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Signature</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.signature }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Medicallicense</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.medicallicense }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className='flex justify-between gap-x-4 py-3'>
|
||||
<dt className='text-gray-500 dark:text-dark-600'>Agreementtype</dt>
|
||||
<dd className='flex items-start gap-x-2'>
|
||||
<div className='font-medium line-clamp-4'>
|
||||
{ item.agreementtype }
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@ -80,6 +80,21 @@ const ListUsers = ({ users, loading, onDelete, currentPage, numPages, onPageChan
|
||||
<p className={'line-clamp-2'}>{ dataFormatter.centersOneListFormatter(item.centers) }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Signature</p>
|
||||
<p className={'line-clamp-2'}>{ item.signature }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Medicallicense</p>
|
||||
<p className={'line-clamp-2'}>{ item.medicallicense }</p>
|
||||
</div>
|
||||
|
||||
<div className={'flex-1 px-3'}>
|
||||
<p className={'text-xs text-gray-500'}>Agreementtype</p>
|
||||
<p className={'line-clamp-2'}>{ item.agreementtype }</p>
|
||||
</div>
|
||||
|
||||
</Link>
|
||||
<ListActionsPopover
|
||||
onDelete={onDelete}
|
||||
|
||||
@ -32,6 +32,15 @@ const TableSampleUsers = ({ filterItems, setFilterItems, filters, showGrid }) =>
|
||||
const [filterRequest, setFilterRequest] = React.useState('');
|
||||
const [columns, setColumns] = useState<GridColDef[]>([]);
|
||||
const [selectedRows, setSelectedRows] = useState([]);
|
||||
const roleOptions = [
|
||||
"Owner Radiologist",
|
||||
"Lab Technician",
|
||||
"In-house Radiologist",
|
||||
"Tele-Radiologist",
|
||||
"Referring Doctor",
|
||||
];
|
||||
const [activeRole, setActiveRole] = useState(roleOptions[0]);
|
||||
|
||||
const [sortModel, setSortModel] = useState([
|
||||
{
|
||||
field: '',
|
||||
@ -157,16 +166,11 @@ const TableSampleUsers = ({ filterItems, setFilterItems, filters, showGrid }) =>
|
||||
loadData(0, '');
|
||||
};
|
||||
|
||||
const onPageChange = (page: number) => {
|
||||
loadData(page);
|
||||
setCurrentPage(page);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadColumns(handleDeleteModalAction, `users`).then((newCols) =>
|
||||
loadColumns(handleDeleteModalAction, `users`, activeRole).then((newCols) =>
|
||||
setColumns(newCols),
|
||||
);
|
||||
}, []);
|
||||
}, [activeRole]);
|
||||
|
||||
const handleTableSubmit = async (id: string, data) => {
|
||||
delete data?.password;
|
||||
|
||||
@ -15,6 +15,7 @@ type Params = (id: string) => void;
|
||||
export const loadColumns = async (
|
||||
onDelete: Params,
|
||||
entityName: string,
|
||||
role: string,
|
||||
) => {
|
||||
async function callOptionsApi(entityName: string) {
|
||||
try {
|
||||
@ -159,6 +160,45 @@ export const loadColumns = async (
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'signature',
|
||||
headerName: 'Signature',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'medicallicense',
|
||||
headerName: 'Medicallicense',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'agreementtype',
|
||||
headerName: 'Agreementtype',
|
||||
flex: 1,
|
||||
minWidth: 120,
|
||||
filterable: false,
|
||||
headerClassName: 'datagrid--header',
|
||||
cellClassName: 'datagrid--cell',
|
||||
|
||||
editable: true,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
field: 'actions',
|
||||
type: 'actions',
|
||||
|
||||
@ -80,6 +80,14 @@ const menuAside: MenuAsideItem[] = [
|
||||
icon: icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_CENTERS'
|
||||
},
|
||||
{
|
||||
href: '/modalities/modalities-list',
|
||||
label: 'Modalities',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
icon: icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_MODALITIES'
|
||||
},
|
||||
{
|
||||
href: '/profile',
|
||||
label: 'Profile',
|
||||
|
||||
@ -34,6 +34,16 @@ const EditCenters = () => {
|
||||
|
||||
'name': '',
|
||||
|
||||
'address': '',
|
||||
|
||||
'city': '',
|
||||
|
||||
'state': '',
|
||||
|
||||
'country': '',
|
||||
|
||||
'gstin': '',
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
@ -93,6 +103,51 @@ const EditCenters = () => {
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Address"
|
||||
>
|
||||
<Field
|
||||
name="address"
|
||||
placeholder="Address"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="City"
|
||||
>
|
||||
<Field
|
||||
name="city"
|
||||
placeholder="City"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="State"
|
||||
>
|
||||
<Field
|
||||
name="state"
|
||||
placeholder="State"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Country"
|
||||
>
|
||||
<Field
|
||||
name="country"
|
||||
placeholder="Country"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Gstin"
|
||||
>
|
||||
<Field
|
||||
name="gstin"
|
||||
placeholder="Gstin"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
|
||||
@ -35,6 +35,16 @@ const EditCentersPage = () => {
|
||||
|
||||
'name': '',
|
||||
|
||||
'address': '',
|
||||
|
||||
'city': '',
|
||||
|
||||
'state': '',
|
||||
|
||||
'country': '',
|
||||
|
||||
'gstin': '',
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
@ -91,6 +101,51 @@ const EditCentersPage = () => {
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Address"
|
||||
>
|
||||
<Field
|
||||
name="address"
|
||||
placeholder="Address"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="City"
|
||||
>
|
||||
<Field
|
||||
name="city"
|
||||
placeholder="City"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="State"
|
||||
>
|
||||
<Field
|
||||
name="state"
|
||||
placeholder="State"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Country"
|
||||
>
|
||||
<Field
|
||||
name="country"
|
||||
placeholder="Country"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Gstin"
|
||||
>
|
||||
<Field
|
||||
name="gstin"
|
||||
placeholder="Gstin"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
|
||||
@ -22,7 +22,7 @@ const CentersTablesPage = () => {
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Address', title: 'address'},{label: 'City', title: 'city'},{label: 'State', title: 'state'},{label: 'Country', title: 'country'},{label: 'Gstin', title: 'gstin'},
|
||||
|
||||
]);
|
||||
const addFilter = () => {
|
||||
|
||||
@ -27,6 +27,16 @@ const initialValues = {
|
||||
|
||||
name: '',
|
||||
|
||||
address: '',
|
||||
|
||||
city: '',
|
||||
|
||||
state: '',
|
||||
|
||||
country: '',
|
||||
|
||||
gstin: '',
|
||||
|
||||
}
|
||||
|
||||
const CentersNew = () => {
|
||||
@ -64,6 +74,51 @@ const CentersNew = () => {
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Address"
|
||||
>
|
||||
<Field
|
||||
name="address"
|
||||
placeholder="Address"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="City"
|
||||
>
|
||||
<Field
|
||||
name="city"
|
||||
placeholder="City"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="State"
|
||||
>
|
||||
<Field
|
||||
name="state"
|
||||
placeholder="State"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Country"
|
||||
>
|
||||
<Field
|
||||
name="country"
|
||||
placeholder="Country"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Gstin"
|
||||
>
|
||||
<Field
|
||||
name="gstin"
|
||||
placeholder="Gstin"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
|
||||
@ -22,7 +22,7 @@ const CentersTablesPage = () => {
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Address', title: 'address'},{label: 'City', title: 'city'},{label: 'State', title: 'state'},{label: 'Country', title: 'country'},{label: 'Gstin', title: 'gstin'},
|
||||
|
||||
]);
|
||||
const addFilter = () => {
|
||||
|
||||
@ -54,6 +54,31 @@ const CentersView = () => {
|
||||
<p>{centers?.name}</p>
|
||||
</div>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Address</p>
|
||||
<p>{centers?.address}</p>
|
||||
</div>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>City</p>
|
||||
<p>{centers?.city}</p>
|
||||
</div>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>State</p>
|
||||
<p>{centers?.state}</p>
|
||||
</div>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Country</p>
|
||||
<p>{centers?.country}</p>
|
||||
</div>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Gstin</p>
|
||||
<p>{centers?.gstin}</p>
|
||||
</div>
|
||||
|
||||
<>
|
||||
<p className={'block font-bold mb-2'}>Users Centers</p>
|
||||
<CardBox
|
||||
@ -75,6 +100,8 @@ const CentersView = () => {
|
||||
|
||||
<th>Disabled</th>
|
||||
|
||||
<th>Agreementtype</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -102,6 +129,10 @@ const CentersView = () => {
|
||||
{ dataFormatter.booleanFormatter(item.disabled) }
|
||||
</td>
|
||||
|
||||
<td data-label="agreementtype">
|
||||
{ item.agreementtype }
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@ -202,6 +233,12 @@ const CentersView = () => {
|
||||
|
||||
<th>Year</th>
|
||||
|
||||
<th>Subtype</th>
|
||||
|
||||
<th>Softwarename</th>
|
||||
|
||||
<th>Purchaseyear</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -225,6 +262,18 @@ const CentersView = () => {
|
||||
{ item.year }
|
||||
</td>
|
||||
|
||||
<td data-label="subtype">
|
||||
{ item.subtype }
|
||||
</td>
|
||||
|
||||
<td data-label="softwarename">
|
||||
{ item.softwarename }
|
||||
</td>
|
||||
|
||||
<td data-label="purchaseyear">
|
||||
{ item.purchaseyear }
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@ -255,6 +304,16 @@ const CentersView = () => {
|
||||
|
||||
<th>History</th>
|
||||
|
||||
<th>Firstname</th>
|
||||
|
||||
<th>Lastname</th>
|
||||
|
||||
<th>Email</th>
|
||||
|
||||
<th>Contactnumber</th>
|
||||
|
||||
<th>Historydescription</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -282,6 +341,26 @@ const CentersView = () => {
|
||||
{ item.history }
|
||||
</td>
|
||||
|
||||
<td data-label="firstname">
|
||||
{ item.firstname }
|
||||
</td>
|
||||
|
||||
<td data-label="lastname">
|
||||
{ item.lastname }
|
||||
</td>
|
||||
|
||||
<td data-label="email">
|
||||
{ item.email }
|
||||
</td>
|
||||
|
||||
<td data-label="contactnumber">
|
||||
{ item.contactnumber }
|
||||
</td>
|
||||
|
||||
<td data-label="historydescription">
|
||||
{ item.historydescription }
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@ -306,6 +385,8 @@ const CentersView = () => {
|
||||
|
||||
<th>AISuggestions</th>
|
||||
|
||||
<th>Aisuggestedfindings</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -321,6 +402,10 @@ const CentersView = () => {
|
||||
{ item.ai_suggestions }
|
||||
</td>
|
||||
|
||||
<td data-label="aisuggestedfindings">
|
||||
{ item.aisuggestedfindings }
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@ -347,6 +432,8 @@ const CentersView = () => {
|
||||
|
||||
<th>Must-DoEvaluations</th>
|
||||
|
||||
<th>Studytype</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -366,6 +453,10 @@ const CentersView = () => {
|
||||
{ item.must_do_evaluations }
|
||||
</td>
|
||||
|
||||
<td data-label="studytype">
|
||||
{ item.studytype }
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@ -414,6 +505,39 @@ const CentersView = () => {
|
||||
</CardBox>
|
||||
</>
|
||||
|
||||
<>
|
||||
<p className={'block font-bold mb-2'}>Modalities centers</p>
|
||||
<CardBox
|
||||
className='mb-6 border border-gray-300 rounded overflow-hidden'
|
||||
hasTable
|
||||
>
|
||||
<div className='overflow-x-auto'>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{centers.modalities_centers && Array.isArray(centers.modalities_centers) &&
|
||||
centers.modalities_centers.map((item: any) => (
|
||||
<tr key={item.id} onClick={() => router.push(`/modalities/modalities-view/?id=${item.id}`)}>
|
||||
|
||||
<td data-label="type">
|
||||
{ item.type }
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{!centers?.modalities_centers?.length && <div className={'text-center py-4'}>No data</div>}
|
||||
</CardBox>
|
||||
</>
|
||||
|
||||
<BaseDivider />
|
||||
|
||||
<BaseButton
|
||||
|
||||
@ -28,10 +28,11 @@ const Dashboard = () => {
|
||||
const [roles, setRoles] = React.useState(loadingMessage);
|
||||
const [permissions, setPermissions] = React.useState(loadingMessage);
|
||||
const [centers, setCenters] = React.useState(loadingMessage);
|
||||
const [modalities, setModalities] = React.useState(loadingMessage);
|
||||
|
||||
async function loadData() {
|
||||
const entities = ['users','consulting_doctors','dicom_studies','machines','patients','reports','studies','templates','roles','permissions','centers',];
|
||||
const fns = [setUsers,setConsulting_doctors,setDicom_studies,setMachines,setPatients,setReports,setStudies,setTemplates,setRoles,setPermissions,setCenters,];
|
||||
const entities = ['users','consulting_doctors','dicom_studies','machines','patients','reports','studies','templates','roles','permissions','centers','modalities',];
|
||||
const fns = [setUsers,setConsulting_doctors,setDicom_studies,setMachines,setPatients,setReports,setStudies,setTemplates,setRoles,setPermissions,setCenters,setModalities,];
|
||||
|
||||
const requests = entities.map((entity, index) => {
|
||||
return axios.get(`/${entity.toLowerCase()}/count`);
|
||||
@ -321,6 +322,34 @@ const Dashboard = () => {
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
<Link href={'/modalities/modalities-list'}>
|
||||
<div
|
||||
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
|
||||
>
|
||||
<div className="flex justify-between align-center">
|
||||
<div>
|
||||
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
|
||||
Modalities
|
||||
</div>
|
||||
<div className="text-3xl leading-tight font-semibold">
|
||||
{modalities}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<BaseIcon
|
||||
className={`${iconsColor}`}
|
||||
w="w-16"
|
||||
h="h-16"
|
||||
size={48}
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
path={icon.mdiTable || icon.mdiTable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
</div>
|
||||
</SectionMain>
|
||||
</>
|
||||
|
||||
@ -42,6 +42,12 @@ const EditMachines = () => {
|
||||
|
||||
centers: null,
|
||||
|
||||
'subtype': '',
|
||||
|
||||
'softwarename': '',
|
||||
|
||||
purchaseyear: '',
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
@ -142,6 +148,34 @@ const EditMachines = () => {
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Subtype"
|
||||
>
|
||||
<Field
|
||||
name="subtype"
|
||||
placeholder="Subtype"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Softwarename"
|
||||
>
|
||||
<Field
|
||||
name="softwarename"
|
||||
placeholder="Softwarename"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Purchaseyear"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="purchaseyear"
|
||||
placeholder="Purchaseyear"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
|
||||
@ -43,6 +43,12 @@ const EditMachinesPage = () => {
|
||||
|
||||
centers: null,
|
||||
|
||||
'subtype': '',
|
||||
|
||||
'softwarename': '',
|
||||
|
||||
purchaseyear: '',
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
@ -140,6 +146,34 @@ const EditMachinesPage = () => {
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Subtype"
|
||||
>
|
||||
<Field
|
||||
name="subtype"
|
||||
placeholder="Subtype"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Softwarename"
|
||||
>
|
||||
<Field
|
||||
name="softwarename"
|
||||
placeholder="Softwarename"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Purchaseyear"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="purchaseyear"
|
||||
placeholder="Purchaseyear"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
|
||||
@ -22,8 +22,8 @@ const MachinesTablesPage = () => {
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Type', title: 'type'},{label: 'SoftwareVersion', title: 'software_version'},
|
||||
{label: 'Year', title: 'year', number: 'true'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Type', title: 'type'},{label: 'SoftwareVersion', title: 'software_version'},{label: 'Subtype', title: 'subtype'},{label: 'Softwarename', title: 'softwarename'},
|
||||
{label: 'Year', title: 'year', number: 'true'},{label: 'Purchaseyear', title: 'purchaseyear', number: 'true'},
|
||||
|
||||
]);
|
||||
const addFilter = () => {
|
||||
|
||||
@ -35,6 +35,12 @@ const initialValues = {
|
||||
|
||||
centers: '',
|
||||
|
||||
subtype: '',
|
||||
|
||||
softwarename: '',
|
||||
|
||||
purchaseyear: '',
|
||||
|
||||
}
|
||||
|
||||
const MachinesNew = () => {
|
||||
@ -104,6 +110,34 @@ const MachinesNew = () => {
|
||||
<Field name="centers" id="centers" component={SelectField} options={[]} itemRef={'centers'}></Field>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Subtype"
|
||||
>
|
||||
<Field
|
||||
name="subtype"
|
||||
placeholder="Subtype"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Softwarename"
|
||||
>
|
||||
<Field
|
||||
name="softwarename"
|
||||
placeholder="Softwarename"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Purchaseyear"
|
||||
>
|
||||
<Field
|
||||
type="number"
|
||||
name="purchaseyear"
|
||||
placeholder="Purchaseyear"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
|
||||
@ -22,8 +22,8 @@ const MachinesTablesPage = () => {
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Type', title: 'type'},{label: 'SoftwareVersion', title: 'software_version'},
|
||||
{label: 'Year', title: 'year', number: 'true'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Type', title: 'type'},{label: 'SoftwareVersion', title: 'software_version'},{label: 'Subtype', title: 'subtype'},{label: 'Softwarename', title: 'softwarename'},
|
||||
{label: 'Year', title: 'year', number: 'true'},{label: 'Purchaseyear', title: 'purchaseyear', number: 'true'},
|
||||
|
||||
]);
|
||||
const addFilter = () => {
|
||||
|
||||
@ -76,6 +76,21 @@ const MachinesView = () => {
|
||||
|
||||
</div>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Subtype</p>
|
||||
<p>{machines?.subtype}</p>
|
||||
</div>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Softwarename</p>
|
||||
<p>{machines?.softwarename}</p>
|
||||
</div>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Purchaseyear</p>
|
||||
<p>{machines?.purchaseyear || 'No data'}</p>
|
||||
</div>
|
||||
|
||||
<BaseDivider />
|
||||
|
||||
<BaseButton
|
||||
|
||||
133
frontend/src/pages/modalities/[modalitiesId].tsx
Normal file
133
frontend/src/pages/modalities/[modalitiesId].tsx
Normal file
@ -0,0 +1,133 @@
|
||||
import { mdiChartTimelineVariant, mdiUpload } from '@mdi/js'
|
||||
import Head from 'next/head'
|
||||
import React, { ReactElement, useEffect, useState } from 'react'
|
||||
import DatePicker from "react-datepicker";
|
||||
import "react-datepicker/dist/react-datepicker.css";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
import CardBox from '../../components/CardBox'
|
||||
import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
|
||||
import { Field, Form, Formik } from 'formik'
|
||||
import FormField from '../../components/FormField'
|
||||
import BaseDivider from '../../components/BaseDivider'
|
||||
import BaseButtons from '../../components/BaseButtons'
|
||||
import BaseButton from '../../components/BaseButton'
|
||||
import FormCheckRadio from '../../components/FormCheckRadio'
|
||||
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup'
|
||||
import { SelectField } from "../../components/SelectField";
|
||||
import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/modalities/modalitiesSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
const EditModalities = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
centers: null,
|
||||
|
||||
'type': '',
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { modalities } = useAppSelector((state) => state.modalities)
|
||||
|
||||
const { modalitiesId } = router.query
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({ id: modalitiesId }))
|
||||
}, [modalitiesId])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof modalities === 'object') {
|
||||
setInitialValues(modalities)
|
||||
}
|
||||
}, [modalities])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof modalities === 'object') {
|
||||
|
||||
const newInitialVal = {...initVals};
|
||||
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (modalities)[el])
|
||||
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [modalities])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: modalitiesId, data }))
|
||||
await router.push('/modalities/modalities-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit modalities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit modalities'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
<Formik
|
||||
enableReinitialize
|
||||
initialValues={initialValues}
|
||||
onSubmit={(values) => handleSubmit(values)}
|
||||
>
|
||||
<Form>
|
||||
|
||||
<FormField label='centers' labelFor='centers'>
|
||||
<Field
|
||||
name='centers'
|
||||
id='centers'
|
||||
component={SelectField}
|
||||
options={initialValues.centers}
|
||||
itemRef={'centers'}
|
||||
|
||||
showField={'name'}
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Type"
|
||||
>
|
||||
<Field
|
||||
name="type"
|
||||
placeholder="Type"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/modalities/modalities-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
EditModalities.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated>
|
||||
{page}
|
||||
</LayoutAuthenticated>
|
||||
)
|
||||
}
|
||||
|
||||
export default EditModalities
|
||||
131
frontend/src/pages/modalities/modalities-edit.tsx
Normal file
131
frontend/src/pages/modalities/modalities-edit.tsx
Normal file
@ -0,0 +1,131 @@
|
||||
import { mdiChartTimelineVariant, mdiUpload } from '@mdi/js'
|
||||
import Head from 'next/head'
|
||||
import React, { ReactElement, useEffect, useState } from 'react'
|
||||
import DatePicker from "react-datepicker";
|
||||
import "react-datepicker/dist/react-datepicker.css";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
import CardBox from '../../components/CardBox'
|
||||
import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
|
||||
import { Field, Form, Formik } from 'formik'
|
||||
import FormField from '../../components/FormField'
|
||||
import BaseDivider from '../../components/BaseDivider'
|
||||
import BaseButtons from '../../components/BaseButtons'
|
||||
import BaseButton from '../../components/BaseButton'
|
||||
import FormCheckRadio from '../../components/FormCheckRadio'
|
||||
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup'
|
||||
import { SelectField } from "../../components/SelectField";
|
||||
import { SelectFieldMany } from "../../components/SelectFieldMany";
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { update, fetch } from '../../stores/modalities/modalitiesSlice'
|
||||
import { useAppDispatch, useAppSelector } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
import dataFormatter from '../../helpers/dataFormatter';
|
||||
|
||||
const EditModalitiesPage = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const initVals = {
|
||||
|
||||
centers: null,
|
||||
|
||||
'type': '',
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
const { modalities } = useAppSelector((state) => state.modalities)
|
||||
|
||||
const { id } = router.query
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({ id: id }))
|
||||
}, [id])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof modalities === 'object') {
|
||||
setInitialValues(modalities)
|
||||
}
|
||||
}, [modalities])
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof modalities === 'object') {
|
||||
const newInitialVal = {...initVals};
|
||||
Object.keys(initVals).forEach(el => newInitialVal[el] = (modalities)[el])
|
||||
setInitialValues(newInitialVal);
|
||||
}
|
||||
}, [modalities])
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(update({ id: id, data }))
|
||||
await router.push('/modalities/modalities-list')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Edit modalities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={'Edit modalities'} main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
<Formik
|
||||
enableReinitialize
|
||||
initialValues={initialValues}
|
||||
onSubmit={(values) => handleSubmit(values)}
|
||||
>
|
||||
<Form>
|
||||
|
||||
<FormField label='centers' labelFor='centers'>
|
||||
<Field
|
||||
name='centers'
|
||||
id='centers'
|
||||
component={SelectField}
|
||||
options={initialValues.centers}
|
||||
itemRef={'centers'}
|
||||
|
||||
showField={'name'}
|
||||
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Type"
|
||||
>
|
||||
<Field
|
||||
name="type"
|
||||
placeholder="Type"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/modalities/modalities-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
EditModalitiesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated>
|
||||
{page}
|
||||
</LayoutAuthenticated>
|
||||
)
|
||||
}
|
||||
|
||||
export default EditModalitiesPage
|
||||
128
frontend/src/pages/modalities/modalities-list.tsx
Normal file
128
frontend/src/pages/modalities/modalities-list.tsx
Normal file
@ -0,0 +1,128 @@
|
||||
import { mdiChartTimelineVariant } from '@mdi/js'
|
||||
import Head from 'next/head'
|
||||
import { uniqueId } from 'lodash';
|
||||
import React, { ReactElement, useState } from 'react'
|
||||
import CardBox from '../../components/CardBox'
|
||||
import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableModalities from '../../components/Modalities/TableModalities'
|
||||
import BaseButton from '../../components/BaseButton'
|
||||
import axios from "axios";
|
||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||
import CardBoxModal from "../../components/CardBoxModal";
|
||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
||||
import {setRefetch, uploadCsv} from '../../stores/modalities/modalitiesSlice';
|
||||
|
||||
const ModalitiesTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const [filters] = useState([{label: 'Type', title: 'type'},
|
||||
|
||||
]);
|
||||
const addFilter = () => {
|
||||
const newItem = {
|
||||
id: uniqueId(),
|
||||
fields: {
|
||||
filterValue: '',
|
||||
filterValueFrom: '',
|
||||
filterValueTo: '',
|
||||
selectedField: '',
|
||||
},
|
||||
};
|
||||
newItem.fields.selectedField = filters[0].title;
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getModalitiesCSV = async () => {
|
||||
const response = await axios({url: '/modalities?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const type = response.headers['content-type']
|
||||
const blob = new Blob([response.data], { type: type })
|
||||
const link = document.createElement('a')
|
||||
link.href = window.URL.createObjectURL(blob)
|
||||
link.download = 'modalitiesCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
const onModalConfirm = async () => {
|
||||
if (!csvFile) return;
|
||||
await dispatch(uploadCsv(csvFile));
|
||||
dispatch(setRefetch(true));
|
||||
setCsvFile(null);
|
||||
setIsModalActive(false);
|
||||
};
|
||||
|
||||
const onModalCancel = () => {
|
||||
setCsvFile(null);
|
||||
setIsModalActive(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Modalities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Modalities" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
<BaseButton className={'mr-3'} href={'/modalities/modalities-new'} color='info' label='New Item' />
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
color='info'
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getModalitiesCSV} />
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Upload CSV'
|
||||
onClick={() => setIsModalActive(true)}
|
||||
/>
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<div id='delete-rows-button'></div>
|
||||
</div>
|
||||
</CardBox>
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TableModalities
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
showGrid={false}
|
||||
/>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
<CardBoxModal
|
||||
title='Upload CSV'
|
||||
buttonColor='info'
|
||||
buttonLabel={'Confirm'}
|
||||
// buttonLabel={false ? 'Deleting...' : 'Confirm'}
|
||||
isActive={isModalActive}
|
||||
onConfirm={onModalConfirm}
|
||||
onCancel={onModalCancel}
|
||||
>
|
||||
<DragDropFilePicker
|
||||
file={csvFile}
|
||||
setFile={setCsvFile}
|
||||
formats={'.csv'}
|
||||
/>
|
||||
</CardBoxModal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
ModalitiesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated>
|
||||
{page}
|
||||
</LayoutAuthenticated>
|
||||
)
|
||||
}
|
||||
|
||||
export default ModalitiesTablesPage
|
||||
95
frontend/src/pages/modalities/modalities-new.tsx
Normal file
95
frontend/src/pages/modalities/modalities-new.tsx
Normal file
@ -0,0 +1,95 @@
|
||||
import { mdiChartTimelineVariant } from '@mdi/js'
|
||||
import Head from 'next/head'
|
||||
import React, { ReactElement } from 'react'
|
||||
import CardBox from '../../components/CardBox'
|
||||
import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
|
||||
import { Field, Form, Formik } from 'formik'
|
||||
import FormField from '../../components/FormField'
|
||||
import BaseDivider from '../../components/BaseDivider'
|
||||
import BaseButtons from '../../components/BaseButtons'
|
||||
import BaseButton from '../../components/BaseButton'
|
||||
import FormCheckRadio from '../../components/FormCheckRadio'
|
||||
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup'
|
||||
import { SwitchField } from '../../components/SwitchField'
|
||||
|
||||
import { SelectField } from '../../components/SelectField'
|
||||
import {RichTextField} from "../../components/RichTextField";
|
||||
|
||||
import { create } from '../../stores/modalities/modalitiesSlice'
|
||||
import { useAppDispatch } from '../../stores/hooks'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
const initialValues = {
|
||||
|
||||
centers: '',
|
||||
|
||||
type: '',
|
||||
|
||||
}
|
||||
|
||||
const ModalitiesNew = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
await dispatch(create(data))
|
||||
await router.push('/modalities/modalities-list')
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('New Item')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
<Formik
|
||||
initialValues={
|
||||
initialValues
|
||||
}
|
||||
onSubmit={(values) => handleSubmit(values)}
|
||||
>
|
||||
<Form>
|
||||
|
||||
<FormField label="centers" labelFor="centers">
|
||||
<Field name="centers" id="centers" component={SelectField} options={[]} itemRef={'centers'}></Field>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Type"
|
||||
>
|
||||
<Field
|
||||
name="type"
|
||||
placeholder="Type"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
<BaseButton type="reset" color="info" outline label="Reset" />
|
||||
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/modalities/modalities-list')}/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
</Formik>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
ModalitiesNew.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated>
|
||||
{page}
|
||||
</LayoutAuthenticated>
|
||||
)
|
||||
}
|
||||
|
||||
export default ModalitiesNew
|
||||
129
frontend/src/pages/modalities/modalities-table.tsx
Normal file
129
frontend/src/pages/modalities/modalities-table.tsx
Normal file
@ -0,0 +1,129 @@
|
||||
import { mdiChartTimelineVariant } from '@mdi/js'
|
||||
import Head from 'next/head'
|
||||
import { uniqueId } from 'lodash';
|
||||
import React, { ReactElement, useState } from 'react'
|
||||
import CardBox from '../../components/CardBox'
|
||||
import LayoutAuthenticated from '../../layouts/Authenticated'
|
||||
import SectionMain from '../../components/SectionMain'
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
||||
import { getPageTitle } from '../../config'
|
||||
import TableModalities from '../../components/Modalities/TableModalities'
|
||||
import BaseButton from '../../components/BaseButton'
|
||||
import axios from "axios";
|
||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||
import CardBoxModal from "../../components/CardBoxModal";
|
||||
import DragDropFilePicker from "../../components/DragDropFilePicker";
|
||||
import {setRefetch, uploadCsv} from '../../stores/modalities/modalitiesSlice';
|
||||
|
||||
const ModalitiesTablesPage = () => {
|
||||
const [filterItems, setFilterItems] = useState([]);
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
const [isModalActive, setIsModalActive] = useState(false);
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const [filters] = useState([{label: 'Type', title: 'type'},
|
||||
|
||||
]);
|
||||
const addFilter = () => {
|
||||
const newItem = {
|
||||
id: uniqueId(),
|
||||
fields: {
|
||||
filterValue: '',
|
||||
filterValueFrom: '',
|
||||
filterValueTo: '',
|
||||
selectedField: '',
|
||||
},
|
||||
};
|
||||
newItem.fields.selectedField = filters[0].title;
|
||||
setFilterItems([...filterItems, newItem]);
|
||||
};
|
||||
|
||||
const getModalitiesCSV = async () => {
|
||||
const response = await axios({url: '/modalities?filetype=csv', method: 'GET',responseType: 'blob'});
|
||||
const type = response.headers['content-type']
|
||||
const blob = new Blob([response.data], { type: type })
|
||||
const link = document.createElement('a')
|
||||
link.href = window.URL.createObjectURL(blob)
|
||||
link.download = 'modalitiesCSV.csv'
|
||||
link.click()
|
||||
};
|
||||
|
||||
const onModalConfirm = async () => {
|
||||
if (!csvFile) return;
|
||||
await dispatch(uploadCsv(csvFile));
|
||||
dispatch(setRefetch(true));
|
||||
setCsvFile(null);
|
||||
setIsModalActive(false);
|
||||
};
|
||||
|
||||
const onModalCancel = () => {
|
||||
setCsvFile(null);
|
||||
setIsModalActive(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Modalities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Modalities" main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox className='mb-6' cardBoxClassName='flex flex-wrap'>
|
||||
<BaseButton className={'mr-3'} href={'/modalities/modalities-new'} color='info' label='New Item' />
|
||||
|
||||
<BaseButton
|
||||
className={'mr-3'}
|
||||
color='info'
|
||||
label='Filter'
|
||||
onClick={addFilter}
|
||||
/>
|
||||
<BaseButton className={'mr-3'} color='info' label='Download CSV' onClick={getModalitiesCSV} />
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Upload CSV'
|
||||
onClick={() => setIsModalActive(true)}
|
||||
/>
|
||||
<div className='md:inline-flex items-center ms-auto'>
|
||||
<div id='delete-rows-button'></div>
|
||||
</div>
|
||||
</CardBox>
|
||||
<CardBox className="mb-6" hasTable>
|
||||
<TableModalities
|
||||
filterItems={filterItems}
|
||||
setFilterItems={setFilterItems}
|
||||
filters={filters}
|
||||
showGrid={true}
|
||||
/>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
<CardBoxModal
|
||||
title='Upload CSV'
|
||||
buttonColor='info'
|
||||
buttonLabel={'Confirm'}
|
||||
// buttonLabel={false ? 'Deleting...' : 'Confirm'}
|
||||
isActive={isModalActive}
|
||||
onConfirm={onModalConfirm}
|
||||
onCancel={onModalCancel}
|
||||
>
|
||||
<DragDropFilePicker
|
||||
file={csvFile}
|
||||
setFile={setCsvFile}
|
||||
formats={'.csv'}
|
||||
/>
|
||||
</CardBoxModal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
ModalitiesTablesPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated>
|
||||
{page}
|
||||
</LayoutAuthenticated>
|
||||
)
|
||||
}
|
||||
|
||||
export default ModalitiesTablesPage
|
||||
85
frontend/src/pages/modalities/modalities-view.tsx
Normal file
85
frontend/src/pages/modalities/modalities-view.tsx
Normal file
@ -0,0 +1,85 @@
|
||||
import React, { ReactElement, useEffect } from 'react';
|
||||
import Head from 'next/head'
|
||||
import DatePicker from "react-datepicker";
|
||||
import "react-datepicker/dist/react-datepicker.css";
|
||||
import dayjs from "dayjs";
|
||||
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
|
||||
import {useRouter} from "next/router";
|
||||
import { fetch } from '../../stores/modalities/modalitiesSlice'
|
||||
import dataFormatter from '../../helpers/dataFormatter';
|
||||
import LayoutAuthenticated from "../../layouts/Authenticated";
|
||||
import {getPageTitle} from "../../config";
|
||||
import SectionTitleLineWithButton from "../../components/SectionTitleLineWithButton";
|
||||
import SectionMain from "../../components/SectionMain";
|
||||
import CardBox from "../../components/CardBox";
|
||||
import BaseButton from "../../components/BaseButton";
|
||||
import BaseDivider from "../../components/BaseDivider";
|
||||
import {mdiChartTimelineVariant} from "@mdi/js";
|
||||
import {SwitchField} from "../../components/SwitchField";
|
||||
import FormField from "../../components/FormField";
|
||||
|
||||
const ModalitiesView = () => {
|
||||
const router = useRouter()
|
||||
const dispatch = useAppDispatch()
|
||||
const { modalities } = useAppSelector((state) => state.modalities)
|
||||
|
||||
const { id } = router.query;
|
||||
|
||||
function removeLastCharacter(str) {
|
||||
console.log(str,`str`)
|
||||
return str.slice(0, -1);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({ id }));
|
||||
}, [dispatch, id]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('View modalities')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View modalities')} main>
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Edit'
|
||||
href={`/modalities/modalities-edit/?id=${id}`}
|
||||
/>
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>centers</p>
|
||||
|
||||
<p>{modalities?.centers?.name ?? 'No data'}</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div className={'mb-4'}>
|
||||
<p className={'block font-bold mb-2'}>Type</p>
|
||||
<p>{modalities?.type}</p>
|
||||
</div>
|
||||
|
||||
<BaseDivider />
|
||||
|
||||
<BaseButton
|
||||
color='info'
|
||||
label='Back'
|
||||
onClick={() => router.push('/modalities/modalities-list')}
|
||||
/>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
ModalitiesView.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<LayoutAuthenticated>
|
||||
{page}
|
||||
</LayoutAuthenticated>
|
||||
)
|
||||
}
|
||||
|
||||
export default ModalitiesView;
|
||||
@ -44,6 +44,16 @@ const EditPatients = () => {
|
||||
|
||||
centers: null,
|
||||
|
||||
'firstname': '',
|
||||
|
||||
'lastname': '',
|
||||
|
||||
'email': '',
|
||||
|
||||
'contactnumber': '',
|
||||
|
||||
'historydescription': '',
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
@ -151,6 +161,51 @@ const EditPatients = () => {
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Firstname"
|
||||
>
|
||||
<Field
|
||||
name="firstname"
|
||||
placeholder="Firstname"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Lastname"
|
||||
>
|
||||
<Field
|
||||
name="lastname"
|
||||
placeholder="Lastname"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
>
|
||||
<Field
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Contactnumber"
|
||||
>
|
||||
<Field
|
||||
name="contactnumber"
|
||||
placeholder="Contactnumber"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Historydescription"
|
||||
>
|
||||
<Field
|
||||
name="historydescription"
|
||||
placeholder="Historydescription"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
|
||||
@ -45,6 +45,16 @@ const EditPatientsPage = () => {
|
||||
|
||||
centers: null,
|
||||
|
||||
'firstname': '',
|
||||
|
||||
'lastname': '',
|
||||
|
||||
'email': '',
|
||||
|
||||
'contactnumber': '',
|
||||
|
||||
'historydescription': '',
|
||||
|
||||
}
|
||||
const [initialValues, setInitialValues] = useState(initVals)
|
||||
|
||||
@ -149,6 +159,51 @@ const EditPatientsPage = () => {
|
||||
></Field>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Firstname"
|
||||
>
|
||||
<Field
|
||||
name="firstname"
|
||||
placeholder="Firstname"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Lastname"
|
||||
>
|
||||
<Field
|
||||
name="lastname"
|
||||
placeholder="Lastname"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
>
|
||||
<Field
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Contactnumber"
|
||||
>
|
||||
<Field
|
||||
name="contactnumber"
|
||||
placeholder="Contactnumber"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Historydescription"
|
||||
>
|
||||
<Field
|
||||
name="historydescription"
|
||||
placeholder="Historydescription"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
|
||||
@ -22,7 +22,7 @@ const PatientsTablesPage = () => {
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Contact', title: 'contact'},{label: 'History', title: 'history'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Contact', title: 'contact'},{label: 'History', title: 'history'},{label: 'Firstname', title: 'firstname'},{label: 'Lastname', title: 'lastname'},{label: 'Email', title: 'email'},{label: 'Contactnumber', title: 'contactnumber'},{label: 'Historydescription', title: 'historydescription'},
|
||||
{label: 'Age', title: 'age', number: 'true'},
|
||||
|
||||
{label: 'Gender', title: 'gender', type: 'enum', options: ['Male','Female','Other']},
|
||||
|
||||
@ -37,6 +37,16 @@ const initialValues = {
|
||||
|
||||
centers: '',
|
||||
|
||||
firstname: '',
|
||||
|
||||
lastname: '',
|
||||
|
||||
email: '',
|
||||
|
||||
contactnumber: '',
|
||||
|
||||
historydescription: '',
|
||||
|
||||
}
|
||||
|
||||
const PatientsNew = () => {
|
||||
@ -113,6 +123,51 @@ const PatientsNew = () => {
|
||||
<Field name="centers" id="centers" component={SelectField} options={[]} itemRef={'centers'}></Field>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Firstname"
|
||||
>
|
||||
<Field
|
||||
name="firstname"
|
||||
placeholder="Firstname"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Lastname"
|
||||
>
|
||||
<Field
|
||||
name="lastname"
|
||||
placeholder="Lastname"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
>
|
||||
<Field
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Contactnumber"
|
||||
>
|
||||
<Field
|
||||
name="contactnumber"
|
||||
placeholder="Contactnumber"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField
|
||||
label="Historydescription"
|
||||
>
|
||||
<Field
|
||||
name="historydescription"
|
||||
placeholder="Historydescription"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
<BaseButtons>
|
||||
<BaseButton type="submit" color="info" label="Submit" />
|
||||
|
||||
@ -22,7 +22,7 @@ const PatientsTablesPage = () => {
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Contact', title: 'contact'},{label: 'History', title: 'history'},
|
||||
const [filters] = useState([{label: 'Name', title: 'name'},{label: 'Contact', title: 'contact'},{label: 'History', title: 'history'},{label: 'Firstname', title: 'firstname'},{label: 'Lastname', title: 'lastname'},{label: 'Email', title: 'email'},{label: 'Contactnumber', title: 'contactnumber'},{label: 'Historydescription', title: 'historydescription'},
|
||||
{label: 'Age', title: 'age', number: 'true'},
|
||||
|
||||
{label: 'Gender', title: 'gender', type: 'enum', options: ['Male','Female','Other']},
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user