Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate patient fields from metadata shared between server and client #185

Merged
merged 34 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
12a86cf
Create Metadata class to store field metadata
fwextensions Jul 15, 2022
638c97f
Move metadata into src/metadata
fwextensions Jul 15, 2022
0310650
Add getters/setters to Ringdown based on field metadata from patient
fwextensions Jul 19, 2022
c021cc6
Prettier nonsense
fwextensions Jul 19, 2022
13cacd1
Add new fields to patient metadata
fwextensions Jul 20, 2022
b2d558d
Add migration for new fields in patient database
fwextensions Jul 21, 2022
185fb35
Tweak names in migration
fwextensions Jul 21, 2022
b4b39ad
Refactor ModelMetadata
fwextensions Jul 21, 2022
ce55e04
Fix server tests to handle new fields
fwextensions Jul 22, 2022
f1a4eee
Add ranges to fields in metadata/patient.js
fwextensions Aug 1, 2022
ea894db
Create Form component to provide context to fields
fwextensions Aug 1, 2022
ae71c02
Move Field component into FormField.js
fwextensions Aug 1, 2022
dc3c960
Add propTypes to Form.js
fwextensions Aug 1, 2022
b0d4154
Clean up after rebasing on master
fwextensions Aug 23, 2022
2d9d881
Fix wrapping in O2 label and field
fwextensions Aug 24, 2022
c8dc2d5
Move Urgency field up into Incident info section
fwextensions Aug 31, 2022
023565e
Add patientDelivery metadata
fwextensions Sep 1, 2022
44635e1
Add metadata for ambulance, emergencyMedicalServiceCall, and emergenc…
fwextensions Sep 1, 2022
85e5ba1
Merge branch 'master' into jdunning/fix/refactor-patient-data
francisli Sep 1, 2022
916a5b4
Make sure defaultValue included in Sequelize attributes, fix tests fo…
francisli Sep 1, 2022
273b9e3
Add metadata for hospital
fwextensions Sep 3, 2022
347748b
Add metadata for hospitalUser
fwextensions Sep 3, 2022
ee6ebda
Add metadata for organization and patientDeliveryUpdate
fwextensions Sep 3, 2022
56b95c4
Add metadata for user
fwextensions Sep 3, 2022
a6f084d
Add defaultValue for timezone in organization to fix tests
fwextensions Sep 3, 2022
4da5add
Unify enumValues and virtualArgs as typeArgs
fwextensions Sep 4, 2022
dcad4ad
Refactor ands simplify ModelMetadata
fwextensions Sep 4, 2022
79c90e0
Move metadata and constants into /src/shared
fwextensions Sep 4, 2022
928020a
Move shared classes and utils to /src/shared
fwextensions Sep 4, 2022
37d7ae5
Create payload sub-objects and defaults programmatically
fwextensions Sep 6, 2022
f942062
Set defaultValue to '' for fields used in comboboxes
fwextensions Sep 7, 2022
59f96ad
Add the field getters/setters to the Ringdown prototype
fwextensions Sep 7, 2022
aeddf4a
Make migration a static standalone script
francisli Sep 8, 2022
bf469e5
Include treatmentNotes and glasgowComaScale fields in ringdown details
francisli Sep 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions constants/deliveryStatus.js

This file was deleted.

1 change: 0 additions & 1 deletion constants/index.js

This file was deleted.

15 changes: 15 additions & 0 deletions migrations/20220721055200-add-gcs-treatments-to-patient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn('patient', 'treatmentnotes', Sequelize.TEXT, { transaction });
await queryInterface.addColumn('patient', 'glasgowcomascale', Sequelize.INTEGER, { transaction });
});
},

async down(queryInterface) {
await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeColumn('patient', 'glasgowcomascale', { transaction });
await queryInterface.removeColumn('patient', 'treatmentnotes', { transaction });
});
},
};
58 changes: 9 additions & 49 deletions models/ambulance.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { Model } = require('sequelize');
const metadata = require('../src/shared/metadata/ambulance');
const convertToSequelizeField = require('../src/shared/convertToSequelizeField');

