Skip to content

Instantly share code, notes, and snippets.

@schultbr
Last active October 12, 2021 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schultbr/46c2ca63ab976a94781f2767a78522ec to your computer and use it in GitHub Desktop.
Save schultbr/46c2ca63ab976a94781f2767a78522ec to your computer and use it in GitHub Desktop.
Sample 2 Plus 1 Workflow
Sample 2 Plus 1 Workflow
Submission*
Signoff Submission Form -> QC
QC
Signoff QC Form - Query -> Submission
Signoff QC Form - Approve -> Processing
Processing
Processing complete -> Read
Read
Signoff Reader Form - Complete -> Complete
Signoff Reader Form - Adjudication -> Adjudication
Reader 1 Read
signoff -> Reader 2 Read
Reader 2 Read
signoff -> Reader 1 Read
Adjudication
Signoff Adjudication Form -> Complete
Complete
var readCount = 0;
var eligibleReadResultCount = 0;
var notEligibleReadResultCount = 0;
function incrementReader(isEligible, model){
readCount++;
isEligible === true ? eligibleReadResultCount++ : notEligibleReadResultCount++;
checkReaderEvents(model);
}
function checkReaderEvents(model){
if(readCount === 2) {
if(notEligibleReadResultCount === 2 || eligibleReadResultCount === 2) {
model.emit("Signoff Reader Form - Complete");
}
model.emit("Signoff Reader Form - Adjudication");
}
else if(model.active_states[0].name === "Reader 1 Read" || model.active_states[0].name === "Reader 2 Read"){
model.emit("signoff");
}
}
function returnHeader(state) {
return $("h1",
{style: {color: "darkBlue"}},
`The current state is: ${state}`);
}
function returnButtons(state, model){
if(state === "Submission"){
return $('button', {style: {position: "relative", left: 50, top: 30},
onClick: function(){ model.emit("Signoff Submission Form") }},
"Signoff");
}
else if(state === "QC"){
return $('div',
$('button', {style: {position: "relative", left: 20, top: 30},
onClick: function(){ model.emit("Signoff QC Form - Query") }},
"Signoff - Query"),
$('button', {style: {position: "relative", left: 100, top: 30},
onClick: function(){ model.emit("Signoff QC Form - Approve"); readCount = 0; eligibleReadResultCount = 0; notEligibleReadResultCount = 0; }},
"Signoff - Approve"));
}
else if(state === "Processing"){
const autoEvent = (function(theModel) {theModel.emit("Processing complete") });
setTimeout(autoEvent, 5000, model);
return $('div',
$('span', {}, "Waiting for processing... this would be background work. Click the 'Processing Complete' link in the Diagram above to simulate a system-driven event or wait for the auto-fired event to continue")
);
}
else if(state.startsWith("Read")){
return $('div',
$('span', {style: {color: "darkBlue"}}, `Read count is ${readCount}`),
$('button', {style: {position: "relative", left: 20, top: 30},
onClick: function(){ incrementReader(true, model); }},
"Signoff Read - Value A"),
$('button', {style: {position: "relative", left: 50, top: 30},
onClick: function(){ incrementReader(false, model); }},
"Signoff Read - Value B"),
);
}
else if(state === "Adjudication"){
return $('button', {style: {position: "relative", left: 50, top: 30},
onClick: function(){ model.emit("Signoff Adjudication Form") }},
"Signoff");
}
else {
return $('div',
$('span', {style: {color: "darkBlue"}}, `Visit workflow is complete!!`),
);
}
}
function render(model){
let current_state_name = model.active_states[0].name;
return $('div',
returnHeader(current_state_name),
returnButtons(current_state_name, model)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment