locked
Sending transform data back to HV RRS feed

  • Question

  • Trying to:

    1. grab the last CCD uploaded to HV,

    2. transform using "tohv",

    3. and send the CCD transformed to HV Thing Types back to Healthvault.

    Is the code below on the right track? And, how would I send the data back to HV?

           HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher();
            HealthRecordFilter filter = new HealthRecordFilter(CCD_THING_GUID);
            filter.View.Sections = HealthRecordItemSections.Core;
            filter.MaxItemsReturned = 1;
            searcher.Filters.Add(filter);
            HealthRecordItemCollection get_CCD = searcher.GetMatchingItems()[0];
            foreach (HealthRecordItem item in get_CCD)
            {
                HealthRecordItemTypeDefinition ccrDefinition = ItemTypeManager.GetHealthRecordItemTypeDefinition(CCD_THING_GUID, ApplicationConnection);
                ccrDefinition.TransformItem("tohv", item);
            }
    Tuesday, October 27, 2009 9:50 PM

Answers

  • Hello Gary,

    You can use the following code to insert the items into HealthVault, after getting the result as xml data.

     //Declaration Part
        private static XmlReaderSettings XmlReaderSettings
        {
            get
            {
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.CheckCharacters = true;
                settings.CloseInput = true;
                settings.ConformanceLevel = ConformanceLevel.Fragment;
                settings.IgnoreComments = true;
                settings.IgnoreProcessingInstructions = true;
                settings.IgnoreWhitespace = true;
                settings.ProhibitDtd = true;
                settings.XmlResolver = null;

                return settings;
            }
        } 

     //Main Code
     string result= ccdDefinition.TransformItem("tohv", newCcdItem);        
            StringReader stringReader = new StringReader(result);
            XmlReader infoReader =
                XmlReader.Create(
                    stringReader,
                    XmlReaderSettings);
            infoReader.NameTable.Add("wc");
            infoReader.MoveToContent();

            Collection<HealthRecordItem> results = new Collection<HealthRecordItem>();
            string CurrentString = result;
            if (infoReader != null)
            {
                infoReader.ReadToDescendant("thing");
                while (CurrentString != string.Empty)
                {
                    HealthRecordItem resultThing = ItemTypeManager.DeserializeItem(CurrentString);
                    infoReader.Read();
                    CurrentString = infoReader.ReadOuterXml();
                    if (resultThing != null)
                    {
                        results.Add(resultThing);
                    }
                }
            }
            //Inserting the items into HV
            PersonInfo.SelectedRecord.NewItems(results);


    -Mahesh
    Friday, October 30, 2009 9:25 PM

All replies

  • Ok, so I managed to get the CCD transformed and assigned to a string variable - thanks to Matt Wagner's presentation at Connected Health.

    Now I'd like to know if someone can help me with sending the string variable back to HV.

    Please see bold code line below.

    How can I send "items" to HealthVault so that it creates new HV Thing Type items?

    Do I have to break "items" apart and assign individual items?

    Or will HV automatically create new items from those in "items" with one command?

    string ccdFile = Server.MapPath("ExampleCCD.xml");
    XmlDocument ccdDoc = new XmlDocument();     
    ccdDoc.Load(ccdFile);
    HealthRecordItem newCcdItem = new HealthRecordItem(CCD_THING_GUID, ccdDoc);
    PersonInfo.SelectedRecord.NewItem(newCcdItem);
    HealthRecordItemTypeDefinition ccdDefinition = ItemTypeManager.GetHealthRecordItemTypeDefinition(CCD_THING_GUID, ApplicationConnection);
    string items = ccdDefinition.TransformItem("tohv", newCcdItem);

    Thanks,
    Gary
    Wednesday, October 28, 2009 12:58 AM
  • Hello Gary,

    I am contacting technical team and will have an update soon.
    -Mahesh
    Friday, October 30, 2009 12:54 AM
  • Thanks Mahesh. Maybe Matt Wagner knows how to do that.
    Friday, October 30, 2009 3:09 AM
  • Hello Gary,

    You can use the following code to insert the items into HealthVault, after getting the result as xml data.

     //Declaration Part
        private static XmlReaderSettings XmlReaderSettings
        {
            get
            {
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.CheckCharacters = true;
                settings.CloseInput = true;
                settings.ConformanceLevel = ConformanceLevel.Fragment;
                settings.IgnoreComments = true;
                settings.IgnoreProcessingInstructions = true;
                settings.IgnoreWhitespace = true;
                settings.ProhibitDtd = true;
                settings.XmlResolver = null;

                return settings;
            }
        } 

     //Main Code
     string result= ccdDefinition.TransformItem("tohv", newCcdItem);        
            StringReader stringReader = new StringReader(result);
            XmlReader infoReader =
                XmlReader.Create(
                    stringReader,
                    XmlReaderSettings);
            infoReader.NameTable.Add("wc");
            infoReader.MoveToContent();

            Collection<HealthRecordItem> results = new Collection<HealthRecordItem>();
            string CurrentString = result;
            if (infoReader != null)
            {
                infoReader.ReadToDescendant("thing");
                while (CurrentString != string.Empty)
                {
                    HealthRecordItem resultThing = ItemTypeManager.DeserializeItem(CurrentString);
                    infoReader.Read();
                    CurrentString = infoReader.ReadOuterXml();
                    if (resultThing != null)
                    {
                        results.Add(resultThing);
                    }
                }
            }
            //Inserting the items into HV
            PersonInfo.SelectedRecord.NewItems(results);


    -Mahesh
    Friday, October 30, 2009 9:25 PM
  • Great!

    Thanks Mahesh.
    Monday, November 2, 2009 10:07 PM
  • Gary-- I'm curious what the scenario is here; what's the context or goal of this feature/code?  Do you mind sharing how it will be used?  Really it's just curiosity, I don't see anything inherently wrong, I just like to understand how the various HealthVault features are being used.

    Thanks!
    Tuesday, November 3, 2009 10:51 PM
  • Hi Lowell,

    Sorry just noticed your post.

    It's somewhat confidential, but in general I was trying to leverage the reconcile feature in HV.

    I was trying to use the "tohv" transform to parse the CCD using HV.

    Since it's has limited features, as compared to the manual reconcile, I would use "tohv" to parse what I could.

    Then manually parse the remaining CCD sections.

    Let me know if you have any comments about this.

    Thanks,
    Gary

    Friday, November 6, 2009 3:17 AM