Microsoft Developer Network > Forums Home > HealthVault Forums > HealthVault Data Types > Not able to cast old Immunization datatype to new Immunization datatype
Ask a questionAsk a question
 

AnswerNot able to cast old Immunization datatype to new Immunization datatype

  • Wednesday, July 22, 2009 11:39 AMcelalit1 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    As new datatype is introduced for Immunization, I am not able to convert/cast the old Immuniations to new datatype or viceversa. Below code stopped working for me:

                // create and add the filter
                HealthRecordFilter filter = new HealthRecordFilter();
                filter.TypeIds.Add(new Guid(ImmunizationGUID));
                filter.TypeIds.Add(Microsoft.Health.ItemTypes.Immunization.TypeId);
                filter.View.Sections = HealthRecordItemSections.All;
                searcher.Filters.Add(filter);

                HealthRecordItemCollection hvItems = searcher.GetMatchingItems()[0];
                foreach (HealthRecordItem item in hvItems)
                {
                    Microsoft.Health.ItemTypes.Immunization hvImm = item as Microsoft.Health.ItemTypes.Immunization;
                }

    Here, for the new Immunization datatypes, it is working fine, but it turns out to be NULL for the old ones. Any way to covert it?

Answers

All Replies