Skip to content
Open
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
24 changes: 11 additions & 13 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 @@ -1108,20 +1108,18 @@ function handlePendingTask() {
const count = baseIdCount.get(baseId) || 0
baseIdCount.set(baseId, count + 1)

const suffix = count === 0 ? "" : `|${count}`

if (count > 0)
appendInputRowAfter(baseId)
appendInputRowAfter(`${baseId}|${count - 1}`)

const fullId = (id) => id + suffix
const fullId = (suffix) => `${baseId}|${count}${suffix != null ? `-${suffix}` : ""}`

const primitiveValue =
values.boolean ?? values.string ?? values.integer ??
values.decimal ?? values.date ?? values.time ??
values.dateTime ?? values.instant ?? values.uri

if (primitiveValue != null) {
const id = fullId(baseId + (values.boolean !== undefined ? `-${values.boolean}` : ""))
const id = fullId(values.boolean)

const input = getInputById(id)

Expand All @@ -1138,31 +1136,31 @@ function handlePendingTask() {
const { reference, identifier } = values.reference

if (reference) {
const input = getInputById(fullId(baseId))
const input = getInputById(fullId())
if (input) input.value = reference

} else if (identifier) {
const { system, value } = identifier

const inputSystem = getInputById(fullId(baseId + "-system"))
const inputValue = getInputById(fullId(baseId + "-value"))
const inputSystem = getInputById(fullId("system"))
const inputValue = getInputById(fullId("value"))

if (inputSystem) inputSystem.value = system
if (inputValue) inputValue.value = value
}
} else if (values.identifier) {
const { system, value } = values.identifier

const inputSystem = getInputById(fullId(baseId + "-system"))
const inputValue = getInputById(fullId(baseId + "-value"))
const inputSystem = getInputById(fullId("system"))
const inputValue = getInputById(fullId("value"))

if (inputSystem) inputSystem.value = system
if (inputValue) inputValue.value = value
} else if (values.coding) {
const { system, code } = values.coding

const inputSystem = getInputById(fullId(baseId + "-system"))
const inputCode = getInputById(fullId(baseId + "-code"))
const inputSystem = getInputById(fullId("system"))
const inputCode = getInputById(fullId("code"))

if (inputSystem) inputSystem.value = system
if (inputCode) inputCode.value = code
Expand All @@ -1173,7 +1171,7 @@ function handlePendingTask() {

Object.entries(fields).forEach(([key, val]) => {
if (val == null) return
const input = getInputById(fullId(`${baseId}-${key}`))
const input = getInputById(fullId(key))
if (input) input.value = val
})
}
Expand Down