none
How do you modify a singleton data type? RRS feed

  • Question

  • I am curently working on a HealthVault app for android, developed using the java sdk. Specifically I am using the android-sdk-simplexml which I found on codeplex. I am trying to change the personal.name thing type, but I keep getting the following exception:

    HVUncategorizedException: Error: 60

    The item specified is of a singleton type for which an existing instance already exists. To update the existing instance, first get the instance, modify the data, and then call HealthVault to update.

    I cannot figure out how to get the instance, because the code seems to just get a copy? Here is the current code to get the name data:

    String name = null;
    PersonalDemographics pd = (PersonalDemographics) thing.getData();
    Name n = pd.getName();
    name = String.valueOf(n.getFull());

    I am not sure how to call HealthVault to update either.

    This is probably a something really simple, but I haven't been able to find anything online about it.

    Monday, August 7, 2017 2:36 PM

Answers

  • There should be nothing special for singleton data type about updating existing data. You will get existing instance (or you may call it "copy"), modify, and then update.  Here are a short sample of .NET SDK.

                        HealthRecordSearcher recSearch = access.CreateSearcher();
                        recSearch.Filters.Add(new HealthRecordFilter(Personal.TypeId));
                        HealthRecordItemCollection recSearchResultsGroup = recSearch.GetMatchingItems()[0];
                        if (recSearchResultsGroup.Count > 0)
                        {
                            Personal perInfo = (Personal)recSearchResultsGroup[0];
                            perInfo.Name.Middle = "Michael";
                            access.UpdateItem(perInfo);
                        }

    • I am not familiar with java SDK. But for HealthVault APIs, "create" and "update" call same API (PutThings). You may find sample java code calling PutThings
    • The application needs permission for both Read and Update. It is not same as Create.
    • The Name is not a string. It is a structured data which consists of such as First, Full. You need to update specific one such as Name.First or Name.Full. 

     

    Takashi Moriyama | Senior Program Manager | Microsoft Health

    • Marked as answer by Alinator13 Wednesday, August 9, 2017 1:10 AM
    Tuesday, August 8, 2017 10:01 PM
    Moderator
  • This seems to work, but it looks very different, so just in case someone else gets stuck, here is some sample code to do it:

    private void putName(PersonalDemographics pd) {
    pd.getName().setFirst("test");
    pd.getName().setLast("test2");
    hvClient.asyncRequest(
    selectedRecord.putThingAsync(pd.getThing()),
    new InfoCallback(InfoCallback.PutInfo));
    }
    • Marked as answer by Alinator13 Wednesday, August 9, 2017 1:09 AM
    Wednesday, August 9, 2017 1:09 AM

All replies

  • There should be nothing special for singleton data type about updating existing data. You will get existing instance (or you may call it "copy"), modify, and then update.  Here are a short sample of .NET SDK.

                        HealthRecordSearcher recSearch = access.CreateSearcher();
                        recSearch.Filters.Add(new HealthRecordFilter(Personal.TypeId));
                        HealthRecordItemCollection recSearchResultsGroup = recSearch.GetMatchingItems()[0];
                        if (recSearchResultsGroup.Count > 0)
                        {
                            Personal perInfo = (Personal)recSearchResultsGroup[0];
                            perInfo.Name.Middle = "Michael";
                            access.UpdateItem(perInfo);
                        }

    • I am not familiar with java SDK. But for HealthVault APIs, "create" and "update" call same API (PutThings). You may find sample java code calling PutThings
    • The application needs permission for both Read and Update. It is not same as Create.
    • The Name is not a string. It is a structured data which consists of such as First, Full. You need to update specific one such as Name.First or Name.Full. 

     

    Takashi Moriyama | Senior Program Manager | Microsoft Health

    • Marked as answer by Alinator13 Wednesday, August 9, 2017 1:10 AM
    Tuesday, August 8, 2017 10:01 PM
    Moderator
  • This seems to work, but it looks very different, so just in case someone else gets stuck, here is some sample code to do it:

    private void putName(PersonalDemographics pd) {
    pd.getName().setFirst("test");
    pd.getName().setLast("test2");
    hvClient.asyncRequest(
    selectedRecord.putThingAsync(pd.getThing()),
    new InfoCallback(InfoCallback.PutInfo));
    }
    • Marked as answer by Alinator13 Wednesday, August 9, 2017 1:09 AM
    Wednesday, August 9, 2017 1:09 AM