Storing CCR and CCD Data in HealthVault

Both the Continuity of Care Record (CCR) and the Continuity of Care Document (CCD) are designed as ways of passing information between entities. For example, when a patient leaves the hospital, information can be passed to their primary care physician through one of these types. These types are examples of XML types (see What Data Type Should I Use?), which simply means that they are types as far as the HealthVault platform is concerned (that is, they have an XML schema and thing type associated with them), but they don't have a client type (that is, a type derived from HealthRecordItem) in the .NET API.

To operate with such types, you need to use the HealthRecordItem type directly. To do so, you need to know the GUID associated with each type. You get the GUIDs from the Thing Types Reference page and encode them 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");

To insert a CCR, use the following:

void AddCCR() 
{ 
   XmlDocument ccrDocument = new XmlDocument(); 
   ccrDocument.Load(MapPath("ExampleCCR.xml")); 
   HealthRecordItem ccr =  
        newHealthRecordItem(CCR_THING_GUID, ccrDocument); 

   PersonInfo.SelectedRecord.NewItem(ccr); 
}

You might want to use XPathDocument instead of XMLDocument because it is cheaper than XMLDocument to use. Also note that the ExampleCCR.xml file must not have anything before the "<ContinuityOfCareRecord>" element—if it does, the framework rejects the file as poorly formatted.

To do the same thing with a CCD, change the appropriate "r" characters in the code to "d" characters.

To retrieve the types is also fairly simple. To look at all the CCDs stored in a record:

      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. For more information about creating a CCR from individual data items in HealthVault, or storing CCR data as individual items in HealthVault, see Using CCR Data in HealthVault.