Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTWS-726: Return diagnoses with an encounter #356

Merged
merged 1 commit into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional not to include these among creatable/updatable properties?

}
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";
}
}