@junctura/health-contracts 0.0.0-stage → 1.0.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.
- package/LICENSE +202 -0
- package/NOTICE +13 -0
- package/README.md +61 -2
- package/capabilities/allergy-list.json +75 -0
- package/capabilities/claim-verify.json +62 -0
- package/capabilities/pre-visit-summary.json +202 -0
- package/capabilities/prescription-verify.json +105 -0
- package/capabilities/referral-summary.json +106 -0
- package/capabilities/vaccination-history.json +81 -0
- package/examples/allergy-list.json +13 -0
- package/examples/claim-verify.json +10 -0
- package/examples/pre-visit-summary.json +50 -0
- package/examples/prescription-verify.json +19 -0
- package/examples/referral-summary.json +18 -0
- package/examples/vaccination-history.json +20 -0
- package/index.d.ts +24 -0
- package/index.mjs +107 -0
- package/package.json +13 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Junctura Health
|
|
2
|
+
Copyright 2026 Junctura Contributors
|
|
3
|
+
|
|
4
|
+
Original Junctura Health source code is licensed under the Apache License,
|
|
5
|
+
Version 2.0. The attribution above is subject to each contributor's actual
|
|
6
|
+
rights and agreement; it does not claim ownership of upstream components.
|
|
7
|
+
|
|
8
|
+
External components retain their own copyright, license and notice terms.
|
|
9
|
+
Dependencies are declared in package manifests and installed from their
|
|
10
|
+
registries; no third-party source code has been copied into this project.
|
|
11
|
+
Patient data under seed/data/ is synthetic: produced by this project's own
|
|
12
|
+
generator (seed/generate.mjs) from team-written vocabulary. It describes no
|
|
13
|
+
real person. Diagnosis codes follow ICD-10 (WHO) and vaccine codes follow CVX.
|
package/README.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- SPDX-FileCopyrightText: 2026 Junctura Contributors -->
|
|
2
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
# Hợp đồng năng lực Junctura Health
|
|
5
|
+
|
|
6
|
+
Nguồn duy nhất cho các năng lực mà ứng dụng Tầng 2 cung cấp và gọi qua Junctura. Bên cung cấp và bên gọi cùng dùng một định nghĩa, nên không lệch nhau.
|
|
7
|
+
|
|
8
|
+
## Cấu trúc
|
|
9
|
+
|
|
10
|
+
| Đường dẫn | Nội dung |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `capabilities/<slug>.json` | Một hợp đồng: phiên bản, bên cung cấp, bên gọi, mục đích được phép, có cho cấp cứu không, tiêu đề, mô tả, schema vào/ra, thời gian chờ |
|
|
13
|
+
| `examples/<slug>.json` | Một cặp `input`/`output` hợp lệ, dùng cho test và dữ liệu demo |
|
|
14
|
+
| `index.mjs`, `index.d.ts` | Thư viện dùng chung (không phụ thuộc thư viện ngoài) |
|
|
15
|
+
|
|
16
|
+
Schema dùng đúng profile payload của Junctura: `object` (bắt buộc `properties`, `required`, `additionalProperties: false`), `array` (bắt buộc `maxItems`), `string` (bắt buộc `maxLength`), `integer`/`number` (bắt buộc `minimum`/`maximum`), `boolean`, `null`. Profile không có `enum` hay `pattern`, nên các giá trị cố định (ví dụ `severity`: `mild | moderate | severe`) được ghi trong `description` và do bên cung cấp đảm bảo.
|
|
17
|
+
|
|
18
|
+
## Quy tắc chung
|
|
19
|
+
|
|
20
|
+
- Mọi năng lực đều về **một người bệnh**. Người bệnh không nằm trong `input` mà đi qua `context.dataSubject` (Keycloak `sub` của người bệnh); Junctura kiểm tra đồng thuận của người đó trước khi cấp vé.
|
|
21
|
+
- Bên gọi luôn khai `context.purpose`, phải nằm trong `purposes` của hợp đồng.
|
|
22
|
+
- `emergency: true` (truy cập cấp cứu) chỉ dùng được với năng lực có `emergencyAccess: true`, kèm `justification`, và bị rà soát sau.
|
|
23
|
+
- Dữ liệu trả về là **tối thiểu**: ví dụ `claim-verify` chỉ trả `matches` có/không, không có chẩn đoán.
|
|
24
|
+
|
|
25
|
+
## Dùng trong ứng dụng
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { buildManifest, checkContext, validateValue, getContract } from "@junctura/health-contracts";
|
|
29
|
+
|
|
30
|
+
// Bên cung cấp: đăng ký manifest với ID ứng dụng đã enroll.
|
|
31
|
+
const manifest = buildManifest("allergy-list", process.env.JUNCTURA_APP_ID);
|
|
32
|
+
|
|
33
|
+
// Bên cung cấp: sau khi đổi vé (SDK redeemTicket), kiểm tra context rồi mới trả dữ liệu.
|
|
34
|
+
const decision = checkContext("allergy-list", redeemed.context);
|
|
35
|
+
if (!decision.allowed) return reply(403, { error: decision.reason });
|
|
36
|
+
|
|
37
|
+
// Cả hai bên: kiểm tra dữ liệu đúng hợp đồng.
|
|
38
|
+
const issues = validateValue(getContract("allergy-list").outputSchema, output);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Đổi hợp đồng
|
|
42
|
+
|
|
43
|
+
Mở PR ở repo này. Thay đổi không tương thích (bỏ trường, đổi kiểu, siết giới hạn) phải tăng **major** version; thêm trường không bắt buộc tăng **minor**. Cập nhật ví dụ, `CHANGELOG.md`, và báo các repo app liên quan.
|
|
44
|
+
|
|
45
|
+
## Cài đặt
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm install @junctura/health-contracts
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Gói không phụ thuộc thư viện ngoài, chạy trên Node 24, có sẵn kiểu TypeScript (`index.d.ts`). Mỗi bản phát hành lên npm kèm provenance (có thể kiểm tra bản build đến từ repo này).
|
|
52
|
+
|
|
53
|
+
## Phát hành lên npm
|
|
54
|
+
|
|
55
|
+
Sau khi PR đổi hợp đồng đã merge: sửa `version` trong `contracts/package.json`, rồi đẩy tag trùng version:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
git tag contracts-v1.0.0
|
|
59
|
+
git push origin contracts-v1.0.0
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Workflow `Publish contracts library` kiểm tra tag khớp version, chạy test, rồi publish.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slug": "allergy-list",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"provider": "junctura-clinic",
|
|
5
|
+
"consumers": [
|
|
6
|
+
"junctura-hospital",
|
|
7
|
+
"junctura-pharmacy"
|
|
8
|
+
],
|
|
9
|
+
"purposes": [
|
|
10
|
+
"treatment",
|
|
11
|
+
"dispensing"
|
|
12
|
+
],
|
|
13
|
+
"emergencyAccess": true,
|
|
14
|
+
"title": "Danh sách dị ứng",
|
|
15
|
+
"description": "Các chất gây dị ứng đã ghi nhận của người bệnh, dùng để cảnh báo khi kê đơn hoặc phát thuốc.",
|
|
16
|
+
"inputSchema": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"description": "Không có tham số: người bệnh được xác định qua context.dataSubject.",
|
|
19
|
+
"properties": {},
|
|
20
|
+
"required": [],
|
|
21
|
+
"additionalProperties": false
|
|
22
|
+
},
|
|
23
|
+
"outputSchema": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"allergies": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"items": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": {
|
|
31
|
+
"substance": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"maxLength": 120,
|
|
34
|
+
"description": "Chất gây dị ứng, ví dụ Penicillin."
|
|
35
|
+
},
|
|
36
|
+
"severity": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"maxLength": 16,
|
|
39
|
+
"description": "mild | moderate | severe"
|
|
40
|
+
},
|
|
41
|
+
"reaction": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"maxLength": 240,
|
|
44
|
+
"description": "Biểu hiện đã ghi nhận."
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"required": [
|
|
48
|
+
"substance",
|
|
49
|
+
"severity",
|
|
50
|
+
"reaction"
|
|
51
|
+
],
|
|
52
|
+
"additionalProperties": false
|
|
53
|
+
},
|
|
54
|
+
"maxItems": 50
|
|
55
|
+
},
|
|
56
|
+
"updatedAt": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"minLength": 20,
|
|
59
|
+
"maxLength": 30,
|
|
60
|
+
"description": "Thời điểm ISO 8601 (UTC)."
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"required": [
|
|
64
|
+
"allergies",
|
|
65
|
+
"updatedAt"
|
|
66
|
+
],
|
|
67
|
+
"additionalProperties": false
|
|
68
|
+
},
|
|
69
|
+
"sideEffects": {
|
|
70
|
+
"kind": "none",
|
|
71
|
+
"description": "Chỉ đọc; không thay đổi dữ liệu của bên cung cấp.",
|
|
72
|
+
"idempotency": "none"
|
|
73
|
+
},
|
|
74
|
+
"timeoutMs": 2000
|
|
75
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slug": "claim-verify",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"provider": "junctura-hospital",
|
|
5
|
+
"consumers": [
|
|
6
|
+
"junctura-insurance"
|
|
7
|
+
],
|
|
8
|
+
"purposes": [
|
|
9
|
+
"claim_review"
|
|
10
|
+
],
|
|
11
|
+
"emergencyAccess": false,
|
|
12
|
+
"title": "Xác minh chi phí điều trị",
|
|
13
|
+
"description": "Cho bên bảo hiểm biết một khoản chi có khớp với hồ sơ điều trị hay không. Chỉ trả lời có/không, không trả chẩn đoán hay chi tiết điều trị.",
|
|
14
|
+
"inputSchema": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"properties": {
|
|
17
|
+
"claimId": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"minLength": 1,
|
|
20
|
+
"maxLength": 64,
|
|
21
|
+
"description": "Mã hồ sơ thanh toán."
|
|
22
|
+
},
|
|
23
|
+
"amountVnd": {
|
|
24
|
+
"type": "integer",
|
|
25
|
+
"minimum": 0,
|
|
26
|
+
"maximum": 1000000000000,
|
|
27
|
+
"description": "Số tiền đề nghị thanh toán (VND)."
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": [
|
|
31
|
+
"claimId",
|
|
32
|
+
"amountVnd"
|
|
33
|
+
],
|
|
34
|
+
"additionalProperties": false
|
|
35
|
+
},
|
|
36
|
+
"outputSchema": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"matches": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"description": "Khoản chi khớp với hồ sơ điều trị."
|
|
42
|
+
},
|
|
43
|
+
"checkedAt": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"minLength": 20,
|
|
46
|
+
"maxLength": 30,
|
|
47
|
+
"description": "Thời điểm ISO 8601 (UTC)."
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"required": [
|
|
51
|
+
"matches",
|
|
52
|
+
"checkedAt"
|
|
53
|
+
],
|
|
54
|
+
"additionalProperties": false
|
|
55
|
+
},
|
|
56
|
+
"sideEffects": {
|
|
57
|
+
"kind": "none",
|
|
58
|
+
"description": "Chỉ đọc; không thay đổi dữ liệu của bên cung cấp.",
|
|
59
|
+
"idempotency": "none"
|
|
60
|
+
},
|
|
61
|
+
"timeoutMs": 2000
|
|
62
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slug": "pre-visit-summary",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"provider": "junctura-clinic",
|
|
5
|
+
"consumers": [
|
|
6
|
+
"junctura-hospital"
|
|
7
|
+
],
|
|
8
|
+
"purposes": [
|
|
9
|
+
"treatment"
|
|
10
|
+
],
|
|
11
|
+
"emergencyAccess": true,
|
|
12
|
+
"title": "Tóm tắt trước khám",
|
|
13
|
+
"description": "Dị ứng, bệnh mạn tính, thuốc đang dùng và tối đa 3 lần khám gần nhất của người bệnh tại trạm y tế, để bác sĩ tuyến trên khám không phải hỏi lại.",
|
|
14
|
+
"inputSchema": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"description": "Không có tham số: người bệnh được xác định qua context.dataSubject.",
|
|
17
|
+
"properties": {},
|
|
18
|
+
"required": [],
|
|
19
|
+
"additionalProperties": false
|
|
20
|
+
},
|
|
21
|
+
"outputSchema": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"patientName": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"maxLength": 120,
|
|
27
|
+
"description": "Họ tên người bệnh."
|
|
28
|
+
},
|
|
29
|
+
"birthYear": {
|
|
30
|
+
"type": "integer",
|
|
31
|
+
"minimum": 1900,
|
|
32
|
+
"maximum": 2100,
|
|
33
|
+
"description": "Năm sinh."
|
|
34
|
+
},
|
|
35
|
+
"sex": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"maxLength": 16,
|
|
38
|
+
"description": "female | male | other"
|
|
39
|
+
},
|
|
40
|
+
"allergies": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"items": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"properties": {
|
|
45
|
+
"substance": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"maxLength": 120,
|
|
48
|
+
"description": "Chất gây dị ứng, ví dụ Penicillin."
|
|
49
|
+
},
|
|
50
|
+
"severity": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"maxLength": 16,
|
|
53
|
+
"description": "mild | moderate | severe"
|
|
54
|
+
},
|
|
55
|
+
"reaction": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"maxLength": 240,
|
|
58
|
+
"description": "Biểu hiện đã ghi nhận."
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"required": [
|
|
62
|
+
"substance",
|
|
63
|
+
"severity",
|
|
64
|
+
"reaction"
|
|
65
|
+
],
|
|
66
|
+
"additionalProperties": false
|
|
67
|
+
},
|
|
68
|
+
"maxItems": 50
|
|
69
|
+
},
|
|
70
|
+
"chronicConditions": {
|
|
71
|
+
"type": "array",
|
|
72
|
+
"items": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"properties": {
|
|
75
|
+
"code": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"maxLength": 16,
|
|
78
|
+
"description": "Mã ICD-10."
|
|
79
|
+
},
|
|
80
|
+
"name": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"maxLength": 160
|
|
83
|
+
},
|
|
84
|
+
"since": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"minLength": 10,
|
|
87
|
+
"maxLength": 10,
|
|
88
|
+
"description": "Ngày dạng YYYY-MM-DD."
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"required": [
|
|
92
|
+
"code",
|
|
93
|
+
"name",
|
|
94
|
+
"since"
|
|
95
|
+
],
|
|
96
|
+
"additionalProperties": false
|
|
97
|
+
},
|
|
98
|
+
"maxItems": 50
|
|
99
|
+
},
|
|
100
|
+
"currentMedications": {
|
|
101
|
+
"type": "array",
|
|
102
|
+
"items": {
|
|
103
|
+
"type": "object",
|
|
104
|
+
"properties": {
|
|
105
|
+
"name": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"maxLength": 160
|
|
108
|
+
},
|
|
109
|
+
"dose": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"maxLength": 80,
|
|
112
|
+
"description": "Liều dùng, ví dụ 500 mg x 2 lần/ngày."
|
|
113
|
+
},
|
|
114
|
+
"since": {
|
|
115
|
+
"type": "string",
|
|
116
|
+
"minLength": 10,
|
|
117
|
+
"maxLength": 10,
|
|
118
|
+
"description": "Ngày dạng YYYY-MM-DD."
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"required": [
|
|
122
|
+
"name",
|
|
123
|
+
"dose",
|
|
124
|
+
"since"
|
|
125
|
+
],
|
|
126
|
+
"additionalProperties": false
|
|
127
|
+
},
|
|
128
|
+
"maxItems": 50
|
|
129
|
+
},
|
|
130
|
+
"recentEncounters": {
|
|
131
|
+
"type": "array",
|
|
132
|
+
"description": "Tối đa 3 lần khám gần nhất, mới nhất trước.",
|
|
133
|
+
"items": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"properties": {
|
|
136
|
+
"date": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"minLength": 10,
|
|
139
|
+
"maxLength": 10,
|
|
140
|
+
"description": "Ngày dạng YYYY-MM-DD."
|
|
141
|
+
},
|
|
142
|
+
"reason": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"maxLength": 240,
|
|
145
|
+
"description": "Lý do khám."
|
|
146
|
+
},
|
|
147
|
+
"diagnosis": {
|
|
148
|
+
"type": "object",
|
|
149
|
+
"properties": {
|
|
150
|
+
"code": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"maxLength": 16,
|
|
153
|
+
"description": "Mã ICD-10."
|
|
154
|
+
},
|
|
155
|
+
"name": {
|
|
156
|
+
"type": "string",
|
|
157
|
+
"maxLength": 160,
|
|
158
|
+
"description": "Tên chẩn đoán."
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"required": [
|
|
162
|
+
"code",
|
|
163
|
+
"name"
|
|
164
|
+
],
|
|
165
|
+
"additionalProperties": false
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"required": [
|
|
169
|
+
"date",
|
|
170
|
+
"reason",
|
|
171
|
+
"diagnosis"
|
|
172
|
+
],
|
|
173
|
+
"additionalProperties": false
|
|
174
|
+
},
|
|
175
|
+
"maxItems": 3
|
|
176
|
+
},
|
|
177
|
+
"updatedAt": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"minLength": 20,
|
|
180
|
+
"maxLength": 30,
|
|
181
|
+
"description": "Thời điểm ISO 8601 (UTC)."
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"required": [
|
|
185
|
+
"patientName",
|
|
186
|
+
"birthYear",
|
|
187
|
+
"sex",
|
|
188
|
+
"allergies",
|
|
189
|
+
"chronicConditions",
|
|
190
|
+
"currentMedications",
|
|
191
|
+
"recentEncounters",
|
|
192
|
+
"updatedAt"
|
|
193
|
+
],
|
|
194
|
+
"additionalProperties": false
|
|
195
|
+
},
|
|
196
|
+
"sideEffects": {
|
|
197
|
+
"kind": "none",
|
|
198
|
+
"description": "Chỉ đọc; không thay đổi dữ liệu của bên cung cấp.",
|
|
199
|
+
"idempotency": "none"
|
|
200
|
+
},
|
|
201
|
+
"timeoutMs": 3000
|
|
202
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slug": "prescription-verify",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"provider": "junctura-hospital",
|
|
5
|
+
"consumers": [
|
|
6
|
+
"junctura-pharmacy"
|
|
7
|
+
],
|
|
8
|
+
"purposes": [
|
|
9
|
+
"dispensing"
|
|
10
|
+
],
|
|
11
|
+
"emergencyAccess": false,
|
|
12
|
+
"title": "Xác minh đơn thuốc",
|
|
13
|
+
"description": "Kiểm tra một đơn thuốc do bệnh viện kê: còn hiệu lực không, gồm những thuốc gì, đã phát chưa.",
|
|
14
|
+
"inputSchema": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"properties": {
|
|
17
|
+
"prescriptionCode": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"minLength": 1,
|
|
20
|
+
"maxLength": 32,
|
|
21
|
+
"description": "Mã đơn thuốc in trên đơn."
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": [
|
|
25
|
+
"prescriptionCode"
|
|
26
|
+
],
|
|
27
|
+
"additionalProperties": false
|
|
28
|
+
},
|
|
29
|
+
"outputSchema": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"properties": {
|
|
32
|
+
"valid": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"description": "Đơn tồn tại, đúng người bệnh và còn hạn."
|
|
35
|
+
},
|
|
36
|
+
"issuedAt": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"minLength": 20,
|
|
39
|
+
"maxLength": 30,
|
|
40
|
+
"description": "Thời điểm ISO 8601 (UTC)."
|
|
41
|
+
},
|
|
42
|
+
"expiresAt": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"minLength": 20,
|
|
45
|
+
"maxLength": 30,
|
|
46
|
+
"description": "Thời điểm ISO 8601 (UTC)."
|
|
47
|
+
},
|
|
48
|
+
"items": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"items": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"properties": {
|
|
53
|
+
"name": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"maxLength": 160,
|
|
56
|
+
"description": "Tên thuốc."
|
|
57
|
+
},
|
|
58
|
+
"strength": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"maxLength": 80,
|
|
61
|
+
"description": "Hàm lượng."
|
|
62
|
+
},
|
|
63
|
+
"quantity": {
|
|
64
|
+
"type": "integer",
|
|
65
|
+
"minimum": 1,
|
|
66
|
+
"maximum": 1000,
|
|
67
|
+
"description": "Số lượng."
|
|
68
|
+
},
|
|
69
|
+
"instructions": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"maxLength": 240,
|
|
72
|
+
"description": "Cách dùng."
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"required": [
|
|
76
|
+
"name",
|
|
77
|
+
"strength",
|
|
78
|
+
"quantity",
|
|
79
|
+
"instructions"
|
|
80
|
+
],
|
|
81
|
+
"additionalProperties": false
|
|
82
|
+
},
|
|
83
|
+
"maxItems": 20
|
|
84
|
+
},
|
|
85
|
+
"dispensed": {
|
|
86
|
+
"type": "boolean",
|
|
87
|
+
"description": "Đơn đã được phát thuốc."
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"required": [
|
|
91
|
+
"valid",
|
|
92
|
+
"issuedAt",
|
|
93
|
+
"expiresAt",
|
|
94
|
+
"items",
|
|
95
|
+
"dispensed"
|
|
96
|
+
],
|
|
97
|
+
"additionalProperties": false
|
|
98
|
+
},
|
|
99
|
+
"sideEffects": {
|
|
100
|
+
"kind": "none",
|
|
101
|
+
"description": "Chỉ đọc; không thay đổi dữ liệu của bên cung cấp.",
|
|
102
|
+
"idempotency": "none"
|
|
103
|
+
},
|
|
104
|
+
"timeoutMs": 2000
|
|
105
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slug": "referral-summary",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"provider": "junctura-clinic",
|
|
5
|
+
"consumers": [
|
|
6
|
+
"junctura-hospital"
|
|
7
|
+
],
|
|
8
|
+
"purposes": [
|
|
9
|
+
"referral_intake"
|
|
10
|
+
],
|
|
11
|
+
"emergencyAccess": false,
|
|
12
|
+
"title": "Hồ sơ chuyển tuyến",
|
|
13
|
+
"description": "Phiếu chuyển tuyến điện tử từ trạm y tế: lý do chuyển, chẩn đoán sơ bộ và xử trí đã làm.",
|
|
14
|
+
"inputSchema": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"properties": {
|
|
17
|
+
"referralId": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"minLength": 1,
|
|
20
|
+
"maxLength": 64,
|
|
21
|
+
"description": "Mã phiếu chuyển tuyến do trạm y tế cấp."
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": [
|
|
25
|
+
"referralId"
|
|
26
|
+
],
|
|
27
|
+
"additionalProperties": false
|
|
28
|
+
},
|
|
29
|
+
"outputSchema": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"properties": {
|
|
32
|
+
"referralId": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"maxLength": 64
|
|
35
|
+
},
|
|
36
|
+
"issuedAt": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"minLength": 20,
|
|
39
|
+
"maxLength": 30,
|
|
40
|
+
"description": "Thời điểm ISO 8601 (UTC)."
|
|
41
|
+
},
|
|
42
|
+
"fromFacility": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"maxLength": 160,
|
|
45
|
+
"description": "Cơ sở chuyển đi."
|
|
46
|
+
},
|
|
47
|
+
"toFacility": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"maxLength": 160,
|
|
50
|
+
"description": "Cơ sở tiếp nhận."
|
|
51
|
+
},
|
|
52
|
+
"urgency": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"maxLength": 16,
|
|
55
|
+
"description": "routine | urgent | emergency"
|
|
56
|
+
},
|
|
57
|
+
"reason": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"maxLength": 500,
|
|
60
|
+
"description": "Lý do chuyển tuyến."
|
|
61
|
+
},
|
|
62
|
+
"provisionalDiagnosis": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"properties": {
|
|
65
|
+
"code": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"maxLength": 16,
|
|
68
|
+
"description": "Mã ICD-10."
|
|
69
|
+
},
|
|
70
|
+
"name": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"maxLength": 160,
|
|
73
|
+
"description": "Tên chẩn đoán."
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"required": [
|
|
77
|
+
"code",
|
|
78
|
+
"name"
|
|
79
|
+
],
|
|
80
|
+
"additionalProperties": false
|
|
81
|
+
},
|
|
82
|
+
"treatmentGiven": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"maxLength": 1000,
|
|
85
|
+
"description": "Xử trí đã thực hiện trước khi chuyển."
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"required": [
|
|
89
|
+
"referralId",
|
|
90
|
+
"issuedAt",
|
|
91
|
+
"fromFacility",
|
|
92
|
+
"toFacility",
|
|
93
|
+
"urgency",
|
|
94
|
+
"reason",
|
|
95
|
+
"provisionalDiagnosis",
|
|
96
|
+
"treatmentGiven"
|
|
97
|
+
],
|
|
98
|
+
"additionalProperties": false
|
|
99
|
+
},
|
|
100
|
+
"sideEffects": {
|
|
101
|
+
"kind": "none",
|
|
102
|
+
"description": "Chỉ đọc; không thay đổi dữ liệu của bên cung cấp.",
|
|
103
|
+
"idempotency": "none"
|
|
104
|
+
},
|
|
105
|
+
"timeoutMs": 3000
|
|
106
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slug": "vaccination-history",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"provider": "junctura-clinic",
|
|
5
|
+
"consumers": [
|
|
6
|
+
"junctura-hospital"
|
|
7
|
+
],
|
|
8
|
+
"purposes": [
|
|
9
|
+
"treatment"
|
|
10
|
+
],
|
|
11
|
+
"emergencyAccess": false,
|
|
12
|
+
"title": "Lịch sử tiêm chủng",
|
|
13
|
+
"description": "Các mũi vắc xin người bệnh đã tiêm tại trạm y tế.",
|
|
14
|
+
"inputSchema": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"description": "Không có tham số: người bệnh được xác định qua context.dataSubject.",
|
|
17
|
+
"properties": {},
|
|
18
|
+
"required": [],
|
|
19
|
+
"additionalProperties": false
|
|
20
|
+
},
|
|
21
|
+
"outputSchema": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"vaccinations": {
|
|
25
|
+
"type": "array",
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"vaccine": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"maxLength": 120,
|
|
32
|
+
"description": "Tên vắc xin."
|
|
33
|
+
},
|
|
34
|
+
"code": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"maxLength": 16,
|
|
37
|
+
"description": "Mã CVX."
|
|
38
|
+
},
|
|
39
|
+
"date": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"minLength": 10,
|
|
42
|
+
"maxLength": 10,
|
|
43
|
+
"description": "Ngày tiêm, YYYY-MM-DD."
|
|
44
|
+
},
|
|
45
|
+
"doseNumber": {
|
|
46
|
+
"type": "integer",
|
|
47
|
+
"minimum": 1,
|
|
48
|
+
"maximum": 10,
|
|
49
|
+
"description": "Mũi thứ mấy."
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"required": [
|
|
53
|
+
"vaccine",
|
|
54
|
+
"code",
|
|
55
|
+
"date",
|
|
56
|
+
"doseNumber"
|
|
57
|
+
],
|
|
58
|
+
"additionalProperties": false
|
|
59
|
+
},
|
|
60
|
+
"maxItems": 200
|
|
61
|
+
},
|
|
62
|
+
"updatedAt": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"minLength": 20,
|
|
65
|
+
"maxLength": 30,
|
|
66
|
+
"description": "Thời điểm ISO 8601 (UTC)."
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"required": [
|
|
70
|
+
"vaccinations",
|
|
71
|
+
"updatedAt"
|
|
72
|
+
],
|
|
73
|
+
"additionalProperties": false
|
|
74
|
+
},
|
|
75
|
+
"sideEffects": {
|
|
76
|
+
"kind": "none",
|
|
77
|
+
"description": "Chỉ đọc; không thay đổi dữ liệu của bên cung cấp.",
|
|
78
|
+
"idempotency": "none"
|
|
79
|
+
},
|
|
80
|
+
"timeoutMs": 2000
|
|
81
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"input": {},
|
|
3
|
+
"output": {
|
|
4
|
+
"patientName": "Nguyễn Văn An",
|
|
5
|
+
"birthYear": 1968,
|
|
6
|
+
"sex": "male",
|
|
7
|
+
"allergies": [
|
|
8
|
+
{
|
|
9
|
+
"substance": "Penicillin",
|
|
10
|
+
"severity": "severe",
|
|
11
|
+
"reaction": "Nổi mề đay, khó thở"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"chronicConditions": [
|
|
15
|
+
{
|
|
16
|
+
"code": "I10",
|
|
17
|
+
"name": "Tăng huyết áp vô căn",
|
|
18
|
+
"since": "2019-03-12"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"code": "E11",
|
|
22
|
+
"name": "Đái tháo đường type 2",
|
|
23
|
+
"since": "2021-08-02"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"currentMedications": [
|
|
27
|
+
{
|
|
28
|
+
"name": "Amlodipin",
|
|
29
|
+
"dose": "5 mg x 1 lần/ngày",
|
|
30
|
+
"since": "2019-03-12"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Metformin",
|
|
34
|
+
"dose": "500 mg x 2 lần/ngày",
|
|
35
|
+
"since": "2021-08-02"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"recentEncounters": [
|
|
39
|
+
{
|
|
40
|
+
"date": "2026-10-28",
|
|
41
|
+
"reason": "Đau ngực, khó thở khi gắng sức",
|
|
42
|
+
"diagnosis": {
|
|
43
|
+
"code": "I20.9",
|
|
44
|
+
"name": "Cơn đau thắt ngực"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"updatedAt": "2026-10-28T09:15:00.000Z"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"input": {
|
|
3
|
+
"prescriptionCode": "DT-2026-004521"
|
|
4
|
+
},
|
|
5
|
+
"output": {
|
|
6
|
+
"valid": true,
|
|
7
|
+
"issuedAt": "2026-10-29T03:00:00.000Z",
|
|
8
|
+
"expiresAt": "2026-11-03T03:00:00.000Z",
|
|
9
|
+
"items": [
|
|
10
|
+
{
|
|
11
|
+
"name": "Clopidogrel",
|
|
12
|
+
"strength": "75 mg",
|
|
13
|
+
"quantity": 30,
|
|
14
|
+
"instructions": "Uống 1 viên/ngày sau ăn sáng"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"dispensed": false
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"input": {
|
|
3
|
+
"referralId": "CT-2026-000123"
|
|
4
|
+
},
|
|
5
|
+
"output": {
|
|
6
|
+
"referralId": "CT-2026-000123",
|
|
7
|
+
"issuedAt": "2026-10-28T09:30:00.000Z",
|
|
8
|
+
"fromFacility": "Trạm Y tế phường Hòa Khánh Bắc",
|
|
9
|
+
"toFacility": "Bệnh viện Đà Nẵng",
|
|
10
|
+
"urgency": "urgent",
|
|
11
|
+
"reason": "Đau ngực tái diễn, cần đánh giá tim mạch chuyên sâu",
|
|
12
|
+
"provisionalDiagnosis": {
|
|
13
|
+
"code": "I20.9",
|
|
14
|
+
"name": "Cơn đau thắt ngực"
|
|
15
|
+
},
|
|
16
|
+
"treatmentGiven": "Nitroglycerin ngậm dưới lưỡi 0,5 mg; theo dõi huyết áp 30 phút"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"input": {},
|
|
3
|
+
"output": {
|
|
4
|
+
"vaccinations": [
|
|
5
|
+
{
|
|
6
|
+
"vaccine": "Vắc xin uốn ván (VAT)",
|
|
7
|
+
"code": "112",
|
|
8
|
+
"date": "2024-05-10",
|
|
9
|
+
"doseNumber": 1
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"vaccine": "Vắc xin cúm mùa",
|
|
13
|
+
"code": "141",
|
|
14
|
+
"date": "2025-10-02",
|
|
15
|
+
"doseNumber": 1
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"updatedAt": "2025-10-02T02:00:00.000Z"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Junctura Contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export type Schema =
|
|
4
|
+
| { type: "object"; description?: string; properties: Record<string, Schema>; required: string[]; additionalProperties: false }
|
|
5
|
+
| { type: "array"; description?: string; items: Schema; minItems?: number; maxItems: number }
|
|
6
|
+
| { type: "string"; description?: string; minLength?: number; maxLength: number }
|
|
7
|
+
| { type: "integer" | "number"; description?: string; minimum: number; maximum: number }
|
|
8
|
+
| { type: "boolean" | "null"; description?: string };
|
|
9
|
+
export type AppName = "junctura-clinic" | "junctura-hospital" | "junctura-myhealth" | "junctura-pharmacy" | "junctura-insurance";
|
|
10
|
+
export type Contract = Readonly<{
|
|
11
|
+
slug: string; version: string; provider: AppName; consumers: AppName[]; purposes: string[]; emergencyAccess: boolean;
|
|
12
|
+
title: string; description: string; inputSchema: Schema; outputSchema: Schema;
|
|
13
|
+
sideEffects: { kind: "none" | "non-idempotent" | "idempotent"; description: string; idempotency: "none" | "provider-key" };
|
|
14
|
+
timeoutMs: number;
|
|
15
|
+
}>;
|
|
16
|
+
export const PURPOSE: RegExp;
|
|
17
|
+
export const APPS: readonly AppName[];
|
|
18
|
+
export const CONTRACTS: readonly Contract[];
|
|
19
|
+
export function getContract(slug: string): Contract;
|
|
20
|
+
export function buildManifest(slugOrContract: string | Contract, providerAppId: string): Record<string, unknown>;
|
|
21
|
+
export function validateValue(schema: Schema, value: unknown, path?: string): { path: string; message: string }[];
|
|
22
|
+
export function checkContext(slugOrContract: string | Contract, context: { purpose?: string; dataSubject?: string; emergency?: boolean } | undefined):
|
|
23
|
+
{ allowed: true } | { allowed: false; reason: "data_subject_required" | "purpose_not_allowed" | "emergency_not_allowed" };
|
|
24
|
+
export function isSlug(value: unknown): boolean;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Junctura Contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Shared capability contracts of Junctura Health. One JSON file per capability in
|
|
4
|
+
// capabilities/; the provider application turns it into a Junctura manifest with
|
|
5
|
+
// its own enrolled application ID (buildManifest), and both sides validate payloads
|
|
6
|
+
// and invocation context against the same definition.
|
|
7
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
8
|
+
|
|
9
|
+
const HERE = new URL("./capabilities/", import.meta.url);
|
|
10
|
+
const SLUG = /^[a-z][a-z0-9-]{0,62}$/;
|
|
11
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
12
|
+
export const PURPOSE = /^[a-z][a-z0-9_]{1,62}$/;
|
|
13
|
+
export const APPS = Object.freeze(["junctura-clinic", "junctura-hospital", "junctura-myhealth", "junctura-pharmacy", "junctura-insurance"]);
|
|
14
|
+
const PLATFORM = ["caller-active", "provider-active", "grant-active", "same-tenant"];
|
|
15
|
+
|
|
16
|
+
const deepFreeze = value => {
|
|
17
|
+
if (value && typeof value === "object") { Object.values(value).forEach(deepFreeze); Object.freeze(value); }
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const CONTRACTS = deepFreeze(readdirSync(HERE).filter(name => name.endsWith(".json")).sort()
|
|
22
|
+
.map(name => JSON.parse(readFileSync(new URL(name, HERE), "utf8"))));
|
|
23
|
+
|
|
24
|
+
export function getContract(slug) {
|
|
25
|
+
const contract = CONTRACTS.find(item => item.slug === slug);
|
|
26
|
+
if (!contract) throw new RangeError(`Unknown capability contract: ${slug}`);
|
|
27
|
+
return contract;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The Junctura manifest (manifestVersion 1.0) a provider registers for this contract. */
|
|
31
|
+
export function buildManifest(slugOrContract, providerAppId) {
|
|
32
|
+
const contract = typeof slugOrContract === "string" ? getContract(slugOrContract) : slugOrContract;
|
|
33
|
+
if (typeof providerAppId !== "string" || !UUID.test(providerAppId)) throw new TypeError("providerAppId must be the provider's enrolled lowercase UUID");
|
|
34
|
+
return {
|
|
35
|
+
manifestVersion: "1.0",
|
|
36
|
+
capabilityId: `urn:junctura:capability:${providerAppId}:${contract.slug}`,
|
|
37
|
+
providerAppId,
|
|
38
|
+
version: contract.version,
|
|
39
|
+
title: contract.title,
|
|
40
|
+
description: contract.description,
|
|
41
|
+
inputSchema: structuredClone(contract.inputSchema),
|
|
42
|
+
outputSchema: structuredClone(contract.outputSchema),
|
|
43
|
+
invocation: { protocol: "http-json", method: "POST", path: `/capabilities/${contract.slug}`, mediaType: "application/json" },
|
|
44
|
+
requiredPermissions: [`urn:junctura:permission:${providerAppId}:${contract.slug}`],
|
|
45
|
+
sideEffects: structuredClone(contract.sideEffects),
|
|
46
|
+
timeoutMs: contract.timeoutMs,
|
|
47
|
+
preconditions: { approval: "none", platform: [...PLATFORM] },
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Validates a JSON value against a contract schema (the Junctura payload profile:
|
|
53
|
+
* object/array/string/integer/number/boolean/null with bounds). Returns issues;
|
|
54
|
+
* an empty array means valid.
|
|
55
|
+
*/
|
|
56
|
+
export function validateValue(schema, value, path = "") {
|
|
57
|
+
const issues = [];
|
|
58
|
+
const fail = message => issues.push({ path: path || "/", message });
|
|
59
|
+
switch (schema.type) {
|
|
60
|
+
case "object":
|
|
61
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) { fail("expected object"); break; }
|
|
62
|
+
for (const key of Object.keys(value)) if (!Object.hasOwn(schema.properties, key)) issues.push({ path: `${path}/${key}`, message: "unknown property" });
|
|
63
|
+
for (const key of schema.required) if (!Object.hasOwn(value, key)) issues.push({ path: `${path}/${key}`, message: "required" });
|
|
64
|
+
for (const [key, child] of Object.entries(schema.properties)) if (Object.hasOwn(value, key)) issues.push(...validateValue(child, value[key], `${path}/${key}`));
|
|
65
|
+
break;
|
|
66
|
+
case "array":
|
|
67
|
+
if (!Array.isArray(value)) { fail("expected array"); break; }
|
|
68
|
+
if (value.length > schema.maxItems || value.length < (schema.minItems ?? 0)) fail(`expected ${schema.minItems ?? 0}-${schema.maxItems} items`);
|
|
69
|
+
value.forEach((item, index) => issues.push(...validateValue(schema.items, item, `${path}/${index}`)));
|
|
70
|
+
break;
|
|
71
|
+
case "string": {
|
|
72
|
+
if (typeof value !== "string") { fail("expected string"); break; }
|
|
73
|
+
const length = [...value].length;
|
|
74
|
+
if (length > schema.maxLength || length < (schema.minLength ?? 0)) fail(`expected length ${schema.minLength ?? 0}-${schema.maxLength}`);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case "integer":
|
|
78
|
+
case "number":
|
|
79
|
+
if (typeof value !== "number" || !Number.isFinite(value) || (schema.type === "integer" && !Number.isSafeInteger(value))) { fail(`expected ${schema.type}`); break; }
|
|
80
|
+
if (value < schema.minimum || value > schema.maximum) fail(`expected ${schema.minimum}-${schema.maximum}`);
|
|
81
|
+
break;
|
|
82
|
+
case "boolean":
|
|
83
|
+
if (typeof value !== "boolean") fail("expected boolean");
|
|
84
|
+
break;
|
|
85
|
+
case "null":
|
|
86
|
+
if (value !== null) fail("expected null");
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
fail(`unsupported schema type ${schema.type}`);
|
|
90
|
+
}
|
|
91
|
+
return issues;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Provider-side policy check on the redeemed invocation context: every health
|
|
96
|
+
* capability concerns one person, is called for a declared purpose, and accepts
|
|
97
|
+
* emergency (break-glass) calls only when the contract allows them.
|
|
98
|
+
*/
|
|
99
|
+
export function checkContext(slugOrContract, context) {
|
|
100
|
+
const contract = typeof slugOrContract === "string" ? getContract(slugOrContract) : slugOrContract;
|
|
101
|
+
if (!context || typeof context.dataSubject !== "string" || !context.dataSubject) return { allowed: false, reason: "data_subject_required" };
|
|
102
|
+
if (!contract.purposes.includes(context.purpose)) return { allowed: false, reason: "purpose_not_allowed" };
|
|
103
|
+
if (context.emergency === true && !contract.emergencyAccess) return { allowed: false, reason: "emergency_not_allowed" };
|
|
104
|
+
return { allowed: true };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const isSlug = value => typeof value === "string" && SLUG.test(value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junctura/health-contracts",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared capability contracts of Junctura Health: schemas, manifests and purpose rules for connected-care applications on Junctura DX-OS.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"homepage": "https://junctura.studio",
|
|
8
|
+
"repository": { "type": "git", "url": "git+https://github.com/vku2-open-source-2026/junctura-health.git", "directory": "contracts" },
|
|
9
|
+
"bugs": { "url": "https://github.com/vku2-open-source-2026/junctura-health/issues" },
|
|
10
|
+
"engines": { "node": ">=24 <25" },
|
|
11
|
+
"exports": { ".": { "types": "./index.d.ts", "import": "./index.mjs" } },
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"files": ["index.mjs", "index.d.ts", "capabilities/", "examples/", "README.md", "LICENSE", "NOTICE"],
|
|
14
|
+
"sideEffects": false
|
|
15
|
+
}
|