/**
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://license.openmrs.org
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */
package org.openmrs.module.webservices.rest.web.v1_0.resource;

import org.openmrs.Drug;
import org.openmrs.annotation.Handler;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource;
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
import org.openmrs.module.webservices.rest.web.response.ResponseException;

/**
 * {@link Resource} for {@link Drug}, supporting standard CRUD operations
 */
@Resource("drug")
@Handler(supports = Drug.class, order = 0)
public class DrugResource extends MetadataDelegatingCrudResource<Drug> {
	
	/**
	 * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String)
	 */
	@Override
	public Drug getByUniqueId(String uniqueId) {
		return Context.getConceptService().getDrugByUuid(uniqueId);
	}
	
	/**
	 * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate()
	 */
	@Override
	public Drug newDelegate() {
		return new Drug();
	}
	
	/**
	 * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object)
	 */
	@Override
	public Drug save(Drug delegate) {
		return Context.getConceptService().saveDrug(delegate);
	}
	
	/**
	 * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, org.openmrs.module.webservices.rest.web.RequestContext)
	 */
	@Override
	public void purge(Drug delegate, RequestContext context) throws ResponseException {
		if (delegate == null)
			return;
		Context.getConceptService().purgeDrug(delegate);
	}
	
	/**
	 * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation)
	 */
	@Override
	public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
		//Let the superclass handle this
		return null;
	}
	
	/**
	 * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext)
	 */
	@Override
	protected NeedsPaging<Drug> doGetAll(RequestContext context) throws ResponseException {
		return new NeedsPaging<Drug>(Context.getConceptService().getAllDrugs(context.getIncludeAll()), context);
	}
}

@@ -2915,32 +2915,748 @@
 ;%0D%0A%09%7D%0D%0A%09%0D%0A%09/**%0D%0A
+%09 * @see org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource#getCreatableProperties()%0D%0A%09 */%0D%0A%09@Override%0D%0A%09public DelegatingResourceDescription getCreatableProperties() %7B%0D%0A%09%09DelegatingResourceDescription description = super.getCreatableProperties();%0D%0A%09%09description.addRequiredProperty(%22combination%22);%0D%0A%09%09description.addRequiredProperty(%22concept%22);%09%0D%0A%0D%0A%09%09description.addProperty(%22name%22);%0D%0A%09%09description.addProperty(%22doseStrength%22);%0D%0A%09%09description.addProperty(%22maximumDailyDose%22);%0D%0A%09%09description.addProperty(%22minimumDailyDose%22);%0D%0A%09%09description.addProperty(%22units%22);%0D%0A%09%09description.addProperty(%22dosageForm%22);%0D%0A%09%09description.addProperty(%22route%22);%0D%0A%09%09%0D%0A%09%09return description;%0D%0A%09%7D%0D%0A%09%0D%0A%09/**%0D%0A
 %09 * @see org.ope

Define creatable/updatable properties on Drug resource - RESTWS-230 Author: nathanleiby