cqm-models 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.json +1 -1
- data/README.md +9 -6
- data/app/assets/javascripts/AdverseEvent.js +9 -3
- data/app/assets/javascripts/AllDataElements.js +18 -6
- data/app/assets/javascripts/AllergyIntolerance.js +8 -2
- data/app/assets/javascripts/AssessmentOrder.js +8 -2
- data/app/assets/javascripts/AssessmentPerformed.js +11 -3
- data/app/assets/javascripts/AssessmentRecommended.js +8 -2
- data/app/assets/javascripts/CareGoal.js +10 -3
- data/app/assets/javascripts/CommunicationPerformed.js +12 -6
- data/app/assets/javascripts/DeviceApplied.js +9 -2
- data/app/assets/javascripts/DeviceOrder.js +8 -2
- data/app/assets/javascripts/DeviceRecommended.js +8 -2
- data/app/assets/javascripts/Diagnosis.js +8 -2
- data/app/assets/javascripts/DiagnosticStudyOrder.js +8 -2
- data/app/assets/javascripts/DiagnosticStudyPerformed.js +9 -2
- data/app/assets/javascripts/DiagnosticStudyRecommended.js +8 -2
- data/app/assets/javascripts/EncounterOrder.js +9 -2
- data/app/assets/javascripts/EncounterPerformed.js +11 -5
- data/app/assets/javascripts/EncounterRecommended.js +8 -2
- data/app/assets/javascripts/FamilyHistory.js +8 -2
- data/app/assets/javascripts/ImmunizationAdministered.js +9 -2
- data/app/assets/javascripts/ImmunizationOrder.js +8 -2
- data/app/assets/javascripts/InterventionOrder.js +8 -2
- data/app/assets/javascripts/InterventionPerformed.js +9 -2
- data/app/assets/javascripts/InterventionRecommended.js +8 -2
- data/app/assets/javascripts/LaboratoryTestOrder.js +8 -2
- data/app/assets/javascripts/LaboratoryTestPerformed.js +9 -2
- data/app/assets/javascripts/LaboratoryTestRecommended.js +8 -2
- data/app/assets/javascripts/MedicationActive.js +9 -2
- data/app/assets/javascripts/MedicationAdministered.js +9 -2
- data/app/assets/javascripts/MedicationDischarge.js +9 -2
- data/app/assets/javascripts/MedicationDispensed.js +10 -4
- data/app/assets/javascripts/MedicationOrder.js +9 -4
- data/app/assets/javascripts/Participation.js +8 -2
- data/app/assets/javascripts/PatientCareExperience.js +8 -2
- data/app/assets/javascripts/PatientCharacteristic.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicBirthdate.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicEthnicity.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicExpired.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicPayer.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicRace.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicSex.js +7 -2
- data/app/assets/javascripts/PhysicalExamOrder.js +8 -2
- data/app/assets/javascripts/PhysicalExamPerformed.js +9 -2
- data/app/assets/javascripts/PhysicalExamRecommended.js +8 -2
- data/app/assets/javascripts/ProcedureOrder.js +10 -3
- data/app/assets/javascripts/ProcedurePerformed.js +11 -3
- data/app/assets/javascripts/ProcedureRecommended.js +9 -3
- data/app/assets/javascripts/ProviderCareExperience.js +8 -2
- data/app/assets/javascripts/QDMPatient.js +25 -9
- data/app/assets/javascripts/RelatedPerson.js +42 -0
- data/app/assets/javascripts/SubstanceAdministered.js +9 -2
- data/app/assets/javascripts/SubstanceOrder.js +9 -2
- data/app/assets/javascripts/SubstanceRecommended.js +8 -2
- data/app/assets/javascripts/Symptom.js +8 -2
- data/app/assets/javascripts/attributes/CarePartner.js +31 -0
- data/app/assets/javascripts/attributes/Component.js +22 -1
- data/app/assets/javascripts/attributes/DiagnosisComponent.js +34 -0
- data/app/assets/javascripts/attributes/Entity.js +58 -0
- data/app/assets/javascripts/attributes/FacilityLocation.js +4 -1
- data/app/assets/javascripts/attributes/Identifier.js +23 -0
- data/app/assets/javascripts/attributes/Organization.js +31 -0
- data/app/assets/javascripts/attributes/PatientEntity.js +30 -0
- data/app/assets/javascripts/attributes/Practitioner.js +33 -0
- data/app/assets/javascripts/attributes/ResultComponent.js +31 -0
- data/app/assets/javascripts/basetypes/Any.js +24 -14
- data/app/assets/javascripts/basetypes/AnyEntity.js +44 -0
- data/app/assets/javascripts/basetypes/Code.js +8 -11
- data/app/assets/javascripts/basetypes/DataElement.js +14 -6
- data/app/assets/javascripts/basetypes/Interval.js +2 -2
- data/app/assets/javascripts/basetypes/QDMDate.js +36 -0
- data/app/assets/javascripts/basetypes/Quantity.js +1 -1
- data/app/assets/javascripts/basetypes/Ratio.js +1 -1
- data/app/assets/javascripts/cqm/Provider.js +0 -2
- data/app/models/cqm/provider.rb +4 -4
- data/app/models/hqmfOid_to_datatype_map.json +1 -1
- data/app/models/models.rb +12 -5
- data/app/models/qdm/adverse_event.rb +3 -2
- data/app/models/qdm/allergy_intolerance.rb +2 -1
- data/app/models/qdm/assessment_order.rb +2 -1
- data/app/models/qdm/assessment_performed.rb +5 -2
- data/app/models/qdm/assessment_recommended.rb +2 -1
- data/app/models/qdm/attributes/care_partner.rb +8 -0
- data/app/models/qdm/attributes/component.rb +1 -1
- data/app/models/qdm/attributes/diagnosis_component.rb +10 -0
- data/app/models/qdm/attributes/entity.rb +15 -0
- data/app/models/qdm/attributes/facility_location.rb +1 -1
- data/app/models/qdm/{id.rb → attributes/identifier.rb} +3 -4
- data/app/models/qdm/attributes/organization.rb +8 -0
- data/app/models/qdm/attributes/patient_entity.rb +7 -0
- data/app/models/qdm/attributes/practitioner.rb +10 -0
- data/app/models/qdm/{result_component.rb → attributes/result_component.rb} +1 -3
- data/app/models/qdm/basetypes/code.rb +8 -10
- data/app/models/qdm/basetypes/data_element.rb +19 -6
- data/app/models/qdm/basetypes/date.rb +38 -0
- data/app/models/qdm/basetypes/interval.rb +2 -2
- data/app/models/qdm/care_goal.rb +4 -2
- data/app/models/qdm/communication_performed.rb +6 -5
- data/app/models/qdm/device_applied.rb +3 -1
- data/app/models/qdm/device_order.rb +2 -1
- data/app/models/qdm/device_recommended.rb +2 -1
- data/app/models/qdm/diagnosis.rb +2 -1
- data/app/models/qdm/diagnostic_study_order.rb +2 -1
- data/app/models/qdm/diagnostic_study_performed.rb +3 -1
- data/app/models/qdm/diagnostic_study_recommended.rb +2 -1
- data/app/models/qdm/encounter_order.rb +3 -1
- data/app/models/qdm/encounter_performed.rb +3 -2
- data/app/models/qdm/encounter_recommended.rb +2 -1
- data/app/models/qdm/family_history.rb +2 -1
- data/app/models/qdm/immunization_administered.rb +3 -1
- data/app/models/qdm/immunization_order.rb +2 -1
- data/app/models/qdm/intervention_order.rb +2 -1
- data/app/models/qdm/intervention_performed.rb +3 -1
- data/app/models/qdm/intervention_recommended.rb +2 -1
- data/app/models/qdm/laboratory_test_order.rb +2 -1
- data/app/models/qdm/laboratory_test_performed.rb +3 -1
- data/app/models/qdm/laboratory_test_recommended.rb +2 -1
- data/app/models/qdm/medication_active.rb +3 -1
- data/app/models/qdm/medication_administered.rb +3 -1
- data/app/models/qdm/medication_discharge.rb +3 -1
- data/app/models/qdm/medication_dispensed.rb +4 -3
- data/app/models/qdm/medication_order.rb +3 -3
- data/app/models/qdm/participation.rb +2 -1
- data/app/models/qdm/patient.rb +1 -1
- data/app/models/qdm/patient_care_experience.rb +2 -1
- data/app/models/qdm/patient_characteristic.rb +1 -1
- data/app/models/qdm/patient_characteristic_birthdate.rb +1 -1
- data/app/models/qdm/patient_characteristic_clinical_trial_participant.rb +1 -1
- data/app/models/qdm/patient_characteristic_ethnicity.rb +1 -1
- data/app/models/qdm/patient_characteristic_expired.rb +1 -1
- data/app/models/qdm/patient_characteristic_payer.rb +1 -1
- data/app/models/qdm/patient_characteristic_race.rb +1 -1
- data/app/models/qdm/patient_characteristic_sex.rb +1 -1
- data/app/models/qdm/physical_exam_order.rb +2 -1
- data/app/models/qdm/physical_exam_performed.rb +3 -1
- data/app/models/qdm/physical_exam_recommended.rb +2 -1
- data/app/models/qdm/procedure_order.rb +4 -2
- data/app/models/qdm/procedure_performed.rb +5 -2
- data/app/models/qdm/procedure_recommended.rb +3 -2
- data/app/models/qdm/provider_care_experience.rb +2 -1
- data/app/models/qdm/related_person.rb +13 -0
- data/app/models/qdm/substance_administered.rb +3 -1
- data/app/models/qdm/substance_order.rb +3 -1
- data/app/models/qdm/substance_recommended.rb +2 -1
- data/app/models/qdm/symptom.rb +2 -1
- data/bin/validate_generator.sh +1 -1
- data/cqm-models.gemspec +2 -2
- data/data/oids_qdm_5.5.json +321 -0
- data/dist/browser.js +3434 -3356
- data/dist/index.js +3433 -3355
- data/lib/generate_models.rb +78 -39
- data/lib/generate_patients.rb +3 -3
- data/lib/generate_types.rb +1 -1
- data/lib/generator_helpers.rb +14 -0
- data/modelinfo/qdm-modelinfo-5.5.xml +982 -0
- data/package.json +2 -2
- data/templates/entity_extension.rb.erb +6 -0
- data/templates/identifier_extension.rb.erb +58 -0
- data/templates/{id_template.js.erb → identifier_template.js.erb} +6 -5
- data/templates/models_template.rb.erb +19 -4
- data/templates/mongoose_template.js.erb +86 -12
- data/templates/patient_template.js.erb +0 -4
- data/yarn.lock +245 -201
- metadata +31 -11
- data/app/assets/javascripts/Id.js +0 -21
- data/app/assets/javascripts/ProviderCharacteristic.js +0 -36
- data/app/assets/javascripts/ResultComponent.js +0 -33
- data/app/models/qdm/provider_characteristic.rb +0 -12
@@ -0,0 +1,31 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const { EntitySchemaFunction } = require('./Entity');
|
4
|
+
const Code = require('../basetypes/Code');
|
5
|
+
const Interval = require('../basetypes/Interval');
|
6
|
+
const Quantity = require('../basetypes/Quantity');
|
7
|
+
const DateTime = require('../basetypes/DateTime');
|
8
|
+
const QDMDate = require('../basetypes/QDMDate');
|
9
|
+
const Any = require('../basetypes/Any');
|
10
|
+
|
11
|
+
const [Number, String] = [
|
12
|
+
mongoose.Schema.Types.Number,
|
13
|
+
mongoose.Schema.Types.String,
|
14
|
+
];
|
15
|
+
|
16
|
+
const CarePartnerSchema = EntitySchemaFunction({
|
17
|
+
relationship: Code,
|
18
|
+
_type: { type: String, default: 'QDM::CarePartner' },
|
19
|
+
|
20
|
+
});
|
21
|
+
|
22
|
+
module.exports.CarePartnerSchema = CarePartnerSchema;
|
23
|
+
class CarePartner extends mongoose.Document {
|
24
|
+
constructor(object) {
|
25
|
+
super(object, CarePartnerSchema);
|
26
|
+
this._type = 'QDM::CarePartner';
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports.CarePartner = CarePartner;
|
31
|
+
|
@@ -4,8 +4,10 @@ const Code = require('../basetypes/Code');
|
|
4
4
|
const Interval = require('../basetypes/Interval');
|
5
5
|
const Quantity = require('../basetypes/Quantity');
|
6
6
|
const DateTime = require('../basetypes/DateTime');
|
7
|
+
const QDMDate = require('../basetypes/QDMDate');
|
7
8
|
const Any = require('../basetypes/Any');
|
8
9
|
|
10
|
+
const [Schema] = [mongoose.Schema];
|
9
11
|
|
10
12
|
const [Number, String] = [
|
11
13
|
mongoose.Schema.Types.Number,
|
@@ -15,7 +17,7 @@ const [Number, String] = [
|
|
15
17
|
const ComponentSchema = new mongoose.Schema({
|
16
18
|
code: Code,
|
17
19
|
result: Any,
|
18
|
-
qdmVersion: { type: String, default: '5.
|
20
|
+
qdmVersion: { type: String, default: '5.5' },
|
19
21
|
_type: { type: String, default: 'QDM::Component' },
|
20
22
|
|
21
23
|
});
|
@@ -27,4 +29,23 @@ class Component extends mongoose.Document {
|
|
27
29
|
this._type = 'QDM::Component';
|
28
30
|
}
|
29
31
|
}
|
32
|
+
|
33
|
+
function ComponentSchemaFunction(add, options) {
|
34
|
+
const extended = new Schema({
|
35
|
+
code: Code,
|
36
|
+
result: Any,
|
37
|
+
qdmVersion: { type: String, default: '5.5' },
|
38
|
+
_type: { type: String, default: 'QDM::Component' },
|
39
|
+
|
40
|
+
|
41
|
+
}, options);
|
42
|
+
|
43
|
+
if (add) {
|
44
|
+
extended.add(add);
|
45
|
+
}
|
46
|
+
|
47
|
+
return extended;
|
48
|
+
}
|
49
|
+
|
30
50
|
module.exports.Component = Component;
|
51
|
+
module.exports.ComponentSchemaFunction = ComponentSchemaFunction;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const Code = require('../basetypes/Code');
|
4
|
+
const Interval = require('../basetypes/Interval');
|
5
|
+
const Quantity = require('../basetypes/Quantity');
|
6
|
+
const DateTime = require('../basetypes/DateTime');
|
7
|
+
const QDMDate = require('../basetypes/QDMDate');
|
8
|
+
const Any = require('../basetypes/Any');
|
9
|
+
|
10
|
+
|
11
|
+
const [Number, String] = [
|
12
|
+
mongoose.Schema.Types.Number,
|
13
|
+
mongoose.Schema.Types.String,
|
14
|
+
];
|
15
|
+
|
16
|
+
const DiagnosisComponentSchema = new mongoose.Schema({
|
17
|
+
code: Code,
|
18
|
+
presentOnAdmissionIndicator: Code,
|
19
|
+
rank: Number,
|
20
|
+
qdmVersion: { type: String, default: '5.5' },
|
21
|
+
_type: { type: String, default: 'QDM::DiagnosisComponent' },
|
22
|
+
|
23
|
+
});
|
24
|
+
|
25
|
+
module.exports.DiagnosisComponentSchema = DiagnosisComponentSchema;
|
26
|
+
class DiagnosisComponent extends mongoose.Document {
|
27
|
+
constructor(object) {
|
28
|
+
super(object, DiagnosisComponentSchema);
|
29
|
+
this._type = 'QDM::DiagnosisComponent';
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
module.exports.DiagnosisComponent = DiagnosisComponent;
|
34
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const { IdentifierSchema } = require('./Identifier');
|
4
|
+
const Code = require('../basetypes/Code');
|
5
|
+
const Interval = require('../basetypes/Interval');
|
6
|
+
const Quantity = require('../basetypes/Quantity');
|
7
|
+
const DateTime = require('../basetypes/DateTime');
|
8
|
+
const QDMDate = require('../basetypes/QDMDate');
|
9
|
+
const Any = require('../basetypes/Any');
|
10
|
+
|
11
|
+
const [Schema] = [mongoose.Schema];
|
12
|
+
|
13
|
+
const [Number, String] = [
|
14
|
+
mongoose.Schema.Types.Number,
|
15
|
+
mongoose.Schema.Types.String,
|
16
|
+
];
|
17
|
+
|
18
|
+
const EntitySchema = new mongoose.Schema({
|
19
|
+
id: String,
|
20
|
+
identifier: IdentifierSchema,
|
21
|
+
qdmVersion: { type: String, default: '5.5' },
|
22
|
+
_type: { type: String, default: 'QDM::Entity' },
|
23
|
+
|
24
|
+
});
|
25
|
+
|
26
|
+
module.exports.EntitySchema = EntitySchema;
|
27
|
+
class Entity extends mongoose.Document {
|
28
|
+
constructor(object) {
|
29
|
+
super(object, EntitySchema);
|
30
|
+
this._type = 'QDM::Entity';
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
function EntitySchemaFunction(add, options) {
|
35
|
+
const extended = new Schema({
|
36
|
+
identifier: IdentifierSchema,
|
37
|
+
qdmVersion: { type: String, default: '5.5' },
|
38
|
+
_type: { type: String, default: 'QDM::Entity' },
|
39
|
+
|
40
|
+
|
41
|
+
id: {
|
42
|
+
type: String,
|
43
|
+
default() {
|
44
|
+
return this._id ? this._id.toString() : mongoose.Types.ObjectId().toString();
|
45
|
+
},
|
46
|
+
},
|
47
|
+
|
48
|
+
}, options);
|
49
|
+
|
50
|
+
if (add) {
|
51
|
+
extended.add(add);
|
52
|
+
}
|
53
|
+
|
54
|
+
return extended;
|
55
|
+
}
|
56
|
+
|
57
|
+
module.exports.Entity = Entity;
|
58
|
+
module.exports.EntitySchemaFunction = EntitySchemaFunction;
|
@@ -4,6 +4,7 @@ const Code = require('../basetypes/Code');
|
|
4
4
|
const Interval = require('../basetypes/Interval');
|
5
5
|
const Quantity = require('../basetypes/Quantity');
|
6
6
|
const DateTime = require('../basetypes/DateTime');
|
7
|
+
const QDMDate = require('../basetypes/QDMDate');
|
7
8
|
const Any = require('../basetypes/Any');
|
8
9
|
|
9
10
|
|
@@ -15,7 +16,7 @@ const [Number, String] = [
|
|
15
16
|
const FacilityLocationSchema = new mongoose.Schema({
|
16
17
|
code: Code,
|
17
18
|
locationPeriod: Interval,
|
18
|
-
qdmVersion: { type: String, default: '5.
|
19
|
+
qdmVersion: { type: String, default: '5.5' },
|
19
20
|
_type: { type: String, default: 'QDM::FacilityLocation' },
|
20
21
|
|
21
22
|
});
|
@@ -27,4 +28,6 @@ class FacilityLocation extends mongoose.Document {
|
|
27
28
|
this._type = 'QDM::FacilityLocation';
|
28
29
|
}
|
29
30
|
}
|
31
|
+
|
30
32
|
module.exports.FacilityLocation = FacilityLocation;
|
33
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const [Number, String] = [
|
4
|
+
mongoose.Schema.Types.Number,
|
5
|
+
mongoose.Schema.Types.String,
|
6
|
+
];
|
7
|
+
|
8
|
+
const IdentifierSchema = mongoose.Schema({
|
9
|
+
namingSystem: String,
|
10
|
+
value: String,
|
11
|
+
qdmVersion: { type: String, default: '5.5' },
|
12
|
+
_type: { type: String, default: 'QDM::Identifier' },
|
13
|
+
|
14
|
+
}, { _id: false, id: false });
|
15
|
+
|
16
|
+
module.exports.IdentifierSchema = IdentifierSchema;
|
17
|
+
class Identifier extends mongoose.Document {
|
18
|
+
constructor(object) {
|
19
|
+
super(object, IdentifierSchema);
|
20
|
+
this._type = 'QDM::Identifier';
|
21
|
+
}
|
22
|
+
}
|
23
|
+
module.exports.Identifier = Identifier;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const { EntitySchemaFunction } = require('./Entity');
|
4
|
+
const Code = require('../basetypes/Code');
|
5
|
+
const Interval = require('../basetypes/Interval');
|
6
|
+
const Quantity = require('../basetypes/Quantity');
|
7
|
+
const DateTime = require('../basetypes/DateTime');
|
8
|
+
const QDMDate = require('../basetypes/QDMDate');
|
9
|
+
const Any = require('../basetypes/Any');
|
10
|
+
|
11
|
+
const [Number, String] = [
|
12
|
+
mongoose.Schema.Types.Number,
|
13
|
+
mongoose.Schema.Types.String,
|
14
|
+
];
|
15
|
+
|
16
|
+
const OrganizationSchema = EntitySchemaFunction({
|
17
|
+
type: Code,
|
18
|
+
_type: { type: String, default: 'QDM::Organization' },
|
19
|
+
|
20
|
+
});
|
21
|
+
|
22
|
+
module.exports.OrganizationSchema = OrganizationSchema;
|
23
|
+
class Organization extends mongoose.Document {
|
24
|
+
constructor(object) {
|
25
|
+
super(object, OrganizationSchema);
|
26
|
+
this._type = 'QDM::Organization';
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports.Organization = Organization;
|
31
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const { EntitySchemaFunction } = require('./Entity');
|
4
|
+
const Code = require('../basetypes/Code');
|
5
|
+
const Interval = require('../basetypes/Interval');
|
6
|
+
const Quantity = require('../basetypes/Quantity');
|
7
|
+
const DateTime = require('../basetypes/DateTime');
|
8
|
+
const QDMDate = require('../basetypes/QDMDate');
|
9
|
+
const Any = require('../basetypes/Any');
|
10
|
+
|
11
|
+
const [Number, String] = [
|
12
|
+
mongoose.Schema.Types.Number,
|
13
|
+
mongoose.Schema.Types.String,
|
14
|
+
];
|
15
|
+
|
16
|
+
const PatientEntitySchema = EntitySchemaFunction({
|
17
|
+
_type: { type: String, default: 'QDM::PatientEntity' },
|
18
|
+
|
19
|
+
});
|
20
|
+
|
21
|
+
module.exports.PatientEntitySchema = PatientEntitySchema;
|
22
|
+
class PatientEntity extends mongoose.Document {
|
23
|
+
constructor(object) {
|
24
|
+
super(object, PatientEntitySchema);
|
25
|
+
this._type = 'QDM::PatientEntity';
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
module.exports.PatientEntity = PatientEntity;
|
30
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const { EntitySchemaFunction } = require('./Entity');
|
4
|
+
const Code = require('../basetypes/Code');
|
5
|
+
const Interval = require('../basetypes/Interval');
|
6
|
+
const Quantity = require('../basetypes/Quantity');
|
7
|
+
const DateTime = require('../basetypes/DateTime');
|
8
|
+
const QDMDate = require('../basetypes/QDMDate');
|
9
|
+
const Any = require('../basetypes/Any');
|
10
|
+
|
11
|
+
const [Number, String] = [
|
12
|
+
mongoose.Schema.Types.Number,
|
13
|
+
mongoose.Schema.Types.String,
|
14
|
+
];
|
15
|
+
|
16
|
+
const PractitionerSchema = EntitySchemaFunction({
|
17
|
+
role: Code,
|
18
|
+
specialty: Code,
|
19
|
+
qualification: Code,
|
20
|
+
_type: { type: String, default: 'QDM::Practitioner' },
|
21
|
+
|
22
|
+
});
|
23
|
+
|
24
|
+
module.exports.PractitionerSchema = PractitionerSchema;
|
25
|
+
class Practitioner extends mongoose.Document {
|
26
|
+
constructor(object) {
|
27
|
+
super(object, PractitionerSchema);
|
28
|
+
this._type = 'QDM::Practitioner';
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
module.exports.Practitioner = Practitioner;
|
33
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const { ComponentSchemaFunction } = require('./Component');
|
4
|
+
const Code = require('../basetypes/Code');
|
5
|
+
const Interval = require('../basetypes/Interval');
|
6
|
+
const Quantity = require('../basetypes/Quantity');
|
7
|
+
const DateTime = require('../basetypes/DateTime');
|
8
|
+
const QDMDate = require('../basetypes/QDMDate');
|
9
|
+
const Any = require('../basetypes/Any');
|
10
|
+
|
11
|
+
const [Number, String] = [
|
12
|
+
mongoose.Schema.Types.Number,
|
13
|
+
mongoose.Schema.Types.String,
|
14
|
+
];
|
15
|
+
|
16
|
+
const ResultComponentSchema = ComponentSchemaFunction({
|
17
|
+
referenceRange: Interval,
|
18
|
+
_type: { type: String, default: 'QDM::ResultComponent' },
|
19
|
+
|
20
|
+
});
|
21
|
+
|
22
|
+
module.exports.ResultComponentSchema = ResultComponentSchema;
|
23
|
+
class ResultComponent extends mongoose.Document {
|
24
|
+
constructor(object) {
|
25
|
+
super(object, ResultComponentSchema);
|
26
|
+
this._type = 'QDM::ResultComponent';
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports.ResultComponent = ResultComponent;
|
31
|
+
|
@@ -8,30 +8,31 @@ Any.prototype = Object.create(mongoose.SchemaType.prototype);
|
|
8
8
|
|
9
9
|
function RecursiveCast(any) {
|
10
10
|
if (any && any.value && any.unit) {
|
11
|
-
return new cql.Quantity(any);
|
11
|
+
return new cql.Quantity(any.value, any.unit);
|
12
12
|
}
|
13
|
-
if (any && any.code && (any.codeSystemOid || any.system)) {
|
14
|
-
if (typeof any.code === 'undefined') {
|
15
|
-
throw new Error(`Code: ${any} does not have a code`);
|
16
|
-
} else if (typeof any.codeSystemOid === 'undefined' && typeof any.system === 'undefined') {
|
17
|
-
throw new Error(`Code: ${any} does not have a code system oid`);
|
18
|
-
}
|
19
13
|
|
20
|
-
|
14
|
+
if (any.isCode || any.isConcept || any.isValueSet || any.isList ||
|
15
|
+
any.isDateTime || any.isDate || any.isRatio || any.isQuantiy ||
|
16
|
+
any.isInterval || any.isBooleanLiteral || any.isIntegerLiteral ||
|
17
|
+
any.isDecimalLiteral || any.isStringLiteral || any.isTuple) {
|
18
|
+
return any;
|
19
|
+
}
|
21
20
|
|
22
|
-
|
21
|
+
if (any && any.code && any.system) {
|
22
|
+
const val = { code: any.code, system: any.system };
|
23
|
+
val.display = (typeof any.display !== 'undefined') ? any.display : null;
|
23
24
|
val.version = (typeof any.version !== 'undefined') ? any.version : null;
|
24
25
|
|
25
|
-
return new cql.Code(val.code, val.
|
26
|
+
return new cql.Code(val.code, val.system, val.version, val.display);
|
26
27
|
}
|
27
28
|
if (any && any.low) {
|
28
29
|
const casted = new cql.Interval(any.low, any.high, any.lowClosed, any.highClosed);
|
29
30
|
|
30
31
|
// Cast Low and High values to Quantities if it is a quantity
|
31
32
|
if (casted.low && casted.low.unit && casted.low.value) {
|
32
|
-
casted.low = new cql.Quantity(casted.low);
|
33
|
+
casted.low = new cql.Quantity(casted.low.value, casted.low.unit);
|
33
34
|
if (casted.high && casted.high.unit && casted.high.value) {
|
34
|
-
casted.high = new cql.Quantity(casted.high);
|
35
|
+
casted.high = new cql.Quantity(casted.high.value, casted.high.unit);
|
35
36
|
}
|
36
37
|
return casted;
|
37
38
|
}
|
@@ -55,8 +56,17 @@ function RecursiveCast(any) {
|
|
55
56
|
if (Number.isFinite(any)) {
|
56
57
|
return any;
|
57
58
|
}
|
58
|
-
if (Date.parse(any)) {
|
59
|
-
|
59
|
+
if (Date.parse(any) || Date.parse(`1984-01-01T${any}`)) {
|
60
|
+
if (any.match(/T/) || any.match(/\+/)) {
|
61
|
+
// If it has a T or a timezoneoffset, it must be a DateTime
|
62
|
+
return cql.DateTime.fromJSDate(new Date(any), 0);
|
63
|
+
}
|
64
|
+
if (any.match(/:/)) {
|
65
|
+
// If it has a : but no T or timezoneoffset, it must be a Time
|
66
|
+
return cql.DateTime.fromJSDate(new Date(`1984-01-01T${any}`), 0).getTime();
|
67
|
+
}
|
68
|
+
// Must be a Date
|
69
|
+
return cql.DateTime.fromJSDate(new Date(any), 0).getDate();
|
60
70
|
}
|
61
71
|
return any;
|
62
72
|
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
const { PatientEntity } = require('../attributes/PatientEntity');
|
3
|
+
const { Practitioner } = require('../attributes/Practitioner');
|
4
|
+
const { CarePartner } = require('../attributes/CarePartner');
|
5
|
+
const { Organization } = require('../attributes/Organization');
|
6
|
+
|
7
|
+
function AnyEntity(key, options) {
|
8
|
+
mongoose.SchemaType.call(this, key, options, 'AnyEntity');
|
9
|
+
}
|
10
|
+
AnyEntity.prototype = Object.create(mongoose.SchemaType.prototype);
|
11
|
+
|
12
|
+
AnyEntity.prototype.cast = (entity) => {
|
13
|
+
if (entity == null) {
|
14
|
+
return null;
|
15
|
+
}
|
16
|
+
|
17
|
+
if (entity instanceof PatientEntity || entity instanceof Practitioner || entity instanceof CarePartner || entity instanceof Organization) {
|
18
|
+
return entity;
|
19
|
+
}
|
20
|
+
|
21
|
+
if (entity._type != null) {
|
22
|
+
// copy _id to id if it isn't defined
|
23
|
+
if (entity.id == null && entity._id != null) {
|
24
|
+
entity.id = entity._id;
|
25
|
+
}
|
26
|
+
switch (entity._type) {
|
27
|
+
case 'QDM::PatientEntity':
|
28
|
+
return new PatientEntity(entity);
|
29
|
+
case 'QDM::Practitioner':
|
30
|
+
return new Practitioner(entity);
|
31
|
+
case 'QDM::CarePartner':
|
32
|
+
return new CarePartner(entity);
|
33
|
+
case 'QDM::Organization':
|
34
|
+
return new Organization(entity);
|
35
|
+
default:
|
36
|
+
throw new Error(`Could not find entity type "${entity._type}".`);
|
37
|
+
}
|
38
|
+
} else {
|
39
|
+
throw new Error('Could not find _type indicator for entity.');
|
40
|
+
}
|
41
|
+
};
|
42
|
+
|
43
|
+
mongoose.Schema.Types.AnyEntity = AnyEntity;
|
44
|
+
module.exports = AnyEntity;
|