Why does PatientService have removeAllergy and voidAllergy methods? When they both do the same, i.e. remove delegates to void
@Wyclif, those methods were transferred from allergyapi module in TRUNK-4747.
@darius, DELETE patient/uuid/allergy as a way of deleting all allergies is proving difficult to implement. DelegatingSubResource does not have a method which can be overridden to implement this behavior as its getAll method can be used to implement GET patient/uuid/allergy. Even if we assume in DelegatingSubResource.delete(allergy, reason, context) that the allergy parameter is null, I canât see a way to access the parent Patient without which the list of allergies canât be retrieved. An alternative is to require the client to delete all allergies one by one. What is the way to go?
Canât you override public void delete(String parentUniqueId, String uuid, String reason, RequestContext context)
and if uuid is null delete all allergies? I assume that parentUniqueId = uuid of patient (maybe Iâm wrong).
Great, that is the solution I am I am looking for.
Thatâs the same thing i mentioned on IRC about delete. As for the duplicate methods, we should get rid of remove since it is doesnât follow our naming convention for void methods
Iâm assuming:
-
DELETE /patient/{uuid}/allergy
would set the allergy list to an unknown status (i.e., we donât know anything about the patientâs allergies). -
DELETE /patient/{uuid}/allergy/{uuid}
on the last known allergy for a patient (i.e., a patient with one allergy) would have the same effect. @jteich has argued that deleting the last allergy from the list should take the patientâs allergies to an unknown status and I agree.
But how does a client set the patientâs allergies to âNo known allergiesâ â i.e., itâs not that we donât know about the patientâs allergies; rather, we know the patientâs allergies and itâs an empty list. Iâve reviewed Dariusâ summary, but didnât see this in the list. Setting the patientâs allergy list to âno known allergiesâ (i.e., an empty list) is a very commonly used operation.
Would it be PUT /patient/{uuid}/allergies
with an empty list? If so, that should return a 400 error if the patient has any known allergies (we shouldnât silently void existing allergies).
@burke if you set the allergy status to unknown, the wouldnât imply we need to void all the patientâs allergies? Which i think @jdegraft is having trouble with
Would it be PUT /patient/{uuid}/allergies with an empty list? If so, that should return a 400 error if the patient has any known allergies (we shouldnât silently void existing allergies).
A problem is this will not allow a patient to move from having allergies to no known allergies if we need to support this. A child might be allergic and grow out of it. The allergies may have been attached by mistake and have to be removed.
It seems we need to differentiate the initial state and the state that is empty, from an explicit void state. If we start with Unknown Status and return to Unknown Status when all Allergies are voided, then we must be able to set No Known Allergies at any time irrespective of whether there are attached allergies or not.
As @Wyclif indicates the webservices infrastructure does not support
DELETE /patient/{uuid}/allergy would set the allergy list to an unknown status (i.e., we donât know anything about the patientâs allergies)
it may support
PUT /patient/{uuid}/allergies with an empty list
however.
@wyclif, @burke is raising a different issue (though a bit related).
In the UI there is a âNo Known Allergyâ button, which is only available if the patientâs allergy state is unknown and will put them in the no known allergies state. However we have never stated how you would put a patient in this state via REST.
I agree with @burke that PUT /patient/{uuid}/allergies
with body []
makes the most sense from an API standpoint.
We havenât used PUT anywhere else, because elsewhere we only support updating certain properties, rather than putting the complete state of the resource. However in this case we are talking about putting the complete state of the resource, soâŠ
-
PUT /patient/{uuid}/allergies
with body[]
, for a patient in the âunknown allergiesâ state should move them to the âno known allergiesâ state by callingAllergies.confirmNoKnownAllergies()
. It should return the patientâs allergies as its response.
-
PUT /patient/{uuid}/allergies
with body[]
, for a patient already in the âno known allergiesâ state should have no effect. It should return the patientâs allergies as its response. -
PUT /patient/{uuid}/allergies
with body[]
, for a patient with 1+ allergies recorded should fail with a 4xx response. -
PUT /patient/{uuid}/allergies
with any value for its body besides the empty list should fail with a 4xx response- Our API doesnât allow creating multiple allergies at a time. This might actually be nice behavior to have but it would be part of another ticket, and weâd only do this if a real consumer requests it.
Aside: for another kind of reasoning why you wouldnât use PUT, but that doesnât apply in our case, you can read about REST without PUT in the ThoughtWorks Tech Radar.
The (intentional) idea is that youâre not allowed to directly go from the state of âsome known allergiesâ to âno known allergiesâ, but rather you (either via the UI, or via the REST API) have to delete/void all of the patientâs existing allergies, which automatically puts them in the âunknown allergiesâ state. Then you can do a PUT to move them to the âno known allergiesâ state.