How to Retrieve Multiple Health data(wight , Blood-pressure, Blood glucose,Allergy ) in Just one Health vault Request

Aug 26, 2013 at 12:58 PM
Edited Aug 26, 2013 at 1:00 PM
Hi ,

I am getting all the data blood pressure , blood glucose, Allergy in different API call
For an Example:

weights = GetHVData.getWeights(); // 1st request to health vault
BP = GetHVData.getBP(); // 2nd request

I want to Retrieve All data in Single Request ????????????????????



Full code for blood Pressure Request


public static List<String> getBP(Record selectedRecord,HealthVaultService service)
    {

         RBP = new ArrayList<BloodPressureData>();

        final BloodPressure mBloodPressure = new BloodPressure();

        Record record = selectedRecord;

        SimpleRequestTemplate template = new SimpleRequestTemplate(
                service.getConnection(),
                record.getPersonId(),
                record.getId());

        String info = "<info><group max=\"20\"><filter><type-id>" +
            "ca3c57f4-f4c1-4e15-be67-0a3caf5414ed" +
            "</type-id></filter><format><section>core</section>" +
            "<xml/></format></group></info>";

        Request request = new Request();
        request.setMethodName("GetThings");
        request.setInfo(info);

        return (List<String>)template.makeRequest(request, new RequestMarshaller() {
            public Object marshal(InputStream istream) throws Exception {
                XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                factory.setNamespaceAware(false);
                XmlPullParser parser= factory.newPullParser();    
                parser.setInput(istream, "utf8");

                XmlUtils.nextStartTag(parser, "response");
                XmlUtils.nextStartTag(parser, "status");
                XmlUtils.skipSubTree(parser);
                XmlUtils.nextStartTag(parser, "wc:info");
                XmlUtils.nextStartTag(parser, "group");

                List<String> systolic = new ArrayList<String>();

                while (parser.nextTag() == XmlPullParser.START_TAG) {
                  if ("thing".equals(parser.getName())) {
                      int thingDepth = parser.getDepth();
                      while (parser.nextTag() == XmlPullParser.START_TAG
                              && parser.getDepth() > thingDepth) {
                          if ("data-xml".equals(parser.getName()))
                          {
                              int dataXmlDepth = parser.getDepth();
                              while (parser.nextTag() == XmlPullParser.START_TAG
                                      && parser.getDepth() > dataXmlDepth) {
                                  if ("blood-pressure".equals(parser.getName())) {


                                      List<BloodPressureData> lBP = mBloodPressure.createFromBloodPressureXml(parser);
                                      for(int i=0;i<lBP.size();i++){



                                          RBP.add(new BloodPressureData(lBP.get(i).getYear(),lBP.get(i).getMonth(),
                                                  lBP.get(i).getDate(),lBP.get(i).getHour(),lBP.get(i).getSystolic(),
                                                  lBP.get(i).getDiastolic(),lBP.get(i).getPulse()
                                            ));

                                      }
                                     // systolic.add(
                                        //  String.valueOf(BloodPressure.createFromXml(parser).getValue()));
                                  }
                                  else {
                                      XmlUtils.skipSubTree(parser);
                                  }
                              }
                          }
                          else
                          {
                              XmlUtils.skipSubTree(parser);
                          }
                      }
                  } else {
                     XmlUtils.skipSubTree(parser);
                  }
                }

                for(int i=0;i<RBP.size();i++){

                  Log.d("DATE", RBP.get(i).getMonth()+"");

              }

                systolic.add("55");
                return systolic;

            }
        });


Is it possible to get All the data in just one single Request??????????
Coordinator
Aug 26, 2013 at 2:48 PM
Hi,

Yes, that is no problem. You can put multiple type-id elements in the request:
<info>
  <group max="20">
    <filter>
      <type-id>ca3c57f4-f4c1-4e15-be67-0a3caf5414ed</type-id>
      <type-id>3d34d87e-7fc1-4153-800f-f56592cb0d1</type-id>
    </filter>
    <format>
      <section>core</section>
      <xml/>
    </format>
  </group>
</info>"
Aug 27, 2013 at 8:33 AM
Edited Aug 27, 2013 at 10:34 AM
Hi robmay
thanks for help me

This is my core code

info = "<info><group max=\"25\"><filter>" +
                /*"<type-id>" +
                "ca3c57f4-f4c1-4e15-be67-0a3caf5414ed" +  // blood pressure
                "</type-id>" +

                "<type-id>" +
                Weight.TYPE+
                "</type-id>" +*/

                "<type-id>" +
                "879e7c04-4e8a-4707-9ad3-b054df467ce4"+  // for blood glucose
                "</type-id>" +


                "</filter><format><section>core</section>" +
                "<xml/></format></group></info>";
Here I am getting blood pressure and weight

but I am not getting blood glucose.

If i debug i found

parser.getName() should be "thing"

but in case of blood glucose it is "filtered"

I don't understand meaning of "filtered"????????????????????

here is my code...................

while (parser.nextTag() == XmlPullParser.START_TAG) {
                  if ("thing".equals(parser.getName())) {     
                      int thingDepth = parser.getDepth();
                      while (parser.nextTag() == XmlPullParser.START_TAG
                              && parser.getDepth() > thingDepth) {
                          if ("data-xml".equals(parser.getName()))
                          {
                              int dataXmlDepth = parser.getDepth();
                              while (parser.nextTag() == XmlPullParser.START_TAG
                                      && parser.getDepth() > dataXmlDepth) {
                                  if ("blood-pressure".equals(parser.getName())) {  // working fine


                                      List<BloodPressureData> lBP = mBloodPressure.createFromBloodPressureXml(parser);
                                      for(int i=0;i<lBP.size();i++){



                                          RBP.add(new BloodPressureData(lBP.get(i).getYear(),lBP.get(i).getMonth(),
                                                  lBP.get(i).getDate(),lBP.get(i).getHour(),lBP.get(i).getSystolic(),
                                                  lBP.get(i).getDiastolic(),lBP.get(i).getPulse()
                                            ));

                                      }
                                     // systolic.add(
                                        //  String.valueOf(BloodPressure.createFromXml(parser).getValue()));
                                  }else if ("blood-glucose".equals(parser.getName())) {  // not working  I am not getting parser.getName() = lood-glucose

                                      mBloodGlucose.createParseBloodGlucoseXml(parser);                                      
                                      }else if ("weight".equals(parser.getName())) {  // working fin e

                                        Log.d("I am on weight", "weight");      ;                                 
                                          }else {
                                      XmlUtils.skipSubTree(parser);
                                  }
                              }
                          }
                          else
                          {
                              XmlUtils.skipSubTree(parser);
                          }
                      }
                  } else {
                     XmlUtils.skipSubTree(parser);
                  }
                }
Aug 27, 2013 at 10:58 AM
Edited Aug 27, 2013 at 3:02 PM
Hi Hi robmay
1>

if I use Blood pressure Id my code It is working file

I am getting "thing" element in Above code

means Here if condition is true----- if ("thing".equals(parser.getName()))


But when I Chang the Id , if id is for Blood glucose, allergy

I am not getting "thing", I am getting "filtered"

means Here if condition is false----- if ("thing".equals(parser.getName())) // here i am getting parser.getName() == "filtered"

Can you please tell me the reason why i am getting "filtered", and What is the meaning of "filtered" ???????????



2> when I try to put blood glucose data i am getting error

com.microsoft.hsg.HVAccessDeniedException: Access is denied.

Here is my input XML For Blood glucose........

<info><thing><type-id>879e7c04-4e8a-4707-9ad3-b054df467ce4</type-id><data-xml><blood-glucose><when><date><y>2013</y><m>8</m><d>27</d></date><time><h>20</h><m>26</m><s>4</s></time></when><value><mmolPerL>.111</mmolPerL><display units="mg/dl">99</display></value><glucose-measurement-type><text>White Blood</text></glucose-measurement-type></blood-glucose><common/></data-xml></thing></info>
Coordinator
Aug 27, 2013 at 5:00 PM
The application you are using has not been authorized for blood glucose.

For your app-id, go to https://config.healthvault-ppe.com and edit the offline rules to include the type-ids your application needs. It may take up to 20 minutes for the change to take affect. You will also need to reauthorize your application -- the use needs to accept the new permissions. In your case, it's easiest to clear your application from your device and start over so that the user will authorize it again.

--Rob
Aug 28, 2013 at 11:26 AM
Edited Aug 28, 2013 at 11:27 AM
Thanks robmay

I edit the offline rule it is working Fine

But i have another problem

if I use Max = 10 it working fine but when I use Max = 25 it gives error

com.microsoft.hsg.HVException: Could not marshal response


<info><group max=\"14\"><filter><type-id>" +
            "879e7c04-4e8a-4707-9ad3-b054df467ce4" +
            "</type-id></filter><format><section>core</section>" +
            "<xml/></format></group></info>";





Coordinator
Aug 28, 2013 at 7:47 PM
My guess is that there is something coming back in items number 11 - 25 that cause your parsing code to fail somehow.
Sep 4, 2013 at 6:26 PM
Hi robmay

in below code i get only 14 result

In health vault if 20 blood pressure Record is present then I get 14 result for blood pressure only , i am not getting any result for weight

How to get 15- 15 result from each record "Blood pressure" and "weight"



<info><group max=\"14\"><filter><type-id>" +
"<type-id>" +
            "ca3c57f4-f4c1-4e15-be67-0a3caf5414ed" +  // blood pressure
            "</type-id>" +

            "<type-id>" +
            Weight.TYPE+
            "</type-id>" +

            "<type-id>" +
            "879e7c04-4e8a-4707-9ad3-b054df467ce4"+  // for blood glucose
            "</type-id>" +
Coordinator
Sep 4, 2013 at 11:06 PM
Hi,

Have a look at the HealthVault Developer Documentation. Specifically here: http://msdn.microsoft.com/en-us/library/jj582876.aspx
Sep 13, 2013 at 7:00 AM
Edited Sep 20, 2013 at 6:52 AM
Thanks