diff --git a/omod-2.5/pom.xml b/omod-2.5/pom.xml new file mode 100644 index 000000000..871e7cac1 --- /dev/null +++ b/omod-2.5/pom.xml @@ -0,0 +1,214 @@ + + + 4.0.0 + + webservices.rest + org.openmrs.module + 2.44.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
+
+
+
+
+
\ No newline at end of file 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..30d70159e --- /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,88 @@ +/** + * 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.BooleanProperty; +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("formNamespaceAndPath"); + } + return description; + } + + /** + * @see BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = super.getCreatableProperties(); + description.addProperty("formNamespaceAndPath"); + return description; + } + + /** + * @see BaseDelegatingResource#getUpdatableProperties() + */ + @Override + public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { + DelegatingResourceDescription description = super.getUpdatableProperties(); + description.addProperty("formNamespaceAndPath"); + 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("formNamespaceAndPath", new BooleanProperty()._default(false)); + } + 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..6321d5b61 --- /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,93 @@ +/** + * 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("formNamespaceAndPath", getObject().getFormNamespaceAndPath()); + } + + @Override + public void validateFullRepresentation() throws Exception { + super.validateFullRepresentation(); + assertPropEquals("formNamespaceAndPath", getObject().getFormNamespaceAndPath()); + } + + @Override + public String getDisplayProperty() { + return ""; + } + + @Test + public void testFormFieldNamespace() { + 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..8105dcc0e --- /dev/null +++ b/omod-2.5/src/test/resources/DiagnosisResourceTestDataset.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/omod/pom.xml b/omod/pom.xml index aab184439..ce479593e 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 b734d08d2..6506e0ff2 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