@nexalink/coding-contracts 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@nexalink/coding-contracts",
3
+ "version": "0.1.0",
4
+ "description": "Versioned coding workflow contracts shared by nexalink-cloud, carecompass-sdk, and nexalink-webapp. Generated from contracts/schemas; includes TypeScript types, zod validators, canonical constants, and raw schema documents.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/cjs/index.cjs",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./schemas/*": "./schemas/*.json",
16
+ "./versions.json": "./versions.json",
17
+ "./workflow-constants.json": "./workflow-constants.json"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "schemas",
22
+ "versions.json",
23
+ "workflow-constants.json"
24
+ ],
25
+ "sideEffects": false,
26
+ "dependencies": {
27
+ "zod": "^4.4.3"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "registry": "https://registry.npmjs.org/",
32
+ "tag": "beta"
33
+ },
34
+ "license": "UNLICENSED"
35
+ }
@@ -0,0 +1,82 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://nexalink.care/contracts/rcm-coding-input.schema.json",
4
+ "title": "RcmCodingInput",
5
+ "description": "Structured coding-case context for a single encounter-based RCM coding-review request. Canonical source for the SDK input shape, the portal request context, and the cloud-hosted encounter payload.",
6
+ "version": "1.0.0",
7
+ "x-wire-version": "rcm-coding-input-v1",
8
+ "x-code": "coding_input",
9
+ "x-keys-code": "coding_input_keys",
10
+ "type": "object",
11
+ "additionalProperties": false,
12
+ "required": ["encounterId", "diagnosisNarrative"],
13
+ "properties": {
14
+ "encounterId": {
15
+ "type": "string",
16
+ "minLength": 1,
17
+ "maxLength": 160,
18
+ "x-code": "encounter_id"
19
+ },
20
+ "diagnosisNarrative": {
21
+ "type": "string",
22
+ "minLength": 1,
23
+ "maxLength": 2000,
24
+ "x-code": "diagnosis_narrative"
25
+ },
26
+ "procedureNarrative": {
27
+ "type": "string",
28
+ "maxLength": 2000,
29
+ "x-code": "procedure_narrative"
30
+ },
31
+ "serviceDate": {
32
+ "type": "string",
33
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
34
+ "x-code": "service_date"
35
+ },
36
+ "placeOfService": {
37
+ "type": "string",
38
+ "minLength": 1,
39
+ "maxLength": 20,
40
+ "x-code": "place_of_service"
41
+ },
42
+ "claimContext": {
43
+ "type": "object",
44
+ "additionalProperties": false,
45
+ "x-code": "claim_context",
46
+ "x-keys-code": "claim_context",
47
+ "properties": {
48
+ "stage": {
49
+ "type": "string",
50
+ "enum": ["development", "staging", "production"],
51
+ "x-code": "claim_context_stage"
52
+ },
53
+ "payerName": {
54
+ "type": "string",
55
+ "minLength": 1,
56
+ "maxLength": 160,
57
+ "x-code": "claim_context_payer_name"
58
+ },
59
+ "submittedCodes": {
60
+ "type": "array",
61
+ "maxItems": 20,
62
+ "x-code": "claim_context_submitted_codes",
63
+ "items": {
64
+ "type": "string",
65
+ "minLength": 1,
66
+ "maxLength": 20,
67
+ "x-code": "claim_context_submitted_codes"
68
+ }
69
+ }
70
+ }
71
+ },
72
+ "supportingReferences": {
73
+ "type": "array",
74
+ "maxItems": 10,
75
+ "x-code": "supporting_references",
76
+ "items": {
77
+ "$ref": "rcm-supporting-reference.schema.json"
78
+ }
79
+ }
80
+ },
81
+ "x-wire-constant": "RCM_INPUT_SCHEMA_VERSION"
82
+ }
@@ -0,0 +1,146 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://nexalink.care/contracts/rcm-coding-output.schema.json",
4
+ "title": "RcmCodingOutput",
5
+ "description": "Grounded RCM coding-review result returned by the hosted runtime. This is the stable compatibility contract behind the legacy rcm-grounded-human-review-v2 output schema version. The runtime postcondition fails closed: any structural or grounding violation is replaced with an escalate response carrying rcm_validation_error.",
6
+ "version": "1.0.0",
7
+ "x-wire-version": "rcm-grounded-human-review-v2",
8
+ "x-code": "not_object",
9
+ "x-keys-code": "top_level_keys",
10
+ "type": "object",
11
+ "additionalProperties": false,
12
+ "required": [
13
+ "disposition",
14
+ "humanReviewRequired",
15
+ "recommendations",
16
+ "documentationGaps",
17
+ "rationale"
18
+ ],
19
+ "properties": {
20
+ "disposition": {
21
+ "type": "string",
22
+ "enum": ["review_required", "abstain", "escalate"],
23
+ "x-code": "disposition"
24
+ },
25
+ "humanReviewRequired": {
26
+ "type": "boolean",
27
+ "const": true,
28
+ "x-code": "human_review_required"
29
+ },
30
+ "rationale": {
31
+ "type": "string",
32
+ "minLength": 1,
33
+ "maxLength": 4000,
34
+ "x-strip-nonempty": true,
35
+ "x-code": "rationale"
36
+ },
37
+ "recommendations": {
38
+ "type": "array",
39
+ "maxItems": 20,
40
+ "x-code": "recommendations",
41
+ "items": {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "x-code": "recommendation_keys",
45
+ "x-keys-code": "recommendation_keys",
46
+ "required": [
47
+ "code",
48
+ "codeSystem",
49
+ "confidence",
50
+ "rationale",
51
+ "evidenceIds"
52
+ ],
53
+ "properties": {
54
+ "code": {
55
+ "type": "string",
56
+ "minLength": 1,
57
+ "maxLength": 64,
58
+ "x-strip-nonempty": true,
59
+ "x-code": "recommendation_code"
60
+ },
61
+ "codeSystem": {
62
+ "type": "string",
63
+ "enum": ["ICD-10-CM", "CPT", "HCPCS"],
64
+ "x-code": "recommendation_code_system"
65
+ },
66
+ "confidence": {
67
+ "type": "string",
68
+ "enum": ["low", "medium", "high"],
69
+ "x-code": "recommendation_confidence"
70
+ },
71
+ "rationale": {
72
+ "type": "string",
73
+ "minLength": 1,
74
+ "maxLength": 2000,
75
+ "x-strip-nonempty": true,
76
+ "x-code": "recommendation_rationale"
77
+ },
78
+ "evidenceIds": {
79
+ "type": "array",
80
+ "minItems": 1,
81
+ "maxItems": 5,
82
+ "x-code": "recommendation_evidence_ids",
83
+ "items": {
84
+ "type": "string",
85
+ "minLength": 1,
86
+ "maxLength": 128,
87
+ "x-strip-nonempty": true,
88
+ "x-code": "recommendation_evidence_ids"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ },
94
+ "documentationGaps": {
95
+ "type": "array",
96
+ "maxItems": 20,
97
+ "x-code": "documentation_gaps",
98
+ "items": {
99
+ "type": "string",
100
+ "minLength": 1,
101
+ "maxLength": 1000,
102
+ "x-strip-nonempty": true,
103
+ "x-code": "documentation_gaps"
104
+ }
105
+ }
106
+ },
107
+ "if": {
108
+ "properties": {
109
+ "disposition": {
110
+ "const": "review_required"
111
+ }
112
+ },
113
+ "required": ["disposition"]
114
+ },
115
+ "then": {
116
+ "properties": {
117
+ "recommendations": {
118
+ "minItems": 1
119
+ }
120
+ },
121
+ "x-code": "review_required_recommendations"
122
+ },
123
+ "else": {
124
+ "properties": {
125
+ "recommendations": {
126
+ "maxItems": 0
127
+ }
128
+ },
129
+ "x-code": "disposition_recommendations"
130
+ },
131
+ "x-semantic": [
132
+ {
133
+ "rule": "grounded_evidence_ids",
134
+ "code": "recommendation_unapproved_evidence",
135
+ "on": "recommendations",
136
+ "option": "allowedReferenceIds"
137
+ },
138
+ {
139
+ "rule": "code_in_cited_excerpt",
140
+ "code": "recommendation_code_not_in_evidence",
141
+ "on": "recommendations",
142
+ "options": ["allowedReferenceIds", "referenceTextById"]
143
+ }
144
+ ],
145
+ "x-wire-constant": "RCM_OUTPUT_SCHEMA_VERSION"
146
+ }
@@ -0,0 +1,91 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://nexalink.care/contracts/rcm-model-prompt.schema.json",
4
+ "title": "RcmModelPrompt",
5
+ "description": "Structured JSON presented to the coding model. The encounter carries the request case fields and supportingReferences carry server-resolved or development-approved evidence. The hosted runtime builds this itself from retrieval and never accepts caller-supplied references outside development.",
6
+ "version": "1.0.0",
7
+ "x-wire-version": "rcm-model-prompt-v1",
8
+ "x-code": "model_prompt",
9
+ "x-keys-code": "model_prompt_keys",
10
+ "type": "object",
11
+ "additionalProperties": false,
12
+ "required": ["encounter", "supportingReferences"],
13
+ "properties": {
14
+ "encounter": {
15
+ "type": "object",
16
+ "additionalProperties": false,
17
+ "required": ["encounterId", "diagnosisNarrative"],
18
+ "x-code": "encounter",
19
+ "x-keys-code": "encounter_keys",
20
+ "properties": {
21
+ "encounterId": {
22
+ "type": "string",
23
+ "minLength": 1,
24
+ "maxLength": 160,
25
+ "x-code": "encounter_id"
26
+ },
27
+ "diagnosisNarrative": {
28
+ "type": "string",
29
+ "minLength": 1,
30
+ "maxLength": 2000,
31
+ "x-code": "diagnosis_narrative"
32
+ },
33
+ "procedureNarrative": {
34
+ "type": "string",
35
+ "maxLength": 2000,
36
+ "x-code": "procedure_narrative"
37
+ },
38
+ "serviceDate": {
39
+ "type": "string",
40
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
41
+ "x-code": "service_date"
42
+ },
43
+ "placeOfService": {
44
+ "type": "string",
45
+ "minLength": 1,
46
+ "maxLength": 20,
47
+ "x-code": "place_of_service"
48
+ },
49
+ "claimContext": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "x-code": "claim_context",
53
+ "x-keys-code": "claim_context",
54
+ "properties": {
55
+ "stage": {
56
+ "type": "string",
57
+ "enum": ["development", "staging", "production"],
58
+ "x-code": "claim_context_stage"
59
+ },
60
+ "payerName": {
61
+ "type": "string",
62
+ "minLength": 1,
63
+ "maxLength": 160,
64
+ "x-code": "claim_context_payer_name"
65
+ },
66
+ "submittedCodes": {
67
+ "type": "array",
68
+ "maxItems": 20,
69
+ "x-code": "claim_context_submitted_codes",
70
+ "items": {
71
+ "type": "string",
72
+ "minLength": 1,
73
+ "maxLength": 20,
74
+ "x-code": "claim_context_submitted_codes"
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ },
81
+ "supportingReferences": {
82
+ "type": "array",
83
+ "maxItems": 5,
84
+ "x-code": "model_prompt_references",
85
+ "items": {
86
+ "$ref": "rcm-supporting-reference.schema.json"
87
+ }
88
+ }
89
+ },
90
+ "x-wire-constant": "RCM_MODEL_PROMPT_SCHEMA_VERSION"
91
+ }
@@ -0,0 +1,61 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://nexalink.care/contracts/rcm-retrieval-metadata.schema.json",
4
+ "title": "RcmRetrievalMetadata",
5
+ "description": "Bounded metadata attached to a hosted RCM retrieval outcome. The client-visible shape omits tenantId and knowledgeBaseId; both are included here as optional so the full runtime envelope and the persisted client-facing metadata validate against the same contract.",
6
+ "version": "1.0.0",
7
+ "x-wire-version": "rcm-retrieval-metadata-v1",
8
+ "x-code": "retrieval_metadata",
9
+ "x-keys-code": "retrieval_metadata_keys",
10
+ "type": "object",
11
+ "additionalProperties": false,
12
+ "required": [
13
+ "corpusId",
14
+ "corpusVersion",
15
+ "outcome",
16
+ "latencyMs",
17
+ "references"
18
+ ],
19
+ "properties": {
20
+ "corpusId": {
21
+ "type": "string",
22
+ "minLength": 1,
23
+ "maxLength": 128,
24
+ "x-code": "corpus_id"
25
+ },
26
+ "corpusVersion": {
27
+ "type": "string",
28
+ "minLength": 1,
29
+ "maxLength": 128,
30
+ "x-code": "corpus_version"
31
+ },
32
+ "outcome": {
33
+ "type": "string",
34
+ "enum": ["completed", "empty", "failed"],
35
+ "x-code": "retrieval_outcome"
36
+ },
37
+ "latencyMs": {
38
+ "type": "integer",
39
+ "minimum": 0,
40
+ "x-code": "retrieval_latency_ms"
41
+ },
42
+ "knowledgeBaseId": {
43
+ "type": "string",
44
+ "maxLength": 128,
45
+ "x-code": "knowledge_base_id"
46
+ },
47
+ "tenantId": {
48
+ "type": "string",
49
+ "maxLength": 128,
50
+ "x-code": "retrieval_tenant_id"
51
+ },
52
+ "references": {
53
+ "type": "array",
54
+ "x-code": "retrieval_references",
55
+ "items": {
56
+ "$ref": "rcm-supporting-reference.schema.json"
57
+ }
58
+ }
59
+ },
60
+ "x-wire-constant": "RCM_RETRIEVAL_SCHEMA_VERSION"
61
+ }
@@ -0,0 +1,170 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://nexalink.care/contracts/rcm-runtime-event.schema.json",
4
+ "title": "RcmRuntimeEvent",
5
+ "description": "Sanitized audit or safety event emitted along a workflow runtime lifecycle. Events never carry prompts, raw PHI, or unrestricted guardrail trace content.",
6
+ "version": "1.0.0",
7
+ "x-wire-version": "rcm-runtime-event-v1",
8
+ "x-code": "runtime_event",
9
+ "x-keys-code": "runtime_event_keys",
10
+ "type": "object",
11
+ "additionalProperties": false,
12
+ "required": ["type", "outcome", "reason", "occurredAt", "workflowId"],
13
+ "properties": {
14
+ "type": {
15
+ "type": "string",
16
+ "enum": ["audit", "safety"],
17
+ "x-code": "runtime_event_type"
18
+ },
19
+ "outcome": {
20
+ "type": "string",
21
+ "enum": ["authorized", "validated", "escalated"],
22
+ "x-code": "runtime_event_outcome"
23
+ },
24
+ "reason": {
25
+ "type": "string",
26
+ "enum": [
27
+ "workflow_authorized",
28
+ "output_validated",
29
+ "output_invalid",
30
+ "workflow_escalated",
31
+ "guardrail_blocked",
32
+ "retrieval_completed",
33
+ "retrieval_failed"
34
+ ],
35
+ "x-code": "runtime_event_reason"
36
+ },
37
+ "occurredAt": {
38
+ "type": "string",
39
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",
40
+ "maxLength": 64,
41
+ "x-code": "runtime_event_occurred_at"
42
+ },
43
+ "workflowId": {
44
+ "type": "string",
45
+ "enum": ["rcm-coding-assistance"],
46
+ "x-code": "runtime_event_workflow_id"
47
+ },
48
+ "guardrail": {
49
+ "type": "object",
50
+ "additionalProperties": false,
51
+ "x-code": "runtime_event_guardrail",
52
+ "x-keys-code": "runtime_event_guardrail_keys",
53
+ "properties": {
54
+ "stopReason": {
55
+ "type": "string",
56
+ "maxLength": 64,
57
+ "x-code": "runtime_event_guardrail_stop_reason"
58
+ },
59
+ "actions": {
60
+ "type": "array",
61
+ "x-code": "runtime_event_guardrail_actions",
62
+ "items": {
63
+ "type": "object",
64
+ "additionalProperties": false,
65
+ "required": ["scope", "policyType", "rule", "action"],
66
+ "x-code": "runtime_event_guardrail_action",
67
+ "x-keys-code": "runtime_event_guardrail_action_keys",
68
+ "properties": {
69
+ "scope": {
70
+ "type": "string",
71
+ "maxLength": 64,
72
+ "x-code": "runtime_event_guardrail_action_scope"
73
+ },
74
+ "policyType": {
75
+ "type": "string",
76
+ "maxLength": 64,
77
+ "x-code": "runtime_event_guardrail_action_policy_type"
78
+ },
79
+ "rule": {
80
+ "type": "string",
81
+ "maxLength": 128,
82
+ "x-code": "runtime_event_guardrail_action_rule"
83
+ },
84
+ "action": {
85
+ "type": "string",
86
+ "maxLength": 64,
87
+ "x-code": "runtime_event_guardrail_action_type"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ },
94
+ "retrieval": {
95
+ "type": "object",
96
+ "additionalProperties": false,
97
+ "required": [
98
+ "corpusId",
99
+ "corpusVersion",
100
+ "outcome",
101
+ "referenceCount",
102
+ "latencyMs",
103
+ "references"
104
+ ],
105
+ "x-code": "runtime_event_retrieval",
106
+ "x-keys-code": "runtime_event_retrieval_keys",
107
+ "properties": {
108
+ "corpusId": {
109
+ "type": "string",
110
+ "minLength": 1,
111
+ "maxLength": 128,
112
+ "x-code": "runtime_event_retrieval_corpus_id"
113
+ },
114
+ "corpusVersion": {
115
+ "type": "string",
116
+ "minLength": 1,
117
+ "maxLength": 128,
118
+ "x-code": "runtime_event_retrieval_corpus_version"
119
+ },
120
+ "outcome": {
121
+ "type": "string",
122
+ "maxLength": 64,
123
+ "x-code": "runtime_event_retrieval_outcome"
124
+ },
125
+ "referenceCount": {
126
+ "type": "integer",
127
+ "minimum": 0,
128
+ "x-code": "runtime_event_retrieval_reference_count"
129
+ },
130
+ "latencyMs": {
131
+ "type": "integer",
132
+ "minimum": 0,
133
+ "x-code": "runtime_event_retrieval_latency_ms"
134
+ },
135
+ "references": {
136
+ "type": "array",
137
+ "x-code": "runtime_event_retrieval_references",
138
+ "items": {
139
+ "type": "object",
140
+ "additionalProperties": false,
141
+ "required": ["referenceId", "documentId", "version"],
142
+ "x-code": "runtime_event_retrieval_reference",
143
+ "x-keys-code": "runtime_event_retrieval_reference_keys",
144
+ "properties": {
145
+ "referenceId": {
146
+ "type": "string",
147
+ "pattern": "^reference-[1-9][0-9]*$",
148
+ "maxLength": 32,
149
+ "x-code": "runtime_event_retrieval_reference_id"
150
+ },
151
+ "documentId": {
152
+ "type": "string",
153
+ "minLength": 1,
154
+ "maxLength": 240,
155
+ "x-code": "runtime_event_retrieval_document_id"
156
+ },
157
+ "version": {
158
+ "type": "string",
159
+ "minLength": 1,
160
+ "maxLength": 80,
161
+ "x-code": "runtime_event_retrieval_reference_version"
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }
168
+ },
169
+ "x-wire-constant": "RCM_RUNTIME_EVENT_SCHEMA_VERSION"
170
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://nexalink.care/contracts/rcm-supporting-reference.schema.json",
4
+ "title": "RcmSupportingReference",
5
+ "description": "One policy/evidence reference attached to an RCM coding request or returned by the tenant-scoped hosted retrieval. Core fields are the portable minimum; the remaining fields are populated by the hosted runtime and may be absent for customer-injected development references.",
6
+ "version": "1.0.0",
7
+ "x-wire-version": "rcm-supporting-reference-v1",
8
+ "x-code": "reference",
9
+ "x-keys-code": "reference_keys",
10
+ "type": "object",
11
+ "additionalProperties": false,
12
+ "required": ["referenceId", "title", "excerpt"],
13
+ "properties": {
14
+ "referenceId": {
15
+ "type": "string",
16
+ "pattern": "^reference-[1-9][0-9]*$",
17
+ "maxLength": 32,
18
+ "x-code": "reference_id"
19
+ },
20
+ "documentId": {
21
+ "type": "string",
22
+ "minLength": 1,
23
+ "maxLength": 240,
24
+ "x-code": "reference_document_id"
25
+ },
26
+ "title": {
27
+ "type": "string",
28
+ "minLength": 1,
29
+ "maxLength": 240,
30
+ "x-code": "reference_title"
31
+ },
32
+ "excerpt": {
33
+ "type": "string",
34
+ "minLength": 1,
35
+ "maxLength": 2000,
36
+ "x-code": "reference_excerpt"
37
+ },
38
+ "version": {
39
+ "type": "string",
40
+ "minLength": 1,
41
+ "maxLength": 80,
42
+ "x-code": "reference_version"
43
+ },
44
+ "corpusScope": {
45
+ "type": "string",
46
+ "enum": ["base", "tenant"],
47
+ "x-code": "reference_corpus_scope"
48
+ },
49
+ "publisher": {
50
+ "type": "string",
51
+ "maxLength": 240,
52
+ "x-code": "reference_publisher"
53
+ },
54
+ "effectiveDate": {
55
+ "type": "string",
56
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
57
+ "x-code": "reference_effective_date"
58
+ },
59
+ "retrievalDate": {
60
+ "type": "string",
61
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
62
+ "x-code": "reference_retrieval_date"
63
+ },
64
+ "coveredPayerProgram": {
65
+ "type": "string",
66
+ "maxLength": 240,
67
+ "x-code": "reference_covered_payer_program"
68
+ },
69
+ "sourceUrl": {
70
+ "type": "string",
71
+ "maxLength": 2048,
72
+ "x-code": "reference_source_url"
73
+ },
74
+ "humanReviewRequired": {
75
+ "type": "boolean",
76
+ "const": true,
77
+ "x-code": "reference_human_review_required"
78
+ }
79
+ },
80
+ "x-wire-constant": "RCM_REFERENCE_SCHEMA_VERSION"
81
+ }