我正在使用 ajv 验证 FHIR 资源。
ajv -s fhir.schema.json -d SampleOperationOutCome.json
这是 SampleOperationOutCome.json 文件
{
"resourceType": "OperationOutcome",
"id": "101",
"text": {
"status": "additional",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>text.<\/p><\/div>"
},
"issue": [
{
"severity": "error",
"codeerror": "invalid",
"details": {
"coding": [
{
"system": "http://hl7.org/fhir/operation-outcome",
"code": "MSG_CANT_PARSE_CONTENT"
}
],
"text": "text"
}
}
]
}
您可以从FHIR build 3.4 json schemas获取 json schema
验证时我面临的主要挑战是了解哪个是真正的源问题。例如,在这种情况下,我将 de“code”字段更改为“codeerror”,但在验证时,我主要得到以下错误列表:
{ keyword: 'additionalProperties',
dataPath: '',
schemaPath: '#/additionalProperties',
params: { additionalProperty: 'issue' },
message: 'should NOT have additional properties' },
我确实知道它是否是正常输出,或者这种行为的来源是否是 json 模式或 ajv,但我会期待一些消息,如“无效字段代码错误,预期代码之一”。
为了能够分析完整输出并获得真正的来源,有什么建议吗?
谢谢。