fhir-net-api (STU3) - Validating
I have been using the Hl7.org tool org.hl7.fhir.validator.jar file to validate my messages but I would like to add this function it to my .Net project. Once I parse the message is there a class I can call to validate the Structure.
Is there a validate FHIR class in fhir-net-api that will display the same results has org.hl7.fhir.validator.jar?
string HL7FilePath = string.Format("{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "Sample.xml");
string HL7FileData = File.ReadAllText(HL7FilePath)
var b = new FhirXmlParser().Parse<PlanDefinition>(HL7FileData);
FHIR Validator Build ??
Arguments: C:HL7ToolsvalidatorREC78_1.xml -version 3.0
.. connect to tx server @ http://tx.fhir.org
.. definitions from hl7.fhir.core#3.0.1
(v3.0.1-null)
.. validate [C:HL7ToolsvalidatorSample.xml]
Terminology server: Check for supported code systems for http://www.nlm.nih.gov/research/umls/rxnorm
Success.
hl7-fhir
add a comment |
I have been using the Hl7.org tool org.hl7.fhir.validator.jar file to validate my messages but I would like to add this function it to my .Net project. Once I parse the message is there a class I can call to validate the Structure.
Is there a validate FHIR class in fhir-net-api that will display the same results has org.hl7.fhir.validator.jar?
string HL7FilePath = string.Format("{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "Sample.xml");
string HL7FileData = File.ReadAllText(HL7FilePath)
var b = new FhirXmlParser().Parse<PlanDefinition>(HL7FileData);
FHIR Validator Build ??
Arguments: C:HL7ToolsvalidatorREC78_1.xml -version 3.0
.. connect to tx server @ http://tx.fhir.org
.. definitions from hl7.fhir.core#3.0.1
(v3.0.1-null)
.. validate [C:HL7ToolsvalidatorSample.xml]
Terminology server: Check for supported code systems for http://www.nlm.nih.gov/research/umls/rxnorm
Success.
hl7-fhir
add a comment |
I have been using the Hl7.org tool org.hl7.fhir.validator.jar file to validate my messages but I would like to add this function it to my .Net project. Once I parse the message is there a class I can call to validate the Structure.
Is there a validate FHIR class in fhir-net-api that will display the same results has org.hl7.fhir.validator.jar?
string HL7FilePath = string.Format("{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "Sample.xml");
string HL7FileData = File.ReadAllText(HL7FilePath)
var b = new FhirXmlParser().Parse<PlanDefinition>(HL7FileData);
FHIR Validator Build ??
Arguments: C:HL7ToolsvalidatorREC78_1.xml -version 3.0
.. connect to tx server @ http://tx.fhir.org
.. definitions from hl7.fhir.core#3.0.1
(v3.0.1-null)
.. validate [C:HL7ToolsvalidatorSample.xml]
Terminology server: Check for supported code systems for http://www.nlm.nih.gov/research/umls/rxnorm
Success.
hl7-fhir
I have been using the Hl7.org tool org.hl7.fhir.validator.jar file to validate my messages but I would like to add this function it to my .Net project. Once I parse the message is there a class I can call to validate the Structure.
Is there a validate FHIR class in fhir-net-api that will display the same results has org.hl7.fhir.validator.jar?
string HL7FilePath = string.Format("{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "Sample.xml");
string HL7FileData = File.ReadAllText(HL7FilePath)
var b = new FhirXmlParser().Parse<PlanDefinition>(HL7FileData);
FHIR Validator Build ??
Arguments: C:HL7ToolsvalidatorREC78_1.xml -version 3.0
.. connect to tx server @ http://tx.fhir.org
.. definitions from hl7.fhir.core#3.0.1
(v3.0.1-null)
.. validate [C:HL7ToolsvalidatorSample.xml]
Terminology server: Check for supported code systems for http://www.nlm.nih.gov/research/umls/rxnorm
Success.
hl7-fhir
hl7-fhir
asked Nov 20 '18 at 18:17
JeffersonJefferson
13610
13610
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Yes, there is. You need to add the Hl7.Fhir.Specification.STU3 package, and can then use the validation methods like this:
using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Validation;
... your code, reading the PlanDefinition from file and parsing it ...
// setup the resolver to use specification.zip, and a folder with custom profiles
var source = new CachedResolver(new MultiResolver(
new DirectorySource(@"<path_to_profile_folder>"),
ZipSource.CreateValidationSource()));
// prepare the settings for the validator
var ctx = new ValidationSettings()
{
ResourceResolver = source,
GenerateSnapshot = true,
Trace = false,
EnableXsdValidation = true,
ResolveExteralReferences = false
}
var validator = new Validator(ctx);
// validate the resource; optionally enter a custom profile url as 2nd parameter
var result = validator.Validate(b);
The result will be an OperationOutcome resource containing the details of the validation.
this is the message I get Overall result: FAILURE (2 errors and 0 warnings) [ERROR] Unable to resolve reference to profile 'hl7.org/fhir/StructureDefinition/PlanDefinition' (at PlanDefinition) [ERROR] Unable to resolve reference to profile 'nccn.org/fhir/StructureDefinition/order-template' (at PlanDefinition)
– Jefferson
Nov 26 '18 at 16:46
I download the whole specification from hl7.org/fhir/downloads.html so I am not sure why I would be getting this error.
– Jefferson
Nov 26 '18 at 17:35
When you add the Hl7.Fhir.Specification.STU3 package, that should automatically add a specification.zip file to your project. This is what is being read when you use the ZipSource.CreateValidationSource. There is no need to download the specs your self, but if you have, you can point the DirectorySource to that folder. The NCCN profiles are not in specification.zip, so you will need to download them and point a DirectorySource to that folder. Please also check the url for the profile, since I have this for the NCCN order-template: ots.nccn.org/fhir/StructureDefinition/OrderTemplate.
– Mirjam Baltus
Nov 26 '18 at 22:21
I tried to use my ig but I am still getting the same error message. var source = new CachedResolver(new MultiResolver( new DirectorySource(string.Format("{0}\{1}", "C:\Project\IGPublisher\Publish", "ig.json")), ZipSource.CreateValidationSource()));
– Jefferson
Nov 27 '18 at 17:32
Could you try to just add your folder instead of a file in the DirectorySource, or take out the DirectorySource to see if the specification.zip is at least found? You can contact me at the address found on docs.simplifier.net/fhirnetapi/contact.html for more troubleshooting, if you want.
– Mirjam Baltus
Nov 27 '18 at 18:41
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399139%2ffhir-net-api-stu3-validating%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Yes, there is. You need to add the Hl7.Fhir.Specification.STU3 package, and can then use the validation methods like this:
using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Validation;
... your code, reading the PlanDefinition from file and parsing it ...
// setup the resolver to use specification.zip, and a folder with custom profiles
var source = new CachedResolver(new MultiResolver(
new DirectorySource(@"<path_to_profile_folder>"),
ZipSource.CreateValidationSource()));
// prepare the settings for the validator
var ctx = new ValidationSettings()
{
ResourceResolver = source,
GenerateSnapshot = true,
Trace = false,
EnableXsdValidation = true,
ResolveExteralReferences = false
}
var validator = new Validator(ctx);
// validate the resource; optionally enter a custom profile url as 2nd parameter
var result = validator.Validate(b);
The result will be an OperationOutcome resource containing the details of the validation.
this is the message I get Overall result: FAILURE (2 errors and 0 warnings) [ERROR] Unable to resolve reference to profile 'hl7.org/fhir/StructureDefinition/PlanDefinition' (at PlanDefinition) [ERROR] Unable to resolve reference to profile 'nccn.org/fhir/StructureDefinition/order-template' (at PlanDefinition)
– Jefferson
Nov 26 '18 at 16:46
I download the whole specification from hl7.org/fhir/downloads.html so I am not sure why I would be getting this error.
– Jefferson
Nov 26 '18 at 17:35
When you add the Hl7.Fhir.Specification.STU3 package, that should automatically add a specification.zip file to your project. This is what is being read when you use the ZipSource.CreateValidationSource. There is no need to download the specs your self, but if you have, you can point the DirectorySource to that folder. The NCCN profiles are not in specification.zip, so you will need to download them and point a DirectorySource to that folder. Please also check the url for the profile, since I have this for the NCCN order-template: ots.nccn.org/fhir/StructureDefinition/OrderTemplate.
– Mirjam Baltus
Nov 26 '18 at 22:21
I tried to use my ig but I am still getting the same error message. var source = new CachedResolver(new MultiResolver( new DirectorySource(string.Format("{0}\{1}", "C:\Project\IGPublisher\Publish", "ig.json")), ZipSource.CreateValidationSource()));
– Jefferson
Nov 27 '18 at 17:32
Could you try to just add your folder instead of a file in the DirectorySource, or take out the DirectorySource to see if the specification.zip is at least found? You can contact me at the address found on docs.simplifier.net/fhirnetapi/contact.html for more troubleshooting, if you want.
– Mirjam Baltus
Nov 27 '18 at 18:41
add a comment |
Yes, there is. You need to add the Hl7.Fhir.Specification.STU3 package, and can then use the validation methods like this:
using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Validation;
... your code, reading the PlanDefinition from file and parsing it ...
// setup the resolver to use specification.zip, and a folder with custom profiles
var source = new CachedResolver(new MultiResolver(
new DirectorySource(@"<path_to_profile_folder>"),
ZipSource.CreateValidationSource()));
// prepare the settings for the validator
var ctx = new ValidationSettings()
{
ResourceResolver = source,
GenerateSnapshot = true,
Trace = false,
EnableXsdValidation = true,
ResolveExteralReferences = false
}
var validator = new Validator(ctx);
// validate the resource; optionally enter a custom profile url as 2nd parameter
var result = validator.Validate(b);
The result will be an OperationOutcome resource containing the details of the validation.
this is the message I get Overall result: FAILURE (2 errors and 0 warnings) [ERROR] Unable to resolve reference to profile 'hl7.org/fhir/StructureDefinition/PlanDefinition' (at PlanDefinition) [ERROR] Unable to resolve reference to profile 'nccn.org/fhir/StructureDefinition/order-template' (at PlanDefinition)
– Jefferson
Nov 26 '18 at 16:46
I download the whole specification from hl7.org/fhir/downloads.html so I am not sure why I would be getting this error.
– Jefferson
Nov 26 '18 at 17:35
When you add the Hl7.Fhir.Specification.STU3 package, that should automatically add a specification.zip file to your project. This is what is being read when you use the ZipSource.CreateValidationSource. There is no need to download the specs your self, but if you have, you can point the DirectorySource to that folder. The NCCN profiles are not in specification.zip, so you will need to download them and point a DirectorySource to that folder. Please also check the url for the profile, since I have this for the NCCN order-template: ots.nccn.org/fhir/StructureDefinition/OrderTemplate.
– Mirjam Baltus
Nov 26 '18 at 22:21
I tried to use my ig but I am still getting the same error message. var source = new CachedResolver(new MultiResolver( new DirectorySource(string.Format("{0}\{1}", "C:\Project\IGPublisher\Publish", "ig.json")), ZipSource.CreateValidationSource()));
– Jefferson
Nov 27 '18 at 17:32
Could you try to just add your folder instead of a file in the DirectorySource, or take out the DirectorySource to see if the specification.zip is at least found? You can contact me at the address found on docs.simplifier.net/fhirnetapi/contact.html for more troubleshooting, if you want.
– Mirjam Baltus
Nov 27 '18 at 18:41
add a comment |
Yes, there is. You need to add the Hl7.Fhir.Specification.STU3 package, and can then use the validation methods like this:
using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Validation;
... your code, reading the PlanDefinition from file and parsing it ...
// setup the resolver to use specification.zip, and a folder with custom profiles
var source = new CachedResolver(new MultiResolver(
new DirectorySource(@"<path_to_profile_folder>"),
ZipSource.CreateValidationSource()));
// prepare the settings for the validator
var ctx = new ValidationSettings()
{
ResourceResolver = source,
GenerateSnapshot = true,
Trace = false,
EnableXsdValidation = true,
ResolveExteralReferences = false
}
var validator = new Validator(ctx);
// validate the resource; optionally enter a custom profile url as 2nd parameter
var result = validator.Validate(b);
The result will be an OperationOutcome resource containing the details of the validation.
Yes, there is. You need to add the Hl7.Fhir.Specification.STU3 package, and can then use the validation methods like this:
using Hl7.Fhir.Specification.Source;
using Hl7.Fhir.Validation;
... your code, reading the PlanDefinition from file and parsing it ...
// setup the resolver to use specification.zip, and a folder with custom profiles
var source = new CachedResolver(new MultiResolver(
new DirectorySource(@"<path_to_profile_folder>"),
ZipSource.CreateValidationSource()));
// prepare the settings for the validator
var ctx = new ValidationSettings()
{
ResourceResolver = source,
GenerateSnapshot = true,
Trace = false,
EnableXsdValidation = true,
ResolveExteralReferences = false
}
var validator = new Validator(ctx);
// validate the resource; optionally enter a custom profile url as 2nd parameter
var result = validator.Validate(b);
The result will be an OperationOutcome resource containing the details of the validation.
answered Nov 22 '18 at 19:24
Mirjam BaltusMirjam Baltus
53029
53029
this is the message I get Overall result: FAILURE (2 errors and 0 warnings) [ERROR] Unable to resolve reference to profile 'hl7.org/fhir/StructureDefinition/PlanDefinition' (at PlanDefinition) [ERROR] Unable to resolve reference to profile 'nccn.org/fhir/StructureDefinition/order-template' (at PlanDefinition)
– Jefferson
Nov 26 '18 at 16:46
I download the whole specification from hl7.org/fhir/downloads.html so I am not sure why I would be getting this error.
– Jefferson
Nov 26 '18 at 17:35
When you add the Hl7.Fhir.Specification.STU3 package, that should automatically add a specification.zip file to your project. This is what is being read when you use the ZipSource.CreateValidationSource. There is no need to download the specs your self, but if you have, you can point the DirectorySource to that folder. The NCCN profiles are not in specification.zip, so you will need to download them and point a DirectorySource to that folder. Please also check the url for the profile, since I have this for the NCCN order-template: ots.nccn.org/fhir/StructureDefinition/OrderTemplate.
– Mirjam Baltus
Nov 26 '18 at 22:21
I tried to use my ig but I am still getting the same error message. var source = new CachedResolver(new MultiResolver( new DirectorySource(string.Format("{0}\{1}", "C:\Project\IGPublisher\Publish", "ig.json")), ZipSource.CreateValidationSource()));
– Jefferson
Nov 27 '18 at 17:32
Could you try to just add your folder instead of a file in the DirectorySource, or take out the DirectorySource to see if the specification.zip is at least found? You can contact me at the address found on docs.simplifier.net/fhirnetapi/contact.html for more troubleshooting, if you want.
– Mirjam Baltus
Nov 27 '18 at 18:41
add a comment |
this is the message I get Overall result: FAILURE (2 errors and 0 warnings) [ERROR] Unable to resolve reference to profile 'hl7.org/fhir/StructureDefinition/PlanDefinition' (at PlanDefinition) [ERROR] Unable to resolve reference to profile 'nccn.org/fhir/StructureDefinition/order-template' (at PlanDefinition)
– Jefferson
Nov 26 '18 at 16:46
I download the whole specification from hl7.org/fhir/downloads.html so I am not sure why I would be getting this error.
– Jefferson
Nov 26 '18 at 17:35
When you add the Hl7.Fhir.Specification.STU3 package, that should automatically add a specification.zip file to your project. This is what is being read when you use the ZipSource.CreateValidationSource. There is no need to download the specs your self, but if you have, you can point the DirectorySource to that folder. The NCCN profiles are not in specification.zip, so you will need to download them and point a DirectorySource to that folder. Please also check the url for the profile, since I have this for the NCCN order-template: ots.nccn.org/fhir/StructureDefinition/OrderTemplate.
– Mirjam Baltus
Nov 26 '18 at 22:21
I tried to use my ig but I am still getting the same error message. var source = new CachedResolver(new MultiResolver( new DirectorySource(string.Format("{0}\{1}", "C:\Project\IGPublisher\Publish", "ig.json")), ZipSource.CreateValidationSource()));
– Jefferson
Nov 27 '18 at 17:32
Could you try to just add your folder instead of a file in the DirectorySource, or take out the DirectorySource to see if the specification.zip is at least found? You can contact me at the address found on docs.simplifier.net/fhirnetapi/contact.html for more troubleshooting, if you want.
– Mirjam Baltus
Nov 27 '18 at 18:41
this is the message I get Overall result: FAILURE (2 errors and 0 warnings) [ERROR] Unable to resolve reference to profile 'hl7.org/fhir/StructureDefinition/PlanDefinition' (at PlanDefinition) [ERROR] Unable to resolve reference to profile 'nccn.org/fhir/StructureDefinition/order-template' (at PlanDefinition)
– Jefferson
Nov 26 '18 at 16:46
this is the message I get Overall result: FAILURE (2 errors and 0 warnings) [ERROR] Unable to resolve reference to profile 'hl7.org/fhir/StructureDefinition/PlanDefinition' (at PlanDefinition) [ERROR] Unable to resolve reference to profile 'nccn.org/fhir/StructureDefinition/order-template' (at PlanDefinition)
– Jefferson
Nov 26 '18 at 16:46
I download the whole specification from hl7.org/fhir/downloads.html so I am not sure why I would be getting this error.
– Jefferson
Nov 26 '18 at 17:35
I download the whole specification from hl7.org/fhir/downloads.html so I am not sure why I would be getting this error.
– Jefferson
Nov 26 '18 at 17:35
When you add the Hl7.Fhir.Specification.STU3 package, that should automatically add a specification.zip file to your project. This is what is being read when you use the ZipSource.CreateValidationSource. There is no need to download the specs your self, but if you have, you can point the DirectorySource to that folder. The NCCN profiles are not in specification.zip, so you will need to download them and point a DirectorySource to that folder. Please also check the url for the profile, since I have this for the NCCN order-template: ots.nccn.org/fhir/StructureDefinition/OrderTemplate.
– Mirjam Baltus
Nov 26 '18 at 22:21
When you add the Hl7.Fhir.Specification.STU3 package, that should automatically add a specification.zip file to your project. This is what is being read when you use the ZipSource.CreateValidationSource. There is no need to download the specs your self, but if you have, you can point the DirectorySource to that folder. The NCCN profiles are not in specification.zip, so you will need to download them and point a DirectorySource to that folder. Please also check the url for the profile, since I have this for the NCCN order-template: ots.nccn.org/fhir/StructureDefinition/OrderTemplate.
– Mirjam Baltus
Nov 26 '18 at 22:21
I tried to use my ig but I am still getting the same error message. var source = new CachedResolver(new MultiResolver( new DirectorySource(string.Format("{0}\{1}", "C:\Project\IGPublisher\Publish", "ig.json")), ZipSource.CreateValidationSource()));
– Jefferson
Nov 27 '18 at 17:32
I tried to use my ig but I am still getting the same error message. var source = new CachedResolver(new MultiResolver( new DirectorySource(string.Format("{0}\{1}", "C:\Project\IGPublisher\Publish", "ig.json")), ZipSource.CreateValidationSource()));
– Jefferson
Nov 27 '18 at 17:32
Could you try to just add your folder instead of a file in the DirectorySource, or take out the DirectorySource to see if the specification.zip is at least found? You can contact me at the address found on docs.simplifier.net/fhirnetapi/contact.html for more troubleshooting, if you want.
– Mirjam Baltus
Nov 27 '18 at 18:41
Could you try to just add your folder instead of a file in the DirectorySource, or take out the DirectorySource to see if the specification.zip is at least found? You can contact me at the address found on docs.simplifier.net/fhirnetapi/contact.html for more troubleshooting, if you want.
– Mirjam Baltus
Nov 27 '18 at 18:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399139%2ffhir-net-api-stu3-validating%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown