REST Module does not document POST for RadiologyOrderResource

radiology

(Ivange94) #1

In the past the only endpoints in radiology for RadiologyOrderResource that have always been documented by the REST module are

DELETE /radiologyorder/{uuid}

GET /radiologyorder/{uuid}

GET /radiologyorder

I always assumed that’s because in the RadiologyOrderResource the newDelegate and save methods threw a ResourceDoesNotSupportOperationException and meaning it could not support creation of orders via REST hence the absence for POST documentation for them.

But looks like my assumption was wrong. Because despite the fact that in the RadiologyOrderResource, purge and delete both threw a ResourceDoesNotSupportOperationException, a delete endpoint is still appearing in the REST api documentation. See screenshot below

ra

In an attempt to make the REST module document POST endpoints for RadiologyOrderResource, I changed the implementation of the newDelegate and save methods to

/**
 * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate()
 */
@Override
public RadiologyOrder newDelegate() {
    
    return new RadiologyOrder();
}

/**
 * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object)
 */
@Override
public RadiologyOrder save(RadiologyOrder delegate) {
    
    return Context.getService(RadiologyOrderService.class)
            .placeRadiologyOrder(delegate)
}

See full RadiologyOrderResource implementation here

But despite doing that I still don’t see any documentation for POST on the REST API docs.

I noticed that the REST module does document POST for RadiologyModalityResource and I the implementation for RadiologyModalityResource is similar to RadiologyOrderResource but for the fact that RadiologyModalityResource is a Subclass of MetadataDelegatingCrudResource while RadiologyOrderResource is a subclass of DataDelegatingCrudResource.


(Ivange94) #2

For reference of how this discussion is coming along, you may want to visit the corresponding thread under openmrs


(Ivange94) #3

Fixed it. I had to implement newDelegate, save and getCreatableProperties to for it to work.