*All example code is in Visual Basic.Net
Architecture Diagram
In the HL7+ Components all roads lead from the HL7PlusController object. The HL7PlusController object communicates with the HL7+ Client Windows Service and dictates whether you can use any of the restricted objects, or restricted methods in partially restricted objects. You check the status by querying the HL7PlusController.IsRunnable property.
In the HL7+ Components all of the different public classes will fall into 1 of 3 categories.
1) Restricted.
If an object is flagged as Restricted it means that you cannot create an instance of that object directly from within your code, but rather you call one of the New...() methods in the HL7PlusController object to instantiate the object. Example:
The HL7PlusMessage object is Restricted. If, in your code you try to declare an object like this: Dim oMsg As New HL7PlusMessage Visual Studio will throw a compiler error. There is no public New() available. Instead you have to do it like this: Dim oMsg As HL7PlusMessage = MyController.NewHL7PlusMessage() Doing it this way, where MyController is a HL7PlusController object will return EITHER a HL7PlusMessage object or Nothing. It depends on the value of MyController.IsRunnable.
2) Unrestricted.
If an object is flagged as Unrestricted it basically means that this is a free object which does not require HL7+ and you CAN freely declare an instance of that object directly from within your code. For the sake of conformity there may also be one of the New...() methods in the HL7PlusController object which you can call as well but it is not required.to instantiate the object. Example:
The HL7PlusUtilities object is Unrestricted. In your code you can declare the object like this: Dim oUtils As New HL7PlusUtilities You can also create the object like this: Dim oUtils As HL7PlusUtilities = MyController.NewHL7PlusUtilities() Either way is functionally identical. Where MyController is a HL7PlusController object it will always return a new HL7PlusUtilities object regardless of the value of MyController.IsRunnable.
3) Partially Restricted.
If an object is flagged as Partially Restricted it means that the object is a free object which you can create directly, BUT it contains some internal methods or properties which ARE restricted and will require a HL7PlusController object to use. For the sake of conformity there may also be one of the New...() methods in the HL7PlusController object which you can call as well but it is not required.to instantiate the object. Example:
The HL7PlusFileInfo object is Partially Restricted. In your code you can declare the object like this: Dim oInfo As New HL7PlusFileInfo("C:\HL7\Mydata.hl7") You can also create the object like this: Dim oInfo As HL7PlusFileInfo = MyController.NewHL7PlusFileInfo("C:\HL7\Mydata.hl7") Either way is functionally identical. Where MyController is a HL7PlusController object it will always return a new HL7PlusFileInfo object regardless of the value of MyController.IsRunnable and you can freely use most of the features of this object. However, IF you want to use any of the HL7+ Specific methods to, for example, retrieve or count all of the HL7PlusMessages in the file you will have to provide those methods with a HL7PlusController object and those methods will fail if that object is not runnable.
Example: Dim oInfo As New HL7PlusFileInfo("C:\HL7\Mydata.hl7") If oInfo.CountHL7PlusMessagesInFile(MyController) > 0 Then ....code ....code ....code End If
|