-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
93 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
52 changes: 52 additions & 0 deletions
52
...a/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/PersonResource2_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,52 @@ | ||
/** | ||
* 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.Person; | ||
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.FullRepresentation; | ||
import org.openmrs.module.webservices.rest.web.representation.Representation; | ||
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; | ||
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; | ||
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; | ||
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_11.PersonResource1_11; | ||
|
||
/** | ||
* {@link Resource} for Person, supporting standard CRUD operations | ||
*/ | ||
@Resource(name = RestConstants.VERSION_1 + "/person", supportedClass = Person.class, supportedOpenmrsVersions = { | ||
"2.2.*" }) | ||
public class PersonResource2_2 extends PersonResource1_11 { | ||
|
||
/** | ||
* @see DelegatingCrudResource#getRepresentationDescription(Representation) | ||
*/ | ||
@Override | ||
public DelegatingResourceDescription getRepresentationDescription(Representation rep) { | ||
DelegatingResourceDescription description = super.getRepresentationDescription(rep); | ||
|
||
if (description != null && rep instanceof FullRepresentation) { | ||
description.addProperty("causeOfDeathNonCoded"); | ||
} | ||
return description; | ||
} | ||
|
||
/** | ||
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() | ||
*/ | ||
@Override | ||
public DelegatingResourceDescription getCreatableProperties() { | ||
DelegatingResourceDescription description = super.getCreatableProperties(); | ||
description.addProperty("causeOfDeathNonCoded"); | ||
return description; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...g/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/PersonResource2_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,40 @@ | ||
/** | ||
* 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.Person; | ||
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 PersonResource2_2Test extends BaseDelegatingResourceTest<PersonResource2_2, Person> { | ||
|
||
@Override | ||
public Person newObject() { | ||
return Context.getPersonService().getPersonByUuid(getUuidProperty()); | ||
} | ||
|
||
@Override | ||
public String getDisplayProperty() { | ||
return "Mr. Horatio Test Hornblower"; | ||
} | ||
|
||
@Override | ||
public String getUuidProperty() { | ||
return RestTestConstants2_2.PERSON_UUID; | ||
} | ||
|
||
@Override | ||
public void validateFullRepresentation() throws Exception { | ||
super.validateFullRepresentation(); | ||
assertPropEquals("causeOfDeathNonCoded", getObject().getCauseOfDeathNonCoded()); | ||
} | ||
|
||
} |