Vous êtes sur la page 1sur 74

Clinical Documentation Solution Accelerator

Developer's Guide

Thursday, 15 April 2010 Version 1.0.0.0

Prepared by Microsoft

Microsoft

The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. The descriptions of other companies products in this document, if any, are provided only as a convenience to you. Any such references should not be considered an endorsement or support by Microsoft. Microsoft cannot guarantee their accuracy, and the products may change over time. Also, the descriptions are intended as brief highlights to aid understanding, rather than as thorough coverage. For authoritative descriptions of these products, please consult their respective manufacturers. 2010 Microsoft Corporation. All rights reserved. Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. SNOMED CT is a registered trademark of the International Health Terminology Standards Development Organization. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. Page ii Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

TABLE OF CONTENTS
1 2 Introduction .............................................................................................................................. 1 Overview of the CDSA Development Environment ................................................................. 3 2.1 2.2 2.3 System Prerequisites ........................................................................................................... 3 Assumed Skills and Knowledge ........................................................................................... 3 Building the CDSA Solution in Visual Studio......................................................................... 4 Visual Studio 2008.......................................................................................................... 4 Visual Studio 2010.......................................................................................................... 4 Office Word 2007 ........................................................................................................... 4 Office Word 2010 ........................................................................................................... 5

2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.5 2.6 2.7 3

Debugging the CDSA Add-in using Visual Studio ................................................................. 4

Installing the CDSA Office Word Add-in ............................................................................... 5 The CDSA Source Folders................................................................................................... 6 Accessing the CDSA Development Environment.................................................................. 6

Constructing a Template Using the Included Controls........................................................... 9 3.1 3.2 3.3 3.4 Introduction.......................................................................................................................... 9 Inserting and Formatting Office Word Tables ....................................................................... 9 Adding and Modifying the CDSA Controls .......................................................................... 10 Deleting Controls ............................................................................................................... 16

Creating a Simple Control ...................................................................................................... 17 4.1 4.2 Introduction........................................................................................................................ 17 Creating the Name Input Control ........................................................................................ 18

Customising the Layout of an Existing Control .................................................................... 21 5.1 5.2 Introduction........................................................................................................................ 21 Creating the Customised Single Concept List Control ........................................................ 21

Creating a WPF-Based Control .............................................................................................. 26 6.1 6.2 Introduction........................................................................................................................ 26 Creating the WPF-Based Control ....................................................................................... 28

Creating a WPF-Based List Control ....................................................................................... 39 7.1 7.2 Introduction........................................................................................................................ 39 Creating the WPF-Based List Control................................................................................. 40

Creating an XML Mapping Class ............................................................................................ 55 8.1 8.2 Introduction........................................................................................................................ 55 Creating the New XML File ................................................................................................ 55
Page iii Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

8.3 8.4 8.5 8.6 8.7 8.8 9

Creating a Storage Class ................................................................................................... 58 Creating a Storage Template ............................................................................................. 58 Changing the Storage Class Reference ............................................................................. 61 Mapping Across All Items................................................................................................... 63 Running Custom Code....................................................................................................... 65 Creating a Model ............................................................................................................... 66

Document Information............................................................................................................ 69 9.1 9.2 9.3 Terms and Abbreviations ................................................................................................... 69 Definitions ............................................................................. Error! Bookmark not defined. Nomenclature .................................................................................................................... 69 Body Text ..................................................................................................................... 69 Cross References......................................................................................................... 70

9.3.1 9.3.2 9.4

References ........................................................................................................................ 70

Page iv Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

INTRODUCTION
The Clinical Documentation Solution Accelerator (CDSA) for the Microsoft Office system enables you to provide solutions for users whose task is to create clinically encoded documents. Users write those documents based on the CDSA templates you have designed (for example, for a Discharge Summary or a Referral) and edit them using Microsoft Office Word. CDSA promotes the safety and consistency of clinical documentation by utilising Microsoft Health Common User Interface (CUI) software toolkit controls. Those controls support the embedding of structured, machine-readable clinical information in a human-readable Office Word document that is shareable across care boundaries. The encoding of clinical information is to industry standard formats (such as the Health Level 7 (HL7) Clinical Document Architecture (CDA)). CDSA allows for the direct utilisation of external clinical data in a document (perhaps from a cloud computing or Windows Azure source). Example external data sources include Systematized Nomenclature of Medicine Clinical Terms (SNOMED CT ) encoding services or drug reference data. That combination of features provides the means of creating clinical documents that incorporate complex encoding but which are written using the familiar Office Word interface. Figure 1 provides an example of what the user might see when editing a CDSA document (on the left is the main document and on the right the summary of clinically-encoded terms from it):

Figure 1: Users View When Editing a CDSA-Enabled document

Such documents can act as significant building blocks within an overall healthcare environment. For example, you can incorporate them as the foundation for clinical document workflows (perhaps in combination with Microsoft Office SharePoint Server 2010). To facilitate this, CDSA allows you to: Tailor documents to the specific Electronic Medical Record (EMR) or Electronic Health Record (EHR) systems in your healthcare environment Create clinical documents suitable for upload to a Personal Health Record (PHR) system (such as Microsoft HealthVault) or to other external storage Easily share clinical documents, passing them across care boundaries whilst retaining the clinically encoded data
Page 1 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

More specifically, the CDSA toolkit extends Office Word to provide the functionality indicated for the following groups: For Clinical Template Designers With the CDSA add-in enabled, a template designer can create Office Word templates. In addition to providing a human-readable document, such templates can allow the data entered in the document to be mapped to a machine-readable representation using clinical encoding taxonomies (such as SNOMED CT) For Clinical Document Creators With the CDSA add-in enabled, a user can complete a clinical form created from a CDSA-enabled Office Word template. The one Office Word (.docx) file contains both human-readable and machine-readable clinical information (such as a HL7 CDA representation). For Clinical Document recipients Without the need for the CDSA add-in, a recipient can read (but not edit) the Office Word document. The document .docx file still contains the machine-readable clinical information and this can be extracted and uploaded to an external clinical system. The remainder of this document provides background information and worked examples to illustrate how you can customise CDSA for your own purposes. The topics covered are: Overview of the CDSA development environment (see section 2) Constructing a template using the included controls (see section 3) Creating a simple control (see section 4) Customising the layout of an existing control (see section 5) Creating a Windows Presentation Foundation (WPF) based control (see section 6) Creating a WPF-based list control (see section 7) Creating a mapping class (see section 8)

Page 2 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

OVERVIEW OF THE CDSA DEVELOPMENT ENVIRONMENT

2.1

System Prerequisites

To run and use the CDSA development environment requires a system matching at least the following requirements. Your computer must be running one of the following operating systems: Windows 7 Windows Vista Service Pack 1 With Windows Vista, you also need Microsoft .NET Framework 3.5 Service Pack 11 Windows XP Service Pack 3 With Windows XP, you also need Microsoft .NET Framework 3.5 Service Pack 11 Your computer must have these applications installed: Microsoft Office Word 2010 or Microsoft Office Word 2007 With Microsoft Office Word 2007, you also need: 2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies2 Microsoft Visual Studio Tools for the Microsoft Office System (version 3.0 Runtime) (x86)3 Microsoft Visual Studio Tools for the Microsoft Office System (version 3.0 Runtime) 4 Service Pack 1 (x86)

Microsoft Visual Studio 2008 Service Pack 1 or Microsoft Visual Studio 2010

2.2

Assumed Skills and Knowledge


Expertise with Office Word, in particular an in-depth knowledge of table formatting and the creation of templates General understanding of Microsoft Visual Studio and its underlying platform technology

This guide assumes that you have at least the following technical knowledge and skills:

Guidelines on the skill sets required in order to make best use of CDSA, as well as reference material and training resources, are detailed on the Microsoft TechNet Web site5. However, the use of Microsoft courses and resources are optional and training on a number of relevant areas can be provided by a variety of certified training partners.

1 2 3 4 5

Downloadable from Microsoft .NET Framework 3.5 Service Pack 1 Downloadable from Redistributable Primary Interop Assemblies Downloadable from Visual Studio Tools for the Microsoft Office System Downloadable from Visual Studio Tools for the Microsoft Office System Service Pack 1 Microsoft TechNet {R1} : http://technet.microsoft.com/ Page 3 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

2.3

Building the CDSA Solution in Visual Studio

You can build the CDSA solution in either Visual Studio 2008 or Visual Studio 2010. Obtain the CDSA solution files by downloading the Microsoft.Cdsa.zip file 6.

2.3.1

Visual Studio 2008

To build the CDSA solution in Visual Studio 2008, follow these steps: 1. Extract all the files from the Microsoft.Cdsa.zip file into their default file structure 2. Navigate to the \Microsoft.Cdsa\Solutions\Main folder and open the Main.sln file 3. Press F6 to build the solution

2.3.2

Visual Studio 2010

The CDSA solution has been created by Visual Studio 2008. The solution needs to be upgraded for use with Visual Studio 2010. To do so, follow these steps: 1. Extract all the files from the Microsoft.Cdsa.zip file into their default file structure. 2. Navigate to the \Microsoft.Cdsa\Solutions\Main folder and open the Main.sln file 3. Follow the steps in the Visual Studio Conversion Wizard to upgrade the solution to Visual Studio 2010 4. A dialog box will appear asking Do you want to upgrade the Web site to use .NET Framework 4.0? Select the Do the same for all Webs check box and click No 5. When the solution has opened, right-click on the Microsoft.Consulting.OfficeTools.Controls project and select the Properties > Code Analysis tab 6. Disable the code analysis rule CA1903 - Microsoft.Portability: Use only API from targetted framework listed under Portability Rules by clearing the check box 7. Disable the same rule for the Microsoft.Consulting.Services project 8. Press F6 to build the solution

2.4

Debugging the CDSA Add-In Using Visual Studio

You can run the Office Word add-in project in debug mode using Visual Studio for either Office Word 2007 or Office Word 2010.

2.4.1

Office Word 2007

To run in debug mode for Office Word 2007, follow these steps: 1. In Solution Explorer, check that the Microsoft.Consulting.OfficeTools.WordAddin project is set as the start-up project by default (the project name should be displayed in bold). If it is not, right-click the project and select Set as StartUp Project 2. Press F5 to launch Office Word with the CDSA add-in enabled

Downloadable from http://www.codeplex.com/cdsa Page 4 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

2.4.2

Office Word 2010

To run in debug mode for Office Word 2010, follow these steps: 1. In Solution Explorer, check that the Microsoft.Consulting.OfficeTools.WordAddin project is set as the start-up project by default (the project name should be displayed in bold). If it is not, right-click the project and select Set as StartUp Project 2. Right-click on the Microsoft.Consulting.OfficeTools.WordAddin project and select the Properties > Debug tab 3. Set the Start Action by selecting the Start external program radio button. 4. Navigate to the location of the Office 2010 WINWORD.EXE file (usually C:\Program Files\Microsoft Office\Office14\WINWORD.EXE) 5. Press F5 to launch Office Word with the CDSA add-in enabled

2.5

Installing the CDSA Office Word Add-In

The CDSA solution includes a set-up project (Microsoft.Consulting.OfficeTools.WordAddin.Setup) that creates a sample MSI. You can use this to install the CDSA Office Word add-in on a per-user basis (that is, for the current user only). The sample installer performs the following actions: Installs the CDSA Office Word add-in for the current user Adds a new registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\Microsoft.Consulting.OfficeTools.WordAddin

Copies the following files to the installation folder: All assemblies used by the CDSA Office Word add-in Schemas for native CDSA XML The CDSABuildingBlocks Word template Unlocked versions of the sample CDSA Office Word templates (for developer demonstration purposes)

By default, the installation folder is:


C:\Users\<username>\AppData\Roaming\Microsoft\Clinical Documentation Solution Accelerator

Copies the sample CDSA Office Word templates to the Clinical Documents folder in the users Templates directory. Those versions of the templates are locked and end users can only update the content of the form fields. On Windows 7 and Windows Vista, the Templates directory is:
C:\Users\<username>\AppData\Roaming\Microsoft\Templates\Clinical Documents Note The sample installer does not check for prerequisites before installing CDSA. When creating a version of the installer for a production environment, you may need to create different versions of the installer for Office 2007 and Office 2010 (Office 2007 has a number of prerequisites that are not required for Office 2010). See the ReadMe.txt for a full list of the end-user prerequisites.

Page 5 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

2.6

The CDSA Source Folders


Content
Two sample Office Word templates (.dotx files) built using CDSA controls: Cardiology Referral form Cardiology Referral form (Unlocked) Discharge Summary form Discharge Summary form (Unlocked)

Table 1 describes the directory structure of the CDSA source and the content of each folder:

Directory
Sample Forms

Microsoft.Cdsa.Services.Common Microsoft.Consulting.Data Microsoft.Consulting.OfficeTools.Controls

Service contracts for the Terminology Service and the Drug Service and data contracts for the Terminology service Data contracts for the Drug Service All controls-related classes including: CDSA section controls WPF controls used by the section controls Layout for the WPF controls on the Document Summary task pane Helper classes for the controls Base storage class and sample classes for the Referral and Discharge Summary forms Referral and Discharge Summary mappings and schema files Model class used by the storage class

Microsoft.Consulting.OfficeTools.WordAddin

The CDSA Office Word add-in project including: Ribbon class Developer Properties window implementation Document Summary task pane implementation

Microsoft.Consulting.OfficeTools.WordAddin.Setup Microsoft.Consulting.Services

Setup project that builds a sample Microsoft Installer (MSI) to install the CDSA Office Word add-in and the two sample templates on a per-user basis Windows Communication Foundation (WCF) service interfaces for: The sample SNOMED CT Terminology Service (TerminologyService.svc) The sample medications Data Service (DrugService.svc)

Table 1: CDSA Directories and Folder Content

2.7

Accessing the CDSA Development Environment

To access the CDSA development environment after installing the CDSA Office Word add-in, follow these steps: 1. Start Office Word 2. Click the CDSA Developer tab. If it is not visible, take these steps first: a. Click the CDSA User tab b. From the CDSA User ribbon, click the Developer Tab button

Page 6 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Figure 2 shows what the CDSA developer ribbon looks like when you first access it:

Figure 2: CDSA Developer Ribbon

Table 2 describes the function of each button on the CDSA developer ribbon:

Button

Description
Converts an Office Word document into a CDSA document by creating the correct XML configuration. You use this tool as the first step in developing a CDSA-compliant document. Until this is done, CDSA disables all of the other developer ribbon buttons. Accesses the configuration and data details of the controls in the document.

Opens the library of built-in controls that you can use in your CDSA document. You can also add controls to the Section Gallery that you have implemented. A control placed in a document is referred to as a section. Table 3 details the controls available in the Section Gallery. Removes a section from your CDSA document. You have to select the section before you can delete it.

Ensures all sections are updated according to the latest configuration and are bound to the native XML. You use this after making amendments to controls or changing other CDSA document definitions. Accesses the array of built-in section building-blocks that you can use to create your own controls. A section building block is referred to as a part. Table 4 details the parts available in the Custom Parts Gallery.
Table 2: CDSA Developer Buttons

If you are implementing a new CDSA template, you can make use of the built-in sections already available in the Section Gallery. Table 3 lists and describes the sections in the Section Gallery:

Section Name
Address Field Allergies Concept List Check Box Date Field Drop Down List Free Text Parser Medication List

Description
Multi-line address entry fields with labels Allergy search and list control with date and status settings (provides encoding) Simple check box with label Automatic and free-text date entry Selection menu with prompt watermark text Clinical terms search and list control based on user entered free-text (provides encoding) Medications search and list control (provides encoding)
Page 7 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Section Name
Mini Patient Banner Patient Banner Radio Button Single Concept List (no date) Single Concept List (with date) Text Field
Table 3: Section Gallery

Description
Simplified patient details banner with labels Full patient details banner with labels Simple radio button with label Single concept search and list control either without date support (provides encoding) Single concept search and list control either with date support (provides encoding) Simple text entry field with prompt watermark text

If you are implementing a new CDSA control, you can make use of the built-in parts available in the Custom Parts Gallery, each of which provides a rich text content control placeholder. Table 4 lists and describes the parts in the Custom Parts Gallery:

Part Name
Action Control Insertion Part Section Edit Button Insertion Part Section Line Delete Button Insertion Part Section Line Edit Button Insertion Part Section Line Part Section Lines Insertion Part Section Part Word Control Insertion Part
Table 4: Custom Parts Gallery

Description
Placeholder for a .NET Framework control Placeholder for a Section Edit button Placeholder for a lines Delete button Placeholder for a lines Edit button Placeholder for a line layout Placeholder for a sections line insertion table Constructs a section layout. Adds a new section to the document and to the Developer Properties window Placeholder for an Office Word Visual Basic for Applications (VBA) control

The worked examples in the remainder of this guide describe how you can use the CDSA development environment to create and customise your own CDSA-compliant documents.

Page 8 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

CONSTRUCTING A TEMPLATE USING THE INCLUDED CONTROLS

3.1

Introduction

The CDSA software includes a number of ready-made controls for you to use when constructing your Office Word templates. You can also use controls of your own making, as described in section 7. However, the built-in controls provide a wide range of functionality and you may find that they are sufficient to implement all of the features you need. You construct a template by using the tools and facilities provided by the CDSA development environment (as described in section 2.3). After starting Office Word, you must open the CDSA Developer tab and click the Convert To Clinical Document button to begin the development process. In outline, the steps involved in constructing a template are: 1. Insert and format Office Word tables to structure your document (for ease of layout and usability purposes, most controls are located in tables) (see section 3.2) 2. Add and modify the required controls (see section 3.3) 3. Delete controls to fine-tune the template layout (see section 3.4) To guide you in implementing your template, the remainder of this section provides more details and examples to illustrate each of those steps.

3.2

Inserting and Formatting Office Word Tables

You use the standard table insertion and layout features of Office Word to create the outline structure of your document. An example set of steps you might follow would be: 1. Insert a table with enough columns and rows to match your input requirements 2. Turn on gridlines to help track the layout of the cells 3. Adjust the size and other features of the cells to match the layout you require 4. Add narrow rows as spacers to separate distinct blocks of the table 5. Use the first row as a header for the material in the table (for example, by adding special formats such as a different background shade with an external border and the text in a coloured font) 6. Prepare the cells that will hold the controls (for example, to emphasise that these are input areas, configure borders around the cells and add an appropriate label to each) When you have completed the outline structure, you can move on to include the CDSA controls that will help your users add their information to the document.

Page 9 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

3.3

Adding and Modifying the CDSA Controls

Although the provided controls offer a wide range of functionality, when adding each one to your template you follow the same top-level procedure: 1. Place the cursor where you want to locate the control 2. Insert the control you require by selecting from the Section Gallery in the CDSA Developer ribbon 3. Click the Developer Properties button and open the controls Configuration screen. Enter a unique Section Id for it 4. If required for your implementation, modify other Configuration screen parameters (for example, to modify label or watermark text) At its simplest, you can use a control in your template just by taking steps 1 to 3. However, the controls also allow you to customise them according to your needs. The remainder of this section provides examples of how you do this by detailing how to add and customise the most useful controls for clinical documents. The examples include controls for entering relatively basic text: Text Field Where a user enters plain text Address Field Where a user enters an address There are also more sophisticated search and match controls to help your users find and enter specific medical terms: Medication List Helps the user build a list of drug prescriptions Single Concept List Helps the user build a list of descriptive terms and concepts (such as symptoms) Free Text Parser Identifies medical terms and concepts from a free-text description entered by the user Additional controls assist the users in selecting from pre-defined options: Drop Down List Where a user selects from a menu of items Radio Button Where a user selects or deselects an item

Page 10 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Table 5 describes how you add and modify each of those controls:

Step Description Adding a Text Field


1. Select the control you want to insert. In this case, create a simple text entry control by selecting Text Field. Note Some controls include paragraph spaces before and after them. Delete if not required. 2. The Text Field control displays default watermark text. To edit this: 1. In the Office Word Developer ribbon, click Design Mode 2. Edit the text as required 3. Click Design Mode to exit 3. As templates can contain a lot of controls, it is good practice to alter the Section Id of each control as you add it. This ensures the Section Id has a more meaningful name for future reference. Alter the Section Id by: 1. In the CDSA Developer ribbon, click Developer Properties 2. Select the control from the left pane 3. Click the Configuration tab 4. Edit the text in the Section Id field so it is specific to this section of the document or is otherwise meaningful to you 5. Click elsewhere in the pane to save the new Section Id 6. Exit the Clinical Documentation Developer Window to return to your document Remember to repeat these steps for every control you add

Screenshot

Page 11 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step Description Adding an Address Field


1. Another commonly required component of a document is a section to hold an address. To include this, select Address Field from the Section Gallery.

Screenshot

2.

To edit the labels: 1. In the Office Word Developer ribbon, click Design Mode 2. Edit the text as required 3. Click Design Mode to exit

Adding a Medication List


1. To include a Medication List, select it from the Section Gallery. This control supports the formal encoding of terms. Therefore, including it in your document also creates an entry in the Document Summary panel 2. Besides altering the Section Id, you can also modify the display and label text. To do so, click Developer Properties and edit these Configuration fields for the control: Display Name Modifies the section header displayed in the Document Summary pane Word Control Label Modifies the label on the Add button Section Line Edit Button Label Modifies the label on the Edit button (only visible after the user has added a medication to the list) Section Line Delete Button Label Modifies the label on the Delete button (only visible after the user has added a medication to the list)

Page 12 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step Description
To include Single Concept Matching, select it from the Section Gallery. This control supports the formal encoding of terms. Therefore, including it in your document also creates an entry in the Document Summary panel 2. Besides altering the Section Id, display and label text, you can also specify the terminology to search through and modify the controls watermarks. To do so, click Developer Properties and edit these Configuration fields for the control: SearchSubset Specifies the clinical terminology subset that CDSA will search against ConceptSearchWatermark Modifies the watermark in the Concept Search box AdditionalTextWatermark Modifies the watermark in the Additional Text box

Screenshot

Adding Single Concept Matching List


1.

3.

You can also alter the headings used in the display of the concepts. To do so, in the Office Word Developer ribbon, click Design Mode and follow these steps: 1. In the document, select the heading to change 2. Click Properties 3. Uncheck the Contents cannot be edited box and click OK 4. Modify the heading 5. Click Properties and recheck the Contents cannot be edited box 6. Click OK and click Design Mode to exit

Page 13 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step Description Adding a Free Text Parser


1. To include a Free-Text parser, add it from the Section Gallery. This control supports the formal encoding of terms. Therefore, including it in your document also creates an entry in the Document Summary panel 2. Change the Section Id as described previously. As also described previously, you can alter other aspects of the freetext parser operation and display by modifying the appropriate fields in the Configuration tab.

Screenshot

Page 14 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step Description Adding a Drop Down List


1. To include a drop-down list, add it from the Section Gallery.

Screenshot

2.

Change the Section ID as described previously. To add items to the drop-down list: 1. Select the list 2. In the Office Word Developer ribbon, click Properties 3. In the Content Control Properties screen, click Add 4. On the Add Choice screen, enter the details for the menu item 5. Click OK 6. Repeat steps 3, 4 and 5 for each item you want to add to the menu 7. When complete, click OK

Page 15 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step Description Adding a Radio Button


1. To include a radio button, add it from the Section Gallery. Add as many radio buttons as needed to match the number of options you wish to offer your users. 2. Besides altering the Section Id, you will also need to specify a label for each button and a group name that they share. To do so, click Developer Properties and edit these Configuration fields for the control: Word Control Label Specifies the label that appears beside the button GroupName Specifies an identifier for this group of buttons (use the same identifier for all the buttons in this group)

Screenshot

Table 5: Adding Controls to the Template

3.4

Deleting Controls

As you progress with the development of your template, you may decide that controls entered earlier are no longer needed. However, because CDSA documents are structured, you cannot simply delete controls as you would normally delete items from an ordinary Office Word document. Instead, you have to use the CDSA Delete Section tool. To delete a control using the Delete Section tool: 1. Select all of the control that you wish to delete 2. Open the CDSA Developer ribbon 3. Click Delete Section 4. To ensure the document is cleanly updated, click Refresh All Sections

Page 16 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

4
4.1

CREATING A SIMPLE CONTROL


Introduction
CDSA controls are made up of parts. Each part is an Office Word content control that has a specific title and/or tag. For more advanced controls, you can insert buttons and .NET controls to handle user input.
Note Not all types of Office Word content control can be bound to the CDSA XML. For example, plain text and drop down lists can be bound but a rich text content control cannot. Therefore, when designing a new control, it is important that you identify which of its areas need to display bound content and which are placeholders for buttons or .NET controls.

This section describes the steps to take when building a simple control. The control used as an example is a name input control that provides fields for the user to enter a family name, a given name and a title. The example shows how the control is constructed from: An outer section content control (a CDSA Section Part) Inner plain text content controls for each field (Office Word content controls) When the control is complete, the example goes on to show: How to bind the control to the CDSA XML How to add the control to the CDSA Section Gallery for use in other documents When adding a new control, you always begin by following the same steps: 1. Start Office Word 2. Open the CDSA Developer tab and click the Convert To Clinical Document button to begin the development process Having done that, you can continue to develop your new control. Follow the steps in the next section to see how this is done for the example name input control.

Page 17 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

4.2
Step
1.

Creating the Name Input Control


Description
In the Custom Parts Gallery menu, select Section Part to insert it in your document

Table 5 shows the steps required to create a simple name input control:

Screenshot

2.

In the Insert ribbon, click Table. Format the table to match the layout requirements for your control. For the example name input control, the layout is: Two columns (resized to fit the content) and three rows No borders Add labels in the first column (Family name, Given name and Title), right-aligned and italic

3.

Insert plain text content controls in each cell of the second column. In the Controls group of the Office Word Developer ribbon, click the button to insert each one.

4.

Select each plain text content control in turn and follow these steps: 1. In the Controls group, click Properties 2. Enter a name for the control in the Title field (respectively Family name, Given name and Title) 3. Click OK

Page 18 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
5.

Description
You may want to change the watermark text displayed (Click here to enter text). To edit this: 1. In the Office Word Developer ribbon, click Design Mode 2. Edit the text as required 3. Click Design Mode to exit Note Design Mode shows the beginning and end section tags and all the fields inside. This lets you see the range your control uses.

Screenshot

6.

Office Word includes paragraph spaces before and after the table to prevent it interfering with the section controls. To better align the table: 1. Place your cursor in the paragraph space 2. In the Home ribbon, open the Paragraph dialog 3. In Spacing, set Before and After to a suitable value 4. From the Line Spacing menu, select Exactly and use the At field to set a suitable height

7.

In the CDSA Developer ribbon, click Refresh All Sections. This updates the new control and creates bindings for it in the CDSA XML using the Content Control Properties title as the name for the binding.

Page 19 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
8.

Description
You can see that your new control (now identified as a CDSA section) is in place by: 1. In the CDSA Developer ribbon, click Developer Properties 2. Select the section in the left pane 3. Click the Data tab Three new UniqueIdentifiers match the plain text content controls you defined. The Developer Properties screen will also reflect content entered in the fields in the document.

Screenshot

Table 6: Creating a Simple Control

Page 20 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

5
5.1

CUSTOMISING THE LAYOUT OF AN EXISTING CONTROL


Introduction
The example in this section describes the steps you take to create a customised version of one of the built-in CDSA controls. The example chosen is that of a single concept list control. To create a custom layout for a single concept list control, you need to include the following parts in your control layout: An outer section content control (a CDSA Section Part) A section line insertion point content control (a CDSA Section Lines Part) An action control insertion point content control (a CDSA Action Control Part) A word control insertion point content control (a CDSA Word Control Part) Each of those parts is available from the CDSA Custom Parts Gallery. As before, when adding a new control, you always begin by following the same steps: 1. Start Office Word 2. Open the CDSA Developer tab and click the Convert To Clinical Document button to begin the development process Having done that, you can continue to create your customised control. Follow the steps in the next section to see how this is done for the example single concept list control.

5.2
Step

Creating the Customised Single Concept List Control


Description
In the Custom Parts Gallery menu, select Section Part to insert it in your document Add some extra paragraphs inside the Section Part to make it easier to insert the other components of the layout.

Table 5 shows the steps required to create the customised single concept list control:

Screenshot

Inserting Parts and Formatting the Layout


1.

2.

For this custom layout, the part that will provide the search control goes in first: 1. Position the cursor on the first paragraph 2. In the Custom Parts Gallery menu, select Action Control Part to add it This provides a rich text content control as a placeholder for the WPF control that will support searching later.

Page 21 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
3.

Description
Add an insertion point for the Add button at the second paragraph: 1. Right-align the second paragraph 2. In the Custom Parts Gallery menu, select Word Control Part to add it

Screenshot

4.

Add a part to position the other lines that will make up the layout: 1. Position the cursor at the paragraph below the Word Control Part 2. In the Custom Parts Gallery menu, select Section Lines Part to add it This provides a rich text content control as a placeholder for the lines that will display the list of search results.

5.

Format the lines in the layout using a table: 1. Position the cursor in the Section Lines Part 2. In the Insert ribbon, click Table Create the layout in this fixed order: 1. Two rows 2. Each row distinctly shaded with a rule below the first and the last 3. No other borders 4. All cell margins = 0

6.

To format the headings, insert another table in the top row with these features: First column width = 35% Second column width = 65% All cell margins = 0 No borders Enter Diagnosis in the first column and Additional Text in the second. Make both bold italic.

Page 22 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
7.

Description
Remove any unwanted space: Set the bottom row height to hide it from view leaving just the table headings visible Delete unneeded paragraphs and modify the size of those remaining to achieve the desired layout (for example, Office Word allows a minimum Multiple line spacing of 0.06)

Screenshot

Adding Control Assembly and Class Information


1. Configure the control properties: 1. In the CDSA Developer ribbon, click Developer Properties 2. Select the section in the left pane 3. Click the Configuration tab Complete the Common Properties fields as follows: Section Id DiagnosisList Display Name Diagnosis List This appears in the Document Summary pane Word Control Label Add Diagnosis This is the label for what will be the Add button Section Line Edit Button Edit This is the label for what will be the Edit button Section Line Delete Button Delete This is the label for what will be the Delete button

Page 23 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
2.

Description
This control is a customised version of the built-in Single Concept List control. Therefore, configure the Section Class Properties fields to match those of the Single Concept List control. The simplest way to do this is to: 1. Position the cursor on an empty line 2. Select Single Concept List from the Section Gallery to insert it 3. Open Developer Properties and use it to move between the configurations 4. Copy the individual Single Concept List settings and paste them into the Configuration tab for your control 5. Use the Delete Section tool to remove the Single Concept List section when you have finished The settings are as shown in the screenshot.

Screenshot

Initialising, Customising and Testing the Control


1. In the CDSA Developer ribbon, click Refresh All Sections. This initialises the control using the assembly information you entered in the previous step.

Page 24 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
2.

Description
Examine and if necessary modify the custom properties inherited from Single Concept List Control: 1. In the CDSA Developer ribbon, click Developer Properties 2. Select DiagnosisList from the left pane 3. Click the Configuration tab For example, to modify the watermark prompt displayed in the additional text field, edit the AdditionalTextWatermark field. When done, exit the Clinical Documentation Developer Window.

Screenshot

3.

To test that the control works: 1. Click the Add Diagnosis button The WPF search control displays above the button 2. In the Search for a concept box, enter Chest pain and click 3. Select the term you want from the list and click Save 4. Repeat steps 1, 2 and 3 but search for hypertension.

4.

As defined in your format: The lines display with rows shaded every second row Edit and Delete buttons enable you to modify the content

Table 7: Customising the Layout of an Existing Control

Page 25 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

6
6.1

CREATING A WPF-BASED CONTROL


Introduction
Simple controls (constructed using the built-in Office Word content controls) Complex, rich-editing controls (constructed using custom-built WPF controls) Section 4 described how to construct a simple control using the Office Word content controls. This section provides a worked example of how to build a complex CDSA control based upon an existing CDSA WPF control.
Important

CDSA provides support for two types of control for use in your clinical document templates:

The example shows how to include an existing WPF control into the CDSA control gallery. It does not
cover how to create a WPF-based control from first principles. To learn more about creating WPF-based controls, consult the relevant articles on the Microsoft Developer Network (MSDN) Web 7 site. In addition, you can find WPF controls in the MSCUI Controls Toolkit .

For further guidance, look at the code for some of the CDSA controls. For example, after inserting a
WPF control into a document, CDSA controls also listen for a number of events raised by Office Word (such as BeforeSave, BeforePrint and SelectionChanged) in order to remove the WPF control from the document if necessary. It is good practice to follow a similar pattern for all controls based on WPF or on other .NET Framework controls.

In the example, you will see how to construct a new CDSA control starting from a WPF-based person-lookup control. That control allows the user to enter some characters and use them to initiate a search against a list of people (such as the names of clinical staff within a hospital stored in a local database).

Available from www.mscui.net Page 26 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Figure 3 shows how such a control might work:

Figure 3: How the WPF-Based Control Might Work

Figure 3 shows the controls sequence of operation: 1. The section in the document shows that no one has yet been selected. It contains a Change button 2. Clicking the Change button causes the WPF control to appear above the section 3. Entering a name and clicking the Search button presents a list of search results, where a result can be selected 4. Clicking the Save button removes the WPF control and displays the selected persons details in the document To create this control, you need to take these steps: Add a new section control to the CDSA Visual Studio solution Create an Office Word building block for the Control Test the new control in a CDSA document To guide you in creating your control, the remainder of this section provides more details and examples to illustrate each of those steps.

Page 27 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

6.2
Step

Creating the WPF-Based Control


Description
In Visual Studio, open the CDSA Solution: 1. Expand the Microsoft.Consulting.OfficeT ools.Controls project 2. In this example, a custom WPF control has already been added to the project, called PersonEntry and the default style and templates are already present in the Generic.xaml file

Table 5 shows the steps required to create a WPF-based control:

Screenshot

Adding a New Section Control to the Visual Studio Solution


1.

2.

Create a new section control to place the Person Entry control in the document and handle the Save and Cancel events. To do this, first create a new class called PersonField

3.

The PersonField class inherits basic behaviour definitions from the provided SectionBase control. Note For security reasons, all sections must derive from SectionBase to prevent execution of code not related to the CDSA solution

namespace Microsoft.Consulting.OfficeTools.Controls { public class PersonField : SectionBase { } }

Page 28 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
4.

Description
Specify the private fields within the class. These fields are:

Screenshot

/// <summary> /// Stores the control wrapper. /// </summary> Wrapper of type private Microsoft.Office.Tools.Word.OLEControl Microsoft.Office.Tools.Word. wrapper; OLEControl /// <summary> PersonEntry of type /// The person entry control. PersonEntry /// </summary> Host of type ElementHost private PersonEntry personEntry; /// <summary> /// The WPF element host. /// </summary> private ElementHost host;

5.

Override the initialisation method to allow addition of a custom configuration value for the watermark in the search field.

public override void Initialize( Microsoft.Office.Interop.Word.ContentControl contentControl) { base.Initialize(contentControl); if (string.IsNullOrEmpty( this.GetConfigurationValue("Watermark"))) { this.AddConfigurationItem( "Watermark", "Enter a search for a person"); } }

6.

Override the EditSection method. protected override void EditSection() CDSA calls EditSection when the { base.EditSection(); user clicks a sections Edit button. this.InsertActionControl(); The button is inserted from the } SectionBase class

Page 29 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
7.

Description
Before inserting the WPF control, check if the WPF control is not already in the document and also check that an action control insertion point was found within the section. If both checks are OK, go ahead and insert the WPF control into the ActionControlInsertionPoint: 1. If necessary, create an instance of the personEntry control. Add handlers to the Save and Canceled events 2. Update the Watermark property to use the value specified in the custom configuration 3.

Screenshot

private void InsertActionControl() { if (this.wrapper == null && this.ActionControlInsertionPoint != null) { if (this.personEntry == null) { this.personEntry = new PersonEntry(); this.personEntry.Saved += new EventHandler(personEntry_Saved); this.personEntry.Canceled += new EventHandler(personEntry_Canceled); }

4.

5.

6.

7. Add the person entry control as a child 8. Lock the action control insertion point. The control is now in the document.

this.personEntry.Watermark = this.GetConfigurationValue("Watermark"); this.host = new ElementHost(); Host the WPF control in a this.host.BackColor = WinForms control (Office Word System.Drawing.Color.White; does not support WPF content this.ActionControlInsertionPoint.LockContents directly in a document) = false; this.wrapper = Create an instance of an ElementHost and set the Microsoft.Office.Tools.Word.Extensions.DocumentExtens background colour to white ions.GetVstoObject( Set the LockContents this.ActionControlInsertionPoint.Range.Document).Cont property to false to enable rols.AddControl( insertion of the control. this.host, Insert the ElementHost into the this.ActionControlInsertionPoint.Range, document. The personEntry this.personEntry.DesiredWidth, control methods set the size at this.personEntry.DesiredHeight, insertion. The method returns string.Format( the wrapper that Office Word uses to host the control. Store System.Globalization.CultureInfo.CurrentCulture, "{0}_PersonEntry_{1}", this locally to allow deletion of this.SectionId, the wrapper when the control is removed from the SectionListXmlHelper.GetUniqueIdentifier())); document. this.host.Child = this.personEntry; this.ActionControlInsertionPoint.LockContents = true; } }

Page 30 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
8.

Description
Add a method called RemoveActionControl that: 1. Deletes the wrapper control from the document 2. Unlocks the action control insertion point 3. Sets the range text to empty to clear out the content control 4. Locks the action control insertion point again and sets focus back to the Edit button

Screenshot
private void RemoveActionControl() { if (this.wrapper != null) { this.wrapper.Delete(); this.wrapper = null; } if (this.host != null) { this.host.Child = null; } this.ActionControlInsertionPoint.LockContents = false; this.ActionControlInsertionPoint.Range.Text = string.Empty; this.ActionControlInsertionPoint.LockContents = true; }

9.

Create an event handler personEntry_Canceled (if it does void personEntry_Canceled(object sender, EventArgs e) not already exist) and call { RemoveActionControl to remove this.RemoveActionControl(); the WPF control from the } document without updating the values

Page 31 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
10.

Description
Create an event handler personEntry_Saved (if it does not already exist). Add a call to RemoveActionControl to remove the WPF control from the document, first saving the information in the control back to the native data XML:

Screenshot
void personEntry_Saved(object sender, EventArgs e) { Office.Core.CustomXMLPart xml =

ElementListXmlHelper.GetElementListPart(this.SectionC ontentControl.Range.Document); ElementListXmlHelper.AddElementNode( xml, "FamilyName", this.SectionId, 1. Create a field for the custom string.Empty, XML part storing the document this.personEntry.SelectedPerson != null ? data 2. Call AddElementNode for each this.personEntry.SelectedPerson.FamilyName : string.Empty); part of the name, passing in the: ElementListXmlHelper.AddElementNode( Custom XML part xml, "GivenName", Element name this.SectionId, Section Id string.Empty, this.personEntry.SelectedPerson != null ? Empty section line ID (as this.personEntry.SelectedPerson.GivenName this is not a list item) : string.Empty); Value ( if no person was selected, pass in an empty ElementListXmlHelper.AddElementNode( string) xml, "Title", 3. Repeat for GivenName and this.SectionId, Title string.Empty, The values in the document this.personEntry.SelectedPerson != null ? update automatically because the this.personEntry.SelectedPerson.Title : plain text content controls in the string.Empty); document are already bound to this.RemoveActionControl(); those elements in the native data } XML.

Creating an Office Word Building Block for the Control


1. To create a reusable Office Word building block, open the CDSABuildingBlocks.dotx template file found in the WordAddin project

Page 32 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
2.

Description
CDSABuildingBlocks.dotx contains all of the building blocks for each of the controls. Each control layout is on a separate page in the document. To change a layout, edit it in these pages and then update the building blocks collection held within the template.

Screenshot

3.

At the end of the document: 1. Add a new page for the new control 2. Add the control title: Person Field 3. Click the CDSA Developer tab (if it is not on view, access it through the CDSA User tab as described in section 2.7). The next steps in creating the building block use options on the CDSA Developer ribbon and the Office Word Developer ribbon. Sections 3 and 4 describe the use of both sets of options.

4.

Insert a Section Part from the Custom Parts Gallery.

5.

Add some paragraphs to create some space and insert an Action Control Insertion Part from the Custom Parts Gallery

6.

Add a table with these features: Three rows and two columns Table width = AutoFit Contents Labels in the left column

Page 33 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
7.

Description
Open the Office Word Developer ribbon and in each cell of the second column: 1. Insert a Plain Text Content Control 2. Select Properties from the Developer ribbon 3. Enter the title for the content control and check the Contents cannot be edited box

Screenshot

8.

Click Design Mode and enter watermark prompt text in each content control. When done, click Design Mode to exit and open the CDSA Developer ribbon again

9.

Add an edit button insertion point by following these steps: 1. Position the cursor below the table 2. Right-align the paragraph 3. Select Section Edit Button Insertion Part from the Custom Parts Gallery

Page 34 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
10.

Description
Click the Developer Properties button to see your new control listed. Next you need to: Set some default properties on the control Point the control at the PersonField class created at the beginning

Screenshot

11.

Select the control name on the Developer Properties screen and set the following values: Section Id = Person Field Section Edit Button Label = Change Section Control Assembly = Microsoft.Consulting.OfficeToo ls.Controls Section Control Class = Microsoft.Consulting.OfficeToo ls.Controls.PersonField. Close the Developer Properties screen.

Page 35 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
12.

Description
Ensure that the section configuration gets used with this building block by following these steps: 1. Click on the section to select it 2. In the Office Word Developer ribbon, click Properties 3. Enter a name in the Title field that is the same as the Section Id set in step 11 (Person Field) 4. Click OK

Screenshot

13.

Save the building block by following these steps: 1. Open the Insert ribbon 2. Click Quick Parts 3. Select Save selection to Quick Part Gallery

Page 36 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
14.

Description
Complete the Create New Building Block fields as follows: Name A unique and meaningful name (in this case, Person Field) Gallery For consistency, add CDSA building blocks to the Custom 1 gallery Category As this is a new section control, select Section Save in Select CDSABuildingBlocks.dotx Note Often, Save in lists two CDSABuildingBlocks.dotx items. Select the top one here. The second is overwritten every time the project is built.

Screenshot

15.

Save the CDSA building blocks template and your new control is ready to use. If you run the project, you can test the control in a document.

Testing the New Control in a CDSA Document


1. To test your new control, follow these steps: 1. Open a new document in Office Word 2. Open the CDSA Developer ribbon 3. Click Convert to Clinical Document 4. Click Section Gallery. You can see that Person Field is now an option 5. Select Person Field to insert it into the document.

Page 37 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
2.

Description
The display shows the Person Field layout, including the Change button

Screenshot

3.

Clicking Change causes the WPF control to appear and you can search for a person

4.

Having found a match, click Save to select the person

5.

CDSA inserts the persons details into the document Clicking Change displays the WPF control again to allow another search and clicking Save again updates the selection

Table 8: Creating a WPF-Based Control

Page 38 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

7
7.1

CREATING A WPF-BASED LIST CONTROL


Introduction
Section 6 covered how to create a simple WPF-based section control. This section covers the creation of a basic list control to input values using the same WPF control (a person-lookup control).
Important

As in Section 6, the example shows how to include an existing WPF control into the CDSA control
gallery. It does not cover how to create a WPF-based control from first principles. To learn more about creating WPF-based controls, consult the relevant articles on the Microsoft Developer Network 8 (MSDN) Web site. In addition, you can find WPF controls in the MSCUI Controls Toolkit .

For further guidance, look at the code for some of the CDSA controls. For example, after inserting a
WPF control into a document, CDSA controls also listen for a number of events raised by Office Word (such as BeforeSave, BeforePrint and SelectionChanged) in order to remove the WPF control from the document if necessary. It is good practice to follow a similar pattern for all controls based on WPF or on other .NET Framework controls.

Figure 4 shows how such a control might work:

Figure 4: How the WPF-Based List Control Might Work

Available from www.mscui.net Page 39 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Figure 4 shows the controls sequence of operation: 1. The section in the document shows that no one has yet been selected. It contains an Add Person button 2. Clicking the Add Person button causes the WPF control to appear in the section 3. Entering a name and clicking the Search button presents a list of search results, where a result can be selected 4. Clicking the Save button removes the WPF control and adds the selected persons details to a new table row in the document. CDSA appends a Delete button to allow the row to be removed later To create this control, you need to take these steps: Add a new section control in the CDSA Visual Studio solution Create an Office Word building block for the control Create another building block to represent a row within the table Test the new control in a CDSA document

7.2
Step

Creating the WPF-Based List Control


Description
In Visual Studio, open the CDSA Solution, and expand the Microsoft.Consulting.OfficeTool s.Controls project. In the example, the custom WPF control named PersonEntry has already been added to the solution and is present in the WPF folder. The default style and templates are already present in the Generic.xaml file located in the Themes folder

Table 5 shows the steps required to create a WPF-based list control:

Screenshot

Adding a New Section Control to the Visual Studio Solution


1.

Page 40 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
2.

Description
Create a new class called PersonList for the new section control in the SectionControls folder

Screenshot

3.

Make the PersonList class inherit the provided SectionListBase class. The SectionListBase class inherits SectionBase and adds virtual methods that are useful when working with list controls. These include methods for populating the lines collection as the control loads and for adding, editing or deleting a line in the table. Note For security reasons, all sections must derive from SectionBase to prevent execution of code not related to the CDSA solution
namespace Microsoft.Consulting.OfficeTools.Controls { class PersonList : SectionListBase { } }

4.

Add the following private fields to the class:

Wrapper of type Microsoft.Office.Tools.Word. /// <summary> OLEControl /// The person entry control. /// </summary> PersonEntry of type private PersonEntry personEntry; PersonEntry Host of type ElementHost
/// <summary> /// The WPF element host. /// </summary> private ElementHost host;

/// <summary> /// Stores the control wrapper. /// </summary> private Microsoft.Office.Tools.Word.OLEControl wrapper;

Page 41 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
5.

Description
Create an override for the Initialize method by adding the code shown opposite. This adds a custom configuration value for the watermark in the search field

Screenshot
public override void Initialize( Microsoft.Office.Interop.Word.ContentControl contentControl) { base.Initialize(contentControl); if (string.IsNullOrEmpty( this.GetConfigurationValue("Watermark"))) { this.AddConfigurationItem( "Watermark", "Enter a search for a person"); } }

6.

Before inserting the WPF control, check if the WPF control is not already in the document and also check that an action control insertion point was found within the section. If both checks are OK, go ahead and insert the WPF control into the ActionControlInsertionPoint: 1. If necessary, create an instance of the personEntry control. Add handlers to the Save and Canceled events 2. Update the Watermark property to use the value specified in the custom configuration

private void InsertActionControl() { if (this.wrapper == null && this.ActionControlInsertionPoint != null) { if (this.personEntry == null) { this.personEntry = new PersonEntry(); this.personEntry.Saved += new EventHandler(personEntry_Saved); this.personEntry.Canceled += new EventHandler(personEntry_Canceled); } this.personEntry.Watermark = this.GetConfigurationValue("Watermark"); this.host = new ElementHost(); this.host.BackColor = System.Drawing.Color.White; this.ActionControlInsertionPoint.LockContents =

3. Host the WPF control in a WinForms control (Office Word does not support WPF content false; directly in a document) 4. Create an instance of an ElementHost and set the background colour to white 5. Set the LockContents property to false to enable insertion of the control.

this.wrapper = Microsoft.Office.Tools.Word.Extensions.DocumentExtensions.Ge tVstoObject(

this.ActionControlInsertionPoint.Range.Document).Controls.Ad dControl( this.host, this.ActionControlInsertionPoint.Range, this.personEntry.DesiredWidth, this.personEntry.DesiredHeight, 6. Insert the ElementHost into the string.Format(

document. The personEntry control methods set the size at insertion. The method returns the wrapper that Office Word uses to host the control. Store this locally to allow deletion of the wrapper when the control is removed from the document.

System.Globalization.CultureInfo.CurrentCulture, "{0}_PersonEntry_{1}", this.SectionId, SectionListXmlHelper.GetUniqueIdentifier())); this.host.Child = this.personEntry; this.ActionControlInsertionPoint.LockContents = true; } }

7. Add the personEntry control as a child 8. Lock the action control insertion point

Page 42 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
7.

Description
Create a new method called RemoveActionControl. This method: 1. Deletes the wrapper control from the document 2. Unlocks the action control insertion point 3. Sets the range text to empty to clear out the content control 4. Locks the action control insertion point again

Screenshot
private void RemoveActionControl() { if (this.wrapper != null) { this.wrapper.Delete(); this.wrapper = null; } if (this.host != null) { this.host.Child = null; } this.ActionControlInsertionPoint.LockContents = false; this.ActionControlInsertionPoint.Range.Text = string.Empty; this.ActionControlInsertionPoint.LockContents = true; } protected override void HandleAddButtonClick() { base.HandleAddButtonClick(); this.InsertActionControl(); }

8.

Create an override for the HandleAddButtonClick method that gets called when the Add button is clicked. Add a call to InsertActionControl to add the WPF control into the document

9.

Create an event handler personEntry_Canceled (if it does void personEntry_Canceled(object sender, EventArgs e) { not already exist) and call this.RemoveActionControl(); RemoveActionControl to remove } the WPF control from the document without creating a line Create an event handler personEntry_Saved (if it does not already exist) and add a call to the CreateSectionLine method to create a new SectionLine in the table: Specify sectionLineId as null so that CDSA will create a randomly generated line id

10.

void personEntry_Saved(object sender, EventArgs e) { Specify SectionLineBase sectionLine = SectionLineBuildingBlockNa this.CreateSectionLine(null, me as this is the name of the this.SectionLineBuildingBlockName); building block that represents }

a line for the table

The default implementation of CreateSectionLine method found in the SectionListBase class checks that the table for insertion exists, adds a row at the bottom of the table and inserts the line building block into the row

Page 43 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
11.

Description
Include these additions in the personEntry_Saved event handler:

Screenshot

void personEntry_Saved(object sender, EventArgs e) { SectionLineBase sectionLine = this.CreateSectionLine(null, 1. Add code to add the line data this.SectionLineBuildingBlockName); if (sectionLine != null) to the native data XML { Office.Core.CustomXMLPart xml = 2. Add a call to CreateBindings for the sectionLine instance ElementListXmlHelper.GetElementListPart(this.SectionContentC ontrol.Range.Document); This finds all plain text content ElementListXmlHelper.AddElementNode(xml, controls in the line and binds "FamilyName", this.SectionId, sectionLine.SectionLineId, this.personEntry.SelectedPerson != null ? them to the native data XML this.personEntry.SelectedPerson.FamilyName : string.Empty); using the section ID, the ElementListXmlHelper.AddElementNode(xml, section line ID and the content "GivenName", this.SectionId, sectionLine.SectionLineId, this.personEntry.SelectedPerson != null ? control title. this.personEntry.SelectedPerson.GivenName : string.Empty); 3. Add a call to InsertControls ElementListXmlHelper.AddElementNode(xml, "Title", for the sectionLine instance this.SectionId, sectionLine.SectionLineId, this.personEntry.SelectedPerson != null ? to add an edit and delete this.personEntry.SelectedPerson.Title : string.Empty);

button for the line, if required

4. Add the sectionLine instance to the controls SectionLines collection 5. Call RemoveActionControl to remove the WPF control from } the document 12. Create an override for the DeleteSectionLine method that gets called when the Delete button is clicked on a line. When the user clicks Delete, the base class will present a dialog box asking for confirmation of the deletion 13. Use the DeleteSectionLine method to remove all lines from the native data XML associated with the current SectionId and SectionLineId.

sectionLine.CreateBindings(); sectionLine.InsertControls(); this.SectionLines.Add(sectionLine); } this.RemoveActionControl();

protected override void DeleteSectionLine(SectionLineBase sectionLine) { base.DeleteSectionLine(sectionLine); }

protected override void DeleteSectionLine(SectionLineBase sectionLine) { To do this, the code: base.DeleteSectionLine(sectionLine); Office.Core.CustomXMLPart xml = 1. Unlocks the ElementListXmlHelper.GetElementListPart(this.SectionContentC SectionLineInsertionPoint ontrol.Range.Document); ElementListXmlHelper.DeleteSectionLineNodes(xml, 2. Deletes the this.SectionId, sectionLine.SectionLineId); SectionLineContentControl this.SectionLineInsertionPoint.LockContents = false; sectionLine.SectionLineContentControl.Delete(true); 3. Removes the row from the line sectionLine.Row.Delete(); insertion table this.SectionLineInsertionPoint.LockContents = true; this.SectionLines.Remove(sectionLine); 4. Locks the

SectionLineInsertionPoint again

5. Removes the line from the SectionLines collections

Page 44 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step

Description
To create a reusable Office Word building block, open the CDSABuildingBlocks.dotx template file found in the WordAddin project

Screenshot

Creating an Office Word Building Block for the Control


1.

2.

At the end of the document: 1. Add a new page for the new control 2. Add the control title: Person List 3. Click the CDSA Developer tab (if it is not on view, access it through the CDSA User tab as described in section 2.7). The next steps in creating the building block use options on the CDSA Developer ribbon and the Office Word Developer ribbon. Sections 3 and 4 describe the use of both sets of options.

3.

Insert a section part by selecting Section Part from the Custom Parts Gallery menu

4.

Add some new lines in the section control to create some space. Move back to the top of the control and add a Section Lines Insertion Part at the top of the control

Page 45 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
5.

Description
Insert a table with two rows and select a style with alternate row colours from the Design ribbon

Screenshot

6.

On the Layout ribbon, select AutoFit > AutoFit Window This fits the table to the width of the document

7.

Click Cell Margins and set Left and Right to 0

8.

In the first row, place another table with four columns. Repeat step 6 to make this table stretch the width of the document

9.

Select all four cells. On the Design ribbon, select Borders > No Borders

Page 46 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
10.

Description
Right-click on the table and click the Table Properties > Column tab. Give each column a percentage width, in this case 30%, 30%, 30% and 10%.

Screenshot

11.

Add headings to the table: Family Name, Given Name and Title. The fourth column is for the Delete button

12.

Move the focus to the next row in the table. On the Home ribbon, click the Paragraph > Indents and Spacing tab. To reduce the visibility of the row, set Line Spacing to Multiple at 0.06

Page 47 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
13.

Description
For the line above and the line below the table, repeat the previous step to set the line spacing to 0.06 and the spacing for Before and After to 0 pt Move the focus below the Section Lines table Select Custom Parts Gallery > Action Control Insertion Part to specify where the WPF control will appear

Screenshot

14.

15.

Use the down arrow key to move the focus to the line below, Change the paragraph alignment to Right-aligned and select Custom Parts Gallery > Word Control Insertion Part This completes the main list control building block layout

16.

Move the focus below the section layout. Select Custom Parts Gallery > Section Line Part

17.

Add a table with four columns. On the Layout ribbon, select AutoFit > AutoFit Window. This fits the table to the width of the document

Page 48 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
18.

Description
Right-click on the table. Click the Table Properties > Columns tab. Give each column a percentage width, in this case, 30%, 30%, 30% and 10% to match the headings in the section part

Screenshot

19.

Put the focus in the first column. Click the Developer tab and click the plain text content control button

20.

Click Properties: 1. Set the Title to FamilyName 2. Select the Content cannot be edited check box 3. Click OK

21.

Repeat the previous step for the next two columns using the titles GivenName and Title Move the focus to the last column. Select Custom Parts Gallery > Section Line Delete Button Insertion part. This adds a part to host the lines delete button

22.

Page 49 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
23.

Description
Remove any extra space within the section line: 1. Move the focus to the line above the table 2. On the Home ribbon, click the Paragraph > Indents and Spacing tab 3. Set Line Spacing to Multiple at 0.06 4. Set spacing for Before and After to 0 pt Repeat the same steps for the line below the table

Screenshot

24.

If not already set, enable the Show/Hide button so that Office Word displays the paragraph markers. You need to do this to see the empty paragraphs before and after the section line. You need to size those paragraphs for when Office Word saves the building block. This prevent the section line content controls spanning more than one row in the section lines table

25.

To prevent the leading paragraph taking up space: 1. Set its Line Spacing to Multiple at 0.06 2. Set its spacing for Before and After to 0 pt Repeat the same steps for the paragraph below the section line.

26.

Select the section line and the paragraphs on either side of it. On the Insert ribbon, select Quick Parts > Save Selection to Quick Part Gallery...

Page 50 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
27.

Description
Complete the Create New Building Block fields as follows: Name A unique and meaningful name (in this case, Person List Line 1) Gallery For consistency, add CDSA building blocks to the Custom 1 gallery Category Select SectionLine Save in Select CDSABuildingBlocks.dotx Note Often, Save in lists two CDSABuildingBlocks.dotx items. Select the top one here. The second is overwritten every time the project is built. Click OK to save the building block

Screenshot

28.

On the CDSA Developer ribbon, click Developer Properties

29.

Select PersonList and click the Configuration tab. Complete the Configuration fields as follows: Section Id PersonList Word Control Label Add Person Section Line Delete Button Label Delete Section Control Assembly Microsoft.Consulting.OfficeToo ls.Controls Section Control Class Microsoft.Consulting.OfficeToo ls.Controls.PersonList Section Line Building Block Name Person List Line 1 When done, exit the Developer Properties window.

Page 51 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
30.

Description
Select the Section control. On the Office Word Developer ribbon, click the Properties button

Screenshot

31.

Set the Title to Person List and click OK

32.

On the Insert ribbon, select Quick Parts > Save Selection to Quick Part Gallery...

Page 52 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
33.

Description
Complete the Create New Building Block fields as follows: Name Person List Gallery For consistency, add CDSA building blocks to the Custom 1 gallery Category Select Section Save in Select CDSABuildingBlocks.dotx Note Often, Save in lists two CDSABuildingBlocks.dotx items. Select the top one here. The second is overwritten every time the project is built. Click OK to save the building block

Screenshot

34.

Save the CDSA building blocks template and your new control is complete

Testing the New Control in a CDSA Document


35. 36. In Visual Studio, press F5 to run the CDSA add-in project On the CDSA Developer ribbon, click Convert to Clinical Document

37.

Select Section Gallery > Person List to insert an instance of the new section control

38.

Click Add Person to activate the WPF control to perform a person search. Enter your search string.

Page 53 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Step
39.

Description
Click Save to store the new line

Screenshot

40.

Click Delete to remove a line

41.

Open the Developer window to view the new PersonList section in the document Select the section line items under the PersonList section in the Developer Properties window You can see each of the lines that have been added and the data associated with each of them in the native data XML

42.

Table 9: Creating a WPF-Based List Control

Page 54 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

8
8.1

CREATING AN XML MAPPING CLASS


Introduction
In earlier sections, you have seen how to use and customise various aspects of CDSA to build richly-featured clinical documents. This section provides a worked example of how you might create a custom storage format for the data in your CDSA documents. This worked example is based on the Discharge Summary template provided with CDSA but exports the data into a custom format. The remainder of this section describes in turn the tasks associated with creating the new format: Creating the new XML file Creating a storage class Creating a storage template Changing the storage class reference Mapping across all items Running custom code Creating a model The new format will be called Woodgrove XML.

8.2

Creating the New XML File

The Woodgrove XML format you create must validate against the Woodgrovexml.xsd schema. Figure 5 shows the Woodgrovexml.xsd schema:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="woodgrove:v1" targetNamespace="woodgrove:v1" elementFormDefault="qualified"> <xs:element name="code" type="xs:string"/> <xs:element name="diagnosisatdischarge"> <xs:complexType> <xs:sequence> <xs:element ref="entry" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="dischargingemployeeemail" type="xs:string"/> <xs:element name="dischargingemployeeid" type="xs:string"/> <xs:element name="entry"> <xs:complexType> <xs:sequence> <xs:element ref="text"/> <xs:element ref="code"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="firstname" type="xs:string"/> <xs:element name="hospitaladdressline1" type="xs:string"/> <xs:element name="hospitaladdressline2" type="xs:string"/> <xs:element name="hospitaladdressline3" type="xs:string"/> <xs:element name="hospitalcountry" type="xs:string"/> <xs:element name="hospitalcounty" type="xs:string"/> Page 55 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

<xs:element name="hospitalpostcode" type="xs:string"/> <xs:element name="hospitaltown" type="xs:string"/> <xs:element name="lotsofotherinformation" type="xs:string"/> <xs:element name="patientdata" type="xs:string"/> <xs:element name="primarycarephysician"> <xs:complexType> <xs:sequence> <xs:element ref="title"/> <xs:element ref="surname"/> <xs:element ref="firstname"/> <xs:element ref="dischargingemployeeid"/> <xs:element ref="dischargingemployeeemail"/> <xs:element ref="hospitaladdressline1"/> <xs:element ref="hospitaladdressline2"/> <xs:element ref="hospitaladdressline3"/> <xs:element ref="hospitaltown"/> <xs:element ref="hospitalcounty"/> <xs:element ref="hospitalpostcode"/> <xs:element ref="hospitalcountry"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="surname" type="xs:string"/> <xs:element name="text" type="xs:string"/> <xs:element name="title" type="xs:string"/> <xs:element name="woodgrovexml"> <xs:complexType> <xs:sequence> <xs:element ref="primarycarephysician"/> <xs:element ref="patientdata"/> <xs:element ref="lotsofotherinformation"/> <xs:element ref="diagnosisatdischarge"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Figure 5: Woodgrove XML Schema

The schema appears complicated but an XML document that validates against it can be fairly simple. Figure 6 shows the example file that will be the basis for the rest of this section, called Woodgrove.xml:
<?xml version="1.0" encoding="UTF-8"?> <woodgrovexml xmlns="woodgrove:v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="woodgrove:v1 woodgrovexml.xsd"> <primarycarephysician> <title/> <surname/> <firstname/> <dischargingemployeeid/> <dischargingemployeeemail/> <hospitaladdressline1/> <hospitaladdressline2/> <hospitaladdressline3/> <hospitaltown/> <hospitalcounty/> <hospitalpostcode/> <hospitalcountry/> Page 56 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

</primarycarephysician> <patientdata/> <lotsofotherinformation/> <diagnosisatdischarge> <entry> <text/> <code/> </entry> <entry> <text/> <code/> </entry> <entry> <text/> <code/> </entry> </diagnosisatdischarge> </woodgrovexml> Figure 6: Woodgrove.xml File Contents

The Woodgrove.xml file shown in Figure 6 contains these basic structures: Primary care physician details Patient details LotsOfOtherInformation element Diagnosis at discharge This section takes you through the steps required to create a storage class that stores documents in that format.

Page 57 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

8.3

Creating a Storage Class

The first task is to create a Storage class for the Woodgrove XML format. You do this by adding a class called Woodgrove to the Woodgrove folder under Storage, as shown in Figure 7:

Figure 7: Creating the Woodgrove Class

The Woodgrove class derives from StorageBase, which is a requirement of storage classes. The next task is to create a template upon which to base the XML storage.

8.4

Creating a Storage Template


1. Add Woodgrove.xml to the Woodgrove folder 2. This is to be an embedded resource, so change the Build Action to Embedded Resource 3. Add Woodgrove.xsd for completeness (though it has no build action)

To create the storage template:

Page 58 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Figure 8 shows those tasks being completed:

Figure 8: Creating a Storage Template

Many of the items in Woodgrove.xml map directly to the items in the Discharge Summary form. The simplest approach is for the items to just map across and this is exactly what the StorageBase class provides.

Page 59 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

To perform the mapping, the class requires a mapping file: 1. Add another XML file to store the mappings. The content of the WoodgroveMappings.xml file is:

2. Add the WoodgroveMappings.xml file to the Woodgrove folder 3. This is to be an embedded resource, so change the Build Action to Embedded Resource Figure 9 shows what the content of the Woodgrove folder now looks like:

Figure 9: Woodgrove Folder with Mappings File Added

You now associate the Woodgrove storage class with those other XML files: 1. Configure the storage class to override the property that provides the mappings. Do this by overriding the MappingsXmlResourceKey property 2. Specify the XML template that automatically has the mappings applied to it. Do this by overriding the AutoMappingXmlResourceKey property

Page 60 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

One more item you need to provide is the namespace for the XML template. Figure 10 shows the example content for this namespace:
public class Woodgrove : StorageBase { public override string AutoMappingXmlResourceKey { get { return "Microsoft.Consulting.OfficeTools.Controls.Storage.Woodgrove.Woodgrove.xml"; } } public override string MappingsXmlResourceKey { get { return "Microsoft.Consulting.OfficeTools.Controls.Storage.Woodgrove.WoodgroveMappings.xml"; } } public override string StorageSchemaUri { get { return "woodgrove:v1"; } } } Figure 10: Content of the Namespace File

At this point, build the solution and check for errors to see that it works. Obviously, nothing is actually mapped yet so all that you see is the XML Template. Next, it is necessary to change the storage class reference in the Office Word template to point to our new Woodgrove class.

8.5

Changing the Storage Class Reference


1. Press F5 to run the solution 2. Open an Office Word document using the Discharge Summary template 3. Click the CDSA Developer tab (if it is not on view, access it through the CDSA User tab as described in section 2.7)

To change the storage class reference, follow these steps:

Page 61 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

4. Click Developer Properties 5. On the Configuration tab, modify the Storage Class reference to point to Woodgrove:

6. The new Woodgrove class is instantiated and called You can click on the Data tab to see the unmodified template, as shown in Figure 11:

Figure 11: Unmodified Woodgrove Template

The next step is to map across all the items.


Page 62 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

8.6

Mapping Across All Items

To illustrate the procedure of mapping across all the items, the first item mapped is the primary care physician title. You need to specify an XPath statement to the location in the XML template and the name of the field. Gather those pieces of information from the relevant Data tab (as shown in Figure 12):

Figure 12: Physician Title Data

The relevant Mapping element looks like this:


<Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianCodeText"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:dischargingemployeeid</XPath> </Mapping>

You have to qualify the XPath statement elements with the namespace. Do this in a short form by overriding the method to provide the namespace manager (in the following specified as x):
public override System.Xml.XmlNamespaceManager GetXmlNamespaceManager(System.Xml.XmlDocument doc) { XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable); manager.AddNamespace("x", this.StorageSchemaUri); return manager; }

Continue with similar procedures to add the other mappings you need, as shown in this example:
<Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianPrefixText"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:title</XPath> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianFamilyNameText"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:surname</XPath> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianGivenNameText"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:firstname</XPath> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianEmailText"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:dischargingemployeeemail</XPath> <FormatString>mailto:{0}</FormatString> <Type>String</Type> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianAddressAddress1"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:hospitaladdressline1</XPath> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianAddressAddress2"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:hospitaladdressline2</XPath> </Mapping> Page 63 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

<Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianAddressAddress3"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:hospitaladdressline3</XPath> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianAddressTown"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:hospitaltown</XPath> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianAddressCounty"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:hospitalcounty</XPath> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianAddressPostcode"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:hospitalpostcode</XPath> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianAddressCountry"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:hospitalcountry</XPath> </Mapping> <Mapping Key="PrimaryCarePhysicianDetails_PrimaryCarePhysicianCodeText"> <XPath>/x:woodgrovexml/x:primarycarephysician/x:dischargingemployeeid</XPath> </Mapping>

If you again re-run the code and change the Storage Class reference, you will see the resulting mappings on the relevant Configuration tab, as shown in Figure 13:

Figure 13: Physician Item Mappings

You can now progress to fill out the physician details in the Discharge Summary form, as shown in Figure 14:

Figure 14: Physician Details Filled In Page 64 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

After selecting Save, look at the Data tab to see how the new document is populated, as shown in Figure 15:

Figure 15: Populated Document

You can map other parts of the document in the same way. You can also add a second mapping to place the same value in more than one location. This method for performing mapping is very effective when the structure of the form is not dynamic and you can reference the field names in advance. However, if you want to handle something more complicated (for example, process lists) then you may need to run some custom code.

8.7

Running Custom Code

To run custom code, all you have to do is add another overridden method to your storage class. In the following example, the method is called Process. This method has access to the XML document with all the mappings applied. To demonstrate using code to manipulate the XML, the code inside of the process method runs XPath statements against the XML file and then updates the Lotsofotherinformation node. Figure 16 shows code performing the Process method override:
public override void Process() { XmlNamespaceManager manager = this.GetXmlNamespaceManager(this.StorageXml); XmlElement element = this.StorageXml.DocumentElement; XmlNode pcp = element.SelectSingleNode("x:primarycarephysician", manager); XmlNode looi = element.SelectSingleNode("x:lotsofotherinformation", manager); looi.InnerText = pcp.SelectSingleNode("x:title", manager).InnerText + " " + pcp.SelectSingleNode("x:firstname", manager).InnerText + " " + pcp.SelectSingleNode("x:surname", manager).InnerText; } Figure 16: Code Performing the Override

Page 65 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

After you have run the code, the updated XML is viewable in the Data tab, as shown in Figure 17:

Figure 17: Updated XML

That method of updating the XML works well for many situations. However, if the XML document is complicated it can be difficult to create the correct structure and cumbersome to manipulate the nodes. Under such circumstances, you may find it better to create strongly typed objects that represent the required XML structure. Such a strongly typed object is known as a model.

8.8

Creating a Model

The following example shows how you create a model using the XSD.exe tool from the Microsoft .NET Framework Software Development Kit (SDK). To create a model for the WoodGroveXml schema, follow these steps: 1. In a Visual Studio command prompt window, navigate to the location of WoodGroveXml.xsd. This file provides the rules that govern the structure of the Woodgrove XML documents 2. Run XSD.exe passing in woodgrovexml.xsd as a parameter, adding other parameters to specify the namespace in which to create the resulting classes and to specify the creation of strongly typed classes:
xsd.exe woodgrovexml.xsd /n:Microsoft.Consulting.OfficeTools.Storage.WoodGroveXml /c

Page 66 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

3. Return back to the solution in Visual Studio 4. Navigate to the Woodgrove folder and add the created model, the woodgrovexml.cs file, into the folder If you open the Woodgrovexml.cs file, you can see the code that was generated. CDSA will examine the storage class to see if it has a model calling the GetStorageModelType virtual property. This property returns the type that has been created for the root element of our XML documents. In our example, this is the woodgrovexml type:
public override Type GetStorageModelType { get { return typeof(Storage.WoodGroveXml.woodgrovexml); } }

CDSA then takes the XML document that we have been manipulating and populates the model with all of the data. You next have to override the model method: 1. Override the ProcessStorageModel method to deal in objects rather than XML. The ProcessStorageModel method is located in the StorageModel property 2. Cast the StorageModel property to a Woodgrovexml object 3. Add some code to inspect and manipulate the model:
public override void ProcessStorageModel() { Storage.WoodGroveXml.woodgrovexml model = (Storage.WoodGroveXml.woodgrovexml)this.StorageModel; string title = model.primarycarephysician.title; model.primarycarephysician.title = model.primarycarephysician.title.ToUpper(CultureInfo.CurrentUICulture); }

If you run the solution and look at this in the debugger, you can see that the model is populated with all the values and that the Title property is settable, as shown in Figure 18:

Figure 18: Debugger View of the Model

You can access the data contained in the CDSA controls via the DataElementCollection:
DataElementCollection elements = this.DocumentBase.DataElementCollection;

Access that collection via the member property DocumentBase.DataElementCollection. Using DataElementCollection you can get all of the line IDs for sections that contain lists. For example, calling the GetLineIds on the CDSA Discharge Summarys DiagnosisOnDischargeList section returns the diagnosis lines.

Page 67 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

Iterate around the diagnosis lines to create the XML required:


var elements = this.DocumentBase.DataElementCollection; List<string> diagnoses = elements.GetLineIds("DiagnosisOnDischargeList"); // make an array for all the diagnosis lines model.diagnosisatdischarge = new Microsoft.Consulting.OfficeTools.Storage.WoodGroveXml.entry[diagnoses.Count]; int entryCounter = 0; foreach (string diagnosis in diagnoses) { model.diagnosisatdischarge[entryCounter] = new Storage.WoodGroveXml.entry(); model.diagnosisatdischarge[entryCounter].text = elements["Description", "DiagnosisOnDischargeList", diagnosis]; entryCounter++; }

Now run the solution and add two diagnoses to the Discharge Summary, as shown in Figure 19:

Figure 19: Two Diagnoses Added to the Discharge Summary

Save the document and the Data tab displays the updated XML, as shown in Figure 20:

Figure 20: Updated XML

That XML is now contained within the Office Word document as a custom XML part.
Page 68 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

9
9.1
CDA CDSA CUI EHR EMR HL7 MSDN MSI PHR SDK

DOCUMENT INFORMATION
Terms and Abbreviations
Definition
Clinical Documentation Architecture Clinical Documentation Solution Accelerator Common User Interface Electronic Health Record Electronic Medical Record Health Level 7 Microsoft Developer Network Microsoft Installer Personal Health Record Software Development Kit Systematized Nomenclature of Medicine Clinical Terms Windows Communication Foundation Windows Presentation Foundation Extensible Markup Language

Abbreviation

SNOMED CT WCF WPF XML


Table 10: Terms and Abbreviations

9.2

Nomenclature

This section shows how to interpret the different styles used in this document to denote various types of information. All content subject to completion, agreement or verification is denoted with highlighting.

9.2.1
Text
Code Script

Body Text
Style
Monospace

Other markup languages Interface dialog names Field names Controls Folder names File names
Table 11: Body Text Styles

Bold

Title Case

Page 69 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Microsoft

9.2.2

Cross References
Style
Section number only Caption number only Italics and possibly a footnote Italics with a footnote Italics and a hyperlinked footnote

Reference
Current document sections Current document figures/tables Other project documents Publicly available documents External Web-based content
Table 12: Cross Reference Styles

9.3
R1.

References
Document
Microsoft TechNet: http://technet.microsoft.com/

Reference

Version

Table 13: References

Page 70 Clinical Documentation Solution Accelerator Developer's Guide Prepared by Microsoft, Version 1.0.0.0 Last modified on 15 April 2010

Vous aimerez peut-être aussi