Skip to content

Commit

Permalink
RESTWS-939: DiagnosisResource should support formFieldPath property (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
IamMujuziMoses authored Jul 25, 2024
1 parent 5564667 commit 96a8cb0
Show file tree
Hide file tree
Showing 8 changed files with 447 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Diagnosis> {

/**
Expand Down Expand Up @@ -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");
Expand All @@ -185,15 +185,15 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
*/
@Override
public Model getCREATEModel(Representation rep) {

return new ModelImpl()
.property("diagnosis", new StringProperty())
.property("encounter", new StringProperty())
.property("condition", new StringProperty())
.property("certainty", new StringProperty())
.property("patient", new StringProperty().example("uuid"))
.property("rank", new IntegerProperty());

}

/**
Expand All @@ -209,7 +209,7 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
description.addRequiredProperty("voided");
description.addRequiredProperty("certainty");
description.addRequiredProperty("encounter");

return description;
}

Expand Down
215 changes: 215 additions & 0 deletions omod-2.5/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>webservices.rest</artifactId>
<version>2.45.0-SNAPSHOT</version>
</parent>

<artifactId>webservices.rest-omod-2.5</artifactId>
<packaging>jar</packaging>
<name>Rest Web Services 2.5 OMOD</name>
<description>OpenMRS module project for Rest Web Services</description>

<properties>
<openmrs.version.2.5.0>2.5.0</openmrs.version.2.5.0>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-common</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-common</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.8</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.8</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.9</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.9</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.10</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.10</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.11</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.11</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-2.0</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-2.0</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-2.2</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-2.2</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-2.3</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-2.3</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-2.4</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-2.4</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<version>${openmrs.version.2.5.0}</version><!--$NO-MVN-MAN-VER$-->
</dependency>

<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<type>test-jar</type>
<scope>test</scope>
<version>${openmrs.version.2.5.0}</version><!--$NO-MVN-MAN-VER$-->
</dependency>

<dependency>
<groupId>org.openmrs.web</groupId>
<artifactId>openmrs-web</artifactId>
<version>${openmrs.version.2.5.0}</version> <!-- $NO-MVN-MAN-VER$ -->
</dependency>

<dependency>
<groupId>org.openmrs.web</groupId>
<artifactId>openmrs-web</artifactId>
<type>test-jar</type>
<scope>test</scope>
<version>${openmrs.version.2.5.0}</version> <!-- $NO-MVN-MAN-VER$-->
</dependency>

<dependency>
<groupId>org.openmrs.test</groupId>
<artifactId>openmrs-test</artifactId>
<type>pom</type>
<scope>test</scope>
<version>${openmrs.version.2.5.0}</version> <!-- $NO-MVN-MAN-VER$ -->
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javaxVersion}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>jasper</artifactId>
<version>${apacheTomcatVersion}</version>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<header>${project.parent.basedir}/license-header.txt</header>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading

0 comments on commit 96a8cb0

Please sign in to comment.