2020-07-30 14:23:51 +02:00
|
|
|
import omit from 'lodash/omit';
|
|
|
|
import pick from 'lodash/pick';
|
2020-06-19 08:43:22 +02:00
|
|
|
import {IdModel} from './id.model';
|
2020-06-22 10:22:45 +02:00
|
|
|
import {BaseModel} from './base.model';
|
2020-06-19 08:43:22 +02:00
|
|
|
|
2020-06-22 10:22:45 +02:00
|
|
|
export class MeasurementModel extends BaseModel {
|
2020-06-19 08:43:22 +02:00
|
|
|
_id: IdModel = null;
|
|
|
|
sample_id: IdModel = null;
|
|
|
|
measurement_template: IdModel;
|
|
|
|
values: {[prop: string]: any} = {};
|
|
|
|
|
|
|
|
constructor(measurementTemplate: IdModel = null) {
|
2020-06-22 10:22:45 +02:00
|
|
|
super();
|
2020-06-19 08:43:22 +02:00
|
|
|
this.measurement_template = measurementTemplate;
|
|
|
|
}
|
|
|
|
|
|
|
|
deserialize(input: any): this {
|
|
|
|
Object.assign(this, input);
|
|
|
|
Object.keys(this.values).forEach(key => {
|
|
|
|
if (this.values[key] === null) {
|
|
|
|
this.values[key] = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2020-07-30 14:23:51 +02:00
|
|
|
sendFormat(omitValues = []) {
|
|
|
|
return omit(pick(this, ['sample_id', 'measurement_template', 'values']), omitValues);
|
2020-06-19 08:43:22 +02:00
|
|
|
}
|
|
|
|
}
|