Skip to content

Commit

Permalink
Merge pull request #507 from opensrp/create-mybatis-artifacts-for-tem…
Browse files Browse the repository at this point in the history
…plate-table

Implement case triggered plan generation
  • Loading branch information
ndegwamartin authored Dec 10, 2021
2 parents e00f2b6 + 78cf0db commit b08216b
Show file tree
Hide file tree
Showing 42 changed files with 4,767 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<artifactId>opensrp-server-core</artifactId>
<packaging>jar</packaging>
<version>2.12.15-SNAPSHOT</version>
<version>2.12.16-SNAPSHOT</version>
<name>opensrp-server-core</name>
<description>OpenSRP Server Core module</description>
<url>https://github.com/OpenSRP/opensrp-server-core</url>
Expand Down
64 changes: 64 additions & 0 deletions src/main/java/org/opensrp/domain/ActionTemplate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.opensrp.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.smartregister.domain.Condition;
import org.smartregister.domain.DynamicValue;
import org.smartregister.domain.Trigger;

import java.io.Serializable;
import java.util.Set;

@Getter
@Setter
@AllArgsConstructor
public class ActionTemplate implements Serializable {
private static final long serialVersionUID = 1L;
private String identifier;
private int prefix;
private String title;
private String description;
private String code;
private PeriodTemplate timingPeriod;
private String reason;
private String goalId;
private ActionTemplate.SubjectConcept subjectCodableConcept;
private String taskTemplate;
private Set<Trigger> trigger;
private Set<Condition> condition;
private String definitionUri;
private Set<DynamicValue> dynamicValue;
private ActionTemplate.ActionType type;

public ActionTemplate() {
this.type = ActionTemplate.ActionType.CREATE;
}

@Getter
@Setter
@AllArgsConstructor
public static class SubjectConcept implements Serializable {
private String text;


}

public static enum ActionType {
@JsonProperty("create")
@SerializedName("create")
CREATE,
@JsonProperty("update")
@SerializedName("update")
UPDATE,
@JsonProperty("remove")
@SerializedName("remove")
REMOVE,
@JsonProperty("fire-event")
@SerializedName("fire-event")
FIRE_EVENT;

}
}
27 changes: 27 additions & 0 deletions src/main/java/org/opensrp/domain/GoalTemplate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.opensrp.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class GoalTemplate implements Serializable {

private static final long serialVersionUID = 1L;
private String id;
private String description;
private String priority;
@JsonProperty("target")
@SerializedName("target")
private List<TargetTemplate> targets;

}
26 changes: 26 additions & 0 deletions src/main/java/org/opensrp/domain/PeriodTemplate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.opensrp.domain;

import java.io.Serializable;

public class PeriodTemplate implements Serializable {

private static final long serialVersionUID = 1L;
private String start;
private String end;

public String getStart() {
return start;
}

public void setStart(String start) {
this.start = start;
}

public String getEnd() {
return end;
}

public void setEnd(String end) {
this.end = end;
}
}
102 changes: 102 additions & 0 deletions src/main/java/org/opensrp/domain/PlanTemplate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package org.opensrp.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.smartregister.domain.Jurisdiction;
import org.smartregister.domain.PlanDefinition;

import java.io.Serializable;
import java.util.List;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class PlanTemplate implements Serializable {

private static final long serialVersionUID = 1L;
@JsonProperty
private String identifier;
@JsonProperty
private String description;
@JsonProperty
private String version;
@JsonProperty
private String name;
@JsonProperty
private String title;
@JsonProperty
private String status;
@JsonProperty
private String date;
@JsonProperty
private PeriodTemplate effectivePeriod;
@JsonProperty
private List<PlanDefinition.UseContext> useContext;
@JsonProperty
private List<Jurisdiction> jurisdiction;
private Long serverVersion;
@JsonProperty("goal")
@SerializedName("goal")
private List<GoalTemplate> goals;
@JsonProperty("action")
@SerializedName("action")
private List<ActionTemplate> actions;
@JsonProperty
private boolean experimental;

public int compareTo(PlanDefinition o) {
return this.getName().equals(o.getName()) ? this.getName().compareTo(o.getIdentifier()) : this.getName().compareTo(o.getName());
}

public static enum PlanStatus {
@SerializedName("draft")
DRAFT("draft"),
@SerializedName("active")
ACTIVE("active"),
@SerializedName("retired")
RETIRED("retired"),
@SerializedName("complete")
COMPLETED("complete"),
@SerializedName("unknown")
UNKNOWN("unknown");

private final String value;

private PlanStatus(String value) {
this.value = value;
}

public String value() {
return this.value;
}

public static PlanTemplate.PlanStatus from(String value) {
PlanTemplate.PlanStatus[] var1 = values();
int var2 = var1.length;

for(int var3 = 0; var3 < var2; ++var3) {
PlanTemplate.PlanStatus c = var1[var3];
if (c.value.equals(value)) {
return c;
}
}

throw new IllegalArgumentException(value);
}
}

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class UseContext implements Serializable {
private String code;
private String valueCodableConcept;

}
}
61 changes: 61 additions & 0 deletions src/main/java/org/opensrp/domain/TargetTemplate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.opensrp.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.AbstractMap;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class TargetTemplate implements Serializable {
private static final long serialVersionUID = 1L;
private String measure;
private TargetTemplate.Detail detail;
private String due;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
static class DetailCodableConcept {
private String text;

}

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
static class MeasureRange implements Serializable {
private TargetTemplate.Measure high;
private TargetTemplate.Measure low;
}

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
static class Measure implements Serializable {
private float value;
private String comparator;
private String unit;

}

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
static class Detail implements Serializable {
private TargetTemplate.Measure detailQuantity;
private TargetTemplate.MeasureRange detailRange;
private AbstractMap.SimpleEntry<String, String> detailCodableConcept;

}

}
49 changes: 49 additions & 0 deletions src/main/java/org/opensrp/domain/Template.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.opensrp.domain;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;

public class Template implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty
private Integer templateId;
@JsonProperty
private PlanTemplate template;
@JsonProperty
private String type;
@JsonProperty
private int version;

public Integer getTemplateId() {
return templateId;
}

public void setTemplateId(Integer templateId) {
this.templateId = templateId;
}

public PlanTemplate getTemplate() {
return template;
}

public void setTemplate(PlanTemplate template) {
this.template = template;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public int getVersion() {
return version;
}

public void setVersion(int version) {
this.version = version;
}
}
Loading

0 comments on commit b08216b

Please sign in to comment.