Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case triggered plan generation logic #507

Merged
merged 53 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f7b8f28
Add mybatis artifacts for template table
Rkareko Sep 6, 2021
aaedb8e
Added mybatis artifacts for plan processing status
Rkareko Sep 11, 2021
ea7dc8c
Add template repository and mapper classes
Rkareko Sep 13, 2021
fff6190
Add template service
Rkareko Sep 13, 2021
d22e2b3
Add Repository and mapper classes for plan processing status
Rkareko Sep 14, 2021
bfa643b
Add plan processing status service
Rkareko Sep 14, 2021
0c3276f
Add method for retrieving processing status by status value
Rkareko Sep 22, 2021
e1950df
Add method for retrieving event by database id
Rkareko Sep 22, 2021
7c45475
Add service method for retrieving event by database id
Rkareko Sep 22, 2021
ee8d3db
add template getAll with limit to get latest version
LZRS Oct 5, 2021
94369e5
Merge branch 'create-mybatis-artifacts-for-template-table' of github.…
Rkareko Oct 6, 2021
a7d6a76
Update custom plan processing status mapper
Rkareko Oct 6, 2021
af79ab2
Add logic for getting plan template
Rkareko Oct 6, 2021
a381292
Add validation for case details event
Rkareko Oct 6, 2021
af32ebe
Update constants
Rkareko Oct 7, 2021
92400e2
Bump up version
Rkareko Oct 7, 2021
7f47cf7
Merge branch 'v2' into create-mybatis-artifacts-for-template-table
Rkareko Oct 7, 2021
1c63cb0
Add logic for updating plan rocessing status
Rkareko Oct 7, 2021
ea26d47
Update method for updating plan processing status
Rkareko Oct 7, 2021
1ac8b31
Refactor method for updating processing status
Rkareko Oct 7, 2021
8b3225b
Add plan template model
Rkareko Oct 8, 2021
b072c2d
Bump up version
Rkareko Oct 8, 2021
4ba727f
Add test
Rkareko Oct 12, 2021
da8744a
Merge v2 into create-mybatis-artifacts-for-template-table
Rkareko Nov 9, 2021
24f3191
Throw illegal argument exceptions instead of runtime exceptions
Rkareko Nov 9, 2021
8620550
Update unit test
Rkareko Nov 9, 2021
879cafc
Add json property annotation
Rkareko Nov 10, 2021
e4f19b0
Bump up version
Rkareko Nov 10, 2021
660c914
Retrieve record by primary key
Rkareko Nov 10, 2021
35c9d84
Bump up version
Rkareko Nov 10, 2021
9f3df34
Add null check for plan actions
Rkareko Nov 12, 2021
0dc093f
Bump up version
Rkareko Nov 12, 2021
bd83526
Add plan constants
Rkareko Nov 12, 2021
3e9cc64
Bump up version
Rkareko Nov 12, 2021
d18c992
Merge branch 'v2' into create-mybatis-artifacts-for-template-table
Rkareko Dec 1, 2021
2b842ee
Merge v2 into create-mybatis-artifacts-for-template-table
Rkareko Dec 7, 2021
953fac9
Update configs
Rkareko Dec 7, 2021
d76b168
Merge v2 into create-mybatis-artifacts-for-template-table
Rkareko Dec 7, 2021
5e22c6d
Add plan processing repository tests
Rkareko Dec 7, 2021
92c681d
Add unit plan processing status unit tests
Rkareko Dec 7, 2021
66abae4
Add template unit tests
Rkareko Dec 7, 2021
98e6ea8
Fix codacy issues
Rkareko Dec 7, 2021
d435f11
Reset plan processing status ud sequence
Rkareko Dec 7, 2021
ceb35b4
Code cleanup
Rkareko Dec 7, 2021
b12430e
Remove unused import
Rkareko Dec 7, 2021
4b9f54f
Add plan service tests
Rkareko Dec 8, 2021
0b455c3
Add get plan template tests
Rkareko Dec 9, 2021
35653a0
Add template and processing status service tests
Rkareko Dec 9, 2021
d1619b4
Update template tests
Rkareko Dec 9, 2021
65a7537
Use sample plan json for test
Rkareko Dec 9, 2021
6b865a5
Update unit tests
Rkareko Dec 9, 2021
f1c5306
Use Lombok to generate setters and getters
Rkareko Dec 9, 2021
78cf0db
Bump up version
Rkareko Dec 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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