Version 17, last updated by markcopenhaver at August 04, 2010 14:25 UTC
HelloWorld Service
Here are the steps to create a HelloWorld Service Component. You can get the source code here: myNewEproService.zip
Step 1 – Create the assembly
Start Visual Studio 2008
New Project – C# Class Library
Add reference to EncounterPRO.OS.Component
Change/replace class to inherit from EncounterPRO.OS.Component.Service
Add stubs for override methods:
protected override string configureService(string InputXml)
{
return null;
}
protected override string doService(string InputXml)
{
return "1";
}
Add desired code to doService()
If desired, set the AssemblyVersion in AssemblyInfo.cs (usually in the “Properties” folder)
Sign assembly
- Right click on project, select Properties
- Click on “Signing” tab
- Check the “Sign the assembly” checkbox
- If you already have a key file then you probably don’t need these instructions. Otherwise, select “New” from the dropdown. On the popup, give your key file a name and a password.
Build the assembly
First, make sure the Target Assembly (on the project property-Application tab) is set to 3.5.1 I've done this exercise successfully with Visual Studio 2008, Visual Studio 2010, and Visual Studio 2010 Express. Both versions of 2010 work but they default to framework 4.0 so you need to go change it. If you download the myNewEproService example project, you'll find that VS2010 will preserve my project setting of framework 3.5, but VS2010 Express will flip it to 4.0 and the assemblies won't go into the GAC until you set it back to 3.5 and rebuild.
For Step 3, you’re going to need the class name of your component. Get that by looking at the “namespace” above your class definition and concatenate it, with a period between, with the class you created descending from the EncounterPRO.OS.Component.Service. In my example this turns out to be “myNewEproService.HelloWorld”.
1 I've tried setting the target framework to 4.0, but I haven't been able to put the resulting assembly into the GAC. It'll probably work if we rebuild the base class with the 4.0 framework too, but I haven't tried that yet.
Step 2 – Create the Installer
Follow these instructions to create the installer using the Generic NSIS Component Installer:
NSIS_Generic_Component_Installer
The only subfolder you need for the example service is GAC. Put both the service assembly from step 1 and the EncounterPRO.OS.Component.dll into the GAC subdirectory and follow the rest of the instructions.
Step 3 – Load the component into EncounterPRO-OS
Create a new component definition and component version by following the instructions here:
http://www.assembla.com/wiki/show/EncounterPRO-OS/Creating_a_Component_Version
Step 4a – Create a new Service Configuration Object
In EncounterPRO-OS, click on the Configuration tab and navigate to Workflow Components. Double or right-click on “Services”.
On the Service Configuration window, click the “New Service” button and answer the questions:
Assign your service a name. This will be the name that is used to refer to this service from all other config objects.
Select all the contexts that this service can run from. If your service does not deal with an individual patient the select “General”. In my example there is no need for my service to know the patient context, so I selected “General”.
Select your service component from the popup list.
A message should display saying your service was successfully created. Check the event viewer if you don’t get this message.
Step 4b – Add a reference to the new service to a config object that you can activate
There are many ways to get to a service. The most common are menus and workplans. To put the service somewhere where you’ll have a patient context is not hard, but to keep this example very simple we’ll just add our new service the “Utilities” menu.
First, go into “Configuration Mode”. Hit the F3 key (if nothing happens then click on any tab and hit F3 again). On the Current Context window, there is a button showing the status of Configuration Mode. Click it so that Configuration Mode is ON.
Go to the Utilities tab. There should now be some small text in the lower left. Click on the small text.
On the Menu Properties screen, look on the right side to see if you are using a “Local Version”. If not, then click “Create Local Copy”. If so, or after you create a local copy, select the Local Version and click “Edit Menu”
On the Menu Properties Edit screen, click “New”
The Menu Item Properties screen will display and a Menu Item Type select window will popup. Select “Service”
On the Context popup, there should only be one choice “General”. Select “General”.
Find your new Service config object from the popup
On the service params screen, just click “Finished”
Now you should be back on the Menu Item Properties screen. If you want to change the button title or button help, do so now.
Click “Finished”
Now when you go back to the Utilities tab you should have a new option for your new service. Go ahead and click on it.