Base for CDA and CCD services provided by HL7Connect



HL7Connect.Cda.ClinicalDocument CreateDocument();
   Create a blank CDA document. Fixed values will be populated

HL7Connect.Ccd.Builder CreateCCD();
   Create a blank CDA document that conforms to the CCD profile. values that are fixed in the CCD profile will be populated. The CCD builder offers a CCD-centric view of the document

HL7Connect.Ccd.Builder CreateCCDFromDocument(HL7Connect.Cda.ClinicalDocument oDocument);
   given a CDA document, provide a CCD-centric presentation of it. Caution: This may be misleading where the document does not conform to the CCD specification.

HL7Connect.Cda.ClinicalDocument CreateDocumentFromStream(Stream stream);
   Read the stream as a CDA document. May be in any character encoding, with or without BOM. The entire stream will be read; it must start at the start of the document and end at the end of the document

todo: is a DOM based method necessary? using what COM library?

HL7Connect.Cda.ClinicalDocument Clone(HL7Connect.Cda.ClinicalDocument document);
   Clone a CDA Document to a new instance that can be modified without altering the original instance

void SaveDocumentToStream(HL7Connect.Cda.ClinicalDocument Document, Stream stream);
   Save the document to a stream using the default character set (UTF-8), and no pretty-printed

void SaveDocumentToStreamWithFormat(HL7Connect.Cda.ClinicalDocument Document, Stream stream, string format);
   Save the document to a stream using the specified format. Format is a series of tokens separated by spaces. The tokens may be one of the following:
  • [char-encoding] where character encoding is ANSI, UTF-8, UTF-16BE etc. Default is ANSI for ER7 and UTF-8 for XML
  • pretty - when writing XML, whether to include spaces for easy visibility
You can only specify one character encoding. Since the list of character encodings is not limited, any unknown token will treated as a character encoding. The encoding is passed onto msxml - use one that msxml recognises.

string GetPatientId(HL7Connect.Cda.ClinicalDocument Document, string oid);
   The patient id - the id identified by the provided OID. If OID is blank, the patient id if there is only one patient id. Otherwise the value will be null.

HL7Connect.Cda.Factory CDAFactory();
   Handle to the underlying CDA factory that can create any of the types that are part of a CDA document

HL7Connect.Ccd.Factory CCDFactory();
   Handle to the underlying CCD factory that can create CCD types where required

HL7Connect.Exchange.TransferredDocument CreateTransferredDocument();
   Create a transferred Document ready for use with sending and/or receiving Documents

HL7Connect.Cda.BaseList1 XPath(HL7Connect.Cda.Base oRoot, string sExpression);
   Select a set of objects by an XPath expression.

The first parameter is the root for the XPath expression. To start at the root of the document, pass the CDA document itself, or nil.

The second parameter is an XPath statement such as //v3:recordTarget/v3:patientRole/v3:id The namespace 'v3' is required on elements or the xpath won't work. Other namespaces that can be used in the XPath are xsi and the xml namespace itself.

The return value is a list of the objects that match the selected XPath statement. The objects may be any of the Cda, structured text or data types. Only objects that have an element can be selected. Although you can execute xpath statements that match text, attributes, comments etc, these will never be able to be matched to any matching object, and nothing will be returned.

For instance, executing the xpath above with the CDA document itself as the root will return the list of Iv3II identifiers for the patient.

Note that the XPath statements operate on the original parsed XML, and the XML is not updated as the object model itself is changed. So if you add an identifier to the list of patient identifiers in a script, then execute the XPath above, the new identifier will not be returned. Further, deleting an identifier from the list, then rerunning the XPath statement, and trying to access the deleted object will cause unpredictable results (technically, the link from the XML back to the object model is not reference counted)

Technical Note: The XPath expression is evaluated by the MSXML engine.

void ExecuteScript(string script, string entryPoint, string language, string param, bool wantDebug, HL7Connect.Cda.Base context);
   pass a CDA Object to vbscript, javascript, COM, or OCL.

script: the name of a file containing the source, or the source itself entrypoint: the name of the procedure to run, or the coclass name for com language: the name of the language to use. will be inferred from the file extension of the script if there is one. wantDebug: when using windows script host context: the object on which the scripting will occur - either a IcdaClinicalDocument, any other CDA class, any data type, or any structured text object

Note that the script can change the contents of the object passed to it. Any handles that the host retains to contents of the objects may be invalid after it executes (except for OCL, which cannot change the object)

1. Windows Script Host

If the language is "VBScript", "JScript", or any other language string the Windows Script Host recognises, or if the file extension is (".vbs, *.js,

  • .py, *.pl).
The script procedure is invoked with a single parameter which is an IExecuteCDAEvent event. The kernel objects therwise available in when using scripts in HL7Connect will be null except for the WScript equivalent object.

The script engine is Windows Script Host, like the rest of HL7Connect. The want debug flag is passed through to the windows script host engine for whether to invoke the debugger or not.

2. COM

If the language is "COM", the script is ignored. The entry point is the coclass name of a registered class that implements the IHL7ConnectEventHandler interface (start mode is single threaded), which will be passed a IExecuteCDAEvent.

3. OCL

if the language is "OCL" or he file extension is ".ocl", the ocl provided will be executed against the message. If any assertions in the ocl script fail, an exception will be raised containing the details

HL7Connect.Cda.ClinicalDocument BuildByKScript(string script);
   Build an IHL7Message by executing a KScript. The KScript must build a valid CDA document. The script may be either a filename or the KScript directly

© Kestral Computing P/L 2000 - 2003. HL7Connect v2.00-063 generated on 30-Nov 2015.
Keywords: XPath, CDAFactory, CDAManager, Clone, BuildByKScript, CCDFactory, CreateCCD, CreateCCDFromDocument, CreateDocument, ExecuteScript, GetPatientId, CreateDocumentFromStream, CreateTransferredDocument, SaveDocumentToStream, SaveDocumentToStreamWithFormat, HL7Connect.Services.CDAManager