Visit REST creates duplicate obs

Just wondering if anyone else noticed this problem with the visit REST? When I post a visit json including a simple encounter with one obs the web service creates duplicate obs. Here is the payload request:

Request URL: http://localhost:8085//openmrs/ws/rest/v1/visit
Request Method: POST
Status Code: 201 Created

{"patient":"4b63b540-dc06-4263-bab1-ab0aea46091b","location":"0d414ce2-5ab4-11e0-870c-9f6107fee88e","visitType":"f01c54cb-2225-471a-9cd5-d348552c337c","encounters":[{"uuid":"d3eb44cd-b7eb-4904-bf9a-b8643e6b2c84","patient":"4b63b540-dc06-4263-bab1-ab0aea46091b","location":"0d414ce2-5ab4-11e0-870c-9f6107fee88e","encounterType":"55a0d3ea-a4d7-4e88-8f01-5aceb2d3c61b","obs":[{"concept":"65664fc2-977f-11e1-8993-905e29aff6c1","value":"6f48e5b0-9ffa-11e8-98d0-529269fb1459"}]}]}

And here is the response:

{"uuid":"92957658-3a18-4179-83d7-85b0f2b5c476","display":"Clinic or Hospital Visit @ Neno District Hospital - 31/08/2018 11:17","patient":{"uuid":"4b63b540-dc06-4263-bab1-ab0aea46091b","display":"NNO 2782 - Chakanika Nowa","links":[{"uri":"http://localhost:8085//openmrs/ws/rest/v1/patient/4b63b540-dc06-4263-bab1-ab0aea46091b","rel":"self"}]},"visitType":{"uuid":"f01c54cb-2225-471a-9cd5-d348552c337c","display":"Clinic or Hospital Visit","links":[{"uri":"http://localhost:8085//openmrs/ws/rest/v1/visittype/f01c54cb-2225-471a-9cd5-d348552c337c","rel":"self"}]},"indication":null,"location":{"uuid":"0d414ce2-5ab4-11e0-870c-9f6107fee88e","display":"Neno District Hospital","links":[{"uri":"http://localhost:8085//openmrs/ws/rest/v1/location/0d414ce2-5ab4-11e0-870c-9f6107fee88e","rel":"self"}]},"startDatetime":"2018-08-31T11:17:47.047+0200","stopDatetime":null,"encounters":[{"uuid":"d3eb44cd-b7eb-4904-bf9a-b8643e6b2c84","display":"Check-in 31/08/2018","links":[{"uri":"http://localhost:8085//openmrs/ws/rest/v1/encounter/d3eb44cd-b7eb-4904-bf9a-b8643e6b2c84","rel":"self"}]}],"attributes":[],"voided":false,"links":[{"uri":"http://localhost:8085//openmrs/ws/rest/v1/visit/92957658-3a18-4179-83d7-85b0f2b5c476","rel":"self"},{"uri":"http://localhost:8085//openmrs/ws/rest/v1/visit/92957658-3a18-4179-83d7-85b0f2b5c476?v=full","rel":"full"}],"resourceVersion":"1.9"}

A simple encounter GET shows the duplicate obs: http://localhost:8085/openmrs/ws/rest/v1/encounter/d3eb44cd-b7eb-4904-bf9a-b8643e6b2c84

{
"uuid": "d3eb44cd-b7eb-4904-bf9a-b8643e6b2c84",
"display": "Check-in 31/08/2018",
"encounterDatetime": "2018-08-31T11:17:47.000+0200",
"patient": {
    "uuid": "4b63b540-dc06-4263-bab1-ab0aea46091b",
    "display": "NNO 2782 - Chakanika Nowa",
    "links": [
        {
            "uri": "http://localhost:8085//openmrs/ws/rest/v1/patient/4b63b540-dc06-4263-bab1-ab0aea46091b",
            "rel": "self"
        }
    ]
},
"location": {
    "uuid": "0d414ce2-5ab4-11e0-870c-9f6107fee88e",
    "display": "Neno District Hospital",
    "links": [
        {
            "uri": "http://localhost:8085//openmrs/ws/rest/v1/location/0d414ce2-5ab4-11e0-870c-9f6107fee88e",
            "rel": "self"
        }
    ]
},
"form": null,
"encounterType": {
    "uuid": "55a0d3ea-a4d7-4e88-8f01-5aceb2d3c61b",
    "display": "Check-in",
    "links": [
        {
            "uri": "http://localhost:8085//openmrs/ws/rest/v1/encountertype/55a0d3ea-a4d7-4e88-8f01-5aceb2d3c61b",
            "rel": "self"
        }
    ]
},
"obs": [
    {
        "uuid": "6905eb6e-d1ad-41f2-a237-116a22a4cecc",
        "display": "Type of referring clinic or hospital: Outside Neno district",
        "links": [
            {
                "uri": "http://localhost:8085//openmrs/ws/rest/v1/obs/6905eb6e-d1ad-41f2-a237-116a22a4cecc",
                "rel": "self"
            }
        ]
    },
    {
        "uuid": "a51956dc-7370-4df3-a908-5f464a056455",
        "display": "Type of referring clinic or hospital: Outside Neno district",
        "links": [
            {
                "uri": "http://localhost:8085//openmrs/ws/rest/v1/obs/a51956dc-7370-4df3-a908-5f464a056455",
                "rel": "self"
            }
        ]
    }
],
"orders": [],
"voided": false,
"visit": {
    "uuid": "92957658-3a18-4179-83d7-85b0f2b5c476",
    "display": "Clinic or Hospital Visit @ Neno District Hospital - 31/08/2018 11:17",
    "links": [
        {
            "uri": "http://localhost:8085//openmrs/ws/rest/v1/visit/92957658-3a18-4179-83d7-85b0f2b5c476",
            "rel": "self"
        }
    ]
},
"encounterProviders": [],
"links": [
    {
        "uri": "http://localhost:8085//openmrs/ws/rest/v1/encounter/d3eb44cd-b7eb-4904-bf9a-b8643e6b2c84",
        "rel": "self"
    },
    {
        "uri": "http://localhost:8085//openmrs/ws/rest/v1/encounter/d3eb44cd-b7eb-4904-bf9a-b8643e6b2c84?v=full",
        "rel": "full"
    }
],
"resourceVersion": "1.9"

}

We use openmrs 1.9.11 and Rest Web Services 2.18.

Thanks!

Thanks for reporting this @cioan

I was able to reproduce it in a unit test and eventually fixed with: https://issues.openmrs.org/browse/RESTWS-719

1 Like

Thank you @dkayiwa. This is awesome! Thank you for the fast resolution to this problem.