Blog archive

Converting Nemsis 3.4 Schema XSL to C Sharp Objects

Nemsis provides the entire schema in XSL files which are used to validate your PCR data for structural correctness.

Normally you are going to use XML validation for this process, but what if you had the schema as C sharp objects in your source code?  

Microsoft has a utility which allows automatic conversion of XSL files to C sharp source code.  We will describe the process of using this utility against the Nemsis schema.

 

Nemsis Schema 

Navigate to the Nemsis EMS download page and save the NEMSIS XSDs Zip file to a folder on your computer hard drive.  Extract the files.  I used the path C:\Temp\NEMSIS_XSDs.

 

Directory

 

Microsoft XSD.exe

The Microsoft Windows SDK contains a utility called XSD.exe.  The Microsoft Windows SDK will be installed during the Visual Studio installation process.

The path C:\Program Files (x86)\Microsoft SDKs\Windows contains the versions of the SDKs you have installed.

 

SDKs

 

I will be using the latest version of the utility located at: C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\XSD.exe 

Open a command prompt:

Run this command to change your directory: CD C:\Temp\NEMSIS_XSDs

Run this command to create your c sharp file: 

"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\xsd.exe" /classes /language:CS EMSDataSet_v3.xsd

This will create a file C:\Temp\NEMSIS_XSDs\EMSDataSet_v3.cs 

 

Class Generation

 

Visual Studio Example 

I have created an example project with the EMSDataSet_v2.cs file.  Download it from my GitHub repository.

https://github.com/twodawg/Nemsis34

 

With the new class you can create objects which conform to the Nemsis spec.  Here is an example of a Patient object.  The field names can be referenced from the Nemsis website: http://nemsis.org/media/nemsis_v3/release-3.4.0/DataDictionary/PDFHTML/DEMEMS/index.html

 

Patient Object

 

Results 

Once the new Patient object is defined we can use it like so:

Results

 

We now have a Nemsis 3.4 compatible C Sharp object group to create many electronic patient software products!

 

 

Support

Has this post been useful to you?

Support me via a Paypal donation http://epcr.allcode.net/donation

Share this article to social media:

Leave your comment