There have been a couple of questions recently about storing CCR and CCD data in HealthVault, so I decided to do a quick sample. The sample will show up in the SDK sometime in the future, so consider this the accompanying discussion for the sample. If you want the actual bits before they show up in the SDK, let me know.
Both the CCR and CCD are designed as ways of passing information between entities. For example, when you leave the hospital, information could be passed back to your primary care physician through one of these types. Or, at least, that's what I understand - my real aptitude relating to these types doesn't go much beyond being able to spell them.
These types are examples of XML types that I talked a bit about in What Data Type Should I Use?, which simply means that they are types as far as the platform is concerned (ie they have an XML schema and thing type associated with them), but they don't have a client type (ie a type derived from HealthRecordItem) in the .NET API.
To operate with such types, we'll need to use the HealthRecordItem type directly. To do so, I need to know the guid associated with each type. I get those from the Thing Types Reference page, which I encode using the following:
readonly Guid CCR_THING_GUID = new Guid("1e1ccbfc-a55d-4d91-8940-fa2fbf73c195");
readonly Guid CCD_THING_GUID = new Guid("9c48a2b8-952c-4f5a-935d-f3292326bf54");
Then, it's really pretty simple. If I want to insert a CCR, I can use the following:
XmlDocument ccrDocument = new XmlDocument();
HealthRecordItem ccr = new HealthRecordItem(CCR_THING_GUID, ccrDocument);
You might want to use XPathDocument instead of XMLDocument, as I hear that it's cheaper than XmlDocument to use. Also note that the ExampleCCR.xml file that I open *does not* have anything before the "<ContinuityOfCareRecord>" element - if it does, the framework will reject it as poorly formatted.
That's about all you need to do to add it in.
To do the same thing with a CCD is pretty much equivalent to changing the appropriate "r" characters in the code to "d" characters.
To get retrieve the types is also fairly simple. Assuming I want to look at all the CCDs that are stored in a record, I can do this:
List<HealthRecordItem> ccdItems = GetValues<HealthRecordItem>(CCD_THING_GUID);
foreach (HealthRecordItem ccd in ccdItems)
// ccd xml data is in ccd.TypeSpecificData
where GetValues() is from the HelloWorld sample.
This is a simple form of support for these data types. Some partners have requested the ability to create a CCR/CCD from individual data items in HealthVault, or to break a CCR/CCD into individual items and store those items in HealthVault. We understand the utility of that scenario, but haven't announced any plans about supporting that.