From Issue List: iMXLStructureFormatter = good; IPipeLineStructureFormatters? = Bad
justin.fyfe1
#1 Posted : Thursday, December 16, 2010 3:35:24 PM(UTC)

Rank: Administration

Medals: Mobile Tech Grasshopper: Mobile Tech GrasshopperHealth Informatics MVP

Groups: Registered, Administrators
Joined: 7/22/2010(UTC)
Posts: 96
Points: 297
Man
Location: Hamilton, ON

Thanks: 2 times
Was thanked: 17 time(s) in 17 post(s)
I was looking to encode the RIM datatype to pipe delimited format. In this way, I can save on my database.

I have seen IStructureFormatter interface; but I dont understand GraphAides!!

Additional documentation would be appreciated.

Thanks,
justin.fyfe1
#2 Posted : Thursday, December 16, 2010 4:04:05 PM(UTC)

Rank: Administration

Medals: Mobile Tech Grasshopper: Mobile Tech GrasshopperHealth Informatics MVP

Groups: Registered, Administrators
Joined: 7/22/2010(UTC)
Posts: 96
Points: 297
Man
Location: Hamilton, ON

Thanks: 2 times
Was thanked: 17 time(s) in 17 post(s)
Hi Uday,

Your question about formatter is a good one. HL7v3 types are heirarchical in nature and may be difficult to store in a pipe delimited format. You could write a SQL formatter that populates tables when graphing data.

There is an example of an IStructureFormatter in the SDK examples called the BinFormatter. This illustrates how to serialize to/from differing formats.

I have written a sample formatter that serializes objects like this:

Simple Types:
(type)name=value

Complex Types:
(type)name={
}

Below is the code for the GraphObect method.

Code:

        /// <summary>
        /// Graph an object
        /// </summary>
        public ResultCode GraphObject(System.IO.Stream s, MARC.Everest.Interfaces.IGraphable o)
        {
            if(o == null)
                return ResultCode.Accepted; // No need to serialize if instance is null

            StreamWriter sw = new StreamWriter(s);

            try
            {
               
                // Iterate through properties in the type
                foreach (var propertyInfo in o.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                {
                    // When serializing a property, we need to make sure it is graphible
                    object value = propertyInfo.GetValue(o, null);
                    if (value is IGraphable && value != null)
                    {
                        sw.WriteLine("({0}){1}={{\r\n", value.GetType(), propertyInfo.Name);
                        sw.Flush();
                        if (GraphObject(s, value as IGraphable) == ResultCode.Rejected)
                            return ResultCode.Rejected;
                        sw.WriteLine("}");
                    }
                    else if(value != null)
                        sw.WriteLine("({0}){1}={2}", value.GetType(), propertyInfo.Name, Util.ToWireFormat(value));
                       
                }

                sw.Flush();
                return ResultCode.Accepted;
            }
            catch (Exception e)
            {
                m_details.Add(new ResultDetail(
                    ResultDetailType.Error,
                    e.Message,
                    e
                ));
                return ResultCode.Rejected;
            }
        }


If I test using this code:

Code:

REPC_IN000076CA r = new REPC_IN000076CA(
                Guid.NewGuid(),
                DateTime.Now,
                ResponseMode.Immediate,
                REPC_IN000076CA.GetInteractionId(),
                REPC_IN000076CA.GetProfileId(),
                ProcessingID.Production,
                AcknowledgementCondition.Always
                );
            TextFormatter fmtr = new TextFormatter();
            fmtr.GraphObject(Console.OpenStandardOutput(), r);
            Console.ReadKey();


I get the following output

Code:

(MARC.Everest.DataTypes.II)Id={

(System.String)Root=1FF5AE66-915F-4CF6-AE0D-3D7620F35FBA
(System.RuntimeType)DataType=MARC.Everest.DataTypes.II
(System.Boolean)IsNull=false
}
(MARC.Everest.DataTypes.TS)CreationTime={

(System.String)Value=20101216160212.444-0500
(MARC.Everest.DataTypes.DatePrecision)DateValuePrecision=Full
(System.DateTime)DateValue=12/16/2010 4:02:12 PM
(System.RuntimeType)DataType=MARC.Everest.DataTypes.TS
(System.Boolean)IsNull=false
}
(MARC.Everest.DataTypes.CS`1[MARC.Everest.RMIM.CA.R020403.Vocabulary.ResponseMode])ResponseModeCode={

(MARC.Everest.DataTypes.Primitives.CodeValue`1[MARC.Everest.RMIM.CA.R020403.Vocabulary.ResponseMode])Code=I
(System.String)CodeSystem=2.16.840.1.113883.19.5.1
(MARC.Everest.DataTypes.Primitives.CodeValue`1[MARC.Everest.RMIM.CA.R020403.Vocabulary.ResponseMode])CodeValue=I
(System.RuntimeType)DataType=MARC.Everest.DataTypes.CS`1[MARC.Everest.RMIM.CA.R020403.Vocabulary.ResponseMode]
(System.Boolean)IsNull=false
}
(MARC.Everest.DataTypes.CS`1[System.String])VersionCode={

(MARC.Everest.DataTypes.Primitives.CodeValue`1[System.String])Code=V3-2008N
(MARC.Everest.DataTypes.Primitives.CodeValue`1[System.String])CodeValue=V3-2008N
(System.RuntimeType)DataType=MARC.Everest.DataTypes.CS`1[System.String]
(System.Boolean)IsNull=false
}
(MARC.Everest.DataTypes.II)InteractionId={

(System.String)Root=2.16.840.1.113883.1.18
(System.String)Extension=REPC_IN000076CA
(System.RuntimeType)DataType=MARC.Everest.DataTypes.II
(System.Boolean)IsNull=false
}
(MARC.Everest.DataTypes.LIST`1[MARC.Everest.DataTypes.II])ProfileId={

(MARC.Everest.DataTypes.II)First={

(System.String)Root=2.16.840.1.113883.2.20.2
(System.String)Extension=R02.04.03
(System.RuntimeType)DataType=MARC.Everest.DataTypes.II
(System.Boolean)IsNull=false
}
(MARC.Everest.DataTypes.II)Last={

(System.String)Root=2.16.840.1.113883.2.20.2
(System.String)Extension=R02.04.03
(System.RuntimeType)DataType=MARC.Everest.DataTypes.II
(System.Boolean)IsNull=false


Hope that helps.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

SoClean Theme By Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.074 seconds.