@icure/form 1.0.1 → 1.0.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/lib/components/index.d.ts +2 -0
- package/lib/components/index.js +14 -0
- package/lib/components/iqr-form/fields/datePicker.d.ts +8 -0
- package/lib/components/iqr-form/fields/datePicker.js +42 -0
- package/lib/components/iqr-form/fields/dateTimePicker.d.ts +8 -0
- package/lib/components/iqr-form/fields/dateTimePicker.js +42 -0
- package/lib/components/iqr-form/fields/measureField.d.ts +8 -0
- package/lib/components/iqr-form/fields/measureField.js +42 -0
- package/lib/components/iqr-form/fields/multipleChoice.d.ts +8 -0
- package/lib/components/iqr-form/fields/multipleChoice.js +42 -0
- package/lib/components/iqr-form/fields/numberField.d.ts +8 -0
- package/lib/components/iqr-form/fields/numberField.js +42 -0
- package/lib/components/iqr-form/fields/textfield.d.ts +1 -0
- package/lib/components/iqr-form/fields/textfield.js +86 -0
- package/lib/components/iqr-form/fields/timePicker.d.ts +8 -0
- package/lib/components/iqr-form/fields/timePicker.js +42 -0
- package/lib/components/iqr-form/index.d.ts +7 -0
- package/lib/components/iqr-form/index.js +83 -0
- package/lib/components/iqr-form/model/index.d.ts +78 -0
- package/lib/components/iqr-form/model/index.js +114 -0
- package/lib/components/iqr-form/renderer/cards.d.ts +2 -0
- package/lib/components/iqr-form/renderer/cards.js +43 -0
- package/lib/components/iqr-form/renderer/form.d.ts +2 -0
- package/lib/components/iqr-form/renderer/form.js +44 -0
- package/lib/components/iqr-form/renderer/index.d.ts +3 -0
- package/lib/components/iqr-form/renderer/index.js +2 -0
- package/lib/components/iqr-text-field/index.d.ts +2 -0
- package/lib/components/iqr-text-field/index.js +335 -0
- package/lib/components/iqr-text-field/plugin/caret-fix-plugin.d.ts +2 -0
- package/lib/components/iqr-text-field/plugin/caret-fix-plugin.js +23 -0
- package/lib/components/iqr-text-field/plugin/has-content-class-plugin.d.ts +2 -0
- package/lib/components/iqr-text-field/plugin/has-content-class-plugin.js +18 -0
- package/lib/components/iqr-text-field/plugin/mask-plugin.d.ts +2 -0
- package/lib/components/iqr-text-field/plugin/mask-plugin.js +143 -0
- package/lib/components/iqr-text-field/plugin/regexp-plugin.d.ts +2 -0
- package/lib/components/iqr-text-field/plugin/regexp-plugin.js +46 -0
- package/lib/components/iqr-text-field/prosemirror-commands.d.ts +4 -0
- package/lib/components/iqr-text-field/prosemirror-commands.js +52 -0
- package/lib/components/iqr-text-field/prosemirror-utils.d.ts +5 -0
- package/lib/components/iqr-text-field/prosemirror-utils.js +15 -0
- package/lib/components/iqr-text-field/schema/common-marks.d.ts +10 -0
- package/lib/components/iqr-text-field/schema/common-marks.js +90 -0
- package/lib/components/iqr-text-field/schema/date-time-schema.d.ts +7 -0
- package/lib/components/iqr-text-field/schema/date-time-schema.js +88 -0
- package/lib/components/iqr-text-field/schema/decimal-schema.d.ts +3 -0
- package/lib/components/iqr-text-field/schema/decimal-schema.js +27 -0
- package/lib/components/iqr-text-field/schema/index.d.ts +11 -0
- package/lib/components/iqr-text-field/schema/index.js +18 -0
- package/lib/components/iqr-text-field/schema/markdown-schema.d.ts +8 -0
- package/lib/components/iqr-text-field/schema/markdown-schema.js +139 -0
- package/lib/components/iqr-text-field/schema/measure-schema.d.ts +3 -0
- package/lib/components/iqr-text-field/schema/measure-schema.js +35 -0
- package/lib/components/iqr-text-field/schema/token-schema.d.ts +6 -0
- package/lib/components/iqr-text-field/schema/token-schema.js +36 -0
- package/lib/components/iqr-text-field/schema/utils.d.ts +11 -0
- package/lib/components/iqr-text-field/schema/utils.js +11 -0
- package/lib/components/iqr-text-field/selection-companion.d.ts +11 -0
- package/lib/components/iqr-text-field/selection-companion.js +52 -0
- package/lib/components/iqr-text-field/suggestion-palette.d.ts +33 -0
- package/lib/components/iqr-text-field/suggestion-palette.js +139 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -2
- package/package.json +1 -1
- package/.editorconfig +0 -12
- package/.mocharc.json +0 -5
- package/app/demo-app.ts +0 -191
- package/test/form.yaml +0 -96
- package/test/simple/test.spec.ts +0 -303
- package/webpack.config.js +0 -41
package/app/demo-app.ts
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import {css, html, LitElement} from 'lit-element';
|
|
2
|
-
import {getRowsUsingPagination, IccCodeXApi} from '@icure/api';
|
|
3
|
-
|
|
4
|
-
console.log("initialized")
|
|
5
|
-
|
|
6
|
-
import '../src/components/iqr-text-field';
|
|
7
|
-
import '../src/components/iqr-form';
|
|
8
|
-
import MiniSearch from 'minisearch'
|
|
9
|
-
import {
|
|
10
|
-
DatePicker,
|
|
11
|
-
DateTimePicker,
|
|
12
|
-
Form, Group,
|
|
13
|
-
MeasureField, MultipleChoice,
|
|
14
|
-
NumberField,
|
|
15
|
-
Section,
|
|
16
|
-
TextField,
|
|
17
|
-
TimePicker
|
|
18
|
-
} from "../src/components/iqr-form/model";
|
|
19
|
-
|
|
20
|
-
const icd10 = [
|
|
21
|
-
['I', new RegExp('^[AB][0–9]')],
|
|
22
|
-
['II', new RegExp('^C[0-9]–D[0-4]')],
|
|
23
|
-
['III', new RegExp('^D[5–9]')],
|
|
24
|
-
['IV', new RegExp('^E[0–9]')],
|
|
25
|
-
['V', new RegExp('^F[0–9]')],
|
|
26
|
-
['VI', new RegExp('^G[0–9]')],
|
|
27
|
-
['VII', new RegExp('^H[0–5]')],
|
|
28
|
-
['VIII', new RegExp('^H[6–9]')],
|
|
29
|
-
['IX', new RegExp('^I[0–9]')],
|
|
30
|
-
['X', new RegExp('^J[0–9]')],
|
|
31
|
-
['XI', new RegExp('^K[0–9]')],
|
|
32
|
-
['XII', new RegExp('^L[0–9]')],
|
|
33
|
-
['XIII', new RegExp('^M[0–9]')],
|
|
34
|
-
['XIV', new RegExp('^N[0–9]')],
|
|
35
|
-
['XV', new RegExp('^O[0–9]')],
|
|
36
|
-
['XVI', new RegExp('^P[0–9]')],
|
|
37
|
-
['XVII', new RegExp('^Q[0–9]')],
|
|
38
|
-
['XVIII', new RegExp('^R[0–9]')],
|
|
39
|
-
['XIX', new RegExp('^[ST][0–9]')],
|
|
40
|
-
['XX', new RegExp('^[VY][0–9]')],
|
|
41
|
-
['XXI', new RegExp('^Z[0–9]')],
|
|
42
|
-
['XXII', new RegExp('^U[0–9]')]
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
const icpc2 = {
|
|
46
|
-
'B': 'XX',
|
|
47
|
-
'D': 'XI',
|
|
48
|
-
'F': 'VI',
|
|
49
|
-
'H': 'VII',
|
|
50
|
-
'K': 'IX',
|
|
51
|
-
'L': 'XIII',
|
|
52
|
-
'N': 'VI',
|
|
53
|
-
'P': 'V',
|
|
54
|
-
'R': 'X',
|
|
55
|
-
'S': 'XII',
|
|
56
|
-
'T': 'VI',
|
|
57
|
-
'U': 'XIV',
|
|
58
|
-
'W': 'XV',
|
|
59
|
-
'X': 'XVI',
|
|
60
|
-
'Y': 'XVIII',
|
|
61
|
-
'Z': 'XXI'
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const stopWords = new Set(['du','au','le','les','un','la','des','sur','de'])
|
|
65
|
-
|
|
66
|
-
class DemoApp extends LitElement {
|
|
67
|
-
private api: IccCodeXApi = new IccCodeXApi("https://kraken.svc.icure.cloud/rest/v1",{ Authorization: 'Basic YWJkZW1vQGljdXJlLmNsb3VkOmtuYWxvdQ=='})
|
|
68
|
-
|
|
69
|
-
private miniSearch: MiniSearch = new MiniSearch({
|
|
70
|
-
fields: ['text'], // fields to index for full-text search
|
|
71
|
-
storeFields: ['code', 'text', 'links'], // fields to return with search results
|
|
72
|
-
processTerm: (term, _fieldName) =>
|
|
73
|
-
term.length === 1 || stopWords.has(term) ?
|
|
74
|
-
null : term.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase()
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
static get styles() {
|
|
78
|
-
return css`
|
|
79
|
-
iqr-text-field {
|
|
80
|
-
display: block;
|
|
81
|
-
}
|
|
82
|
-
h2 {
|
|
83
|
-
width: 100%;
|
|
84
|
-
font-size: 2em;
|
|
85
|
-
margin-top: 1em;
|
|
86
|
-
margin-bottom: 0;
|
|
87
|
-
font-family: 'Roboto', Helvetica, sans-serif;
|
|
88
|
-
}
|
|
89
|
-
`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async firstUpdated() {
|
|
93
|
-
const codes = await getRowsUsingPagination<any>((key, docId, limit) => {
|
|
94
|
-
return this.api.findPaginatedCodes('be', 'BE-THESAURUS', undefined, undefined, key, docId || undefined, 10000).then(x => ({
|
|
95
|
-
rows: (x.rows || []).map(x => ({id: x.id, code: x.code, text: x.label?.fr, links:x.links})),
|
|
96
|
-
nextKey: x.nextKeyPair?.startKey && JSON.stringify(x.nextKeyPair?.startKey),
|
|
97
|
-
nextDocId: x.nextKeyPair?.startKeyDocId,
|
|
98
|
-
done: (x.rows || []).length < 10000
|
|
99
|
-
}))
|
|
100
|
-
})
|
|
101
|
-
codes && this.miniSearch.addAll(codes)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
codeColorProvider(type: string, code: string) {
|
|
105
|
-
return type === 'ICD' ? (icd10.find(x => code.match(x[1])) || [])[0] || 'XXII' : icpc2[code.substring(0,1)] || 'XXII'
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
suggestionProvider(terms: string[]) {
|
|
109
|
-
let normalisedTerms = terms.map(x => x.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase());
|
|
110
|
-
const res: any[] = []
|
|
111
|
-
if (this.miniSearch) {
|
|
112
|
-
while(normalisedTerms.length && res.length<20) {
|
|
113
|
-
res.push(...this.miniSearch.search(normalisedTerms.join(' '))
|
|
114
|
-
.filter(x => {
|
|
115
|
-
return normalisedTerms.every(t => x.terms.includes(t))
|
|
116
|
-
})
|
|
117
|
-
.map(s => Object.assign(s, {terms}))
|
|
118
|
-
.filter(t => !res.some(x => x.text === t.text)))
|
|
119
|
-
res.length<20 && res.push(...this.miniSearch.search(normalisedTerms.join(' '), {prefix: true})
|
|
120
|
-
.filter(x => normalisedTerms.every(t => x.terms.some(mt => mt.startsWith(t))))
|
|
121
|
-
.map(s => Object.assign(s, {terms})).filter(t => !res.some(x => x.text === t.text)))
|
|
122
|
-
normalisedTerms = normalisedTerms.slice(1)
|
|
123
|
-
terms = terms.slice(1)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return res
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async linksProvider(sug: { id: string, code: string, text: string, terms: string[], links: string[] }) {
|
|
130
|
-
const links = (await Promise.all((sug.links || []).map(id => this.api.getCode(id)))).map(c => ({id:c.id, code:c.code, text:c.label?.fr, type:c.type}))
|
|
131
|
-
.concat([Object.assign({type: sug.id.split('|')[0]}, sug)])
|
|
132
|
-
return {href: links.map(c => `c-${c.type}://${c.code}`).join(','), title: links.map(c => c.text).join('; ')}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
render() {
|
|
137
|
-
//@ts-ignore
|
|
138
|
-
const form = new Form("Waiting room GP", [
|
|
139
|
-
new Section("All fields", [
|
|
140
|
-
new TextField("This field is a TextField", "TextField"),
|
|
141
|
-
new NumberField("This field is a NumberField", "NumberField"),
|
|
142
|
-
new MeasureField("This field is a MeasureField", "MeasureField"),
|
|
143
|
-
new DatePicker("This field is a DatePicker", "DatePicker"),
|
|
144
|
-
new TimePicker("This field is a TimePicker", "TimePicker"),
|
|
145
|
-
new DateTimePicker("This field is a DateTimePicker", "DateTimePicker"),
|
|
146
|
-
new MultipleChoice("This field is a MultipleChoice", "MultipleChoice"),
|
|
147
|
-
]),
|
|
148
|
-
new Section("Grouped fields", [
|
|
149
|
-
new Group("You can group fields together", [
|
|
150
|
-
new TextField("This field is a TextField", "TextField"),
|
|
151
|
-
new NumberField("This field is a NumberField", "NumberField"),
|
|
152
|
-
new MeasureField("This field is a MeasureField", "MeasureField"),
|
|
153
|
-
new DatePicker("This field is a DatePicker", "DatePicker"),
|
|
154
|
-
new TimePicker("This field is a TimePicker", "TimePicker"),
|
|
155
|
-
new DateTimePicker("This field is a DateTimePicker", "DateTimePicker"),
|
|
156
|
-
new MultipleChoice("This field is a MultipleChoice", "MultipleChoice"),
|
|
157
|
-
]),
|
|
158
|
-
new Group("And you can add tags and codes", [
|
|
159
|
-
new TextField("This field is a TextField", "TextField", 3, true, "text-document", ['CD-ITEM|diagnosis|1'], ['BE-THESAURUS','ICD10'], {option: "blink"}),
|
|
160
|
-
new NumberField("This field is a NumberField", "NumberField", ['CD-ITEM|parameter|1', 'CD-PARAMETER|bmi|1'], [], {option: "bang"}),
|
|
161
|
-
new MeasureField("This field is a MeasureField", "MeasureField", ['CD-ITEM|parameter|1', 'CD-PARAMETER|heartbeat|1'], [], {unit: "bpm"}),
|
|
162
|
-
new MultipleChoice("This field is a MultipleChoice", "MultipleChoice", 4, 4, [], ['KATZ'], {many:"no"}),
|
|
163
|
-
])
|
|
164
|
-
]),
|
|
165
|
-
], "Fill in the patient information inside the waiting room")
|
|
166
|
-
|
|
167
|
-
//@ts-ignore
|
|
168
|
-
const shortForm = new Form("Semantic example", [
|
|
169
|
-
new Section("Dates & Time", [
|
|
170
|
-
new DatePicker("This field is a DatePicker", "DatePicker"),
|
|
171
|
-
new TimePicker("This field is a TimePicker", "DatePicker"),
|
|
172
|
-
new DateTimePicker("This field is a DateTimePicker", "DateTimePicker"),
|
|
173
|
-
]),
|
|
174
|
-
new Section("Completion & Links", [
|
|
175
|
-
new TextField("This field is a TextField", "TextField", 3, true, "text-document", ['CD-ITEM|diagnosis|1'], [], {
|
|
176
|
-
codeColorProvider : this.codeColorProvider,
|
|
177
|
-
suggestionStopWords : this.codeColorProvider,
|
|
178
|
-
linksProvider : this.codeColorProvider,
|
|
179
|
-
suggestionProvider : this.codeColorProvider
|
|
180
|
-
})
|
|
181
|
-
]),
|
|
182
|
-
], "Fill in the patient information inside the waiting room")
|
|
183
|
-
|
|
184
|
-
return html`
|
|
185
|
-
<iqr-text-field .codeColorProvider="${this.codeColorProvider}" .suggestionStopWords="${stopWords}" .linksProvider="${this.linksProvider.bind(this)}" .suggestionProvider="${this.suggestionProvider.bind(this)}" value="[Céphalée de tension](c-ICPC://N01,c-ICD://G05.8,i-he://1234) persistante avec [migraine ophtalmique](c-ICPC://N02) associée. [Grosse fatigue](c-ICPC://K56). A suivi un [protocole de relaxation](x-doc://5678)" owner="M. Mennechet"></iqr-text-field>
|
|
186
|
-
<iqr-form .form="${shortForm}" labelPosition="above" skin="kendo" theme="gray" renderer="form"></iqr-form>
|
|
187
|
-
`
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
customElements.define('demo-app', DemoApp);
|
package/test/form.yaml
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
form: Waiting room GP
|
|
2
|
-
description: Fill in the patient information inside the waiting room
|
|
3
|
-
sections:
|
|
4
|
-
- section: All fields
|
|
5
|
-
fields:
|
|
6
|
-
- field: This field is a TextField
|
|
7
|
-
type: textfield
|
|
8
|
-
shortLabel: TextField
|
|
9
|
-
schema: styled-text-with-codes
|
|
10
|
-
- field: This field is a NumberField
|
|
11
|
-
type: number-field
|
|
12
|
-
shortLabel: NumberField
|
|
13
|
-
- field: This field is a MeasureField
|
|
14
|
-
type: measure-field
|
|
15
|
-
shortLabel: MeasureField
|
|
16
|
-
- field: This field is a DatePicker
|
|
17
|
-
type: date-picker
|
|
18
|
-
shortLabel: DatePicker
|
|
19
|
-
- field: This field is a TimePicker
|
|
20
|
-
type: time-picker
|
|
21
|
-
shortLabel: TimePicker
|
|
22
|
-
- field: This field is a DateTimePicker
|
|
23
|
-
type: date-time-picker
|
|
24
|
-
shortLabel: DateTimePicker
|
|
25
|
-
- field: This field is a MultipleChoice
|
|
26
|
-
type: multiple-choice
|
|
27
|
-
shortLabel: MultipleChoice
|
|
28
|
-
- section: Grouped fields
|
|
29
|
-
groups:
|
|
30
|
-
- group: You can group fields together
|
|
31
|
-
fields:
|
|
32
|
-
- field: This field is a TextField
|
|
33
|
-
type: textfield
|
|
34
|
-
shortLabel: TextField
|
|
35
|
-
schema: styled-text-with-codes
|
|
36
|
-
- field: This field is a NumberField
|
|
37
|
-
type: number-field
|
|
38
|
-
shortLabel: NumberField
|
|
39
|
-
- field: This field is a MeasureField
|
|
40
|
-
type: measure-field
|
|
41
|
-
shortLabel: MeasureField
|
|
42
|
-
- field: This field is a DatePicker
|
|
43
|
-
type: date-picker
|
|
44
|
-
shortLabel: DatePicker
|
|
45
|
-
- field: This field is a TimePicker
|
|
46
|
-
type: time-picker
|
|
47
|
-
shortLabel: TimePicker
|
|
48
|
-
- field: This field is a DateTimePicker
|
|
49
|
-
type: date-time-picker
|
|
50
|
-
shortLabel: DateTimePicker
|
|
51
|
-
- field: This field is a MultipleChoice
|
|
52
|
-
type: multiple-choice
|
|
53
|
-
shortLabel: MultipleChoice
|
|
54
|
-
- group: And you can add tags and codes
|
|
55
|
-
fields:
|
|
56
|
-
- field: This field is a TextField
|
|
57
|
-
type: textfield
|
|
58
|
-
shortLabel: TextField
|
|
59
|
-
rows: 3
|
|
60
|
-
grows: true
|
|
61
|
-
schema: text-document
|
|
62
|
-
tags:
|
|
63
|
-
- CD-ITEM|diagnosis|1
|
|
64
|
-
codifications:
|
|
65
|
-
- BE-THESAURUS
|
|
66
|
-
- ICD10
|
|
67
|
-
options:
|
|
68
|
-
option: blink
|
|
69
|
-
- field: This field is a NumberField
|
|
70
|
-
type: number-field
|
|
71
|
-
shortLabel: NumberField
|
|
72
|
-
tags:
|
|
73
|
-
- CD-ITEM|parameter|1
|
|
74
|
-
- CD-PARAMETER|bmi|1
|
|
75
|
-
codifications: []
|
|
76
|
-
options:
|
|
77
|
-
option: bang
|
|
78
|
-
- field: This field is a MeasureField
|
|
79
|
-
type: measure-field
|
|
80
|
-
shortLabel: MeasureField
|
|
81
|
-
tags:
|
|
82
|
-
- CD-ITEM|parameter|1
|
|
83
|
-
- CD-PARAMETER|heartbeat|1
|
|
84
|
-
codifications: []
|
|
85
|
-
options:
|
|
86
|
-
unit: bpm
|
|
87
|
-
- field: This field is a MultipleChoice
|
|
88
|
-
type: multiple-choice
|
|
89
|
-
shortLabel: MultipleChoice
|
|
90
|
-
rows: 4
|
|
91
|
-
columns: 4
|
|
92
|
-
tags: []
|
|
93
|
-
codifications:
|
|
94
|
-
- KATZ
|
|
95
|
-
options:
|
|
96
|
-
many: no
|
package/test/simple/test.spec.ts
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
import { strictEqual } from "assert";
|
|
2
|
-
import YAML from "yaml"
|
|
3
|
-
import {
|
|
4
|
-
Form,
|
|
5
|
-
Section,
|
|
6
|
-
Group,
|
|
7
|
-
TextField,
|
|
8
|
-
NumberField,
|
|
9
|
-
DatePicker,
|
|
10
|
-
TimePicker, DateTimePicker, MultipleChoice, MeasureField
|
|
11
|
-
} from "../../src/app/components/iqr-form/model"
|
|
12
|
-
|
|
13
|
-
describe("Typescript usage suite", () => {
|
|
14
|
-
it("should Render simple form", () => {
|
|
15
|
-
const text = YAML.stringify(JSON.parse(JSON.stringify(new Form("Waiting room GP", [
|
|
16
|
-
new Section("The reason of your visit", [
|
|
17
|
-
new TextField("What symptoms, or more generally what reason motivated your visit" ),
|
|
18
|
-
new MultipleChoice("What is the level of pain that you are experiencing" )
|
|
19
|
-
]),
|
|
20
|
-
new Section("The reason of your visit", [
|
|
21
|
-
new Group("If you have measured your blood pressure. Please introduce it below", [
|
|
22
|
-
new MeasureField("Systolic blood pressure"),
|
|
23
|
-
new MeasureField( "Diastolic blood pressure")
|
|
24
|
-
])
|
|
25
|
-
]),
|
|
26
|
-
], "Fill in the patient information inside the waiting room"))))
|
|
27
|
-
console.log(text)
|
|
28
|
-
strictEqual(text, "form: Waiting room GP\n" +
|
|
29
|
-
"description: Fill in the patient information inside the waiting room\n" +
|
|
30
|
-
"sections:\n" +
|
|
31
|
-
" - section: The reason of your visit\n" +
|
|
32
|
-
" fields:\n" +
|
|
33
|
-
" - field: What symptoms, or more generally what reason motivated your visit\n" +
|
|
34
|
-
" type: textfield\n" +
|
|
35
|
-
" schema: styled-text-with-codes\n" +
|
|
36
|
-
" - field: What is the level of pain that you are experiencing\n" +
|
|
37
|
-
" type: multiple-choice\n" +
|
|
38
|
-
" - section: The reason of your visit\n" +
|
|
39
|
-
" fields:\n" +
|
|
40
|
-
" - group: If you have measured your blood pressure. Please introduce it below\n" +
|
|
41
|
-
" fields:\n" +
|
|
42
|
-
" - field: Systolic blood pressure\n" +
|
|
43
|
-
" type: measure-field\n" +
|
|
44
|
-
" - field: Diastolic blood pressure\n" +
|
|
45
|
-
" type: measure-field\n");
|
|
46
|
-
});
|
|
47
|
-
it("should Parse simple form", () => {
|
|
48
|
-
const original = "form: Waiting room GP\n" +
|
|
49
|
-
"description: Fill in the patient information inside the waiting room\n" +
|
|
50
|
-
"sections:\n" +
|
|
51
|
-
" - section: The reason of your visit\n" +
|
|
52
|
-
" fields:\n" +
|
|
53
|
-
" - field: What symptoms, or more generally what reason motivated your visit\n" +
|
|
54
|
-
" type: textfield\n" +
|
|
55
|
-
" schema: styled-text-with-codes\n" +
|
|
56
|
-
" - field: What is the level of pain that you are experiencing\n" +
|
|
57
|
-
" type: multiple-choice\n" +
|
|
58
|
-
" - section: The reason of your visit\n" +
|
|
59
|
-
" fields:\n" +
|
|
60
|
-
" - group: If you have measured your blood pressure. Please introduce it below\n" +
|
|
61
|
-
" fields:\n" +
|
|
62
|
-
" - field: Systolic blood pressure\n" +
|
|
63
|
-
" type: measure-field\n" +
|
|
64
|
-
" - field: Diastolic blood pressure\n" +
|
|
65
|
-
" type: measure-field\n"
|
|
66
|
-
const form = Form.parse(YAML.parse(original))
|
|
67
|
-
const text = YAML.stringify(JSON.parse(JSON.stringify(form)))
|
|
68
|
-
console.log(text)
|
|
69
|
-
strictEqual(text, original);
|
|
70
|
-
});
|
|
71
|
-
it("should Render complex form", () => {
|
|
72
|
-
const text = YAML.stringify(JSON.parse(JSON.stringify(new Form("Waiting room GP", [
|
|
73
|
-
new Section("All fields", [
|
|
74
|
-
new TextField("This field is a TextField", "TextField"),
|
|
75
|
-
new NumberField("This field is a NumberField", "NumberField"),
|
|
76
|
-
new MeasureField("This field is a MeasureField", "MeasureField"),
|
|
77
|
-
new DatePicker("This field is a DatePicker", "DatePicker"),
|
|
78
|
-
new TimePicker("This field is a TimePicker", "TimePicker"),
|
|
79
|
-
new DateTimePicker("This field is a DateTimePicker", "DateTimePicker"),
|
|
80
|
-
new MultipleChoice("This field is a MultipleChoice", "MultipleChoice"),
|
|
81
|
-
]),
|
|
82
|
-
new Section("Grouped fields", [
|
|
83
|
-
new Group("You can group fields together", [
|
|
84
|
-
new TextField("This field is a TextField", "TextField"),
|
|
85
|
-
new NumberField("This field is a NumberField", "NumberField"),
|
|
86
|
-
new MeasureField("This field is a MeasureField", "MeasureField"),
|
|
87
|
-
new DatePicker("This field is a DatePicker", "DatePicker"),
|
|
88
|
-
new TimePicker("This field is a TimePicker", "TimePicker"),
|
|
89
|
-
new DateTimePicker("This field is a DateTimePicker", "DateTimePicker"),
|
|
90
|
-
new MultipleChoice("This field is a MultipleChoice", "MultipleChoice"),
|
|
91
|
-
]),
|
|
92
|
-
new Group("And you can add tags and codes", [
|
|
93
|
-
new TextField("This field is a TextField", "TextField", 3, true, "text-document", ['CD-ITEM|diagnosis|1'], ['BE-THESAURUS','ICD10'], {option: "blink"}),
|
|
94
|
-
new NumberField("This field is a NumberField", "NumberField", ['CD-ITEM|parameter|1', 'CD-PARAMETER|bmi|1'], [], {option: "bang"}),
|
|
95
|
-
new MeasureField("This field is a MeasureField", "MeasureField", ['CD-ITEM|parameter|1', 'CD-PARAMETER|heartbeat|1'], [], {unit: "bpm"}),
|
|
96
|
-
new MultipleChoice("This field is a MultipleChoice", "MultipleChoice", 4, 4, [], ['KATZ'], {many:"no"}),
|
|
97
|
-
])
|
|
98
|
-
]),
|
|
99
|
-
], "Fill in the patient information inside the waiting room"))))
|
|
100
|
-
console.log(text)
|
|
101
|
-
strictEqual(text, `form: Waiting room GP
|
|
102
|
-
description: Fill in the patient information inside the waiting room
|
|
103
|
-
sections:
|
|
104
|
-
- section: All fields
|
|
105
|
-
fields:
|
|
106
|
-
- field: This field is a TextField
|
|
107
|
-
type: textfield
|
|
108
|
-
shortLabel: TextField
|
|
109
|
-
schema: styled-text-with-codes
|
|
110
|
-
- field: This field is a NumberField
|
|
111
|
-
type: number-field
|
|
112
|
-
shortLabel: NumberField
|
|
113
|
-
- field: This field is a MeasureField
|
|
114
|
-
type: measure-field
|
|
115
|
-
shortLabel: MeasureField
|
|
116
|
-
- field: This field is a DatePicker
|
|
117
|
-
type: date-picker
|
|
118
|
-
shortLabel: DatePicker
|
|
119
|
-
- field: This field is a TimePicker
|
|
120
|
-
type: time-picker
|
|
121
|
-
shortLabel: TimePicker
|
|
122
|
-
- field: This field is a DateTimePicker
|
|
123
|
-
type: date-time-picker
|
|
124
|
-
shortLabel: DateTimePicker
|
|
125
|
-
- field: This field is a MultipleChoice
|
|
126
|
-
type: multiple-choice
|
|
127
|
-
shortLabel: MultipleChoice
|
|
128
|
-
- section: Grouped fields
|
|
129
|
-
fields:
|
|
130
|
-
- group: You can group fields together
|
|
131
|
-
fields:
|
|
132
|
-
- field: This field is a TextField
|
|
133
|
-
type: textfield
|
|
134
|
-
shortLabel: TextField
|
|
135
|
-
schema: styled-text-with-codes
|
|
136
|
-
- field: This field is a NumberField
|
|
137
|
-
type: number-field
|
|
138
|
-
shortLabel: NumberField
|
|
139
|
-
- field: This field is a MeasureField
|
|
140
|
-
type: measure-field
|
|
141
|
-
shortLabel: MeasureField
|
|
142
|
-
- field: This field is a DatePicker
|
|
143
|
-
type: date-picker
|
|
144
|
-
shortLabel: DatePicker
|
|
145
|
-
- field: This field is a TimePicker
|
|
146
|
-
type: time-picker
|
|
147
|
-
shortLabel: TimePicker
|
|
148
|
-
- field: This field is a DateTimePicker
|
|
149
|
-
type: date-time-picker
|
|
150
|
-
shortLabel: DateTimePicker
|
|
151
|
-
- field: This field is a MultipleChoice
|
|
152
|
-
type: multiple-choice
|
|
153
|
-
shortLabel: MultipleChoice
|
|
154
|
-
- group: And you can add tags and codes
|
|
155
|
-
fields:
|
|
156
|
-
- field: This field is a TextField
|
|
157
|
-
type: textfield
|
|
158
|
-
shortLabel: TextField
|
|
159
|
-
rows: 3
|
|
160
|
-
grows: true
|
|
161
|
-
schema: text-document
|
|
162
|
-
tags:
|
|
163
|
-
- CD-ITEM|diagnosis|1
|
|
164
|
-
codifications:
|
|
165
|
-
- BE-THESAURUS
|
|
166
|
-
- ICD10
|
|
167
|
-
options:
|
|
168
|
-
option: blink
|
|
169
|
-
- field: This field is a NumberField
|
|
170
|
-
type: number-field
|
|
171
|
-
shortLabel: NumberField
|
|
172
|
-
tags:
|
|
173
|
-
- CD-ITEM|parameter|1
|
|
174
|
-
- CD-PARAMETER|bmi|1
|
|
175
|
-
codifications: []
|
|
176
|
-
options:
|
|
177
|
-
option: bang
|
|
178
|
-
- field: This field is a MeasureField
|
|
179
|
-
type: measure-field
|
|
180
|
-
shortLabel: MeasureField
|
|
181
|
-
tags:
|
|
182
|
-
- CD-ITEM|parameter|1
|
|
183
|
-
- CD-PARAMETER|heartbeat|1
|
|
184
|
-
codifications: []
|
|
185
|
-
options:
|
|
186
|
-
unit: bpm
|
|
187
|
-
- field: This field is a MultipleChoice
|
|
188
|
-
type: multiple-choice
|
|
189
|
-
shortLabel: MultipleChoice
|
|
190
|
-
rows: 4
|
|
191
|
-
columns: 4
|
|
192
|
-
tags: []
|
|
193
|
-
codifications:
|
|
194
|
-
- KATZ
|
|
195
|
-
options:
|
|
196
|
-
many: no
|
|
197
|
-
`);
|
|
198
|
-
});
|
|
199
|
-
it("should Parse complex form", () => {
|
|
200
|
-
const original = "form: Waiting room GP\n" +
|
|
201
|
-
"description: Fill in the patient information inside the waiting room\n" +
|
|
202
|
-
"sections:\n" +
|
|
203
|
-
" - section: All fields\n" +
|
|
204
|
-
" fields:\n" +
|
|
205
|
-
" - field: This field is a TextField\n" +
|
|
206
|
-
" type: textfield\n" +
|
|
207
|
-
" shortLabel: TextField\n" +
|
|
208
|
-
" schema: styled-text-with-codes\n" +
|
|
209
|
-
" - field: This field is a NumberField\n" +
|
|
210
|
-
" type: number-field\n" +
|
|
211
|
-
" shortLabel: NumberField\n" +
|
|
212
|
-
" - field: This field is a MeasureField\n" +
|
|
213
|
-
" type: measure-field\n" +
|
|
214
|
-
" shortLabel: MeasureField\n" +
|
|
215
|
-
" - field: This field is a DatePicker\n" +
|
|
216
|
-
" type: date-picker\n" +
|
|
217
|
-
" shortLabel: DatePicker\n" +
|
|
218
|
-
" - field: This field is a TimePicker\n" +
|
|
219
|
-
" type: time-picker\n" +
|
|
220
|
-
" shortLabel: TimePicker\n" +
|
|
221
|
-
" - field: This field is a DateTimePicker\n" +
|
|
222
|
-
" type: date-time-picker\n" +
|
|
223
|
-
" shortLabel: DateTimePicker\n" +
|
|
224
|
-
" - field: This field is a MultipleChoice\n" +
|
|
225
|
-
" type: multiple-choice\n" +
|
|
226
|
-
" shortLabel: MultipleChoice\n" +
|
|
227
|
-
" - section: Grouped fields\n" +
|
|
228
|
-
" fields:\n" +
|
|
229
|
-
" - group: You can group fields together\n" +
|
|
230
|
-
" fields:\n" +
|
|
231
|
-
" - field: This field is a TextField\n" +
|
|
232
|
-
" type: textfield\n" +
|
|
233
|
-
" shortLabel: TextField\n" +
|
|
234
|
-
" schema: styled-text-with-codes\n" +
|
|
235
|
-
" - field: This field is a NumberField\n" +
|
|
236
|
-
" type: number-field\n" +
|
|
237
|
-
" shortLabel: NumberField\n" +
|
|
238
|
-
" - field: This field is a MeasureField\n" +
|
|
239
|
-
" type: measure-field\n" +
|
|
240
|
-
" shortLabel: MeasureField\n" +
|
|
241
|
-
" - field: This field is a DatePicker\n" +
|
|
242
|
-
" type: date-picker\n" +
|
|
243
|
-
" shortLabel: DatePicker\n" +
|
|
244
|
-
" - field: This field is a TimePicker\n" +
|
|
245
|
-
" type: time-picker\n" +
|
|
246
|
-
" shortLabel: TimePicker\n" +
|
|
247
|
-
" - field: This field is a DateTimePicker\n" +
|
|
248
|
-
" type: date-time-picker\n" +
|
|
249
|
-
" shortLabel: DateTimePicker\n" +
|
|
250
|
-
" - field: This field is a MultipleChoice\n" +
|
|
251
|
-
" type: multiple-choice\n" +
|
|
252
|
-
" shortLabel: MultipleChoice\n" +
|
|
253
|
-
" - group: And you can add tags and codes\n" +
|
|
254
|
-
" fields:\n" +
|
|
255
|
-
" - field: This field is a TextField\n" +
|
|
256
|
-
" type: textfield\n" +
|
|
257
|
-
" shortLabel: TextField\n" +
|
|
258
|
-
" rows: 3\n" +
|
|
259
|
-
" grows: true\n" +
|
|
260
|
-
" schema: text-document\n" +
|
|
261
|
-
" tags:\n" +
|
|
262
|
-
" - CD-ITEM|diagnosis|1\n" +
|
|
263
|
-
" codifications:\n" +
|
|
264
|
-
" - BE-THESAURUS\n" +
|
|
265
|
-
" - ICD10\n" +
|
|
266
|
-
" options:\n" +
|
|
267
|
-
" option: blink\n" +
|
|
268
|
-
" - field: This field is a NumberField\n" +
|
|
269
|
-
" type: number-field\n" +
|
|
270
|
-
" shortLabel: NumberField\n" +
|
|
271
|
-
" tags:\n" +
|
|
272
|
-
" - CD-ITEM|parameter|1\n" +
|
|
273
|
-
" - CD-PARAMETER|bmi|1\n" +
|
|
274
|
-
" codifications: []\n" +
|
|
275
|
-
" options:\n" +
|
|
276
|
-
" option: bang\n" +
|
|
277
|
-
" - field: This field is a MeasureField\n" +
|
|
278
|
-
" type: measure-field\n" +
|
|
279
|
-
" shortLabel: MeasureField\n" +
|
|
280
|
-
" tags:\n" +
|
|
281
|
-
" - CD-ITEM|parameter|1\n" +
|
|
282
|
-
" - CD-PARAMETER|heartbeat|1\n" +
|
|
283
|
-
" codifications: []\n" +
|
|
284
|
-
" options:\n" +
|
|
285
|
-
" unit: bpm\n" +
|
|
286
|
-
" - field: This field is a MultipleChoice\n" +
|
|
287
|
-
" type: multiple-choice\n" +
|
|
288
|
-
" shortLabel: MultipleChoice\n" +
|
|
289
|
-
" rows: 4\n" +
|
|
290
|
-
" columns: 4\n" +
|
|
291
|
-
" tags: []\n" +
|
|
292
|
-
" codifications:\n" +
|
|
293
|
-
" - KATZ\n" +
|
|
294
|
-
" options:\n" +
|
|
295
|
-
" many: no\n"
|
|
296
|
-
const form = Form.parse(YAML.parse(original))
|
|
297
|
-
const text = YAML.stringify(JSON.parse(JSON.stringify(form)))
|
|
298
|
-
console.log(text)
|
|
299
|
-
strictEqual(text, original);
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
});
|
package/webpack.config.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
2
|
-
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
3
|
-
|
|
4
|
-
module.exports = ({mode}) => {
|
|
5
|
-
return {
|
|
6
|
-
mode,
|
|
7
|
-
entry: './app/demo-app.ts',
|
|
8
|
-
plugins: [
|
|
9
|
-
new HtmlWebpackPlugin({
|
|
10
|
-
template: 'index.html'
|
|
11
|
-
}),
|
|
12
|
-
new CopyWebpackPlugin({
|
|
13
|
-
patterns: [
|
|
14
|
-
{context: 'node_modules/@webcomponents/webcomponentsjs', from: '**/*.js', to: 'webcomponents'},
|
|
15
|
-
]
|
|
16
|
-
})
|
|
17
|
-
],
|
|
18
|
-
devtool: mode === 'development' ? 'source-map' : 'none',
|
|
19
|
-
module: {
|
|
20
|
-
rules: [
|
|
21
|
-
{
|
|
22
|
-
test: /\.tsx?$/,
|
|
23
|
-
use: 'ts-loader',
|
|
24
|
-
exclude: /node_modules/,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
test: /\.css|\.s(c|a)ss$/,
|
|
28
|
-
use: [{
|
|
29
|
-
loader: 'lit-scss-loader',
|
|
30
|
-
options: {
|
|
31
|
-
minify: true, // defaults to false
|
|
32
|
-
},
|
|
33
|
-
}, 'extract-loader', 'css-loader', 'sass-loader'],
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
resolve: {
|
|
38
|
-
extensions: ['.tsx', '.ts', '.js'],
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
};
|