[resolved] Issue with the filter in GetThings method

May 30, 2011 at 4:47 AM

Hi Rob.

I apologize in advance for the length of this post since I have to include some XML snippets. I am using GetThings, with created-date-min filter and the result I get seems to be off by exactly 20 minutes. To make this clear, here is the XML for my request:

<wc-request:request xmlns:wc-request="urn:com.microsoft.wc.request">
  <auth>
    <hmac-data algName="HMACSHA1">
    R2WoONtqXCYRr5vnP+a+eo9sisE=</hmac-data>
  </auth>
  <header>
    <method>GetThings</method>
    <method-version>2</method-version>
    <record-id>*******</record-id>
    <auth-session>
      <auth-token>******</auth-token>
      <offline-person-info>
        <offline-person-id>********</offline-person-id>
      </offline-person-info>
    </auth-session>
    <language>en</language>
    <country>US</country>
    <msg-time>2011-05-29T23:21:44.791-05:00</msg-time>
    <msg-ttl>29100</msg-ttl>
    <version>0.0.0.1</version>
    <info-hash>
      <hash-data algName="SHA1">
      xXDRjH40DlRZkow/RfY7rXo/l40=</hash-data>
    </info-hash>
  </header>
  <info>
    <group max-full="100" max="100">
      <filter>
        <type-id>879e7c04-4e8a-4707-9ad3-b054df467ce4</type-id>
        <created-date-min>
        2011-05-30T00:41:15.492Z</created-date-min>
      </filter>
      <format>
        <section>core</section>
        <xml></xml>
      </format>
    </group>
  </info>
</wc-request:request>

and here is the response that I get:

<response>
  <status>
    <code>0</code>
  </status>
  <wc:info xmlns:wc="urn:com.microsoft.wc.methods.response.GetThings">

    <group>
      <thing>
        <thing-id version-stamp="61e775d9-edbc-4ab0-94f3-c65cb65296f5">
        937d6eca-1543-4aba-9eb0-cb7c8835b3e5</thing-id>
        <type-id name="Blood Glucose Measurement">
        879e7c04-4e8a-4707-9ad3-b054df467ce4</type-id>
        <thing-state>Active</thing-state>
        <flags>0</flags>
        <eff-date>2011-05-30T00:21:16</eff-date>
        <data-xml>
          <blood-glucose>
            <when>
              <date>
                <y>2011</y>
                <m>5</m>
                <d>30</d>
              </date>
              <time>
                <h>0</h>
                <m>21</m>
                <s>16</s>
              </time>
            </when>
            <value>
              <mmolPerL>7.0</mmolPerL>
              <display units="mg/dL" units-code="mg/dL">
              120.0</display>
            </value>
            <glucose-measurement-type>
              <text>Whole Blood</text>
            </glucose-measurement-type>
          </blood-glucose>
          <common>
            <source>Ali Naddaf</source>
          </common>
        </data-xml>
      </thing>
    </group>
  </wc:info>
</response>

As you can see, in my GetThings, I am setting the created-date-min in the filter to be 2011-05-30T00:41:15.492Z and yet, I am getting a record in the response that was created at 2011-05-30T00:21:16.492Z
(20 minutes prior to the created-date-min of the filter). If I send a second request and change the created-date-min filter to 2011-05-30T00:41:17.492Z (two seconds later than the one sent in the first request), then I get no records back in the response. So for
some reason, it seems that date in the data returned is exactly 20 minutes off compared to the one in the filter.

Am I doing something wrong?

Thanks,
ali.

May 30, 2011 at 2:10 PM

I also noticed the following. When I requested the AUDIT part to be added to the response, here is what I got:

<response>
  <status>
    <code>0</code>
  </status>
  <wc:info xmlns:wc="urn:com.microsoft.wc.methods.response.GetThings">

    <group>
      <thing>
        <thing-id version-stamp="61e775d9-edbc-4ab0-94f3-c65cb65296f5">
        937d6eca-1543-4aba-9eb0-cb7c8835b3e5</thing-id>
        <type-id name="Blood Glucose Measurement">
        879e7c04-4e8a-4707-9ad3-b054df467ce4</type-id>
        <thing-state>Active</thing-state>
        <flags>0</flags>
        <eff-date>2011-05-30T00:21:16</eff-date>
        <created>
          <timestamp>2011-05-30T00:41:16.22Z</timestamp>
          <app-id name="******">*****</app-id>
          <person-id name="Ali Naddaf">****</person-id>
          <access-avenue>Offline</access-avenue>
          <audit-action>Created</audit-action>
        </created>
        <updated>
          <timestamp>2011-05-30T00:41:16.22Z</timestamp>
          <app-id name="******">****</app-id>
          <person-id name="Ali Naddaf">*****</person-id>
          <access-avenue>Offline</access-avenue>
          <audit-action>Created</audit-action>
        </updated>
        <data-xml>
          <blood-glucose>
            <when>
              <date>
                <y>2011</y>
                <m>5</m>
                <d>30</d>
              </date>
              <time>
                <h>0</h>
                <m>21</m>
                <s>16</s>
              </time>
            </when>
            <value>
              <mmolPerL>7.0</mmolPerL>
              <display units="mg/dL" units-code="mg/dL">
              120.0</display>
            </value>
            <glucose-measurement-type>
              <text>Whole Blood</text>
            </glucose-measurement-type>
          </blood-glucose>
          <common>
            <source>Ali Naddaf</source>
          </common>
        </data-xml>
      </thing>
    </group>
  </wc:info>
</response>

So the Audit section shows the <timestamp>2011-05-30T00:41:16.22Z</timestamp> for both created and updated, which doesn't match with the WHEN element. Hope this extra piece of information helps.

Thanks

Ali.

May 30, 2011 at 2:59 PM

I have noticed where the issue was coming from. My mistake was that I thought I could directly query based on the "when" portion of the record by setting the "created" time of the filter. That is not the case and the created time is really a timestamp of when the

application created the record, independent of the "when" portion of the record. My objective was to query based on "when"and since that is not accessible as a search parameter in the filter, I hav now changed my code to use the "effective date" in the

query and it seems to work fine.

 

Thanks,

Ali.