NHSDigital / integration-adaptor-nhais

Adaptors which accelerate integration with national NHS systems
Apache License 2.0
4 stars 3 forks source link

Parameter value property defined as "valueString" is accepting boolean and integer values also #191

Closed sonalnegivarma closed 4 years ago

sonalnegivarma commented 4 years ago

This Defect is logged considering multiple cases in different transactions.

Eg. Date of Deduction
Reason for Deduction GP Notes

All are defined as value String, but are giving 202 response when value is passed as an integer or boolean (true or false) Expected - 400 Bad request

michael-kainos commented 4 years ago

Needs more information, please follow the defect management process shared when raising issues. @sonalnegivarma

srujan479 commented 4 years ago

Hi @michael-kainos please find the description of the issue:

First Case:

{ "nhsNumber": "9999999999", "gpCode": "2750922,295", "gpTradingPartnerCode": "TES5", "healthcarePartyCode": "XX1", "freeText": "NOW AT THE ARTHUR ANDREWS CENTRE", "patches": [

{
  "op": "replace",
  "path": "/extension/0",
  "value": {
    "url": "https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-NHAIS-DrugsDispensedMarker",
    **"valueBoolean": "abc"**
  }
},
{
  "op": "add",
  "path": "/extension/0",
  "value": {
    "url": "https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-NHAIS-ResidentialInstituteCode",
    "valueString": "AA"
  }
}

] }

The valueBoolean is accepting String("abc")in the above payload for Amendment transaction "New Drugs dispensed marker" field, As it is expecting Boolean value(true or false) It should return 400 status code instead of 202.

Second Case:

{ "nhsNumber": "9999999999", "gpCode": "2750922,295", "gpTradingPartnerCode": "TES5", "healthcarePartyCode": "XX1", "freeText": "NOW AT THE ARTHUR ANDREWS CENTRE", "patches": [

{
  "op": "replace",
  "path": "/extension/0",
  "value": {
    "url": "https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-NHAIS-DrugsDispensedMarker",
    "valueBoolean": true
  }
},
{
  "op": "add",
  "path": "/extension/0",
  "value": {
    "url": "https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-NHAIS-ResidentialInstituteCode",
    **"valueString": 123**
  }
}

] }

In This Case the valueString is accepting Integer(123) in the above payload for Amendment transaction "Residential Institute Code" field, As it is expecting String Value it should return 400 status code instead of 202.

mattd-kainos commented 4 years ago

First case: Cannot reproduce. I get a 400 error response

REQUEST

curl --location --request PATCH 'http://localhost:8888/fhir/Patient/9999999999' \
--header 'content-type: application/json' \
--data-raw '{
"nhsNumber": "9999999999",
"gpCode": "2750922,295",
"gpTradingPartnerCode": "TES5",
"healthcarePartyCode": "XX1",
"freeText": "NOW AT THE ARTHUR ANDREWS CENTRE",
"patches": [

{
  "op": "replace",
  "path": "/extension/0",
  "value": {
    "url": "https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-NHAIS-DrugsDispensedMarker",
    "valueBoolean": "abc"
  }
},
{
  "op": "add",
  "path": "/extension/0",
  "value": {
    "url": "https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-NHAIS-ResidentialInstituteCode",
    "valueString": "AA"
  }
}
]
}'

RESPONSE BODY, STATUS 400

{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "invalid",
      "details": {
        "text": "Cannot deserialize value of type `boolean` from String \"abc\": only \"true\" or \"false\" recognized\n at [Source: (String)\"{\n\"nhsNumber\": \"9999999999\",\n\"gpCode\": \"2750922,295\",\n\"gpTradingPartnerCode\": \"TES5\",\n\"healthcarePartyCode\": \"XX1\",\n\"freeText\": \"NOW AT THE ARTHUR ANDREWS CENTRE\",\n\"patches\": [\n\n{\n  \"op\": \"replace\",\n  \"path\": \"/extension/0\",\n  \"value\": {\n    \"url\": \"https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-NHAIS-DrugsDispensedMarker\",\n    \"valueBoolean\": \"abc\"\n  }\n},\n{\n  \"op\": \"add\",\n  \"path\": \"/extension/0\",\n  \"value\": {\n    \"url\": \"https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-\"[truncated 66 chars]; line: 14, column: 21] (through reference chain: uk.nhs.digital.nhsconnect.nhais.model.jsonpatch.AmendmentBody[\"patches\"]->java.util.ArrayList[0]->uk.nhs.digital.nhsconnect.nhais.model.jsonpatch.AmendmentPatch[\"value\"]->uk.nhs.digital.nhsconnect.nhais.model.jsonpatch.AmendmentValue[\"valueBoolean\"])"
      }
    }
  ]
}
mattd-kainos commented 4 years ago

Second case is a duplicate of #198 . Closing this issue as it cannot be reproduced / is a duplicate.