Simple script that returns the current study_id

Includes test and bpmn
This commit is contained in:
mike cullerton 2023-02-24 11:05:27 -05:00
parent ee77d51d1c
commit acaf3c2fd2
3 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,13 @@
from crc.scripts.script import Script
class GetStudyID(Script):
def get_description(self):
return """This script returns the current study_id"""
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
return self.do_task(task, study_id, workflow_id, *args, **kwargs)
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
return study_id

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_fbeb372" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="Process_fbeb372" name="Get Study ID" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_1xhzrdw</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1xhzrdw" sourceRef="StartEvent_1" targetRef="Activity_1fkzafi" />
<bpmn:task id="Activity_0xgq35j" name="Display Study ID">
<bpmn:documentation>## Current Study ID
{{ current_study_id }}
</bpmn:documentation>
<bpmn:incoming>Flow_17fdsuf</bpmn:incoming>
<bpmn:outgoing>Flow_1q476gy</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="Flow_17fdsuf" sourceRef="Activity_1fkzafi" targetRef="Activity_0xgq35j" />
<bpmn:endEvent id="Event_0i0z8hm">
<bpmn:incoming>Flow_1q476gy</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1q476gy" sourceRef="Activity_0xgq35j" targetRef="Event_0i0z8hm" />
<bpmn:scriptTask id="Activity_1fkzafi" name="Get Study ID">
<bpmn:incoming>Flow_1xhzrdw</bpmn:incoming>
<bpmn:outgoing>Flow_17fdsuf</bpmn:outgoing>
<bpmn:script>current_study_id = get_study_id()</bpmn:script>
</bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_fbeb372">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0xgq35j_di" bpmnElement="Activity_0xgq35j">
<dc:Bounds x="430" y="137" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0i0z8hm_di" bpmnElement="Event_0i0z8hm">
<dc:Bounds x="592" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_08k6rvl_di" bpmnElement="Activity_1fkzafi">
<dc:Bounds x="270" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1xhzrdw_di" bpmnElement="Flow_1xhzrdw">
<di:waypoint x="215" y="177" />
<di:waypoint x="270" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_17fdsuf_di" bpmnElement="Flow_17fdsuf">
<di:waypoint x="370" y="177" />
<di:waypoint x="430" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1q476gy_di" bpmnElement="Flow_1q476gy">
<di:waypoint x="530" y="177" />
<di:waypoint x="592" y="177" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -0,0 +1,11 @@
from tests.base_test import BaseTest
class TestGetStudyId(BaseTest):
def test_get_study_id(self):
workflow = self.create_workflow('get_study_id')
workflow_api = self.get_workflow_api(workflow)
task = workflow_api.next_task
self.assertEqual(task.data['current_study_id'], workflow.study.id)