@ai-ecom/medusa-plugin-patient-record
Version:
A plugin for patient record
275 lines (274 loc) • 21.5 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.intialPatientRecord1688582288836 = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var intialPatientRecord1688582288836 = exports.intialPatientRecord1688582288836 = /*#__PURE__*/function () {
function intialPatientRecord1688582288836() {
(0, _classCallCheck2["default"])(this, intialPatientRecord1688582288836);
(0, _defineProperty2["default"])(this, "name", "intialPatientRecord1688582288836");
}
return (0, _createClass2["default"])(intialPatientRecord1688582288836, [{
key: "up",
value: function () {
var _up = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(queryRunner) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return queryRunner.query("CREATE TABLE \"physical_measurement\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"value\" double precision NOT NULL, \"examination_id\" character varying, \"record_unit_id\" character varying, CONSTRAINT \"REL_24027ca7a232f1031646623291\" UNIQUE (\"examination_id\"), CONSTRAINT \"PK_92161dde0b0118462ba9c626dbe\" PRIMARY KEY (\"id\"))");
case 2:
_context.next = 4;
return queryRunner.query("CREATE TABLE \"unit_category\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, CONSTRAINT \"PK_712ecbc07fd22c595283395f4c9\" PRIMARY KEY (\"id\"))");
case 4:
_context.next = 6;
return queryRunner.query("CREATE TABLE \"conversion\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"factor\" double precision NOT NULL, \"record_unit_from_id\" character varying, \"record_unit_to_id\" character varying, CONSTRAINT \"PK_47d350fae88ddb04db6de706bc8\" PRIMARY KEY (\"id\"))");
case 6:
_context.next = 8;
return queryRunner.query("CREATE TABLE \"record_unit\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"unit_category_id\" character varying, CONSTRAINT \"PK_9a78628d8217abd2f9b60949846\" PRIMARY KEY (\"id\"))");
case 8:
_context.next = 10;
return queryRunner.query("CREATE TABLE \"examination_title\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"title\" character varying NOT NULL, CONSTRAINT \"PK_b39bfc0d6beed0daaf0feecfe5d\" PRIMARY KEY (\"id\"))");
case 10:
_context.next = 12;
return queryRunner.query("CREATE TYPE \"super_customer_gender_enum\" AS ENUM('male', 'female', 'diverse')");
case 12:
_context.next = 14;
return queryRunner.query("CREATE TABLE \"reference_value\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"gender\" \"super_customer_gender_enum\" NOT NULL, \"low_bad_value\" double precision NOT NULL, \"high_bad_value\" double precision NOT NULL, \"low_normal_value\" double precision NOT NULL, \"high_normal_value\" double precision NOT NULL, \"low_good_value\" double precision NOT NULL, \"high_good_value\" double precision NOT NULL, \"hint\" character varying NOT NULL, \"examination_title_id\" character varying, \"record_unit_id\" character varying, CONSTRAINT \"PK_1b72f1fc843b6231050392aa4e9\" PRIMARY KEY (\"id\"))");
case 14:
_context.next = 16;
return queryRunner.query("CREATE TABLE \"ethnicity\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, CONSTRAINT \"PK_bbeaf6fff4fda1b0daabe64ed2d\" PRIMARY KEY (\"id\"))");
case 16:
_context.next = 18;
return queryRunner.query("CREATE TABLE \"super_customer\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"gender\" \"super_customer_gender_enum\" NOT NULL, \"birthday\" date, \"ethnicity_id\" character varying, CONSTRAINT \"PK_9e0937d5fd8df233582d5b47fb7\" PRIMARY KEY (\"id\"))");
case 18:
_context.next = 20;
return queryRunner.query("CREATE TYPE \"examination_status_enum\" AS ENUM('pending', 'in_progress', 'completed', 'cancelled', 'failed', 'passed', 'not_started')");
case 20:
_context.next = 22;
return queryRunner.query("CREATE TYPE \"examination_type_enum\" AS ENUM('blood_work', 'dicon_examination', 'physical_measurement')");
case 22:
_context.next = 24;
return queryRunner.query("CREATE TABLE \"examination\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"date\" date NOT NULL, \"reference_id\" character varying NOT NULL, \"appointment_id\" character varying NOT NULL, \"status\" \"examination_status_enum\" NOT NULL, \"type\" \"examination_type_enum\" NOT NULL, \"user_id\" character varying, \"examination_title_id\" character varying, CONSTRAINT \"PK_de7c2a81d379fdf37174356fc12\" PRIMARY KEY (\"id\"))");
case 24:
_context.next = 26;
return queryRunner.query("CREATE TABLE \"blood_work_method\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"name\" character varying NOT NULL, CONSTRAINT \"PK_7e2ca1817c8774b44099a170e4b\" PRIMARY KEY (\"id\"))");
case 26:
_context.next = 28;
return queryRunner.query("CREATE TABLE \"blood_work\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"value\" double precision NOT NULL, \"hint\" character varying NOT NULL, \"examination_id\" character varying, \"blood_work_method_id\" character varying, \"record_unit_id\" character varying, CONSTRAINT \"REL_ddc1c8d49dbbe744214259b9c0\" UNIQUE (\"examination_id\"), CONSTRAINT \"PK_04649cc57ea997e59a26f907282\" PRIMARY KEY (\"id\"))");
case 28:
_context.next = 30;
return queryRunner.query("CREATE TABLE \"dicom_examination\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"hint\" character varying NOT NULL, \"examination_id\" character varying, CONSTRAINT \"REL_6c7fc3c0f6d954d393b856caad\" UNIQUE (\"examination_id\"), CONSTRAINT \"PK_82f53534da4edb775d154ae73f1\" PRIMARY KEY (\"id\"))");
case 30:
_context.next = 32;
return queryRunner.query("CREATE TABLE \"dicom_image\" (\"id\" character varying NOT NULL, \"created_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"updated_at\" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), \"deleted_at\" TIMESTAMP WITH TIME ZONE, \"url\" character varying NOT NULL, \"metadata\" jsonb, \"dicom_examination_id\" character varying, CONSTRAINT \"PK_f06abb78e4493e4e5f911ed9214\" PRIMARY KEY (\"id\"))");
case 32:
_context.next = 34;
return queryRunner.query("CREATE TABLE \"ethnicities_have_reference_values\" (\"ethnicity_id\" character varying NOT NULL, \"reference_value_id\" character varying NOT NULL, CONSTRAINT \"PK_0aaf2577476dbdfe04eae58a037\" PRIMARY KEY (\"ethnicity_id\", \"reference_value_id\"))");
case 34:
_context.next = 36;
return queryRunner.query("CREATE INDEX \"IDX_f2f8d11319c3db60d75d5ae9df\" ON \"ethnicities_have_reference_values\" (\"ethnicity_id\") ");
case 36:
_context.next = 38;
return queryRunner.query("CREATE INDEX \"IDX_a53cf2b2fdf22424cbea09591b\" ON \"ethnicities_have_reference_values\" (\"reference_value_id\") ");
case 38:
_context.next = 40;
return queryRunner.query("ALTER TABLE \"physical_measurement\" ADD CONSTRAINT \"FK_24027ca7a232f1031646623291e\" FOREIGN KEY (\"examination_id\") REFERENCES \"examination\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 40:
_context.next = 42;
return queryRunner.query("ALTER TABLE \"physical_measurement\" ADD CONSTRAINT \"FK_6ac2827dfebf422be9f5d894a74\" FOREIGN KEY (\"record_unit_id\") REFERENCES \"record_unit\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 42:
_context.next = 44;
return queryRunner.query("ALTER TABLE \"conversion\" ADD CONSTRAINT \"FK_61902974bb07c03933398e00a6f\" FOREIGN KEY (\"record_unit_from_id\") REFERENCES \"record_unit\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 44:
_context.next = 46;
return queryRunner.query("ALTER TABLE \"conversion\" ADD CONSTRAINT \"FK_dc594b299e396510db53df54304\" FOREIGN KEY (\"record_unit_to_id\") REFERENCES \"record_unit\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 46:
_context.next = 48;
return queryRunner.query("ALTER TABLE \"conversion\" ADD CONSTRAINT \"UQ_conversion_record_unit\" UNIQUE (\"record_unit_from_id\", \"record_unit_to_id\");");
case 48:
_context.next = 50;
return queryRunner.query("ALTER TABLE \"record_unit\" ADD CONSTRAINT \"FK_70a5c921a2da40c4eea40af5119\" FOREIGN KEY (\"unit_category_id\") REFERENCES \"unit_category\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 50:
_context.next = 52;
return queryRunner.query("ALTER TABLE \"reference_value\" ADD CONSTRAINT \"FK_4b792a087f5abaa087bef3ff247\" FOREIGN KEY (\"examination_title_id\") REFERENCES \"examination_title\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 52:
_context.next = 54;
return queryRunner.query("ALTER TABLE \"reference_value\" ADD CONSTRAINT \"FK_53860204daed4ce5bfeb1eb906e\" FOREIGN KEY (\"record_unit_id\") REFERENCES \"record_unit\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 54:
_context.next = 56;
return queryRunner.query("ALTER TABLE \"super_customer\" ADD CONSTRAINT \"FK_c271c5e1d090c1351ceafd9ca8d\" FOREIGN KEY (\"ethnicity_id\") REFERENCES \"ethnicity\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 56:
_context.next = 58;
return queryRunner.query("ALTER TABLE \"examination\" ADD CONSTRAINT \"FK_9f8174834a9f49e59853173e6c7\" FOREIGN KEY (\"user_id\") REFERENCES \"super_customer\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 58:
_context.next = 60;
return queryRunner.query("ALTER TABLE \"examination\" ADD CONSTRAINT \"FK_95ee643366c76da4312b99d2ce0\" FOREIGN KEY (\"examination_title_id\") REFERENCES \"examination_title\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 60:
_context.next = 62;
return queryRunner.query("ALTER TABLE \"blood_work\" ADD CONSTRAINT \"FK_ddc1c8d49dbbe744214259b9c02\" FOREIGN KEY (\"examination_id\") REFERENCES \"examination\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 62:
_context.next = 64;
return queryRunner.query("ALTER TABLE \"blood_work\" ADD CONSTRAINT \"FK_8f0e1763ed29e24f13f3f19c316\" FOREIGN KEY (\"blood_work_method_id\") REFERENCES \"blood_work_method\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 64:
_context.next = 66;
return queryRunner.query("ALTER TABLE \"blood_work\" ADD CONSTRAINT \"FK_f42a0db8411be3aa0a2fbaa61bc\" FOREIGN KEY (\"record_unit_id\") REFERENCES \"record_unit\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 66:
_context.next = 68;
return queryRunner.query("ALTER TABLE \"dicom_examination\" ADD CONSTRAINT \"FK_6c7fc3c0f6d954d393b856caad4\" FOREIGN KEY (\"examination_id\") REFERENCES \"examination\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 68:
_context.next = 70;
return queryRunner.query("ALTER TABLE \"dicom_image\" ADD CONSTRAINT \"FK_f1e5310173d19aec55153af40a3\" FOREIGN KEY (\"dicom_examination_id\") REFERENCES \"dicom_examination\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 70:
_context.next = 72;
return queryRunner.query("ALTER TABLE \"ethnicities_have_reference_values\" ADD CONSTRAINT \"FK_f2f8d11319c3db60d75d5ae9df6\" FOREIGN KEY (\"ethnicity_id\") REFERENCES \"ethnicity\"(\"id\") ON DELETE CASCADE ON UPDATE CASCADE");
case 72:
_context.next = 74;
return queryRunner.query("ALTER TABLE \"ethnicities_have_reference_values\" ADD CONSTRAINT \"FK_a53cf2b2fdf22424cbea09591b9\" FOREIGN KEY (\"reference_value_id\") REFERENCES \"reference_value\"(\"id\") ON DELETE NO ACTION ON UPDATE NO ACTION");
case 74:
case "end":
return _context.stop();
}
}, _callee);
}));
function up(_x) {
return _up.apply(this, arguments);
}
return up;
}()
}, {
key: "down",
value: function () {
var _down = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(queryRunner) {
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return queryRunner.query("ALTER TABLE \"ethnicities_have_reference_values\" DROP CONSTRAINT \"FK_a53cf2b2fdf22424cbea09591b9\"");
case 2:
_context2.next = 4;
return queryRunner.query("ALTER TABLE \"ethnicities_have_reference_values\" DROP CONSTRAINT \"FK_f2f8d11319c3db60d75d5ae9df6\"");
case 4:
_context2.next = 6;
return queryRunner.query("ALTER TABLE \"dicom_image\" DROP CONSTRAINT \"FK_f1e5310173d19aec55153af40a3\"");
case 6:
_context2.next = 8;
return queryRunner.query("ALTER TABLE \"dicom_examination\" DROP CONSTRAINT \"FK_6c7fc3c0f6d954d393b856caad4\"");
case 8:
_context2.next = 10;
return queryRunner.query("ALTER TABLE \"blood_work\" DROP CONSTRAINT \"FK_f42a0db8411be3aa0a2fbaa61bc\"");
case 10:
_context2.next = 12;
return queryRunner.query("ALTER TABLE \"blood_work\" DROP CONSTRAINT \"FK_8f0e1763ed29e24f13f3f19c316\"");
case 12:
_context2.next = 14;
return queryRunner.query("ALTER TABLE \"blood_work\" DROP CONSTRAINT \"FK_ddc1c8d49dbbe744214259b9c02\"");
case 14:
_context2.next = 16;
return queryRunner.query("ALTER TABLE \"examination\" DROP CONSTRAINT \"FK_95ee643366c76da4312b99d2ce0\"");
case 16:
_context2.next = 18;
return queryRunner.query("ALTER TABLE \"examination\" DROP CONSTRAINT \"FK_9f8174834a9f49e59853173e6c7\"");
case 18:
_context2.next = 20;
return queryRunner.query("ALTER TABLE \"super_customer\" DROP CONSTRAINT \"FK_c271c5e1d090c1351ceafd9ca8d\"");
case 20:
_context2.next = 22;
return queryRunner.query("ALTER TABLE \"reference_value\" DROP CONSTRAINT \"FK_53860204daed4ce5bfeb1eb906e\"");
case 22:
_context2.next = 24;
return queryRunner.query("ALTER TABLE \"reference_value\" DROP CONSTRAINT \"FK_4b792a087f5abaa087bef3ff247\"");
case 24:
_context2.next = 26;
return queryRunner.query("ALTER TABLE \"record_unit\" DROP CONSTRAINT \"FK_70a5c921a2da40c4eea40af5119\"");
case 26:
_context2.next = 28;
return queryRunner.query("ALTER TABLE \"conversion\" DROP CONSTRAINT \"UQ_conversion_record_unit\"");
case 28:
_context2.next = 30;
return queryRunner.query("ALTER TABLE \"conversion\" DROP CONSTRAINT \"FK_dc594b299e396510db53df54304\"");
case 30:
_context2.next = 32;
return queryRunner.query("ALTER TABLE \"conversion\" DROP CONSTRAINT \"FK_61902974bb07c03933398e00a6f\"");
case 32:
_context2.next = 34;
return queryRunner.query("ALTER TABLE \"physical_measurement\" DROP CONSTRAINT \"FK_6ac2827dfebf422be9f5d894a74\"");
case 34:
_context2.next = 36;
return queryRunner.query("ALTER TABLE \"physical_measurement\" DROP CONSTRAINT \"FK_24027ca7a232f1031646623291e\"");
case 36:
_context2.next = 38;
return queryRunner.query("DROP INDEX \"IDX_a53cf2b2fdf22424cbea09591b\"");
case 38:
_context2.next = 40;
return queryRunner.query("DROP INDEX \"IDX_f2f8d11319c3db60d75d5ae9df\"");
case 40:
_context2.next = 42;
return queryRunner.query("DROP TABLE \"ethnicities_have_reference_values\"");
case 42:
_context2.next = 44;
return queryRunner.query("DROP TABLE \"dicom_image\"");
case 44:
_context2.next = 46;
return queryRunner.query("DROP TABLE \"dicom_examination\"");
case 46:
_context2.next = 48;
return queryRunner.query("DROP TABLE \"blood_work\"");
case 48:
_context2.next = 50;
return queryRunner.query("DROP TABLE \"blood_work_method\"");
case 50:
_context2.next = 52;
return queryRunner.query("DROP TABLE \"examination\"");
case 52:
_context2.next = 54;
return queryRunner.query("DROP TYPE \"examination_type_enum\"");
case 54:
_context2.next = 56;
return queryRunner.query("DROP TYPE \"examination_status_enum\"");
case 56:
_context2.next = 58;
return queryRunner.query("DROP TABLE \"super_customer\"");
case 58:
_context2.next = 60;
return queryRunner.query("DROP TABLE \"ethnicity\"");
case 60:
_context2.next = 62;
return queryRunner.query("DROP TABLE \"reference_value\"");
case 62:
_context2.next = 64;
return queryRunner.query("DROP TYPE \"super_customer_gender_enum\"");
case 64:
_context2.next = 66;
return queryRunner.query("DROP TABLE \"examination_title\"");
case 66:
_context2.next = 68;
return queryRunner.query("DROP TABLE \"record_unit\"");
case 68:
_context2.next = 70;
return queryRunner.query("DROP TABLE \"conversion\"");
case 70:
_context2.next = 72;
return queryRunner.query("DROP TABLE \"unit_category\"");
case 72:
_context2.next = 74;
return queryRunner.query("DROP TABLE \"physical_measurement\"");
case 74:
case "end":
return _context2.stop();
}
}, _callee2);
}));
function down(_x2) {
return _down.apply(this, arguments);
}
return down;
}()
}]);
}();