Run and data blaze

I'm tinkering with using datablaze to make my lists but I've run into a snag (see my other post). I've managed to import my table and I am using "multiple select" coloumns. It seems like when I use the run command to initialize my variables they dont seem to actually assign any values (they just assign an empty string ""). When I remove the "run" from the command (ex: {run: plan_selected=db_list["plan default"]} to {plan_selected= db_list["plan default"]}) and check the variable (ex {=plan_selected}) it seems to actually have assigned the list from the database.

Any idea how to fix this?

{note: preview=no; trim=yes}
dx / complaint: {dx="Acute sinusitis"}
{dbselect: SELECT ddx, investigation, treatment, follow-up, discussion, ddx default, investigation default, treatment default, follow-up default, discussion default, plan default FROM plan WHERE dx / complaint = @dx; space=57Y9Lcf1LFEnYOwzkFVofq; menu=no; name=db_list}

Variables/Lists:
Ddx list: {ddx_list=db_list["ddx"]}
Investigation list: {investigations_list=db_list["investigation"]}
Treatment list: {treatments_list=db_list["treatment"]}
Discussed list: {discussed_list=db_list["discussion"]}
Follow-up list: {fu_list=db_list["follow-up"]}

Initial selections:
dx / complaint : {run: problem = {=dx}}
Plan selected: {run: plan_selected=db_list["plan default"]}
Ddx selected: {run: ddx_selected=db_list["ddx default"]}
Treatment selected: {run: treatments_selected= db_list["treatment default"]}
Investigations selected: {run: investigations_selected= db_list["investigation default"]}
Follow-up selected: {run: fu_selected= db_list["follow-up default"]}
Discussed selected: {run: discussed_selected= db_list["discussion default"]}
{endnote: trim=yes}
{import: /template-db-plan}

Another example

snippet:

output:

Hi @Doc_Krieger , you need to move your dbselect into the same run block shared by all the run assignments. Here's an example snippet below:

{run: 
# run the dbselect command and store the list
db_list={dbselect: SELECT col1, col2, col3 FROM plan; space=ID; menu=no}

# perform variable assignments
col1=db_list["col1"]
col2=db_list["col2"]
col3=db_list["col3"]
}

In this setup, {dbselect} will first fetch the data from the given table. And then we will store its results into relevant variables.

In your example, the {run} command is running its assignment before the {dbselect} command was able to finish fetching the data.

Let me know if it works for you.

1 Like

Thanks! I'll try this later today.

Random other questions I had about writing forum posts:

  • Is there a way to reference snippets to use the {import: } function in a forum post?
  • when writing a datablaze example in the forum how do you write the entries for a "multiple select" column? (Thought it was like a list ["a", "b", ...] But doesn't seem to work)

Thanks again for your help

1 Like
  • Currently there's no way to reference {import}s in the forum posts. I understand your request is to be able to share a snippet collection on the community, where the snippets are interlinked using {import}s. Is that right?
  • You can use this syntax:
[space]
Name,MS{multiple_select}
John, A
Sally, A|B
[/space]

Use the pipe operator (|) to separate multiple values. It looks like this:

1 Like

Thanks for clarifying the datablaze syntax.

For {import} it is just for sharing snippets in the forums. Just find its a bit tricky demonstrating on the forums how to use my snippets that rely on the import function but thats ok (might just take a snap shot and share it)