Uploaded image for project: 'Webservices REST Module'
  1. Webservices REST Module
  2. RESTWS-636

Can’t create Obs through REST with many levels of groupMembers

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • TBD
    • Resolution: Fixed
    • None
    • 2.17
    • None
    • None

    Description

      This issue refers to this openmrs Talk topic:
      https://talk.openmrs.org/t/cant-create-obs-through-rest-with-many-levels-of-groupmembers/9505

      Marcin Kruszyński:

      I'm not able to create Obs with groupMembers during creating Encounter.
      Firstly I was trying to create an encounter (/encounter endpoint) using following JSON in request:

      {
         "encounterType":"72607bf4-28f6-4866-91d4-6798c0ea0ae1",
         "encounterDatetime":"2017-01-09T00:00:00.000+0100",
         "patient":"f045c657-ab4b-4309-b560-18f7d616e9f4",
         "provider":"f045c657-ab4b-4309-b560-18f7d616e9f4",
         "obs":[
            {
               "concept":"54915241-0aaa-4c33-b3bd-9213815a2454",
               "obsDatetime":"2017-01-09T00:00:00.000+0100",
               "groupMembers":[
                  {
                     "concept":"19d83cea-66a5-4bbf-a5a3-737b1be686f6",
                     "obsDatetime":"2017-01-09T00:00:00.000+0100",
                     "groupMembers":[
                        {
                           "concept":"b7d4fa65-2cc4-47c6-8196-2f3ffcdff318",
                           "value":"No",
                           "obsDatetime":"2017-01-09T00:00:00.000+0100"
                        },
                        {
                           "concept":"96bd2056-d77a-4438-ae10-92b872b0255d",
                           "value":"Yes",
                           "obsDatetime":"2017-01-09T00:00:00.000+0100"
                        }
                     ]
                  },
                  {
                     "concept":"f1b54f69-7169-4369-8f7a-722e96916abc",
                     "value":"2nd",
                     "obsDatetime":"2017-01-09T00:00:00.000+0100"
                  },
                  {
                     "concept":"973fb9f2-114a-47c4-abe2-f2d2d9dcd799",
                     "value":"Maybe",
                     "obsDatetime":"2017-01-09T00:00:00.000+0100"
                  }
               ]
            }
         ]
      }
      

      When I was using this method, Concepts with uuid's b7d4fa65-2cc4-47c6-8196-2f3ffcdff318 and 96bd2056-d77a-4438-ae10-92b872b0255d aren't created, and the both parents of these Concepts has a null value.

      The next attempt was using a /obs endpoint. Firstly I was creating an encounter without observations, then the observations was assigning to this encounter by the /obs endpoint using following JSON:

      {
         "concept":"54915241-0aaa-4c33-b3bd-9213815a2454",
         "encounter":"e42a4933-1cc6-4c76-9e91-24c4cfc53c8e",
         "obsDatetime":"2017-01-09T00:00:00.000+0100",
         "person":"f045c657-ab4b-4309-b560-18f7d616e9f4",
         "groupMembers":[
            {
               "concept":"19d83cea-66a5-4bbf-a5a3-737b1be686f6",
               "encounter":"e42a4933-1cc6-4c76-9e91-24c4cfc53c8e",
               "obsDatetime":"2017-01-09T00:00:00.000+0100",
               "person":"f045c657-ab4b-4309-b560-18f7d616e9f4",
               "groupMembers":[
                  {
                     "concept":"b7d4fa65-2cc4-47c6-8196-2f3ffcdff318",
                     "encounter":"e42a4933-1cc6-4c76-9e91-24c4cfc53c8e",
                     "value":"No",
                     "obsDatetime":"2017-01-09T00:00:00.000+0100",
                     "person":"f045c657-ab4b-4309-b560-18f7d616e9f4",
                     "groupMembers":[]
                  },
                  {
                     "concept":"96bd2056-d77a-4438-ae10-92b872b0255d",
                     "encounter":"e42a4933-1cc6-4c76-9e91-24c4cfc53c8e",
                     "value":"Yes",
                     "obsDatetime":"2017-01-09T00:00:00.000+0100",
                     "person":"f045c657-ab4b-4309-b560-18f7d616e9f4",
                     "groupMembers":[]
                  }
               ]
            },
            {
               "concept":"f1b54f69-7169-4369-8f7a-722e96916abc",
               "encounter":"e42a4933-1cc6-4c76-9e91-24c4cfc53c8e",
               "value":"2nd",
               "obsDatetime":"2017-01-09T00:00:00.000+0100",
               "person":"f045c657-ab4b-4309-b560-18f7d616e9f4",
               "groupMembers":[]
            },
            {
               "concept":"973fb9f2-114a-47c4-abe2-f2d2d9dcd799",
               "encounter":"e42a4933-1cc6-4c76-9e91-24c4cfc53c8e",
               "value":"Maybe",
               "obsDatetime":"2017-01-09T00:00:00.000+0100",
               "person":"f045c657-ab4b-4309-b560-18f7d616e9f4",
               "groupMembers":[]
            }
         ]
      }
      

      In response I'm getting 400 code and message:
      Error while creating observation. Response body:

      {
         "error":{
            "message":"Invalid Submission",
            "code":"webservices.rest.error.invalid.submission",
            "globalErrors":[
               {
                  "code":"error.noValue",
                  "message":"error.noValue"
               }
            ],
            "fieldErrors":{
               "groupMembers":[
                  {
                     "code":"Obs.error.inGroupMember",
                     "message":"A member of this obs group has an error"
                  }
               ]
            }
         }
      }
      

      After the addition of the required value to the observation, the most nested Observation are not created again.

      There isn't any stack traces. I'm working with version 1.12.0 Build 8f283e.

      Gliffy Diagrams

        Attachments

          Activity

            People

              Unassigned Unassigned
              tmarzeion Tomasz Marzeion
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 2 hours
                  1d 2h