diff --git a/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/DiagnosisResource2_2.java b/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/DiagnosisResource2_2.java index 1b278fafb..4be563061 100644 --- a/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/DiagnosisResource2_2.java +++ b/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/DiagnosisResource2_2.java @@ -46,7 +46,7 @@ * {@link Resource} for Diagnosis, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/patientdiagnoses", supportedClass = Diagnosis.class, supportedOpenmrsVersions = { - "2.2.* - 9.*" }) + "2.2.* - 2.4.*" }) public class DiagnosisResource2_2 extends DataDelegatingCrudResource { /** @@ -169,7 +169,7 @@ public String getDisplayString(Diagnosis diagnosis) { @Override public DelegatingResourceDescription getCreatableProperties() throws ResourceDoesNotSupportOperationException { DelegatingResourceDescription description = new DelegatingResourceDescription(); - + description.addRequiredProperty("diagnosis"); description.addRequiredProperty("encounter"); description.addRequiredProperty("condition"); @@ -185,7 +185,7 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe */ @Override public Model getCREATEModel(Representation rep) { - + return new ModelImpl() .property("diagnosis", new StringProperty()) .property("encounter", new StringProperty()) @@ -193,7 +193,7 @@ public Model getCREATEModel(Representation rep) { .property("certainty", new StringProperty()) .property("patient", new StringProperty().example("uuid")) .property("rank", new IntegerProperty()); - + } /** @@ -209,7 +209,7 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe description.addRequiredProperty("voided"); description.addRequiredProperty("certainty"); description.addRequiredProperty("encounter"); - + return description; } diff --git a/omod-2.5/pom.xml b/omod-2.5/pom.xml new file mode 100644 index 000000000..f6eca1cef --- /dev/null +++ b/omod-2.5/pom.xml @@ -0,0 +1,215 @@ + + + 4.0.0 + + org.openmrs.module + webservices.rest + 2.45.0-SNAPSHOT + + + webservices.rest-omod-2.5 + jar + Rest Web Services 2.5 OMOD + OpenMRS module project for Rest Web Services + + + 2.5.0 + 1.8 + 1.8 + + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-common + ${project.parent.version} + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-common + ${project.parent.version} + tests + test + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-1.8 + ${project.parent.version} + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-1.8 + ${project.parent.version} + tests + test + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-1.9 + ${project.parent.version} + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-1.9 + ${project.parent.version} + tests + test + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-1.10 + ${project.parent.version} + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-1.10 + ${project.parent.version} + tests + test + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-1.11 + ${project.parent.version} + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-1.11 + ${project.parent.version} + tests + test + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.0 + ${project.parent.version} + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.0 + ${project.parent.version} + tests + test + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.2 + ${project.parent.version} + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.2 + ${project.parent.version} + tests + test + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.3 + ${project.parent.version} + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.3 + ${project.parent.version} + tests + test + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.4 + ${project.parent.version} + + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.4 + ${project.parent.version} + tests + test + + + + org.openmrs.api + openmrs-api + ${openmrs.version.2.5.0} + + + + org.openmrs.api + openmrs-api + test-jar + test + ${openmrs.version.2.5.0} + + + + org.openmrs.web + openmrs-web + ${openmrs.version.2.5.0} + + + + org.openmrs.web + openmrs-web + test-jar + test + ${openmrs.version.2.5.0} + + + + org.openmrs.test + openmrs-test + pom + test + ${openmrs.version.2.5.0} + + + + javax.servlet + javax.servlet-api + ${javaxVersion} + test + + + + org.apache.tomcat + jasper + ${apacheTomcatVersion} + provided + + + + + + + + org.jacoco + jacoco-maven-plugin + + + com.mycila + license-maven-plugin + +
${project.parent.basedir}/license-header.txt
+
+
+
+
+
diff --git a/omod-2.5/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_5/DiagnosisResource2_5.java b/omod-2.5/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_5/DiagnosisResource2_5.java new file mode 100644 index 000000000..4a55be051 --- /dev/null +++ b/omod-2.5/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_5/DiagnosisResource2_5.java @@ -0,0 +1,92 @@ +/** + * 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_5; + +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.StringProperty; +import org.openmrs.Diagnosis; +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.BaseDelegatingResource; +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.openmrs2_2.DiagnosisResource2_2; + +/** + * {@link Resource} for Diagnosis, supporting standard CRUD operations + */ +@Resource(name = RestConstants.VERSION_1 + "/patientdiagnoses", order = 1, supportedClass = Diagnosis.class, supportedOpenmrsVersions = { + "2.5.* - 9.*" }) +public class DiagnosisResource2_5 extends DiagnosisResource2_2 { + + /** + * @see DelegatingCrudResource#getRepresentationDescription(Representation) + */ + @Override + public DelegatingResourceDescription getRepresentationDescription(Representation rep) { + DelegatingResourceDescription description = super.getRepresentationDescription(rep); + if (description != null) { + description.addProperty("formFieldNamespace"); + description.addProperty("formFieldPath"); + } + return description; + } + + /** + * @see BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = super.getCreatableProperties(); + description.addProperty("formFieldNamespace"); + description.addProperty("formFieldPath"); + return description; + } + + /** + * @see BaseDelegatingResource#getUpdatableProperties() + */ + @Override + public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { + DelegatingResourceDescription description = super.getUpdatableProperties(); + description.addProperty("formFieldNamespace"); + description.addProperty("formFieldPath"); + return description; + } + + @Override + public Model getGETModel(Representation rep) { + return addNewProperties(super.getGETModel(rep), rep); + } + + @Override + public Model getCREATEModel(Representation rep) { + return addNewProperties(super.getCREATEModel(rep), rep); + } + + @Override + public Model getUPDATEModel(Representation rep) { + return addNewProperties(super.getUPDATEModel(rep), rep); + } + + private Model addNewProperties(Model model, Representation rep) { + if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + ((ModelImpl) model) + .property("formFieldNamespace", new StringProperty()) + .property("formFieldPath", new StringProperty()); + } + return model; + } +} diff --git a/omod-2.5/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_5/DiagnosisResource2_5Test.java b/omod-2.5/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_5/DiagnosisResource2_5Test.java new file mode 100644 index 000000000..d260cbd48 --- /dev/null +++ b/omod-2.5/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_5/DiagnosisResource2_5Test.java @@ -0,0 +1,95 @@ +/** + * 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_5; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openmrs.Diagnosis; +import org.openmrs.api.DiagnosisService; +import org.openmrs.api.EncounterService; +import org.openmrs.api.PatientService; +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; + +/** + * Tests functionality of {@link DiagnosisResource2_5}. + */ +public class DiagnosisResource2_5Test extends BaseDelegatingResourceTest { + + + private DiagnosisService diagnosisService; + + private EncounterService encounterService; + + private PatientService patientService; + + + @Before + public void before() { + this.diagnosisService = Context.getDiagnosisService(); + this.encounterService = Context.getEncounterService(); + this.patientService = Context.getPatientService(); + executeDataSet("DiagnosisResourceTestDataset.xml"); + } + + @Override + public Diagnosis newObject() { + return diagnosisService.getDiagnosisByUuid(getUuidProperty()); + } + + @Override + public String getUuidProperty() { + return RestTestConstants2_2.DIAGNOSIS_UUID; + } + + @Override + public void validateDefaultRepresentation() throws Exception { + super.validateDefaultRepresentation(); + assertPropEquals("formFieldNamespace", getObject().getFormFieldNamespace()); + assertPropEquals("formFieldPath", getObject().getFormFieldPath()); + } + + @Override + public void validateFullRepresentation() throws Exception { + super.validateFullRepresentation(); + assertPropEquals("formFieldNamespace", getObject().getFormFieldNamespace()); + assertPropEquals("formFieldPath", getObject().getFormFieldPath()); + } + + @Override + public String getDisplayProperty() { + return ""; + } + + @Test + public void testFormFieldNamespaceAndPath() { + String uuid = "a303bbfb-w5w4-25d1-9f11-4f33f99d456r"; + Diagnosis diagnosis = new Diagnosis(); + diagnosis.setUuid(uuid); + diagnosis.setEncounter(encounterService.getEncounter(1)); + diagnosis.setPatient(patientService.getPatient(1)); + diagnosis.setRank(2); + + final String NAMESPACE = "namespace"; + final String FORMFIELD_PATH = "formFieldPath"; + diagnosis.setFormField(NAMESPACE, FORMFIELD_PATH); + diagnosisService.save(diagnosis); + + Diagnosis savedDiagnosis = diagnosisService.getDiagnosisByUuid(uuid); + String formFieldNameSpace = savedDiagnosis.getFormFieldNamespace(); + String formFieldPath = savedDiagnosis.getFormFieldPath(); + + Assert.assertEquals("namespace", formFieldNameSpace); + Assert.assertEquals("formFieldPath", formFieldPath); + Assert.assertNotNull(savedDiagnosis.getFormNamespaceAndPath()); + } +} diff --git a/omod-2.5/src/test/resources/DiagnosisResourceTestDataset.xml b/omod-2.5/src/test/resources/DiagnosisResourceTestDataset.xml new file mode 100644 index 000000000..ca779465b --- /dev/null +++ b/omod-2.5/src/test/resources/DiagnosisResourceTestDataset.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/omod/pom.xml b/omod/pom.xml index e0cd4bfff..e2a42d1bc 100644 --- a/omod/pom.xml +++ b/omod/pom.xml @@ -143,6 +143,18 @@ tests test + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.5 + ${project.parent.version} + + + ${project.parent.groupId} + ${project.parent.artifactId}-omod-2.5 + ${project.parent.version} + tests + test + diff --git a/omod/src/main/resources/config.xml b/omod/src/main/resources/config.xml index 0b2d6222f..2b0fc0cc7 100644 --- a/omod/src/main/resources/config.xml +++ b/omod/src/main/resources/config.xml @@ -50,6 +50,10 @@ /lib/webservices.rest-omod-2.4.* 2.4.* - 9.* + + /lib/webservices.rest-omod-2.5.* + 2.5.* - 9.* + diff --git a/pom.xml b/pom.xml index 76649b8e4..cd1c9c437 100644 --- a/pom.xml +++ b/pom.xml @@ -428,6 +428,7 @@ omod-2.2 omod-2.3 omod-2.4 + omod-2.5 omod integration-tests @@ -501,6 +502,7 @@ omod-2.2 omod-2.3 omod-2.4 + omod-2.5 omod integration-tests