locked
Error on CCR update: The thing type is immutable RRS feed

  • Question

  • Hi all,

    I am trying to update a CCR record to the health vault. On the UpdateItem statement, I am getting the error "The thing type is immutable", but I have checked the recordItem's IsImmutable property is false. Following is the code. I am made the line bold in which error occurs.

    Guid recordGuid = new Guid(strRecordID);
                OfflineWebApplicationConnection offlineConn =
                        new OfflineWebApplicationConnection(new Guid(strPersonId));

                offlineConn.Authenticate();
                PersonInfo info = offlineConn.GetPersonInfo();

                HealthRecordAccessor accessor =
                    new HealthRecordAccessor(offlineConn, recordGuid);

                HealthRecordSearcher searcher = accessor.CreateSearcher();
                HealthRecordFilter filter = new HealthRecordFilter(new Guid(strCCRID));
                searcher.Filters.Add(filter);

                HealthRecordItemCollection items = searcher.GetMatchingItems()[0];
                XmlDocument doc = new XmlDocument();

                XmlDocument ccrDocument = new XmlDocument();
                ccrDocument.LoadXml(strCCR);

                XmlNode node = null;

                foreach (HealthRecordItem ccrItem in items)
                {
                    try
                    {
                        doc.LoadXml(ccrItem.GetItemXml());
                        node = doc.SelectSingleNode(@"//*[local-name()='ContinuityOfCareRecord']");
                        if (node != null)
                        {
                            if (node["CCRDocumentObjectID"].InnerXml.Equals(ccrDocument.SelectSingleNode(@"//*[local-name()='CCRDocumentObjectID']").InnerXml))
                            {
                                if (!ccrItem.IsImmutable)
                                {
                                    HealthRecordItem ccr = info.SelectedRecord.GetItem(ccrItem.Key.Id);
                                    ccr.TypeSpecificData = new XPathDocument(new StringReader(strCCR));
                                    info.SelectedRecord.UpdateItem(ccr);  
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {                   
                        continue;
                    }
                }

    Any suggestion on whether the implementation is right or wrong, will be of great help!! Or is there any other way to update a CCR?

    Thanks.
    • Edited by Janani R Friday, May 22, 2009 2:10 PM
    Friday, May 22, 2009 12:22 PM

Answers

All replies