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 committed Jun 7, 2024
1 parent 193af52 commit 2c6aa6b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.openmrs.Diagnosis;
import org.openmrs.Patient;
import org.openmrs.api.context.Context;
import org.openmrs.module.ModuleUtil;
import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty;
import org.openmrs.module.webservices.rest.web.ConversionUtil;
import org.openmrs.module.webservices.rest.web.RequestContext;
Expand Down Expand Up @@ -98,6 +99,9 @@ public void purge(Diagnosis diagnosis, RequestContext requestContext) throws Res
public DelegatingResourceDescription getRepresentationDescription(Representation representation) {
if (representation instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
if (ModuleUtil.isOpenmrsVersionInVersions("2.5.* - 9.*")) {
description.addProperty("formNamespaceAndPath");
}
description.addProperty("uuid");
description.addProperty("diagnosis", Representation.REF);
description.addProperty("condition", Representation.REF);
Expand All @@ -112,6 +116,9 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return description;
} else if (representation instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
if (ModuleUtil.isOpenmrsVersionInVersions("2.5.* - 9.*")) {
description.addProperty("formNamespaceAndPath");
}
description.addProperty("uuid");
description.addProperty("diagnosis");
description.addProperty("patient", Representation.REF);
Expand All @@ -135,6 +142,9 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
public Model getGETModel(Representation rep) {
ModelImpl model = (ModelImpl) super.getGETModel(rep);
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
if (ModuleUtil.isOpenmrsVersionInVersions("2.5.* - 9.*")) {
model.property("formNamespaceAndPath", new StringProperty());
}
model
.property("uuid", new StringProperty())
.property("diagnosis", new StringProperty())
Expand Down Expand Up @@ -169,7 +179,10 @@ public String getDisplayString(Diagnosis diagnosis) {
@Override
public DelegatingResourceDescription getCreatableProperties() throws ResourceDoesNotSupportOperationException {
DelegatingResourceDescription description = new DelegatingResourceDescription();

if (ModuleUtil.isOpenmrsVersionInVersions("2.5.* - 9.*")) {
description.addProperty("formNamespaceAndPath");
}

description.addRequiredProperty("diagnosis");
description.addRequiredProperty("encounter");
description.addRequiredProperty("condition");
Expand All @@ -185,15 +198,18 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
*/
@Override
public Model getCREATEModel(Representation rep) {

return new ModelImpl()
ModelImpl model = (ModelImpl) super.getCREATEModel(rep);
if (ModuleUtil.isOpenmrsVersionInVersions("2.5.* - 9.*")) {
model.property("formNamespaceAndPath", new StringProperty());
}
model
.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());

return model;
}

/**
Expand All @@ -202,14 +218,17 @@ public Model getCREATEModel(Representation rep) {
@Override
public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException {
DelegatingResourceDescription description = new DelegatingResourceDescription();
if (ModuleUtil.isOpenmrsVersionInVersions("2.5.* - 9.*")) {
description.addProperty("formNamespaceAndPath");
}
description.addRequiredProperty("diagnosis");
description.addRequiredProperty("condition");
description.addRequiredProperty("rank");
description.removeProperty("patient");
description.addRequiredProperty("voided");
description.addRequiredProperty("certainty");
description.addRequiredProperty("encounter");

return description;
}

Expand All @@ -218,13 +237,18 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe
*/
@Override
public Model getUPDATEModel(Representation rep) {
return new ModelImpl()
ModelImpl model = (ModelImpl) super.getUPDATEModel(rep);
if (ModuleUtil.isOpenmrsVersionInVersions("2.5.* - 9.*")) {
model.property("formNamespaceAndPath", new StringProperty());
}
model
.property("diagnosis", new StringProperty())
.property("condition", new StringProperty())
.property("encounter", new StringProperty())
.property("certainty", new EnumProperty(ConditionVerificationStatus.class))
.property("rank", new IntegerProperty())
.property("voided", new BooleanProperty());
return model;
}

@Override
Expand Down
214 changes: 0 additions & 214 deletions omod-2.5/pom.xml

This file was deleted.

Loading

0 comments on commit 2c6aa6b

Please sign in to comment.