30 lines
807 B
TypeScript
30 lines
807 B
TypeScript
|
import _ from 'lodash';
|
||
|
import {IdModel} from './id.model';
|
||
|
import {SendFormat} from './sendformat.model';
|
||
|
import {Deserializable} from './deserializable.model';
|
||
|
|
||
|
export class MeasurementModel implements Deserializable, SendFormat{
|
||
|
_id: IdModel = null;
|
||
|
sample_id: IdModel = null;
|
||
|
measurement_template: IdModel;
|
||
|
values: {[prop: string]: any} = {};
|
||
|
|
||
|
constructor(measurementTemplate: IdModel = null) {
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
sendFormat(omit = []) {
|
||
|
return _.omit(_.pick(this, ['sample_id', 'measurement_template', 'values']), omit);
|
||
|
}
|
||
|
}
|