hayun-vite 0.0.3 → 0.1.0

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.
Files changed (42) hide show
  1. package/assets/styles-test.css +90 -90
  2. package/assets/styles.css +90 -90
  3. package/data/formData1.js +42 -42
  4. package/data/officesObjStore.js +56 -56
  5. package/data/patientsObjStore.js +73 -73
  6. package/data/sampleData.js +94 -94
  7. package/index.js +11 -11
  8. package/package.json +1 -1
  9. package/src/Audiogram/Audiogram.js +194 -197
  10. package/src/Audiogram/dims.js +83 -83
  11. package/src/Form/Form.js +268 -276
  12. package/src/Form/Form_N.js +158 -158
  13. package/src/Form/Forms-Test.html +124 -124
  14. package/src/Form/Forms.js +121 -134
  15. package/src/Form/Header.js +91 -91
  16. package/src/Form/Reflex.js +141 -141
  17. package/src/Form/Sections.js +71 -71
  18. package/src/Form/Speech.js +132 -132
  19. package/src/Form/TextBox.js +66 -82
  20. package/src/Form/Tympanogram.js +355 -355
  21. package/src/Form/formStyles.css +122 -122
  22. package/src/Form/globalinfo.js +68 -68
  23. package/src/Form/grid/drawGrid.js +84 -84
  24. package/src/Form/grid/hideGrid.js +8 -8
  25. package/src/Form/printForm.js +122 -75
  26. package/src/Form/templates/combo.js +248 -248
  27. package/src/Form/templates/dims.js +204 -204
  28. package/src/Form/templates/rasaAud.js +287 -287
  29. package/src/Symbol/Symbols.js +29 -29
  30. package/src/Symbol/createSymbolSVG.js +240 -240
  31. package/src/Symbol/getAllSymbolsSVG.js +21 -21
  32. package/src/Symbol/insertSymbol.js +10 -10
  33. package/src/Symbol/symbolChart.js +47 -47
  34. package/src/common/putLine.js +16 -16
  35. package/src/common/putPoint.js +12 -12
  36. package/src/common/putRect.js +13 -13
  37. package/src/common/putText.js +17 -16
  38. package/src/common/putTopLayer.js +17 -17
  39. package/src/main.js +88 -87
  40. package/src/note.css +62 -0
  41. package/src/style.css +189 -156
  42. package/src/note.html +0 -1
