Skip to content

Commit

Permalink
RESTWS-726: Return diagnoses with an encounter (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsurrao authored and mogoodrich committed Oct 24, 2018
1 parent b77134b commit 7c82178
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* {@link Resource} for {@link EncounterResource1_9}, supporting standard CRUD operations
*/
@Resource(name = RestConstants.VERSION_1 + "/encounter", supportedClass = Encounter.class, supportedOpenmrsVersions = {
"1.9.*", "1.10.*", "1.11.*", "1.12.*", "2.0.*", "2.1.*", "2.2.*" })
"1.9.*", "1.10.*", "1.11.*", "1.12.*", "2.0.*", "2.1.*" })
public class EncounterResource1_9 extends org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.EncounterResource1_8 {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_2;

import org.openmrs.Encounter;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
import org.openmrs.module.webservices.rest.web.representation.FullRepresentation;
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.v1_0.resource.openmrs1_9.EncounterResource1_9;

/**
* {@link Resource} for {@link EncounterResource2_2}, supporting standard CRUD operations
*/
@Resource(name = RestConstants.VERSION_1 + "/encounter", supportedClass = Encounter.class, supportedOpenmrsVersions = { "2.2.*" })
public class EncounterResource2_2 extends EncounterResource1_9 {

@Override
public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
DelegatingResourceDescription description = null;
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
description = super.getRepresentationDescription(rep);
description.addProperty("diagnoses");
}
return description;
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getResourceVersion()
*/
@Override
public String getResourceVersion() {
return RestConstants2_2.RESOURCE_VERSION;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_2;

public class RestConstants2_2 {

public static final String RESOURCE_VERSION = "2.2";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_2;

import org.junit.Before;
import org.openmrs.Encounter;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest;
import org.openmrs.module.webservices.rest.web.v1_0.RestTestConstants2_2;

public class EncounterResource2_2Test extends BaseDelegatingResourceTest<EncounterResource2_2, Encounter> {

@Before
public void before() throws Exception {
executeDataSet(RestTestConstants2_2.DIAGNOSIS_TEST_DATA_XML);
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#newObject()
*/
@Override
public Encounter newObject() {
return Context.getEncounterService().getEncounterByUuid(getUuidProperty());
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#validateDefaultRepresentation()
*/
@Override
public void validateDefaultRepresentation() throws Exception {
super.validateDefaultRepresentation();
assertPropEquals("encounterDatetime", getObject().getEncounterDatetime());
assertPropPresent("patient");
assertPropPresent("location");
assertPropPresent("form");
assertPropPresent("encounterType");
assertPropPresent("diagnoses");
assertPropPresent("obs");
assertPropPresent("orders");
assertPropPresent("encounterProviders");
assertPropEquals("voided", getObject().getVoided());
assertPropPresent("visit");
assertPropEquals("resourceVersion", "2.2");
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#validateFullRepresentation()
*/
@Override
public void validateFullRepresentation() throws Exception {
super.validateFullRepresentation();
assertPropEquals("encounterDatetime", getObject().getEncounterDatetime());
assertPropPresent("patient");
assertPropPresent("location");
assertPropPresent("form");
assertPropPresent("encounterType");
assertPropPresent("encounterProviders");
assertPropPresent("diagnoses");
assertPropPresent("obs");
assertPropPresent("orders");
assertPropEquals("voided", getObject().getVoided());
assertPropPresent("auditInfo");
assertPropPresent("visit");
assertPropEquals("resourceVersion", "2.2");
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#getDisplayProperty()
*/
@Override
public String getDisplayProperty() {
return "Scheduled 12/08/2017";
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#getUuidProperty()
*/
@Override
public String getUuidProperty() {
return "44444-fcdb-4a5b-97ea-0d5c4b4315a1";
}
}

0 comments on commit 7c82178

Please sign in to comment.