hayun-vite 0.0.0 → 0.0.1

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 (43) hide show
  1. package/assets/Daco_1154502.png +0 -0
  2. package/assets/ear-logo-1.png +0 -0
  3. package/assets/fonts/Vazirmatn-Regular.woff2 +0 -0
  4. package/assets/hearing-aid-computer-icons-sound-ears-.png +0 -0
  5. package/assets/logo.svg +1 -0
  6. package/assets/logo192.png +0 -0
  7. package/assets/rasa.png +0 -0
  8. package/assets/styles-test.css +90 -0
  9. package/assets/styles.css +90 -0
  10. package/data/formData1.js +42 -0
  11. package/data/officesObjStore.js +57 -0
  12. package/data/patientsObjStore.js +74 -0
  13. package/data/sampleData.js +95 -0
  14. package/index.js +7 -3
  15. package/package.json +1 -1
  16. package/src/{Audiogram.js → Audiogram/Audiogram.js} +6 -4
  17. package/src/Form/Form.js +277 -0
  18. package/src/Form/Form_N.js +159 -0
  19. package/src/Form/Forms-Test.html +125 -0
  20. package/src/Form/Forms.js +135 -0
  21. package/src/Form/Header.js +92 -0
  22. package/src/Form/Reflex.js +142 -0
  23. package/src/Form/Sections.js +72 -0
  24. package/src/Form/Speech.js +133 -0
  25. package/src/Form/TextBox.js +81 -0
  26. package/src/Form/Tympanogram.js +356 -0
  27. package/src/Form/formStyles.css +122 -0
  28. package/src/Form/globalinfo.js +68 -0
  29. package/src/Form/grid/drawGrid.js +84 -0
  30. package/src/Form/grid/hideGrid.js +9 -0
  31. package/src/Form/printForm.js +76 -0
  32. package/src/Form/rasa-audio-208-293.png +0 -0
  33. package/src/Form/templates/combo.js +248 -0
  34. package/src/Form/templates/dims.js +204 -0
  35. package/src/Form/templates/rasaAud.js +287 -0
  36. package/src/Form/templates/rasaAud.png +0 -0
  37. package/src/Form/templates/rasaTymp.jpg +0 -0
  38. package/src/fonts/Vazirmatn-Regular.woff2 +0 -0
  39. package/src/main.js +87 -74
  40. package/src/note.html +1 -0
  41. package/src/style.css +157 -96
  42. package/src/AudiogramChart-Test.html +0 -56
  43. /package/src/{dims.js → Audiogram/dims.js} +0 -0
