Skip to content

Commit d1dcd20

Browse files
Remove CN reached target goal weight logic (#6)
1 parent 2530bbc commit d1dcd20

File tree

3 files changed

+3
-64
lines changed

3 files changed

+3
-64
lines changed

api/src/main/java/org/openmrs/module/lamp/ChildNutritionProgramStrategy.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,15 @@ public void execute(Encounter encounter, User currentUser, Date currentDate, Str
5050
}
5151

5252
ProgramWorkflowState targetState = null;
53-
boolean isReachedTargetGoalWeightStateFromMalnutritionStatusValue = false;
5453

5554
if (malnutritionStatusValue != null) {
5655
targetState = Utils.getStateByConcept(programWorkflow, malnutritionStatusValue);
57-
if (targetState == null) {
58-
return;
59-
}
60-
if (targetState.getConcept().getUuid().equalsIgnoreCase(LampConfig.CONCEPT_REACHED_TARGET_GOAL_WEIGHT_UUID)) {
61-
isReachedTargetGoalWeightStateFromMalnutritionStatusValue = true;
62-
}
6356
}
64-
6557
if (reasonForDischargeValue != null) {
6658
targetState = Utils.getStateByConcept(programWorkflow, reasonForDischargeValue);
67-
if (targetState == null) {
68-
return;
69-
}
70-
if (targetState.getConcept().getUuid().equalsIgnoreCase(LampConfig.CONCEPT_REACHED_TARGET_GOAL_WEIGHT_UUID)) {
71-
isReachedTargetGoalWeightStateFromMalnutritionStatusValue = false;
72-
}
7359
}
74-
75-
if (isReachedTargetGoalWeightStateFromMalnutritionStatusValue) {
76-
targetState.setTerminal(false);
60+
if (targetState == null) {
61+
return;
7762
}
7863

7964
PatientState patientState = patientProgram.getCurrentState(programWorkflow);

api/src/main/java/org/openmrs/module/lamp/LampConfig.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ public class LampConfig {
1616

1717
public static final String CHILD_NUTRITION_ENCOUNTER_TYPE_UUID = "a46c50d1-f8f2-4b73-9940-7e77c64bcffc";
1818

19-
public static final String CONCEPT_REACHED_TARGET_GOAL_WEIGHT_UUID = "0a947c3b-ac0a-42af-9299-674620dc7a6d";
20-
2119
public static final String CONCEPT_CHILD_NUTRITION_REASON_FOR_DISCHARGE_UUID = "a7781567-2c1e-4bfd-ad3a-182915722916";
2220

2321
public static final String CONCEPT_CHILD_NUTRITION_MALNUTRITION_STATUS_UUID = "0ae3326d-592b-4ce0-a523-6e03bbe99b69";

api/src/test/java/org/openmrs/module/lamp/ChildNutritionProgramStrategyTest.java

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.openmrs.module.lamp;
22

33
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertFalse;
54
import static org.junit.Assert.assertNull;
65
import static org.junit.Assert.assertTrue;
76
import static org.mockito.Mockito.*;
@@ -236,49 +235,7 @@ public void shouldExitWhenTargetStateFromReasonForDischargeValueIsNull() {
236235
}
237236

238237
@Test
239-
public void shouldNotSetDateCompletedWhenReachedTargetFromMalnutritionStatus() {
240-
Encounter encounter = buildEncounter(true);
241-
Date now = new Date();
242-
Program program = new Program();
243-
when(mockProgramWorkflowService.getProgramByUuid(LampConfig.PROGRAM_CHILD_NUTRITION_UUID)).thenReturn(program);
244-
245-
Concept malC = new Concept(101);
246-
Concept reasonC = new Concept(102);
247-
when(mockConceptService.getConceptByUuid(LampConfig.CONCEPT_CHILD_NUTRITION_MALNUTRITION_STATUS_UUID)).thenReturn(
248-
malC);
249-
when(mockConceptService.getConceptByUuid(LampConfig.CONCEPT_CHILD_NUTRITION_REASON_FOR_DISCHARGE_UUID)).thenReturn(
250-
reasonC);
251-
252-
PatientProgram pp = new PatientProgram();
253-
PowerMockito.when(
254-
Utils.getOrCreateActiveProgramEnrollment(eq(mockProgramWorkflowService), eq(encounter.getPatient()),
255-
eq(program), any(Date.class))).thenReturn(pp);
256-
257-
Concept malValue = new Concept(201);
258-
malValue.setUuid(LampConfig.CONCEPT_REACHED_TARGET_GOAL_WEIGHT_UUID);
259-
PowerMockito.when(Utils.findLatestCodedObsValue(encounter, malC)).thenReturn(malValue);
260-
PowerMockito.when(Utils.findLatestCodedObsValue(encounter, reasonC)).thenReturn(null);
261-
262-
ProgramWorkflow wf = new ProgramWorkflow();
263-
PowerMockito.when(Utils.getWorkflowByUuid(program, LampConfig.WORKFLOW_CHILD_NUTRITION_UUID)).thenReturn(wf);
264-
265-
ProgramWorkflowState state = new ProgramWorkflowState();
266-
state.setConcept(malValue);
267-
PowerMockito.when(Utils.getStateByConcept(wf, malValue)).thenReturn(state);
268-
269-
childNutritionProgramStrategy.execute(encounter, new User(), now, "reason");
270-
271-
// dateCompleted should NOT be set because it came from malnutrition path
272-
assertNull(pp.getDateCompleted());
273-
assertFalse(state.getTerminal());
274-
275-
// transition & save
276-
assertEquals(encounter.getLocation(), pp.getLocation());
277-
verify(mockProgramWorkflowService, times(1)).savePatientProgram(pp);
278-
}
279-
280-
@Test
281-
public void shouldSetDateCompletedWhenReachedTargetFromReasonForDischarge() {
238+
public void shouldSetDateCompletedWhenReachedTargetWeight() {
282239
Encounter encounter = buildEncounter(true);
283240
Date now = new Date();
284241
Program program = new Program();
@@ -300,7 +257,6 @@ public void shouldSetDateCompletedWhenReachedTargetFromReasonForDischarge() {
300257
PowerMockito.when(Utils.findLatestCodedObsValue(encounter, malC)).thenReturn(null);
301258

302259
Concept reasonValue = new Concept(301);
303-
reasonValue.setUuid(LampConfig.CONCEPT_REACHED_TARGET_GOAL_WEIGHT_UUID);
304260
PowerMockito.when(Utils.findLatestCodedObsValue(encounter, reasonC)).thenReturn(reasonValue);
305261

306262
ProgramWorkflow wf = new ProgramWorkflow();

0 commit comments

Comments
 (0)