Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ private Function<ParameterComponent, InputItem> toInputItem(Map<String, Integer>
id = id + '|' + count;
}
else
{
idCounter.put(id, 0);
id = id + '|' + 0;
}

String label = i.hasType() && i.getType().hasCoding() ? i.getType().getCoding().stream()
.filter(Coding::hasSystemElement).filter(c -> c.getSystemElement().hasValue())
Expand Down
44 changes: 26 additions & 18 deletions dsf-fhir/dsf-fhir-server/src/main/resources/fhir/static/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ function readTaskInputsFromForm() {

if (id !== "http://dsf.dev/fhir/CodeSystem/bpmn-message|message-name") {
document.querySelectorAll(`div.row[for^="${CSS.escape(id)}"]`).forEach(row => {
const result = readAndValidateTaskInput(input, row)
if (id === toIdWithoutIndex(row.getAttribute("for"))) {
const result = readAndValidateTaskInput(input, row)

if (result.input)
newInputs.push(result.input)
else if (!result.valid)
valid = false
if (result.input)
newInputs.push(result.input)
else if (!result.valid)
valid = false
}
})
} else {
newInputs.push(input)
Expand Down Expand Up @@ -95,12 +97,12 @@ function readAndValidateTaskInput(input, row) {
return newTaskInputBoolean(input.type, id, htmlInputs[0].checked, htmlInputs[1].checked, optional)
}
else if (htmlInputs?.length === 5) {
const input0FhirType = htmlInputs[0].getAttribute("fhir-type")
const input0FhirType = htmlInputs[0].getAttribute("fhir-type")

if (input0FhirType.startsWith("Quantity")) {
return new newTaskInputQuantity(input.type, id, htmlInputs[0].value, htmlInputs[1].value, htmlInputs[2].value, htmlInputs[3].value, htmlInputs[4].value, optional)
}
}
if (input0FhirType.startsWith("Quantity")) {
return new newTaskInputQuantity(input.type, id, htmlInputs[0].value, htmlInputs[1].value, htmlInputs[2].value, htmlInputs[3].value, htmlInputs[4].value, optional)
}
}

return { input: null, valid: false }
}
Expand Down Expand Up @@ -267,7 +269,7 @@ function readQuestionnaireResponseAnswersFromForm() {
}
}
})

const practitionerIdentifierValue = document.querySelector('#practitionerIdentifierValue')?.value
if (practitionerIdentifierValue !== undefined) {
questionnaireResponse.author.type = "Practitioner"
Expand Down Expand Up @@ -440,8 +442,8 @@ function newQuestionnaireResponseItemQuantity(text, id, comparator, value, unit,
code: result.value.code
}
}]
}
return { item: item, valid: true }
}
return { item: item, valid: true }
} else
return { input: null, valid: result.valid }
}
Expand Down Expand Up @@ -587,7 +589,7 @@ function validateString(errorListElement, value, optional, valueName) {

function validateStringInList(errorListElement, value, list, optional, valueName) {
const valueInList = s => list.includes(s)
return validateType(errorListElement, value, optional, valueName, valueInList, "not in [" + list.toString() + "]" , v => v)
return validateType(errorListElement, value, optional, valueName, valueInList, "not in [" + list.toString() + "]", v => v)
}

function validateInteger(errorListElement, value, optional, valueName) {
Expand Down Expand Up @@ -830,7 +832,7 @@ function getValueOfDifferential(differentials, path, property) {
}

function modifyTaskInputRow(definition) {
const id = definition.typeSystem + "|" + definition.typeCode
const id = definition.typeSystem + "|" + definition.typeCode + "|0"
const row = document.querySelector(`div.row[for="${CSS.escape(id)}"]`)

if (row) {
Expand Down Expand Up @@ -874,14 +876,20 @@ function modifyQuestionnaireInputRow(item) {
}
}

function toIdWithoutIndex(id) {
return id.slice(0, id.lastIndexOf('|'))
}

function appendInputRowAfter(id) {
const rows = document.querySelectorAll(`div.row[for^="${CSS.escape(id)}"]`)
id = toIdWithoutIndex(id);

const rows = document.querySelectorAll(`div.row[for^="${CSS.escape(id)}"]`).values().filter(e => id === toIdWithoutIndex(e.getAttribute("for"))).toArray()

if (rows.length <= 0)
return

const idParts = rows[rows.length - 1].getAttribute("for")?.split("|")
const index = idParts && idParts.length === 3 ? parseInt(idParts[2]) + 1 : 1
const forAttr = rows[rows.length - 1].getAttribute("for")
const index = parseInt(forAttr.slice(forAttr.lastIndexOf("|") + 1)) + 1
const clone = rows[0].cloneNode(true)

clone.setAttribute("for", id + "|" + index)
Expand Down
Loading