@@ -0,0 +1,277 @@
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
+ }
277
+ }
@@ -0,0 +1,159 @@
1
+ const svgNS = "http://www.w3.org/2000/svg";
2
+
3
+ import printForm from "./printForm.js";
4
+ import Template from "./Templates/Template.js";
5
+ import Template1 from "./Templates/Template1.js";
6
+ import Template2 from "./Templates/Template2.js";
7
+ import Template3 from "./Templates/Template3.js";
8
+
9
+
10
+ export default class Form {
11
+ constructor({ name, container } = {}) {
12
+ // ایجاد یک دیو برای قرار دادن دکمه ها و لینک های فرم
13
+ const div = document.createElement('div');
14
+ div.style = 'border: 1px solid brown; margin: 0; padding: 0;'
15
+ container.appendChild(div);
16
+ // اضافه کردن دکمه به دیو فرم
17
+ const btn1 = this.putButton({ container: div, text: 'Form 1', id: 'template1' });
18
+ const btn2 = this.putButton({ container: div, text: 'Form 2', id: 'template2' });
19
+ const btn3 = this.putButton({ container: div, text: 'Form 3', id: 'template3' });
20
+ const printBtn = this.putButton({ container: div, text: 'Print', id: 'print' });
21
+
22
+ // this.container = div;
23
+
24
+ // یک دیو تعریف میکنیم که سمت ادیولاگ برای تعریف لیستنر استفاده می‌شود
25
+ this.div = document.createElement('div'); // این بخش فقط شامل بخش اس‌وی‌جی هست
26
+ container.appendChild(this.div)
27
+
28
+ this.template1 = new Template({ container: this.div });
29
+ this.template2 = new Template2({ container: this.div });
30
+ this.template3 = new Template3({ container: this.div });
31
+
32
+ // تعریف رویداد دکمه چاپ فرم نمایشی
33
+ printBtn.addEventListener('click', () => { printForm({ container: this.activeForm }) })
34
+
35
+ // ایجاد المنت چک باکس با برچسب
36
+ // const checkBox = document.createElement('input');
37
+ // checkBox.setAttribute('type', 'checkbox');
38
+ // checkBox.setAttribute('id', 'chkb');
39
+ // const label = document.createElement('label');
40
+ // label.innerHTML = 'Select for Print';
41
+ // label.setAttribute('for', checkBox.getAttribute('id'))
42
+ // div.appendChild(checkBox)
43
+ // div.appendChild(label)
44
+
45
+ this.draw2();
46
+ // نمایش پیش‌فرض فرم شماره یک
47
+ this.template1.form.style.display = 'block';
48
+ this.activeForm = this.template1.form;
49
+
50
+ btn1.addEventListener('click', () => {
51
+ this.template2.form.style.display = 'none'
52
+ this.template3.form.style.display = 'none'
53
+ this.template1.form.style.display = 'block';
54
+ this.activeForm = this.template1.form;
55
+ console.log(this.activeForm);
56
+
57
+ });
58
+
59
+ btn2.addEventListener('click', () => {
60
+ this.template1.form.style.display = 'none'
61
+ this.template3.form.style.display = 'none'
62
+ this.template2.form.style.display = 'block';
63
+ this.activeForm = this.template2.form;
64
+
65
+ });
66
+
67
+ btn3.addEventListener('click', () => {
68
+ this.template1.form.style.display = 'none'
69
+ this.template2.form.style.display = 'none'
70
+ this.template3.form.style.display = 'block';
71
+ this.activeForm = this.template3.form;
72
+
73
+ });
74
+ // for Develop
75
+ this.event();
76
+
77
+ }
78
+
79
+ draw2() {
80
+ this.template1.draw();
81
+ this.template2.draw();
82
+ this.template3.draw();
83
+
84
+ }
85
+
86
+ draw() { }
87
+
88
+ event() {
89
+ this.div.addEventListener('click', (e) => {
90
+ console.log(e.target);
91
+ })
92
+ }
93
+
94
+ update({ template, data, officeData, patientData, sessionIndex = 0 }) {
95
+
96
+ this.template1.update({ data, officeData, patientData, sessionIndex })
97
+ this.template2.update({ data, officeData, patientData, sessionIndex })
98
+ this.template3.update({ data, officeData, patientData, sessionIndex })
99
+
100
+ }
101
+
102
+ // ایجاد دکمه تاگل خطوط مرزی فرم و سکشن و المان
103
+ toggleBorders({ activeForm, container = 'form' }) {
104
+
105
+ const borders = activeForm.querySelectorAll(`[data-name="${container}-border"]`);
106
+ // آبجکت نگهداری رنگ بوردرها
107
+ const color = { form: 'black', section: 'blue', element: 'green' }
108
+ borders.forEach(border => {
109
+ // console.log(border.style.stroke);
110
+ border.style.stroke = (border.style.stroke === 'transparent') ? color[container] : 'transparent';
111
+ })
112
+ }
113
+
114
+ // توابع داخلی ایجاد دکمه و لینک های بالای فرم
115
+ putButton({ container, id, text, }) {
116
+ let style = `
117
+ background-color:rgb(0, 149, 149);
118
+ /* Green background */
119
+ border: none;
120
+ /* Remove borders */
121
+ color: white;
122
+ /* White text */
123
+ padding: 15px 32px;
124
+ /* Some padding */
125
+ text-align: center;
126
+ /* Centered text */
127
+ text-decoration: none;
128
+ /* Remove underline */
129
+ display: inline-block;
130
+ /* Make the button inline */
131
+ font-size: 16px;
132
+ /* Increase font size */
133
+ margin: 4px 2px;
134
+ /* Add some margin */
135
+ cursor: pointer;
136
+ /* Pointer cursor on hover */
137
+ border-radius: 8px;
138
+ /* Rounded corners */
139
+ transition: background-color 0.3s;
140
+ /* Smooth transition */
141
+ `;
142
+ const button = document.createElement('button');
143
+ button.setAttribute('id', id);
144
+ button.setAttribute('style', style);
145
+ button.innerHTML = text;
146
+
147
+ button.addEventListener('mouseenter', () => {
148
+ button.style.backgroundColor = 'rgb(54, 115, 115)'; // Change color on hover
149
+ });
150
+ button.addEventListener('mouseleave', () => {
151
+ button.style.backgroundColor = 'rgb(0, 149, 149)'; // Revert color when not hovering
152
+ });
153
+
154
+ container.appendChild(button);
155
+ return button;
156
+
157
+ }
158
+
159
+ }
@@ -0,0 +1,125 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Form New Test</title>
8
+ <style>
9
+ button {
10
+ background-color: #4CAF50;
11
+ /* Green background */
12
+ border: none;
13
+ /* Remove borders */
14
+ color: white;
15
+ /* White text */
16
+ padding: 15px 32px;
17
+ /* Some padding */
18
+ text-align: center;
19
+ /* Centered text */
20
+ text-decoration: none;
21
+ /* Remove underline */
22
+ display: inline-block;
23
+ /* Make the button inline */
24
+ font-size: 16px;
25
+ /* Increase font size */
26
+ margin: 4px 2px;
27
+ /* Add some margin */
28
+ cursor: pointer;
29
+ /* Pointer cursor on hover */
30
+ border-radius: 8px;
31
+ /* Rounded corners */
32
+ transition: background-color 0.3s;
33
+ /* Smooth transition */
34
+ }
35
+
36
+ button:hover {
37
+ background-color: #45a049;
38
+ /* Darker green on hover */
39
+ }
40
+
41
+ button:active {
42
+ background-color: #3e8e41;
43
+ /* Even darker green when clicked */
44
+ }
45
+ </style>
46
+ <style>
47
+ @page {
48
+
49
+ size: a4 portrait;
50
+ margin: 0cm;
51
+ }
52
+
53
+ @media print {
54
+
55
+ /* All your print styles go here */
56
+ button {
57
+ display: none !important;
58
+ }
59
+
60
+ svg {
61
+ margin: 0;
62
+ }
63
+
64
+ body {
65
+ margin: 0;
66
+ }
67
+ }
68
+ </style>
69
+ </head>
70
+ <!-- <button></button> -->
71
+
72
+ <body>
73
+ <input type="checkbox" id="a">
74
+ <label for="a">Select for Print</label>
75
+ <button id="formBtn">Hide Form Margins</button>
76
+ <button id="sectionBtn">Hide Section Margins</button>
77
+ <button id="elementBtn">Hide Element Margins</button>
78
+ <button id="printBtn">Print Form</button>
79
+ <!-- <svg width="210mm" height="298mm" id="form-div" style="border: 1px solid blue"></svg> -->
80
+ <div id="form-div"></div>
81
+
82
+ <script type="module">
83
+ import Forms from "./Forms.js";
84
+ import { officeData, patientData } from "../../data/sampleData.js"
85
+ const forms = new Forms({ container: document.getElementById('form-div'), name: 'form1' });
86
+ // form.draw();
87
+ // تابع افزودن دکمه‌های تاگل نمایش و محو خطوط راهنما هر سه نوع
88
+ // form section element
89
+ // document.getElementById('formBtn').addEventListener('mouseenter', () => {
90
+ // forms.toggleBorders({ container: 'form', activeForm: form.activeForm });
91
+ // });
92
+
93
+ // document.getElementById('sectionBtn').addEventListener('mouseenter', () => {
94
+ // forms.toggleBorders({ container: 'section', activeForm: form.activeForm });
95
+ // });
96
+
97
+ // document.getElementById('elementBtn').addEventListener('mouseenter', () => {
98
+ // forms.toggleBorders({ container: 'element', activeForm: form.activeForm });
99
+ // });
100
+
101
+ // document.getElementById('printBtn').addEventListener('mouseenter', () => {
102
+ // // form.toggleBorders({container: 'element'});
103
+ // // window.print()
104
+ // // const printDateTime = form.print();
105
+ // // console.log(printDateTime);
106
+
107
+ // });
108
+
109
+
110
+
111
+ // const data = {
112
+ // audiogram: {
113
+ // R: { R_AC: { 500: 25, 1000: 35, 2000: 45, 4000: 55, 8000: 60 } },
114
+ // L: { L_AC: { 500: 70, 1000: 75, 2000: 80, 4000: 65, 8000: 60 } }
115
+ // },
116
+ // tympanogram: {
117
+ // R: { ECV: 2.52, SC: 0.80, MEP: -100, type: 'An' },
118
+ // L: { ECV: 2.52, SC: 0.80, MEP: -300, type: 'An' }
119
+ // }
120
+ // }
121
+ forms.update({ officeData, patientData, sessionIndex: 0 })
122
+ </script>
123
+ </body>
124
+
125
+ </html>