vendredi 10 juillet 2020

Can someone help me create a test in Postman in order to validate that a key has the expected value inside a nested group?

Can someone point me in the right direction to write a test in Postman in order to validate that a certain key or value from the following response is present. The response has a lot of nested objects. Specifically I want to validate the following:

  1. I want to validate that in the output.treatments there's a key "type" with the value "Diet" present
  2. and I also want to validate that in the output.treatments.details there's a key "name" with the value "SULFAMETHOXAZOLE/TRIMETHOPRIM"

Or if it's easier, I could also only add a single test that would look for a certain value, in this case "SULFAMETHOXAZOLE/TRIMETHOPRIM" because I don't really care the key that returns it since it's always going to be the same.

Thanks!

The API response looks like this:

{
  "additionalInformation": {
    "knownDrugAllergies": [],
    "knownDrugConflicts": [
      {
        "conflict": "OXYBUTYNIN CHLORIDE",
        "potentialDrugs": [
          "item1",
          "item2"
        ]
      }
    ],
    "knownPrecautionConflicts": [
      {
        "conflict": "OXYBUTYNIN CHLORIDE",
        "potentialDrugs": [
          "Drowsy",
          "Gastroesophageal Reflux",
          "Myasthenia Gravis",
          "Parkinsonism",
          "Ulcerative Colitis"
        ]
      }
    ]
  },
  "output": [
    {
      "icdCode": "N39.3",
      "icdDesc": "Stress incontinence (female) (male)",
      "isIllness": true,
      "treatments": [
        {
          "details": [],
          "type": "Physical Exam"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Group Placeholder",
              "longName": "Normal Diet",
              "name": "Normal Diet",
              "nameDetails": "The patient has no dietary restrictions",
              "priority": 16,
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ],
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            }
          ],
          "type": "Diet"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Group Placeholder",
              "longName": "No Restrictions",
              "name": "No Restrictions",
              "nameDetails": "The patient has no activity restrictions",
              "priority": 16,
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ],
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            }
          ],
          "type": "Activity"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Group Placeholder",
              "longName": "None Needed ",
              "name": "None Needed",
              "nameDetails": "No physical therapy is needed.",
              "priority": 20,
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ],
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            }
          ],
          "type": "Physical Therapy"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Group Placeholder",
              "longName": "Kegel Exercises",
              "name": "Kegel Exercises",
              "nameDetails": "INCOMPLETE",
              "priority": 20,
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ],
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            }
          ],
          "type": "Counseling"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Group Placeholder",
              "longName": "Patient Can Resume Work/School Immediately",
              "name": "Immediately",
              "nameDetails": "Patient Can Resume Work/School Immediately",
              "priority": 8,
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ],
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            }
          ],
          "type": "Return to Work/School Status"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Group Placeholder",
              "longName": "Wound Care Not Needed",
              "name": "Not Needed",
              "nameDetails": "Wound Care Not Needed",
              "priority": 20,
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ],
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            }
          ],
          "type": "Wound Care"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Group Placeholder",
              "longName": "Urine Analysis",
              "name": "Urine Analysis",
              "nameDetails": "Evaluate the urine for electrolytes and pH.",
              "priority": 20,
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            }
          ],
          "type": "Labs"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Group Placeholder",
              "longName": "Specialist Consultation",
              "name": "Specialist Consult",
              "nameDetails": "The patient should consult with a specialist in the appropriate field.",
              "priority": 29,
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            }
          ],
          "type": "Discharge Disposition"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Group 2",
              "longName": "placeholder",
              "name": "DULOXETINE HCL",
              "nameDetails": "Name Details Placeholder",
              "priority": 20,
              "protocol": [
                "example"
              ],
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            },
            {
              "directions": [],
              "dosage": "",
              "groupName": "Standard",
              "longName": "placeholder",
              "name": "SULFAMETHOXAZOLE/TRIMETHOPRIM",
              "nameDetails": "Name Details Placeholder",
              "priority": 20,
              "protocol": [
                "example"
              ],
              "rank": 3,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            },
            {
              "directions": [],
              "dosage": "",
              "groupName": "Standard",
              "longName": "placeholder",
              "name": "TOLTERODINE TARTRATE",
              "nameDetails": "Name Details Placeholder",
              "priority": 20,
              "protocol": [
                "example"
              ],
              "rank": 1,
              "reasons": [],
              "sources": [
                [
                  "no sources",
                  "no URL"
                ]
              ]
            }
          ],
          "type": "Prescription Drugs"
        },
        {
          "details": [
            {
              "directions": [],
              "dosage": "",
              "groupName": "Standard",
              "longName": "placeholder",
              "name": "OXYBUTYNIN",
              "nameDetails": "Name Details Placeholder",
              "priority": 20,
              "protocol": [
                "example"
              ],
              "rank": 2,
              "reasons": [],
              "sources": [
                [
                  "TEST",
                  "https://google.com"
                ]
              ]
            }
          ],
          "type": "OTC Drugs"
        }
      ]
    }
  ],
  "status": "Complete",
  "version": 3
} 

Aucun commentaire:

Enregistrer un commentaire