hayun-vite 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/templates/mainTemplate.js +1 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/Audiogram/Audiogram_box.js +89 -66
- package/src/Form/Form.js +34 -38
- package/src/Form/{Form_N.js → Form_box.js} +5 -9
- package/src/{Form → Forms}/Forms.js +6 -3
- package/src/MultiText/MultiText.js +85 -23
- package/src/MultiText/MultiText_box.js +37 -0
- package/src/Reflex/Reflex.js +2 -1
- package/src/Speech/Speech.js +2 -2
- package/src/Speech/{Speech_N.js → Speech_box.js} +0 -5
- package/src/Tympanogram/Tympanogram.js +2 -1
- package/src/main.js +71 -19
- package/src/Box/Box.js +0 -105
- /package/src/{Form → Forms}/printForm.js +0 -0
- /package/src/Header/{Header_N.js → Header_box.js} +0 -0
package/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import Audiogram from './src/Audiogram/Audiogram'
|
2
2
|
import dims from './src/Audiogram/dims'
|
3
3
|
import { officeData, patientData } from './assets/data/sampleData'
|
4
|
-
import Forms from './src/
|
4
|
+
import Forms from './src/Forms/Forms'
|
5
5
|
import combo_template from './assets/templates/template_combo'
|
6
6
|
// import rasa_aud_template from './assets/templates/rasa_audiometry'
|
7
7
|
// import rasa_tymp_reflex_template from './assets/templates/rasa_tymp_reflex'
|
package/package.json
CHANGED
@@ -1,43 +1,42 @@
|
|
1
|
+
import putG from "../common/putG.js";
|
1
2
|
import putLine from "../common/putLine.js";
|
2
3
|
import putPoint from "../common/putPoint.js";
|
3
4
|
import putRect from "../common/putRect.js";
|
4
5
|
import putSVG from "../common/putSVG.js";
|
5
6
|
import putText from "../common/putText.js";
|
6
7
|
import getAllSymbolsSVG from "../Symbol/getAllSymbolsSVG.js";
|
7
|
-
import mainDims from './
|
8
|
+
import mainDims from './dims.js';
|
8
9
|
|
9
10
|
export default class Audiogram {
|
10
|
-
constructor({ box, side, events = true }) {
|
11
|
+
constructor({ box, container, side, dims, events = true }) {
|
12
|
+
console.log(box);
|
13
|
+
|
14
|
+
this.container = container;
|
15
|
+
this.dims = {}
|
16
|
+
Object.assign(this.dims, mainDims)
|
17
|
+
// dims = { blank: false }
|
18
|
+
// اضافه کردن ابعاد جایگزین و یا اختصاصی دیگر به آبجکت ابعاد
|
19
|
+
dims && Object.assign(this.dims, dims);
|
20
|
+
// console.log(dims);
|
11
21
|
|
12
|
-
// this.container = container;
|
13
22
|
|
14
23
|
this.events = events;
|
15
24
|
this.side = side;
|
16
25
|
this.data = {};
|
17
26
|
const symbols = getAllSymbolsSVG();
|
18
27
|
this.symbols = symbols;
|
19
|
-
this.draw(
|
28
|
+
this.draw();
|
20
29
|
events && this.addEvents();
|
21
30
|
}
|
22
31
|
|
23
|
-
draw(
|
24
|
-
|
25
|
-
const { container, width, height, margin, elements, name } = box
|
26
|
-
|
27
|
-
// this.dims = {}
|
28
|
-
// Object.assign(this.dims, mainDims)
|
29
|
-
|
30
|
-
// اضافه کردن ابعاد جایگزین و یا اختصاصی دیگر به آبجکت ابعاد
|
31
|
-
// dims && Object.assign(this.dims, dims);
|
32
|
-
|
33
|
-
|
34
|
-
// const [container, dims] = [this.container, this.dims]
|
32
|
+
draw() {
|
33
|
+
const [container, dims] = [this.container, this.dims]
|
35
34
|
let
|
36
35
|
{
|
37
|
-
vbWidth, vbHeight, chartPadding, symbolDims, vf, vfArray,
|
36
|
+
vbWidth, vbHeight, width, height, chartPadding, symbolDims, vf, vfArray,
|
38
37
|
vfToF, fToVf, intensity, styles, frequencies
|
39
38
|
}
|
40
|
-
=
|
39
|
+
= dims;
|
41
40
|
// متناسب سازی مقدار ارتفاع ویوباکس بر حسب نسبت طول و عرض پیکسلی
|
42
41
|
const
|
43
42
|
kpx = height / width,
|
@@ -45,8 +44,8 @@ export default class Audiogram {
|
|
45
44
|
|
46
45
|
vbHeight = vbHeight * kpx * kvb;
|
47
46
|
|
48
|
-
let x = margin.left
|
49
|
-
let y = margin.top
|
47
|
+
let x = dims.margin.left
|
48
|
+
let y = dims.margin.top
|
50
49
|
|
51
50
|
this.symbolDims = symbolDims;
|
52
51
|
this.vf = vf;
|
@@ -75,64 +74,88 @@ export default class Audiogram {
|
|
75
74
|
this.yAxisLength = yAxisLength
|
76
75
|
|
77
76
|
// Main SVG for Audiogram
|
77
|
+
style = styles.svg;
|
78
78
|
const viewBox = [-chartPadding.left, -chartPadding.top, vbWidth, vbHeight]
|
79
|
-
const svg = putSVG({ container, x, y, width, height, viewBox })
|
79
|
+
const svg = putSVG({ container, x, y, width, height, viewBox, style })
|
80
80
|
this.svg = svg; // کل نودی که به کانتینر اپند میشه
|
81
81
|
|
82
82
|
// برای فرمهای پیش چاپ نشده
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
83
|
+
if (!dims.blank) {
|
84
|
+
// محدوده مختصات خطوط جدول
|
85
|
+
putRect({
|
86
|
+
container: svg,
|
87
|
+
x: this.getX(vf.min), y: this.getY(intensity.min),
|
88
|
+
width: xAxisLength.vb, height: yAxisLength.vb,
|
89
|
+
style: 'stroke-width: 0.4; stroke: gray; fill: transparent'
|
90
|
+
})
|
91
|
+
|
92
|
+
// رسم خطوط افقی از بالا به پایین
|
93
|
+
let g = putG({ container: svg });
|
94
|
+
|
95
|
+
let x1 = this.getX(vf.min);
|
96
|
+
let x2 = this.getX(vf.max);
|
97
|
+
|
98
|
+
for (let i = intensity.min; i <= intensity.max; i += intensity.step) {
|
99
|
+
const y1 = this.getY(i)
|
100
|
+
const y2 = y1;
|
101
|
+
style = (i === 0) ? styles.boldLine : styles.line;
|
102
|
+
putLine({ container: g, x1, y1, x2, y2, style })
|
103
|
+
}
|
100
104
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
105
|
+
svg.appendChild(g);
|
106
|
+
|
107
|
+
// رسم خطوط عمودی از چپ به راست
|
108
|
+
g = putG({ container: svg });
|
109
|
+
|
110
|
+
let y1 = this.getY(intensity.min)
|
111
|
+
let y2 = this.getY(intensity.max)
|
112
|
+
|
113
|
+
frequencies.
|
114
|
+
forEach(item => {
|
115
|
+
const x1 = this.getX(item.vf)
|
116
|
+
const x2 = x1
|
117
|
+
style = (item.semiOctav) ? styles.semiOctavFreqline : styles.mainFreqline;
|
118
|
+
(item.f === 1000) && (style = styles.boldLine);
|
119
|
+
putLine({ container: g, x1, y1, x2, y2, style })
|
120
|
+
});
|
121
|
+
|
122
|
+
svg.appendChild(g);
|
123
|
+
|
124
|
+
// برچسب های اعداد فرکانس
|
125
|
+
style = styles.frequency
|
126
|
+
g = putG({ container: svg, style });
|
127
|
+
const y = this.getY(-25)
|
128
|
+
|
129
|
+
frequencies.
|
130
|
+
forEach(item => {
|
131
|
+
const value = item.f
|
132
|
+
const x = this.getX(item.vf)
|
133
|
+
!item.semiOctav && item.f != 125 && item.f != 16000 &&
|
134
|
+
putText({ container: g, value, x, y, });
|
135
|
+
});
|
136
|
+
|
137
|
+
svg.appendChild(g);
|
138
|
+
|
139
|
+
// رسم اعداد شدت محور عمودی
|
140
|
+
style = styles.intensity
|
141
|
+
g = putG({ container: svg, style });
|
142
|
+
const x = this.getX(-0.1)
|
143
|
+
|
144
|
+
for (let i = -10; i <= 120; i += 10) {
|
145
|
+
const y = this.getY(i)
|
146
|
+
const value = i
|
147
|
+
putText({ container: g, x, y, value })
|
148
|
+
}
|
149
|
+
|
150
|
+
svg.appendChild(g);
|
120
151
|
|
121
|
-
// رسم اعداد شدت محور عمودی
|
122
|
-
style = styles.intensity
|
123
|
-
const x = this.getX(-0.1)
|
124
|
-
for (let i = -10; i <= 120; i += 10) {
|
125
|
-
const y = this.getY(i)
|
126
|
-
const value = i
|
127
|
-
putText({ container: svg, x, y, value, style })
|
128
152
|
}
|
129
|
-
// }
|
130
153
|
// یک بوردر راهنمای توسعه برای اس وی جی به تمام پهنا و ارتفاع رسم میکنیم
|
131
154
|
// این مربع مرزی را آخرین ایجاد میکنیم تا بالاترین لایه باشد و روی ریودادها درست عمل کند
|
132
155
|
const borderRect = putRect({
|
133
156
|
container: svg, x: -chartPadding.left, y: -chartPadding.top,
|
134
157
|
width: vbWidth, height: vbHeight, name: '',
|
135
|
-
style: 'fill: transparent; stroke:
|
158
|
+
style: 'fill: transparent; stroke: green;',
|
136
159
|
});
|
137
160
|
this.borderRect = borderRect;
|
138
161
|
|
package/src/Form/Form.js
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
// import Symbols from "../Symbol/Symbols.js";
|
2
|
-
import Box from "../Box/Box.js";
|
3
1
|
import Header from "../Header/Header.js";
|
4
2
|
import Reflex from "../Reflex/Reflex.js";
|
5
3
|
import Sections from "./Sections.js";
|
@@ -7,9 +5,9 @@ import Speech from "../Speech/Speech.js";
|
|
7
5
|
import Tympanogram from "../Tympanogram/Tympanogram.js";
|
8
6
|
import putRect from "../common/putRect.js";
|
9
7
|
import AudiogramChart from "../Audiogram/Audiogram.js";
|
8
|
+
import MultiText from "../MultiText/MultiText.js";
|
10
9
|
const svgNS = "http://www.w3.org/2000/svg";
|
11
10
|
|
12
|
-
|
13
11
|
export default class Form {
|
14
12
|
constructor({ container, template } = {}) {
|
15
13
|
this.template = template;
|
@@ -18,6 +16,7 @@ export default class Form {
|
|
18
16
|
let { width, height, margin, paper } = template;
|
19
17
|
this.form = this.create({ paper, margin });
|
20
18
|
this.form.style.display = 'none';
|
19
|
+
let dims;
|
21
20
|
// رسم مارجین های فرم
|
22
21
|
this.drawMarginLines({ container: this.form, width, height });
|
23
22
|
|
@@ -29,18 +28,17 @@ export default class Form {
|
|
29
28
|
this.header.draw({ dims: template.header });
|
30
29
|
}
|
31
30
|
if (sections.patient) {
|
32
|
-
|
33
|
-
|
34
|
-
this.patient = new Box({ container: sections.patient });
|
35
|
-
this.patient.draw({ dims: template.patient });
|
31
|
+
dims = template.patient;
|
32
|
+
this.patient = new MultiText({ container: sections.patient, dims });
|
36
33
|
}
|
37
34
|
if (sections.history) {
|
38
|
-
|
39
|
-
this.history
|
35
|
+
dims = template.history;
|
36
|
+
this.history = new MultiText({ container: sections.history, dims })
|
37
|
+
// this.history.draw({ dims: template.history });
|
40
38
|
}
|
41
39
|
if (sections['Audiogram Titles']) {
|
42
|
-
|
43
|
-
|
40
|
+
dims = template['Audiogram Titles'];
|
41
|
+
new MultiText({ container: sections['Audiogram Titles'], dims });
|
44
42
|
}
|
45
43
|
if (sections.RAudiogram) {
|
46
44
|
this.RAudiogram = new AudiogramChart({
|
@@ -48,9 +46,7 @@ export default class Form {
|
|
48
46
|
dims: template.RAudiogram,
|
49
47
|
side: 'R',
|
50
48
|
events: false
|
51
|
-
})
|
52
|
-
console.log(template.RAudiogram);
|
53
|
-
|
49
|
+
})
|
54
50
|
}
|
55
51
|
if (sections.LAudiogram) {
|
56
52
|
this.LAudiogram = new AudiogramChart({
|
@@ -58,51 +54,51 @@ export default class Form {
|
|
58
54
|
dims: template.LAudiogram,
|
59
55
|
side: 'L',
|
60
56
|
events: false
|
61
|
-
})
|
57
|
+
})
|
62
58
|
}
|
63
59
|
if (sections['Speech Titles']) {
|
64
|
-
|
65
|
-
titles
|
60
|
+
dims= template['Speech Titles'];
|
61
|
+
const titles = new MultiText({ container: sections['Speech Titles'], dims });
|
66
62
|
}
|
67
63
|
if (sections['RSpeech']) {
|
68
|
-
|
69
|
-
this.RSpeech
|
64
|
+
dims= template.RSpeech
|
65
|
+
this.RSpeech = new Speech({ container: sections.RSpeech, side: 'R', dims})
|
70
66
|
}
|
71
67
|
if (sections.LSpeech) {
|
72
|
-
|
73
|
-
this.LSpeech
|
68
|
+
dims= template.LSpeech
|
69
|
+
this.LSpeech = new Speech({ container: sections.LSpeech, side: 'L', dims })
|
74
70
|
}
|
75
71
|
if (sections['Tympanogram Titles']) {
|
76
|
-
|
77
|
-
|
72
|
+
dims= template['Tympanogram Titles'];
|
73
|
+
new MultiText({ container: sections['Tympanogram Titles'], dims });
|
78
74
|
}
|
79
75
|
if (sections.RTympanogram) {
|
80
|
-
|
81
|
-
this.RTympanogram
|
76
|
+
dims= template.RTympanogram
|
77
|
+
this.RTympanogram = new Tympanogram({ container: sections.RTympanogram, side: 'R', dims })
|
82
78
|
}
|
83
79
|
if (sections.LTympanogram) {
|
84
|
-
|
85
|
-
this.LTympanogram
|
80
|
+
dims= template.LTympanogram
|
81
|
+
this.LTympanogram = new Tympanogram({ container: sections.LTympanogram, side: 'L', dims })
|
86
82
|
}
|
87
|
-
|
88
|
-
|
89
|
-
titles
|
83
|
+
if (sections['Reflex Titles']) {
|
84
|
+
dims= template['Reflex Titles'];
|
85
|
+
const titles = new MultiText({ container: sections['Reflex Titles'], dims });
|
90
86
|
}
|
91
87
|
if (sections.RReflex) {
|
92
|
-
|
93
|
-
this.RReflex
|
88
|
+
dims= template.RReflex
|
89
|
+
this.RReflex = new Reflex({ container: sections.RReflex, side: 'R', dims })
|
94
90
|
}
|
95
91
|
if (sections.LReflex) {
|
96
|
-
|
97
|
-
this.LReflex
|
92
|
+
dims= template.LReflex
|
93
|
+
this.LReflex = new Reflex({ container: sections.LReflex, side: 'L', dims })
|
98
94
|
}
|
99
95
|
if (sections.report) {
|
100
|
-
|
101
|
-
this.report
|
96
|
+
dims= template.report;
|
97
|
+
this.report = new MultiText({ container: sections.report, dims })
|
102
98
|
}
|
103
99
|
if (sections.footer) {
|
104
|
-
|
105
|
-
this.footer
|
100
|
+
dims= template.footer;
|
101
|
+
this.footer = new MultiText({ container: sections.footer, dims})
|
106
102
|
}
|
107
103
|
|
108
104
|
this.container.appendChild(this.form);
|
@@ -1,14 +1,10 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import Reflex from "../Reflex/Reflex.js";
|
4
|
-
import Sections from "./Sections_N.js";
|
5
|
-
import Speech from "../Speech/Speech_N.js";
|
6
|
-
import Tympanogram from "../Tympanogram/Tympanogram.js";
|
1
|
+
import Header from "../Header/Header_box.js";
|
2
|
+
import Speech from "../Speech/Speech_box.js";
|
7
3
|
import putRect from "../common/putRect.js";
|
8
|
-
import Audiogram from "../Audiogram/
|
4
|
+
import Audiogram from "../Audiogram/Audiogram_box.js";
|
9
5
|
import mainTemplate from "../../assets/templates/mainTemplate.js";
|
10
6
|
import putSVG from "../common/putSVG.js";
|
11
|
-
import MultiText from "../MultiText/
|
7
|
+
import MultiText from "../MultiText/MultiText_box.js";
|
12
8
|
const svgNS = "http://www.w3.org/2000/svg";
|
13
9
|
|
14
10
|
export default class Form {
|
@@ -40,7 +36,7 @@ export default class Form {
|
|
40
36
|
case 'history':
|
41
37
|
break;
|
42
38
|
case 'RAudiogram':
|
43
|
-
const RAudiogram = new Audiogram({ box, side: 'R', events: false })
|
39
|
+
const RAudiogram = new Audiogram({ box, container: box.container, side: 'R', events: false })
|
44
40
|
break;
|
45
41
|
case 'LAudiogram':
|
46
42
|
// const LAudiogram = new Audiogram({ container: box.container, side: 'L', dims: box, events: false })
|
@@ -1,7 +1,7 @@
|
|
1
1
|
const svgNS = "http://www.w3.org/2000/svg";
|
2
2
|
|
3
3
|
import printForm from "./printForm.js";
|
4
|
-
import Form from "
|
4
|
+
import Form from "../Form/Form.js";
|
5
5
|
// import combo from "./templates/combo.js"; // این در حقیقیت یک تمپلت هست
|
6
6
|
// import rasaAud from "./templates/rasa_audiometry.js";
|
7
7
|
// import rasaTymp from './templates/rasa_tymp_reflex.js'
|
@@ -22,9 +22,9 @@ export default class Forms {
|
|
22
22
|
// افزودن فرم
|
23
23
|
addForms({ templates, defaultTemplateIndex }) {
|
24
24
|
const container = this.container
|
25
|
+
|
25
26
|
// ایجاد یک دیو برای قرار دادن دکمه ها و لینک های فرم
|
26
27
|
const div = document.createElement('div');
|
27
|
-
|
28
28
|
div.style = 'border: 1px solid brown; margin: 0; padding: 0;'
|
29
29
|
container.appendChild(div);
|
30
30
|
|
@@ -37,7 +37,8 @@ export default class Forms {
|
|
37
37
|
this.pages = forms
|
38
38
|
|
39
39
|
templates.forEach((template, index) => {
|
40
|
-
(this.mode == 'develop') &&
|
40
|
+
(this.mode == 'develop') &&
|
41
|
+
(btns[index] = this.putButton({ container: div, text: template.label, className }));
|
41
42
|
this.forms.push(new Form({ container, template }));
|
42
43
|
});
|
43
44
|
|
@@ -76,6 +77,8 @@ export default class Forms {
|
|
76
77
|
}
|
77
78
|
}
|
78
79
|
|
80
|
+
|
81
|
+
|
79
82
|
// این تابع یک بار از بیرون کلاس فراخوانی میشه و یک بار وقتی از داخل تمپلت فرم را عوض میکنیم
|
80
83
|
update({ data, officeData, patientData, sessionIndex = 0 }) {
|
81
84
|
// ذخیره کل دیتا برای استفاده داخلی آپدیت فرم انتخاب شده
|
@@ -1,37 +1,99 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
import putLine from "../common/putLine.js";
|
2
|
+
import putRect from "../common/putRect.js";
|
3
|
+
import putSVG from "../common/putSVG.js";
|
4
|
+
import putText from "../common/putText.js";
|
5
|
+
const svgNS = "http://www.w3.org/2000/svg";
|
6
6
|
|
7
|
+
export default class MultiText {
|
8
|
+
constructor({ container, dims }) {
|
9
|
+
this.container = container;
|
10
|
+
this.draw({ dims })
|
7
11
|
}
|
8
12
|
|
13
|
+
draw({ dims }) {
|
14
|
+
// دریافت اطلاعات مختصات چاپ ورودی ها به جز عادی محاسبه شده
|
15
|
+
this.inputs = (dims.forceInsert) ? dims.forceInputs : dims.inputs;
|
9
16
|
|
17
|
+
let value;
|
18
|
+
let width = dims.width;
|
19
|
+
let height = dims.height;
|
20
|
+
let x = dims.margin.left;
|
21
|
+
let y = dims.margin.top;
|
10
22
|
|
23
|
+
let style, className;
|
24
|
+
style = `
|
25
|
+
font-family: Vazir;
|
26
|
+
font-size: 1mm;
|
27
|
+
white-space: break-spaces;
|
28
|
+
/* font-weight: bold; */
|
29
|
+
direction: rtl !important;
|
30
|
+
user-select: none;
|
31
|
+
dominant-baseline: middle;
|
32
|
+
`;
|
33
|
+
const svg = putSVG({ x, y, width, height, style })
|
11
34
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
35
|
+
// اگر مقدار استروک درست بود لیبل ها را چاپ کن
|
36
|
+
if (!dims.hideContext) {
|
37
|
+
dims.elements
|
38
|
+
.forEach(
|
39
|
+
element => {
|
40
|
+
switch (element.type) {
|
41
|
+
case 'text':
|
42
|
+
({ x, y, value, style } = element);
|
43
|
+
putText({ container: svg, value, x, y, style, className: 'persian bold' });
|
44
|
+
break;
|
45
|
+
case 'line':
|
46
|
+
let { x1, y1, x2, y2 } = element;
|
47
|
+
putLine({ container: svg, x1, y1, x2, y2 });
|
48
|
+
break;
|
49
|
+
}
|
50
|
+
});
|
51
|
+
}
|
16
52
|
|
17
|
-
|
18
|
-
|
53
|
+
// محل اینپوتهای دیتا
|
54
|
+
let name;
|
55
|
+
this.inputs && this.inputs.
|
56
|
+
forEach(input => {
|
57
|
+
({ name, x, y } = input);
|
58
|
+
putText({ container: svg, x, y, className: 'persian', name });
|
59
|
+
});
|
19
60
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
putText({ container, x, y, style, name });
|
61
|
+
// مربع احاطهکننده کل جدول برای راهنمای توسعه
|
62
|
+
const borderRect = putRect({
|
63
|
+
container: svg, x: 0, y: 0, width, height,
|
64
|
+
name: dims.name, className: 'no-print',
|
65
|
+
style: 'stroke: green; fill: transparent; stroke-width: 0.3;'
|
66
|
+
});
|
27
67
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
68
|
+
this.borderRect = borderRect;
|
69
|
+
this.container.appendChild(svg)
|
70
|
+
}
|
32
71
|
|
33
|
-
|
72
|
+
update(data) {
|
73
|
+
this.inputs.forEach(input => {
|
74
|
+
let value = data?.[input.name];
|
75
|
+
const textInput = this.container.querySelector(`text[data-name=${input.name}]`)
|
34
76
|
|
77
|
+
// پیدا کردن کاراکترهای رفتن به سرخط در متن
|
78
|
+
const textLines = value.toString().split(/\n|\r|\r\n/);
|
79
|
+
const x = textInput.getAttribute('x')
|
80
|
+
// اگر متن چند خطی بود
|
81
|
+
if (textLines.length >= 2) {
|
82
|
+
let y = 5;
|
83
|
+
textLines.forEach(value => {
|
84
|
+
putTspan({ container: textInput, value, x, y });
|
85
|
+
y += 6;
|
86
|
+
})
|
87
|
+
} else textInput.innerHTML = value || "";
|
88
|
+
});
|
35
89
|
}
|
90
|
+
}
|
36
91
|
|
92
|
+
function putTspan({ container, value, x, y = 5, dx = 0, dy = 0, style }) {
|
93
|
+
const tspan = document.createElementNS(svgNS, "tspan");
|
94
|
+
tspan.setAttribute('x', x);
|
95
|
+
tspan.setAttribute('y', y)
|
96
|
+
tspan.textContent = value;
|
97
|
+
container && container.appendChild(tspan)
|
98
|
+
return tspan;
|
37
99
|
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
export default class MultiText {
|
2
|
+
constructor({ box }) {
|
3
|
+
this.box = box;
|
4
|
+
this.container = box.container;
|
5
|
+
// this.draw({ box })
|
6
|
+
|
7
|
+
}
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
draw({ box }) {
|
13
|
+
// همه چیز را توی کانتینر باکس آبجکت رسم کن
|
14
|
+
const { container, elements, width, height } = box
|
15
|
+
console.log(box);
|
16
|
+
|
17
|
+
elements.forEach(element => {
|
18
|
+
const { name, value, x, y, style } = element;
|
19
|
+
|
20
|
+
switch (element.type) {
|
21
|
+
case 'label':
|
22
|
+
// const { value, x, y, style } = element
|
23
|
+
putText({ container, value, x, y, style })
|
24
|
+
break;
|
25
|
+
case 'input':
|
26
|
+
putText({ container, x, y, style, name });
|
27
|
+
|
28
|
+
break;
|
29
|
+
default:
|
30
|
+
break;
|
31
|
+
}
|
32
|
+
|
33
|
+
});
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
}
|
package/src/Reflex/Reflex.js
CHANGED
@@ -5,9 +5,10 @@ import putCell from "../common/putCell.js";
|
|
5
5
|
import units from "./units.js";
|
6
6
|
|
7
7
|
export default class Reflex {
|
8
|
-
constructor({ container, side }) {
|
8
|
+
constructor({ container, side, dims }) {
|
9
9
|
this.container = container;
|
10
10
|
this.side = side; // این برای تعیین رنگ راست و چپ استفاده میشود
|
11
|
+
this.draw({dims})
|
11
12
|
}
|
12
13
|
|
13
14
|
draw({ dims }) {
|
package/src/Speech/Speech.js
CHANGED
@@ -6,9 +6,10 @@ import units from "./units.js";
|
|
6
6
|
const svgNS = "http://www.w3.org/2000/svg";
|
7
7
|
|
8
8
|
export default class Speech {
|
9
|
-
constructor({ container, side = 'R' }) {
|
9
|
+
constructor({ container, side = 'R', dims }) {
|
10
10
|
this.container = container;
|
11
11
|
this.side = side;
|
12
|
+
this.draw({dims})
|
12
13
|
}
|
13
14
|
|
14
15
|
draw({ dims }) {
|
@@ -49,7 +50,6 @@ export default class Speech {
|
|
49
50
|
}
|
50
51
|
}
|
51
52
|
|
52
|
-
|
53
53
|
// ایجاد ماتریکس سلول های چارت که آدرس و مختصات مرکز هر سلول را نگهداری میکند
|
54
54
|
const matrix = [
|
55
55
|
[],
|
@@ -7,13 +7,10 @@ const svgNS = "http://www.w3.org/2000/svg";
|
|
7
7
|
|
8
8
|
export default class Speech {
|
9
9
|
constructor({ box, side = 'R' }) {
|
10
|
-
console.log(box);
|
11
|
-
|
12
10
|
// const { container, width, height, elements } = box
|
13
11
|
// this.container = container;
|
14
12
|
this.side = side;
|
15
13
|
this.draw({ box })
|
16
|
-
|
17
14
|
}
|
18
15
|
|
19
16
|
draw({ box }) {
|
@@ -52,7 +49,6 @@ export default class Speech {
|
|
52
49
|
}
|
53
50
|
}
|
54
51
|
|
55
|
-
|
56
52
|
// ایجاد ماتریکس سلول های چارت که آدرس و مختصات مرکز هر سلول را نگهداری میکند
|
57
53
|
const matrix = [
|
58
54
|
[],
|
@@ -69,7 +65,6 @@ export default class Speech {
|
|
69
65
|
}
|
70
66
|
|
71
67
|
style = styles.label;
|
72
|
-
|
73
68
|
// برچسب های سطر اول
|
74
69
|
// برای فرم های پیش چاپ شده انجام نمیشود
|
75
70
|
// !dims.hideContext &&
|
@@ -5,12 +5,13 @@ import units from "./units.js";
|
|
5
5
|
const svgNS = "http://www.w3.org/2000/svg";
|
6
6
|
|
7
7
|
export default class Tympanogram {
|
8
|
-
constructor({ container, side }) {
|
8
|
+
constructor({ container, side, dims }) {
|
9
9
|
this.pressure = { min: -600, max: +400, step: 200 };
|
10
10
|
this.compliance = { min: -0.50, max: 3, step: 0.50 };
|
11
11
|
this.padding = { right: 5, left: 8, top: 7, bottom: 14 };
|
12
12
|
this.container = container;
|
13
13
|
this.side = side
|
14
|
+
this.draw({dims})
|
14
15
|
}
|
15
16
|
|
16
17
|
draw({ dims }) {
|
package/src/main.js
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
// import './style.css'
|
2
2
|
import Audiogram from "./Audiogram/Audiogram.js"
|
3
|
-
import Forms from "./
|
3
|
+
import Forms from "./Forms/Forms.js";
|
4
4
|
import { officeData, patientData } from "../assets/data/sampleData.js"
|
5
5
|
import template from "../assets/templates/template_combo.js";
|
6
6
|
import Tympanogram from "./Tympanogram/Tympanogram.js";
|
7
7
|
import Speech from "./Speech/Speech.js";
|
8
8
|
import Reflex from "./Reflex/Reflex.js";
|
9
|
-
import
|
9
|
+
import MultiText from "./MultiText/MultiText.js";
|
10
|
+
|
10
11
|
|
11
12
|
|
12
13
|
document.querySelector('#app').innerHTML = `
|
@@ -40,9 +41,8 @@ let dims = {
|
|
40
41
|
]
|
41
42
|
}
|
42
43
|
|
43
|
-
const RSpeech = new Speech({ container, side: 'R' })
|
44
|
-
RSpeech.
|
45
|
-
RSpeech.update({ MCL: '55', SAT: '25', SDS: '98', UCL: '120', SRT: '30' })
|
44
|
+
// const RSpeech = new Speech({ container, side: 'R' , dims})
|
45
|
+
// RSpeech.update({ MCL: '55', SAT: '25', SDS: '98', UCL: '120', SRT: '30' })
|
46
46
|
|
47
47
|
dims = {
|
48
48
|
"name": "RTympanogram",
|
@@ -59,8 +59,7 @@ dims = {
|
|
59
59
|
"height": 60 * 6
|
60
60
|
}
|
61
61
|
|
62
|
-
const RTympanogram = new Tympanogram({ container, side: 'R' })
|
63
|
-
RTympanogram.draw({ dims });
|
62
|
+
// const RTympanogram = new Tympanogram({ container, side: 'R', dims })
|
64
63
|
|
65
64
|
dims = {
|
66
65
|
"name": "RReflex",
|
@@ -77,13 +76,12 @@ dims = {
|
|
77
76
|
"height": 30 * 6
|
78
77
|
}
|
79
78
|
|
80
|
-
const RReflex = new Reflex({ container, side: 'R' })
|
81
|
-
RReflex.draw({ dims });
|
79
|
+
// const RReflex = new Reflex({ container, side: 'R' , dims})
|
82
80
|
|
83
81
|
dims = {
|
84
|
-
"name": "
|
82
|
+
"name": "patient",
|
85
83
|
"w": 200,
|
86
|
-
"h":
|
84
|
+
"h": 8,
|
87
85
|
"margin": {
|
88
86
|
"left": 1,
|
89
87
|
"top": 0,
|
@@ -92,26 +90,80 @@ dims = {
|
|
92
90
|
},
|
93
91
|
"display": "block",
|
94
92
|
"width": 198,
|
95
|
-
"height":
|
93
|
+
"height": 8,
|
96
94
|
"elements": [
|
97
95
|
{
|
98
96
|
"type": "text",
|
99
97
|
"x": 198,
|
100
98
|
"y": 5,
|
101
|
-
"value": "
|
99
|
+
"value": "نام:"
|
100
|
+
},
|
101
|
+
{
|
102
|
+
"type": "text",
|
103
|
+
"x": 160,
|
104
|
+
"y": 5,
|
105
|
+
"value": "نام خانوادگی:"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"type": "text",
|
109
|
+
"x": 108,
|
110
|
+
"y": 5,
|
111
|
+
"value": "سن:"
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"type": "text",
|
115
|
+
"x": 68,
|
116
|
+
"y": 5,
|
117
|
+
"value": "ارجاع از:"
|
102
118
|
}
|
103
119
|
],
|
104
120
|
"inputs": [
|
105
121
|
{
|
106
|
-
"name": "
|
107
|
-
"x":
|
122
|
+
"name": "name",
|
123
|
+
"x": 191,
|
124
|
+
"y": 5
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"name": "lastName",
|
128
|
+
"x": 139,
|
129
|
+
"y": 5
|
130
|
+
},
|
131
|
+
{
|
132
|
+
"name": "age",
|
133
|
+
"x": 100,
|
134
|
+
"y": 5
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"name": "referrer",
|
138
|
+
"x": 55,
|
139
|
+
"y": 5
|
140
|
+
}
|
141
|
+
],
|
142
|
+
"forceInputs": [
|
143
|
+
{
|
144
|
+
"name": "name",
|
145
|
+
"x": 188,
|
146
|
+
"y": 4
|
147
|
+
},
|
148
|
+
{
|
149
|
+
"name": "lastName",
|
150
|
+
"x": 151,
|
151
|
+
"y": 5
|
152
|
+
},
|
153
|
+
{
|
154
|
+
"name": "age",
|
155
|
+
"x": 101,
|
156
|
+
"y": 5
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"name": "referrer",
|
160
|
+
"x": 56,
|
108
161
|
"y": 5
|
109
162
|
}
|
110
163
|
]
|
111
164
|
}
|
112
165
|
|
113
|
-
// const
|
114
|
-
// report.draw({ dims });
|
166
|
+
// const patient = new MultiText({ container, dims })
|
115
167
|
|
116
168
|
dims = {
|
117
169
|
"blank": false,
|
@@ -130,7 +182,7 @@ dims = {
|
|
130
182
|
"height": 600
|
131
183
|
}
|
132
184
|
|
133
|
-
const RAudiogram = new Audiogram({ container, side: 'R', dims })
|
185
|
+
// const RAudiogram = new Audiogram({ container, side: 'R', dims })
|
134
186
|
// RAudiogram.update({
|
135
187
|
// data: {
|
136
188
|
// // R_AC_M: { 8000: 25, 2000: 5, 1500: 0, },
|
@@ -143,7 +195,7 @@ const RAudiogram = new Audiogram({ container, side: 'R', dims })
|
|
143
195
|
// side: 'R',
|
144
196
|
// })
|
145
197
|
|
146
|
-
const forms = new Forms({ container: document.getElementById('forms-div'), templates: [template], mode: '
|
198
|
+
const forms = new Forms({ container: document.getElementById('forms-div'), templates: [template], mode: 'production' });
|
147
199
|
forms.update({ officeData, patientData, sessionIndex: 0 })
|
148
200
|
|
149
201
|
|
package/src/Box/Box.js
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
import putLine from "../common/putLine.js";
|
2
|
-
import putRect from "../common/putRect.js";
|
3
|
-
import putText from "../common/putText.js";
|
4
|
-
const svgNS = "http://www.w3.org/2000/svg";
|
5
|
-
|
6
|
-
export default class Box {
|
7
|
-
constructor({ container }) {
|
8
|
-
this.container = container;
|
9
|
-
}
|
10
|
-
draw({ dims, stroke = true }) {
|
11
|
-
// دریافت اطلاعات مختصات چاپ ورودی ها به جز عادی محاسبه شده
|
12
|
-
this.inputs = (dims.forceInsert) ? dims.forceInputs : dims.inputs
|
13
|
-
|
14
|
-
let value;
|
15
|
-
let width = dims.width;
|
16
|
-
let height = dims.height;
|
17
|
-
let x = dims.margin.left;
|
18
|
-
let y = dims.margin.top;
|
19
|
-
|
20
|
-
let style, className;
|
21
|
-
style = `
|
22
|
-
/* font-family: Arial, Helvetica, sans-serif !important; */
|
23
|
-
font-size: 1mm;
|
24
|
-
white-space: break-spaces;
|
25
|
-
/* font-weight: bold; */
|
26
|
-
direction: rtl !important;
|
27
|
-
user-select: none;
|
28
|
-
/* dominant-baseline: middle; /* تراز عمودی*/
|
29
|
-
`;
|
30
|
-
// بوردر کل چارت
|
31
|
-
const svg = document.createElementNS(svgNS, "svg");
|
32
|
-
svg.setAttribute("x", x);
|
33
|
-
svg.setAttribute("y", y);
|
34
|
-
svg.setAttribute("width", width);
|
35
|
-
svg.setAttribute("height", height);
|
36
|
-
svg.setAttribute('style', style)
|
37
|
-
// svg.setAttribute('class', 'text-box')
|
38
|
-
|
39
|
-
// اگر مقدار استروک درست بود لیبل ها را چاپ کن
|
40
|
-
if (!dims.hideContext) {
|
41
|
-
dims.elements
|
42
|
-
.forEach(
|
43
|
-
element => {
|
44
|
-
switch (element.type) {
|
45
|
-
case 'text':
|
46
|
-
({ x, y, value, style } = element);
|
47
|
-
putText({ container: svg, value, x, y, style, className: 'persian bold' });
|
48
|
-
break;
|
49
|
-
case 'line':
|
50
|
-
let { x1, y1, x2, y2 } = element;
|
51
|
-
putLine({ container: svg, x1, y1, x2, y2 });
|
52
|
-
break;
|
53
|
-
}
|
54
|
-
});
|
55
|
-
}
|
56
|
-
|
57
|
-
// محل اینپوتهای دیتا
|
58
|
-
let name;
|
59
|
-
this.inputs && this.inputs.forEach(input => {
|
60
|
-
({ name, x, y } = input);
|
61
|
-
putText({ container: svg, x, y, className: 'persian', name });
|
62
|
-
});
|
63
|
-
|
64
|
-
// مربع احاطهکننده کل جدول برای راهنمای توسعه
|
65
|
-
const borderRect = putRect({
|
66
|
-
container: svg, x: 0, y: 0, width, height,
|
67
|
-
name: dims.name, className: 'no-print',
|
68
|
-
style: 'stroke: transparent; fill: transparent '
|
69
|
-
});
|
70
|
-
this.borderRect = borderRect;
|
71
|
-
// console.log(dims);
|
72
|
-
|
73
|
-
this.container.appendChild(svg)
|
74
|
-
// this.patient = svg;
|
75
|
-
|
76
|
-
}
|
77
|
-
|
78
|
-
update(data) {
|
79
|
-
this.inputs.forEach(input => {
|
80
|
-
let value = data?.[input.name];
|
81
|
-
const textInput = this.container.querySelector(`text[data-name=${input.name}]`)
|
82
|
-
|
83
|
-
// پیدا کردن کاراکترهای رفتن به سرخط در متن
|
84
|
-
const textLines = value.toString().split(/\n|\r|\r\n/);
|
85
|
-
const x = textInput.getAttribute('x')
|
86
|
-
// اگر متن چند خطی بود
|
87
|
-
if (textLines.length >= 2) {
|
88
|
-
let y = 5;
|
89
|
-
textLines.forEach(value => {
|
90
|
-
putTspan({ container: textInput, value, x, y });
|
91
|
-
y += 6;
|
92
|
-
})
|
93
|
-
} else textInput.innerHTML = value || "";
|
94
|
-
});
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
function putTspan({ container, value, x , y = 5, dx = 0, dy = 0, style }) {
|
99
|
-
const tspan = document.createElementNS(svgNS, "tspan");
|
100
|
-
tspan.setAttribute('x', x);
|
101
|
-
tspan.setAttribute('y', y)
|
102
|
-
tspan.textContent = value;
|
103
|
-
container && container.appendChild(tspan)
|
104
|
-
return tspan;
|
105
|
-
}
|
File without changes
|
File without changes
|