package/src/Form/Form.js CHANGED
@@ -1,277 +1,269 @@
1
- // import Audiogram from "../Audiogram/Audiogram_N.js";
2
- import putLine from "../common/putLine.js";
3
- import drawTopLayer from "../common/putTopLayer.js";
4
- import Symbols from "../Symbol/Symbols.js";
5
- import TextBox from "./TextBox.js";
6
- import Header from "./Header.js";
7
- import Reflex from "./Reflex.js";
8
- import Sections from "./Sections.js";
9
- import Speech from "./Speech.js";
10
- import Tympanogram from "./Tympanogram.js";
11
- // import AudiogramChart from "../Audiogram/AudiogramChart_N.js";
12
-
13
- import dims from "../Audiogram/dims.js";
14
- import putRect from "../common/putRect.js";
15
- import AudiogramChart from "../Audiogram/Audiogram.js";
16
- const svgNS = "http://www.w3.org/2000/svg";
17
-
18
-
19
-
20
-
21
- export default class Form {
22
- constructor({ container, template, image } = {}) {
23
- this.image = image;
24
- // const dims = template;
25
- this.template = template;
26
- this.container = container;
27
- this.data = {};
28
- let { width, height, margin, paper } = template;
29
- this.form = this.create({ paper, margin });
30
- this.form.style.display = 'none';
31
- // رسم مارجین های فرم
32
- this.drawMarginLines({ container: this.form, width, height });
33
-
34
- const sections = new Sections({ container: this.form, dims: template });
35
- this.sections = sections;
36
-
37
- if (sections.header) {
38
- this.header = new Header({ container: sections.header })
39
- this.header.draw({ dims: template.header });
40
- }
41
-
42
- if (sections.patient) {
43
- this.patient = new TextBox({ container: sections.patient });
44
- this.patient.draw({ dims: template.patient });
45
- }
46
-
47
-
48
- if (sections.history) {
49
- this.history = new TextBox({ container: sections.history })
50
- this.history.draw({ dims: template.history });
51
- }
52
-
53
- this.symbols = new Symbols();
54
-
55
- if (sections.RAudiogram) {
56
- this.RAudiogram = new AudiogramChart({
57
- container: sections.RAudiogram,
58
- dims: template.RAudiogram,
59
- side: 'R',
60
- });
61
- }
62
- if (sections.LAudiogram) {
63
- this.LAudiogram = new AudiogramChart({
64
- container: sections.LAudiogram,
65
- dims: template.LAudiogram,
66
- side: 'L',
67
- });
68
- }
69
- if (sections.RSpeech) {
70
- this.RSpeech = new Speech({ container: sections.RSpeech, side: 'R' })
71
- this.RSpeech.draw({ dims: template.RSpeech, })
72
- }
73
- if (sections.LSpeech) {
74
- this.LSpeech = new Speech({ container: sections.LSpeech, side: 'L' })
75
- this.LSpeech.draw({ dims: template.LSpeech, });
76
- }
77
- if (sections.RTympanogram) {
78
- this.RTympanogram = new Tympanogram({ container: sections.RTympanogram, dims: template.RTympanogram })
79
- this.RTympanogram.draw({ dims: template.RTympanogram });
80
- }
81
- if (sections.LTympanogram) {
82
- this.LTympanogram = new Tympanogram({ container: sections.LTympanogram, dims: template.LTympanogram })
83
- this.LTympanogram.draw({ dims: template.LTympanogram });
84
- }
85
- if (sections.RReflex) {
86
- this.RReflex = new Reflex({ container: sections.RReflex, dims: template.RReflex })
87
- this.RReflex.draw({ dims: template.RReflex });
88
- }
89
- if (sections.LReflex) {
90
- this.LReflex = new Reflex({ container: sections.LReflex, dims: template.LReflex })
91
- this.LReflex.draw({ dims: template.LReflex });
92
- }
93
- if (sections.report) {
94
- this.report = new TextBox({ container: sections.report })
95
- this.report.draw({ dims: template.report });
96
- }
97
- if (sections.footer) {
98
-
99
- this.footer = new TextBox({ container: sections.footer })
100
- this.footer.draw({ dims: template.footer });
101
- }
102
-
103
- this.container.appendChild(this.form);
104
-
105
- }
106
-
107
- draw() {
108
-
109
- let pad;
110
- let style = `
111
- user-select: none;
112
- direction: ltr !important;
113
- /* text-align: center; */
114
- font-family: Arial, Helvetica, sans-serif !important;
115
- font-size: 1.3mm;
116
- font-weight: bold;
117
- color: red;
118
- text-anchor: middle; /*تراز افقی*/
119
- dominant-baseline: middle; /* تراز عمودی*/
120
- `;
121
- // Draw Titles first
122
- // putText({ container: this.sections.audiograms, value: "Right Ear", x: 42.5, y: 4, style: style })
123
- // putText({ container: this.sections.speechs, value: "Speech Tests", x: this.sectionWidth / 2, y: 4, style: style })
124
- // putText({ container: this.sections.tympanograms, value: "Tympanometry", x: this.sectionWidth / 2, y: 4, style: style })
125
- // putText({ container: this.sections.reflexes, value: "Acoustic Reflexes", x: this.sectionWidth / 2, y: 4, style: style })
126
-
127
-
128
- // برای مخفی کردن بوردرها تابع تاگل بوردر همین جا فراخوانی شود
129
- // this.toggleBorders({ container: 'form' })
130
- // this.toggleBorders({ container: 'section' })
131
- // this.toggleBorders({ container: 'element' })
132
-
133
-
134
- // بعد از رسم همه المنت ها یک المنت مستطیل تاپ لایر
135
- // drawTopLayer({ container: this.form, dims: this.sections.dims });
136
- }
137
-
138
- create({ paper, margin }) {
139
- const { width, height } = paper;
140
- const { left, top } = margin;
141
-
142
- const backgroundImage = this.template.backgroundImage;
143
- let svg = document.createElementNS(svgNS, "svg");
144
- svg.setAttribute("viewBox", [-left, -top, width, height])
145
- svg.setAttribute("style", "background-color: BlanchedAlmond");
146
- if (this.image) {
147
- let image = document.createElementNS(svgNS, "image");
148
- image.setAttribute('width', width);
149
- image.setAttribute('height', height);
150
-
151
- image.setAttribute('x', 0)
152
- image.setAttribute('y', 0)
153
- // image.setAttribute('height', height);
154
- image.setAttribute('href', this.image);
155
-
156
- svg.appendChild(image);
157
- }
158
-
159
- // div.appendChild(svg);
160
- return svg;
161
- }
162
-
163
- update({ data, officeData, patientData, sessionIndex = 0 }) {
164
-
165
- const session = patientData.sessions[sessionIndex]
166
- // Prevent undefined error
167
- if (!data) {
168
- data = {
169
- common: {
170
- audiometer: "",
171
- tympanometers: "",
172
- },
173
- header: {
174
- officeName: officeData.name,
175
- officeLogo: officeData.logo,
176
- createDate: patientData.sessions[sessionIndex]?.createDate,
177
- },
178
- patient: {
179
- name: patientData.name,
180
- lastName: patientData.lastName,
181
- gender: patientData?.gender,
182
- age: patientData.sessions[sessionIndex]?.age,
183
- referrer: patientData.sessions[sessionIndex]?.referrer,
184
-
185
- },
186
- footer: {
187
- address: officeData.addresses[0],
188
- tel: officeData.tels[0],
189
- },
190
- id: +sessionIndex + 1,
191
- };
192
- // data = { audiogram: {}, common: {}, footer: {}, header: {}, patient: {}, reflex: {}, report: {}, speech: {}, tympanometry: {} }
193
- }
194
- // find which data reach and then call corresponding update function
195
- // get array of keys (audiogram, header, footer, ...)
196
- let keys = Object.keys(data)
197
- // if (keys.includes("header")) {
198
-
199
- this.header?.update(data.header)
200
- // }
201
- // if (keys.includes("patient")) {
202
- this.patient?.update(data.patient)
203
- // }
204
- // if (keys.includes("history")) {
205
-
206
- this.history?.update(session?.history)
207
- this.data.history = session.history;
208
- // }
209
- // if (keys.includes("audiogram")) {
210
- this.RAudiogram?.update({ data: session.audiogram?.R, side: 'R' })
211
- this.LAudiogram?.update({ data: session.audiogram?.L, side: 'L' })
212
- this.data.audiogram = session.audiogram
213
- // }
214
- // if (keys.includes("speech")) {
215
- this.RSpeech?.update(session.speech?.R)
216
- this.LSpeech?.update(session.speech?.L)
217
- this.data.speech = session.speech
218
- // }
219
- // if (keys.includes("tympanogram")) {
220
- this.RTympanogram?.update(session.tympanogram?.R)
221
- this.LTympanogram?.update(session.tympanogram?.L)
222
- this.data.tympanogram = session.tympanogram;
223
- // }
224
- // if (keys.includes("reflex")) {
225
- this.RReflex?.update(session.reflex?.R)
226
- this.LReflex?.update(session.reflex?.L)
227
- this.data.tympanogram = session.reflex;
228
- // }
229
- // if (keys.includes("report")) {
230
- this.report?.update(session.report)
231
- this.data.report = session.report;
232
- // }
233
- // if (keys.includes("footer")) {
234
- // console.log("footer Data:", data?.footer);
235
-
236
- this.footer?.update(data?.footer)
237
- this.data.footer = data.footer;
238
- // }
239
- }
240
-
241
- // خطوط نقطه چین مارجین فرم
242
- drawMarginLines({ container, width, height }) {
243
- // console.log(container.attributes.viewBox);
244
-
245
- const style = `
246
- stroke: black;
247
- stroke-width: 0.3;
248
- stroke-opacity: 0.5;
249
- stroke-dasharray: 0.5;
250
- fill: transparent;
251
- `;
252
- putRect({ container, x: 0, y: 0, width, height, style })
253
- // Horizontal Lines
254
- // putLine({
255
- // container: container, x1: 0, y1: margin.top,
256
- // x2: width, y2: margin.top, style: style, name: 'form-border'
257
- // })
258
- // putLine({
259
- // container: container, x1: 0, y1: height - margin.bottom,
260
- // x2: width, y2: height - margin.bottom, style: style, name: 'form-border'
261
- // })
262
- // // Vertical Lines
263
- // putLine({
264
- // container: container, x1: margin.left, y1: 0,
265
- // x2: margin.left, y2: height, style: style, name: 'form-border'
266
- // })
267
- // putLine({
268
- // container: container, x1: width - margin.right, y1: 0,
269
- // x2: width - margin.right, y2: height, style: style, name: 'form-border'
270
- // })
271
- // // Middle Line
272
- // putLine({
273
- // container: container, x1: width / 2, y1: 0,
274
- // x2: width / 2, y2: height, style: style, name: 'form-border'
275
- // })
276
- }
1
+ import Symbols from "../Symbol/Symbols.js";
2
+ import TextBox from "./TextBox.js";
3
+ import Header from "./Header.js";
4
+ import Reflex from "./Reflex.js";
5
+ import Sections from "./Sections.js";
6
+ import Speech from "./Speech.js";
7
+ import Tympanogram from "./Tympanogram.js";
8
+ import putRect from "../common/putRect.js";
9
+ import AudiogramChart from "../Audiogram/Audiogram.js";
10
+ const svgNS = "http://www.w3.org/2000/svg";
11
+
12
+
13
+ export default class Form {
14
+ constructor({ container, template, image } = {}) {
15
+ this.image = image;
16
+ // const dims = template;
17
+ this.template = template;
18
+ this.container = container;
19
+ this.data = {};
20
+ let { width, height, margin, paper } = template;
21
+ this.form = this.create({ paper, margin });
22
+ this.form.style.display = 'none';
23
+ // رسم مارجین های فرم
24
+ this.drawMarginLines({ container: this.form, width, height });
25
+
26
+ const sections = new Sections({ container: this.form, dims: template });
27
+ this.sections = sections;
28
+
29
+ if (sections.header) {
30
+ this.header = new Header({ container: sections.header })
31
+ this.header.draw({ dims: template.header });
32
+ }
33
+
34
+ if (sections.patient) {
35
+ this.patient = new TextBox({ container: sections.patient });
36
+ this.patient.draw({ dims: template.patient });
37
+ }
38
+
39
+
40
+ if (sections.history) {
41
+ this.history = new TextBox({ container: sections.history })
42
+ this.history.draw({ dims: template.history });
43
+ }
44
+
45
+ this.symbols = new Symbols();
46
+
47
+ if (sections.RAudiogram) {
48
+ this.RAudiogram = new AudiogramChart({
49
+ container: sections.RAudiogram,
50
+ dims: template.RAudiogram,
51
+ side: 'R',
52
+ });
53
+ }
54
+ if (sections.LAudiogram) {
55
+ this.LAudiogram = new AudiogramChart({
56
+ container: sections.LAudiogram,
57
+ dims: template.LAudiogram,
58
+ side: 'L',
59
+ });
60
+ }
61
+ if (sections.RSpeech) {
62
+ this.RSpeech = new Speech({ container: sections.RSpeech, side: 'R' })
63
+ this.RSpeech.draw({ dims: template.RSpeech, })
64
+ }
65
+ if (sections.LSpeech) {
66
+ this.LSpeech = new Speech({ container: sections.LSpeech, side: 'L' })
67
+ this.LSpeech.draw({ dims: template.LSpeech, });
68
+ }
69
+ if (sections.RTympanogram) {
70
+ this.RTympanogram = new Tympanogram({ container: sections.RTympanogram, dims: template.RTympanogram })
71
+ this.RTympanogram.draw({ dims: template.RTympanogram });
72
+ }
73
+ if (sections.LTympanogram) {
74
+ this.LTympanogram = new Tympanogram({ container: sections.LTympanogram, dims: template.LTympanogram })
75
+ this.LTympanogram.draw({ dims: template.LTympanogram });
76
+ }
77
+ if (sections.RReflex) {
78
+ this.RReflex = new Reflex({ container: sections.RReflex, dims: template.RReflex })
79
+ this.RReflex.draw({ dims: template.RReflex });
80
+ }
81
+ if (sections.LReflex) {
82
+ this.LReflex = new Reflex({ container: sections.LReflex, dims: template.LReflex })
83
+ this.LReflex.draw({ dims: template.LReflex });
84
+ }
85
+ if (sections.report) {
86
+ this.report = new TextBox({ container: sections.report })
87
+ this.report.draw({ dims: template.report });
88
+ }
89
+ if (sections.footer) {
90
+
91
+ this.footer = new TextBox({ container: sections.footer })
92
+ this.footer.draw({ dims: template.footer });
93
+ }
94
+
95
+ this.container.appendChild(this.form);
96
+
97
+ }
98
+
99
+ draw() {
100
+
101
+ let pad;
102
+ let style = `
103
+ user-select: none;
104
+ direction: ltr !important;
105
+ /* text-align: center; */
106
+ font-family: Arial, Helvetica, sans-serif !important;
107
+ font-size: 1.3mm;
108
+ font-weight: bold;
109
+ color: red;
110
+ text-anchor: middle; /*تراز افقی*/
111
+ dominant-baseline: middle; /* تراز عمودی*/
112
+ `;
113
+ // Draw Titles first
114
+ // putText({ container: this.sections.audiograms, value: "Right Ear", x: 42.5, y: 4, style: style })
115
+ // putText({ container: this.sections.speechs, value: "Speech Tests", x: this.sectionWidth / 2, y: 4, style: style })
116
+ // putText({ container: this.sections.tympanograms, value: "Tympanometry", x: this.sectionWidth / 2, y: 4, style: style })
117
+ // putText({ container: this.sections.reflexes, value: "Acoustic Reflexes", x: this.sectionWidth / 2, y: 4, style: style })
118
+
119
+
120
+ // برای مخفی کردن بوردرها تابع تاگل بوردر همین جا فراخوانی شود
121
+ // this.toggleBorders({ container: 'form' })
122
+ // this.toggleBorders({ container: 'section' })
123
+ // this.toggleBorders({ container: 'element' })
124
+
125
+
126
+ // بعد از رسم همه المنت ها یک المنت مستطیل تاپ لایر
127
+ // drawTopLayer({ container: this.form, dims: this.sections.dims });
128
+ }
129
+
130
+ create({ paper, margin }) {
131
+ const { width, height } = paper;
132
+ const { left, top } = margin;
133
+
134
+ const backgroundImage = this.template.backgroundImage;
135
+ let svg = document.createElementNS(svgNS, "svg");
136
+ svg.setAttribute("viewBox", [-left, -top, width, height])
137
+ svg.setAttribute("style", "background-color: BlanchedAlmond");
138
+ if (this.image) {
139
+ let image = document.createElementNS(svgNS, "image");
140
+ image.setAttribute('width', width);
141
+ image.setAttribute('height', height);
142
+
143
+ image.setAttribute('x', 0)
144
+ image.setAttribute('y', 0)
145
+ // image.setAttribute('height', height);
146
+ image.setAttribute('href', this.image);
147
+
148
+ svg.appendChild(image);
149
+ }
150
+
151
+ // div.appendChild(svg);
152
+ return svg;
153
+ }
154
+
155
+ update({ data, officeData, patientData, sessionIndex = 0 }) {
156
+
157
+ const session = patientData.sessions[sessionIndex]
158
+ // Prevent undefined error
159
+ if (!data) {
160
+ data = {
161
+ common: {
162
+ audiometer: "",
163
+ tympanometers: "",
164
+ },
165
+ header: {
166
+ officeName: officeData.name,
167
+ officeLogo: officeData.logo,
168
+ createDate: patientData.sessions[sessionIndex]?.createDate,
169
+ },
170
+ patient: {
171
+ name: patientData.name,
172
+ lastName: patientData.lastName,
173
+ gender: patientData?.gender,
174
+ age: patientData.sessions[sessionIndex]?.age,
175
+ referrer: patientData.sessions[sessionIndex]?.referrer,
176
+
177
+ },
178
+ footer: {
179
+ address: officeData.addresses[0],
180
+ tel: officeData.tels[0],
181
+ },
182
+ id: +sessionIndex + 1,
183
+ };
184
+ // data = { audiogram: {}, common: {}, footer: {}, header: {}, patient: {}, reflex: {}, report: {}, speech: {}, tympanometry: {} }
185
+ }
186
+ // find which data reach and then call corresponding update function
187
+ // get array of keys (audiogram, header, footer, ...)
188
+ let keys = Object.keys(data)
189
+ // if (keys.includes("header")) {
190
+
191
+ this.header?.update(data.header)
192
+ // }
193
+ // if (keys.includes("patient")) {
194
+ this.patient?.update(data.patient)
195
+ // }
196
+ // if (keys.includes("history")) {
197
+
198
+ this.history?.update(session?.history)
199
+ this.data.history = session.history;
200
+ // }
201
+ // if (keys.includes("audiogram")) {
202
+ this.RAudiogram?.update({ data: session.audiogram?.R, side: 'R' })
203
+ this.LAudiogram?.update({ data: session.audiogram?.L, side: 'L' })
204
+ this.data.audiogram = session.audiogram
205
+ // }
206
+ // if (keys.includes("speech")) {
207
+ this.RSpeech?.update(session.speech?.R)
208
+ this.LSpeech?.update(session.speech?.L)
209
+ this.data.speech = session.speech
210
+ // }
211
+ // if (keys.includes("tympanogram")) {
212
+ this.RTympanogram?.update(session.tympanogram?.R)
213
+ this.LTympanogram?.update(session.tympanogram?.L)
214
+ this.data.tympanogram = session.tympanogram;
215
+ // }
216
+ // if (keys.includes("reflex")) {
217
+ this.RReflex?.update(session.reflex?.R)
218
+ this.LReflex?.update(session.reflex?.L)
219
+ this.data.tympanogram = session.reflex;
220
+ // }
221
+ // if (keys.includes("report")) {
222
+ this.report?.update(session.report)
223
+ this.data.report = session.report;
224
+ // }
225
+ // if (keys.includes("footer")) {
226
+ // console.log("footer Data:", data?.footer);
227
+
228
+ this.footer?.update(data?.footer)
229
+ this.data.footer = data.footer;
230
+ // }
231
+ }
232
+
233
+ // خطوط نقطه چین مارجین فرم
234
+ drawMarginLines({ container, width, height }) {
235
+ // console.log(container.attributes.viewBox);
236
+
237
+ const style = `
238
+ stroke: black;
239
+ stroke-width: 0.3;
240
+ stroke-opacity: 0.5;
241
+ stroke-dasharray: 0.5;
242
+ fill: transparent;
243
+ `;
244
+ putRect({ container, x: 0, y: 0, width, height, style })
245
+ // Horizontal Lines
246
+ // putLine({
247
+ // container: container, x1: 0, y1: margin.top,
248
+ // x2: width, y2: margin.top, style: style, name: 'form-border'
249
+ // })
250
+ // putLine({
251
+ // container: container, x1: 0, y1: height - margin.bottom,
252
+ // x2: width, y2: height - margin.bottom, style: style, name: 'form-border'
253
+ // })
254
+ // // Vertical Lines
255
+ // putLine({
256
+ // container: container, x1: margin.left, y1: 0,
257
+ // x2: margin.left, y2: height, style: style, name: 'form-border'
258
+ // })
259
+ // putLine({
260
+ // container: container, x1: width - margin.right, y1: 0,
261
+ // x2: width - margin.right, y2: height, style: style, name: 'form-border'
262
+ // })
263
+ // // Middle Line
264
+ // putLine({
265
+ // container: container, x1: width / 2, y1: 0,
266
+ // x2: width / 2, y2: height, style: style, name: 'form-border'
267
+ // })
268
+ }
277
269
  }