-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RESTWS-726: Return diagnoses with an encounter (#356)
- Loading branch information
1 parent
b77134b
commit 7c82178
Showing
4 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...rg/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/EncounterResource2_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...va/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/RestConstants2_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
||
} |
89 changes: 89 additions & 0 deletions
89
...penmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/EncounterResource2_2Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |