Questions about resources in Allergy UI module

This is what to implement

Summary: (based on Questions about resources in Allergy UI module and several following comments:

  1. Allergies will be a subresource of patient. Mostly this will behave like the existing personattribute and patientidentifier subresources.

  2. The patient/allergy subresource will function like:

  • GET patient/uuid/allergy => gets current allergies (see below for what is returned)
  • POST patient/uuid/allergy => creates one new allergy
  • DELETE patient/uuid/allergy => sets allergyStatus to unknown and voids all allergies
  • this is “new” (i.e. there’s no equivalent mechanism in personattribute or patientidentifier)
  • GET patient/uuid/allergy/allergyuuid => { representation of one allergy }
  • POST patient/uuid/allergy/allergyuuid => updates a specific allergy
  • DELETE patient/uuid/allergy/allergyuuid => voids a specific allergy
  1. What is returned when you fetch a patient’s complete allergy status (i.e. GET patient/uuid/allergy)

(We will take a leap of faith and follow @burke and @kristopherschmidt’s suggestion about how a REST-first API should behave, even though @dkayiwa and I think this is less intuitive.)

If the patient’s allergy status is “Unknown” => return a response status of 404

If the patient’s allergy status is “No known allergies” => return { results: [] }

If the patient’s allergy status is “See list” => return

{
    results: [
        { /* representation of a single allergy */ },
        ...
    ],
    links: [
        /* if >1 page of results, we have next/prev links, just like other resources */
    ]
}
  1. Personally I think that the patient resource should also have an “allergyStatus” field added to it (and the underlying Patient.java and Patient.hbm.xml should reflect this), but I’m not 100% certain about this. (And further discussion on this point should not block the bulk of the web service work from being done now.)