locked
Reg: Error while retrive LabTestResults data from health Vault RRS feed

  • Question

  •  

    Hi ,

           In my application we are getting LabTestResults Information from Health Vault . While converting

    HealthRecordItem to LabTestResults , I am getting the following error

    " Unable to cast object of type 'Microsoft.Health.HealthRecordItem'
    to type 'Microsoft.Health.ItemTypes.LabTestResults  "

    I had written the following code .

    HealthRecordAccessor access = healthInfo;

     

    filter = new HealthRecordFilter();

    filter.TypeIds.Add(Microsoft.Health.ItemTypes.LabTestResults.TypeId);

    filter.View.Sections = HealthRecordItemSections.Core | HealthRecordItemSections.Audits | HealthRecordItemSections.Xml;

    searcher.Filters.Add(filter);

     

    searchResultsGroup = searcher.GetMatchingItems();

     

    if (searchResultsGroup[0].Count > 0)

    {

    HealthRecordItem HealthRecItem = searchResultsGroup[0][0];

    LabTestResults LTR = (LabTestResults)HealthRecItem;

    }

    I am getting above mentioned error in this line

    LabTestResults LTR = (LabTestResults)HealthRecItem;

     

    Some times I am not getting any errors in that line .

    Please let me know any reasons for getting this error

     

    Thanks & regards ,

    shashidhar N .

     

    Tuesday, October 21, 2008 2:01 PM

Answers


  • I have seen this behaviour at times...There seems to be some problems getting types registered to ItemTypeManager (at times). While I have not been able to consistently reproduce this behaviour, adding the following line to global.asax and doing an iisreset seem to work for me.  The problem with the SDK code is that if some exeption occurs during ItemTypes getting registered to ItemTypeManager, the exception is ignored.


      protected void Application_Start(object sender, EventArgs e)
      {
                Microsoft.Health.ItemTypes.ItemTypeRegistrar.RegisterAssemblyHealthRecordItemTypes();
      }


    Let me know if this works for you. 

    Raj
    Tuesday, October 21, 2008 3:42 PM

All replies


  • I have seen this behaviour at times...There seems to be some problems getting types registered to ItemTypeManager (at times). While I have not been able to consistently reproduce this behaviour, adding the following line to global.asax and doing an iisreset seem to work for me.  The problem with the SDK code is that if some exeption occurs during ItemTypes getting registered to ItemTypeManager, the exception is ignored.


      protected void Application_Start(object sender, EventArgs e)
      {
                Microsoft.Health.ItemTypes.ItemTypeRegistrar.RegisterAssemblyHealthRecordItemTypes();
      }


    Let me know if this works for you. 

    Raj
    Tuesday, October 21, 2008 3:42 PM
  • Did this solve your issue?
    Thursday, October 30, 2008 6:23 AM
  • Hi Rajesh,

    I placed the code in my global.asax page as you mentioned in the above link but it doesn't works for me.

    Here I am giving complete details.

    Application ID: "b3ef0579-3d88-4d61-b426-2132e049eff2 "

    I followed the following steps.

    In HealthVault PPE Environment(https://xray.getrealconsulting.com/") I tried to create a record in Immunization [ImmunizationV1]. I entered the Name "ChickenPox Vaccine" and entered all fields then i clicked on Create button and I got the following Error message

    "An error occurred while processing your request

    The error has been logged. If you continue to experience this error, please contact technical support.

    Error Message:Object reference not set to an instance of an object. "

    But when I go to my HealthVault account I found that a record was created in Immunizations category(i.e Exception occured but Immunization is created).

    Now when i tried to Synch with healthvault from my application, I am getting the following error message: "Unable to cast object of type 'HealthRecordItem' to type 'Microsoft.Health.ItemTypes.Immunization".

    I noticed the following things in
     
    In ViewLatest Items of https://xray.getrealconsulting.com in Immunizations " Microsoft.Health.HealthRecordItem " is coming in the "DisplayValue" Column instead of Immunization name.

    When I tried to edit, It shows the same exception which showed in creation. But when I edit it from my HealthVault account it is working fine.

    Here are the Immunization id's which are causing Exception:

    1) key.Id "26f36ad8-96d0-44a3-9119-a9e50ddf852f"   VersionStamp "218ee46e-3e11-4983-9899-2764ccf6845b"
    2) key.Id "56e07e19-519c-4e66-9bc0-aa5bc2016f20"   VersionStamp "682e9666-2e29-4b08-ad5b-aeefcdc93c7f"

    Code:
    foreach (HealthRecordItem item in items)
            {
                typedList.Add((T)item); //
    Code Causes Error
           
    }

    please guide me how to fix this as it is urgent for me.

    Thanks and Regards
    ChellamNaidu

    Tuesday, October 27, 2009 11:48 AM
  • Just posted a possible work around for this problem here

    http://social.msdn.microsoft.com/Forums/en-US/healthvault/thread/c81728a2-fd1e-414b-97e1-c30490e1af81

    Let me know if this solves it


    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    Tuesday, October 27, 2009 1:55 PM