module.exports = (sequelize, DataTypes) => {
module.exports = (sequelize) => {
class Ambulance extends Model {
static associate(models) {
Ambulance.belongsTo(models.Organization);
Expand All @@ -14,53 +16,11 @@ module.exports = (sequelize, DataTypes) => {
}
}

Ambulance.init(
{
id: {
field: 'ambulance_uuid',
type: DataTypes.UUID,
primaryKey: true,
autoIncrement: true,
},
OrganizationId: {
field: 'emsorganization_uuid',
type: DataTypes.UUID,
},
ambulanceIdentifier: {
field: 'ambulanceidentifier',
type: DataTypes.STRING,
unique: true,
allowNull: false,
},
isActive: {
field: 'activeindicator',
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true,
},
createdAt: {
field: 'recordcreatetimestamp',
type: DataTypes.DATE,
},
CreatedById: {
field: 'recordcreateuser_uuid',
type: DataTypes.UUID,
},
updatedAt: {
field: 'recordupdatetimestamp',
type: DataTypes.DATE,
},
UpdatedById: {
field: 'recordupdateuser_uuid',
type: DataTypes.UUID,
},
},
{
sequelize,
timestamps: true,
tableName: 'ambulance',
modelName: 'Ambulance',
}
);
Ambulance.init(metadata.getFieldHash(convertToSequelizeField), {
sequelize,
timestamps: true,
tableName: metadata.tableName,
modelName: metadata.modelName,
});
return Ambulance;
};
52 changes: 9 additions & 43 deletions models/emergencyMedicalServiceCall.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { Model } = require('sequelize');
const metadata = require('../src/shared/metadata/emergencyMedicalServiceCall');
const convertToSequelizeField = require('../src/shared/convertToSequelizeField');

module.exports = (sequelize, DataTypes) => {
module.exports = (sequelize) => {
class EmergencyMedicalServiceCall extends Model {
/**
* Helper method for defining associations.
Expand All @@ -17,47 +19,11 @@ module.exports = (sequelize, DataTypes) => {
EmergencyMedicalServiceCall.belongsTo(models.User, { as: 'UpdatedBy' });
}
}
EmergencyMedicalServiceCall.init(
{
id: {
field: 'emergencymedicalservicecall_uuid',
type: DataTypes.UUID,
primaryKey: true,
autoIncrement: true,
},
dispatchCallNumber: {
field: 'dispatchcallnumber',
type: DataTypes.INTEGER,
allowNull: false,
},
startDateTimeLocal: {
field: 'startdatetimelocal',
type: DataTypes.DATE,
allowNull: false,
},
createdAt: {
field: 'recordcreatetimestamp',
type: DataTypes.DATE,
},
CreatedById: {
field: 'recordcreateuser_uuid',
type: DataTypes.UUID,
},
updatedAt: {
field: 'recordupdatetimestamp',
type: DataTypes.DATE,
},
UpdatedById: {
field: 'recordupdateuser_uuid',
type: DataTypes.UUID,
},
},
{
sequelize,
timestamps: true,
tableName: 'emergencymedicalservicecall',
modelName: 'EmergencyMedicalServiceCall',
}
);
EmergencyMedicalServiceCall.init(metadata.getFieldHash(convertToSequelizeField), {
sequelize,
timestamps: true,
tableName: metadata.tableName,
modelName: metadata.modelName,
});
return EmergencyMedicalServiceCall;
};
55 changes: 9 additions & 46 deletions models/emergencyMedicalServiceCallAmbulance.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { Model } = require('sequelize');
const metadata = require('../src/shared/metadata/emergencyMedicalServiceCallAmbulance');
const convertToSequelizeField = require('../src/shared/convertToSequelizeField');

module.exports = (sequelize, DataTypes) => {
module.exports = (sequelize) => {
class EmergencyMedicalServiceCallAmbulance extends Model {
/**
* Helper method for defining associations.
Expand All @@ -15,50 +17,11 @@ module.exports = (sequelize, DataTypes) => {
EmergencyMedicalServiceCallAmbulance.belongsTo(models.User, { as: 'UpdatedBy' });
}
}
EmergencyMedicalServiceCallAmbulance.init(
{
id: {
field: 'emergencymedicalservicecallambulance_uuid',
type: DataTypes.UUID,
primaryKey: true,
autoIncrement: true,
},
EmergencyMedicalServiceCallId: {
field: 'emergencymedicalservicecall_uuid',
type: DataTypes.UUID,
},
AmbulanceId: {
field: 'ambulance_uuid',
type: DataTypes.UUID,
},
startDateTimeLocal: {
field: 'startdatetimelocal',
type: DataTypes.DATE,
allowNull: false,
},
createdAt: {
field: 'recordcreatetimestamp',
type: DataTypes.DATE,
},
CreatedById: {
field: 'recordcreateuser_uuid',
type: DataTypes.UUID,
},
updatedAt: {
field: 'recordupdatetimestamp',
type: DataTypes.DATE,
},
UpdatedById: {
field: 'recordupdateuser_uuid',
type: DataTypes.UUID,
},
},
{
sequelize,
timestamps: true,
tableName: 'emergencymedicalservicecallambulance',
modelName: 'EmergencyMedicalServiceCallAmbulance',
}
);
EmergencyMedicalServiceCallAmbulance.init(metadata.getFieldHash(convertToSequelizeField), {
sequelize,
timestamps: true,
tableName: metadata.tableName,
modelName: metadata.modelName,
});
return EmergencyMedicalServiceCallAmbulance;
};
73 changes: 10 additions & 63 deletions models/hospital.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const _ = require('lodash');
const { Model } = require('sequelize');
const { DeliveryStatus } = require('../constants');
const { DeliveryStatus } = require('../src/shared/constants');
const metadata = require('../src/shared/metadata/hospital');
const convertToSequelizeField = require('../src/shared/convertToSequelizeField');

module.exports = (sequelize, DataTypes) => {
module.exports = (sequelize) => {
class Hospital extends Model {
static associate(models) {
Hospital.belongsTo(models.Organization);
Expand Down Expand Up @@ -48,66 +50,11 @@ module.exports = (sequelize, DataTypes) => {
}
}

Hospital.init(
{
// this is the value used to determine who each nurse belongs to
id: {
field: 'hospital_uuid',
type: DataTypes.UUID,
primaryKey: true,
autoIncrement: true,
},
OrganizationId: {
field: 'healthcareorganization_uuid',
type: DataTypes.UUID,
},
name: {
field: 'hospitalname',
type: DataTypes.STRING,
unique: true,
allowNull: false,
},
state: {
field: 'hospitalstate',
type: DataTypes.STRING,
},
stateFacilityCode: {
field: 'hospitalstatefacilitycode',
type: DataTypes.STRING,
},
sortSequenceNumber: {
field: 'sortsequencenumber',
type: DataTypes.INTEGER,
},
isActive: {
field: 'activeindicator',
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true,
},
createdAt: {
field: 'recordcreatetimestamp',
type: DataTypes.DATE,
},
CreatedById: {
field: 'recordcreateuser_uuid',
type: DataTypes.UUID,
},
updatedAt: {
field: 'recordupdatetimestamp',
type: DataTypes.DATE,
},
UpdatedById: {
field: 'recordupdateuser_uuid',
type: DataTypes.UUID,
},
},
{
sequelize,
timestamps: true,
tableName: 'hospital',
modelName: 'Hospital',
}
);
Hospital.init(metadata.getFieldHash(convertToSequelizeField), {
sequelize,
timestamps: true,
tableName: metadata.tableName,
modelName: metadata.modelName,
});
return Hospital;
};
Loading