Search in sources :

Example 6 with ProgramRuleAction

use of org.hisp.dhis.programrule.ProgramRuleAction in project dhis2-core by dhis2.

the class DhisConvenienceTest method createProgramRuleAction.

public static ProgramRuleAction createProgramRuleAction(char uniqueCharacter) {
    ProgramRuleAction programRuleAction = new ProgramRuleAction();
    programRuleAction.setAutoFields();
    programRuleAction.setName("ProgramRuleAction" + uniqueCharacter);
    programRuleAction.setProgramRuleActionType(ProgramRuleActionType.HIDEFIELD);
    return programRuleAction;
}
Also used : ProgramRuleAction(org.hisp.dhis.programrule.ProgramRuleAction)

Example 7 with ProgramRuleAction

use of org.hisp.dhis.programrule.ProgramRuleAction in project dhis2-core by dhis2.

the class ProgramRuleEngineTest method setUpNotificationForD2HasValue.

private void setUpNotificationForD2HasValue() {
    ProgramNotificationTemplate pnt = new ProgramNotificationTemplate();
    pnt.setName("Test-PNT");
    pnt.setMessageTemplate("message_template");
    pnt.setSubjectTemplate("subject_template");
    pnt.setNotificationTrigger(NotificationTrigger.PROGRAM_RULE);
    pnt.setRecipientProgramAttribute(attributeEmail);
    pnt.setNotificationRecipient(ProgramNotificationRecipient.PROGRAM_ATTRIBUTE);
    pnt.setAutoFields();
    pnt.setUid("PNT-2");
    programNotificationTemplateStore.save(pnt);
    ProgramRuleAction programRuleActionForSendMessage = createProgramRuleAction('C', programRuleE);
    programRuleActionForSendMessage.setProgramRuleActionType(ProgramRuleActionType.SENDMESSAGE);
    programRuleActionForSendMessage.setTemplateUid(pnt.getUid());
    programRuleActionForSendMessage.setContent("STATIC-TEXT");
    programRuleActionService.addProgramRuleAction(programRuleActionForSendMessage);
    programRuleE.setProgramRuleActions(Sets.newHashSet(programRuleActionForSendMessage));
    programRuleService.updateProgramRule(programRuleE);
}
Also used : ProgramRuleAction(org.hisp.dhis.programrule.ProgramRuleAction) ProgramNotificationTemplate(org.hisp.dhis.program.notification.ProgramNotificationTemplate)

Example 8 with ProgramRuleAction

use of org.hisp.dhis.programrule.ProgramRuleAction in project dhis2-core by dhis2.

the class ProgramRuleEngineTest method setUpSendMessageForEnrollment.

private void setUpSendMessageForEnrollment() {
    ProgramNotificationTemplate pnt = new ProgramNotificationTemplate();
    pnt.setName("Test-PNT");
    pnt.setMessageTemplate("message_template");
    pnt.setDeliveryChannels(Sets.newHashSet(DeliveryChannel.SMS));
    pnt.setSubjectTemplate("subject_template");
    pnt.setNotificationTrigger(NotificationTrigger.PROGRAM_RULE);
    pnt.setAutoFields();
    pnt.setUid("PNT-1");
    programNotificationTemplateStore.save(pnt);
    ProgramRuleAction programRuleActionForSendMessage = createProgramRuleAction('C', programRuleC);
    programRuleActionForSendMessage.setProgramRuleActionType(ProgramRuleActionType.SENDMESSAGE);
    programRuleActionForSendMessage.setTemplateUid(pnt.getUid());
    programRuleActionForSendMessage.setContent("STATIC-TEXT");
    programRuleActionService.addProgramRuleAction(programRuleActionForSendMessage);
    programRuleC.setProgramRuleActions(Sets.newHashSet(programRuleActionForSendMessage));
    programRuleService.updateProgramRule(programRuleC);
}
Also used : ProgramRuleAction(org.hisp.dhis.programrule.ProgramRuleAction) ProgramNotificationTemplate(org.hisp.dhis.program.notification.ProgramNotificationTemplate)

Example 9 with ProgramRuleAction

use of org.hisp.dhis.programrule.ProgramRuleAction in project dhis2-core by dhis2.

the class TrackerProgramRuleBundleServiceTest method initTest.

@Override
protected void initTest() throws IOException {
    ObjectBundle bundle = setUpMetadata("tracker/event_metadata.json");
    ProgramRule programRule = createProgramRule('A', bundle.getPreheat().get(PreheatIdentifier.UID, Program.class, "BFcipDERJwr"));
    programRuleService.addProgramRule(programRule);
    ProgramRuleAction programRuleAction = createProgramRuleAction('A', programRule);
    programRuleAction.setProgramRuleActionType(ProgramRuleActionType.SENDMESSAGE);
    programRuleActionService.addProgramRuleAction(programRuleAction);
    programRule.setProgramRuleActions(Sets.newHashSet(programRuleAction));
    programRuleService.updateProgramRule(programRule);
    manager.flush();
}
Also used : ProgramRuleAction(org.hisp.dhis.programrule.ProgramRuleAction) ObjectBundle(org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle) Program(org.hisp.dhis.program.Program) ProgramRule(org.hisp.dhis.programrule.ProgramRule)

Example 10 with ProgramRuleAction

use of org.hisp.dhis.programrule.ProgramRuleAction in project dhis2-core by dhis2.

the class DhisConvenienceTest method createProgramRuleAction.

public static ProgramRuleAction createProgramRuleAction(char uniqueCharacter, ProgramRule parentRule) {
    ProgramRuleAction programRuleAction = createProgramRuleAction(uniqueCharacter);
    programRuleAction.setProgramRule(parentRule);
    return programRuleAction;
}
Also used : ProgramRuleAction(org.hisp.dhis.programrule.ProgramRuleAction)

Aggregations

ProgramRuleAction (org.hisp.dhis.programrule.ProgramRuleAction)10 ProgramNotificationTemplate (org.hisp.dhis.program.notification.ProgramNotificationTemplate)4 Program (org.hisp.dhis.program.Program)3 ProgramRule (org.hisp.dhis.programrule.ProgramRule)3 List (java.util.List)2 DataElement (org.hisp.dhis.dataelement.DataElement)2 ObjectBundle (org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle)2 ProgramStage (org.hisp.dhis.program.ProgramStage)2 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)1 ObjectBundleParams (org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundleParams)1 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)1 ErrorCode (org.hisp.dhis.feedback.ErrorCode)1 ErrorReport (org.hisp.dhis.feedback.ErrorReport)1 ProgramRuleActionValidationResult (org.hisp.dhis.programrule.ProgramRuleActionValidationResult)1 ProgramRuleVariable (org.hisp.dhis.programrule.ProgramRuleVariable)1 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)1