@@ -35,10 +35,7 @@ function readTaskInputsFromForm() {
3535
3636 if ( id !== "http://dsf.dev/fhir/CodeSystem/bpmn-message|message-name" ) {
3737 document . querySelectorAll ( `div.row[for^="${ CSS . escape ( id ) } "]` ) . forEach ( row => {
38- const idAttr = row . getAttribute ( "for" )
39- const idx = idAttr . lastIndexOf ( "|" )
40- const idNoIndex = idAttr . slice ( 0 , idx )
41- if ( id === idNoIndex ) {
38+ if ( id === toIdWithoutIndex ( row . getAttribute ( "for" ) ) ) {
4239 const result = readAndValidateTaskInput ( input , row )
4340
4441 if ( result . input )
@@ -100,12 +97,12 @@ function readAndValidateTaskInput(input, row) {
10097 return newTaskInputBoolean ( input . type , id , htmlInputs [ 0 ] . checked , htmlInputs [ 1 ] . checked , optional )
10198 }
10299 else if ( htmlInputs ?. length === 5 ) {
103- const input0FhirType = htmlInputs [ 0 ] . getAttribute ( "fhir-type" )
100+ const input0FhirType = htmlInputs [ 0 ] . getAttribute ( "fhir-type" )
104101
105- if ( input0FhirType . startsWith ( "Quantity" ) ) {
106- return new newTaskInputQuantity ( input . type , id , htmlInputs [ 0 ] . value , htmlInputs [ 1 ] . value , htmlInputs [ 2 ] . value , htmlInputs [ 3 ] . value , htmlInputs [ 4 ] . value , optional )
107- }
108- }
102+ if ( input0FhirType . startsWith ( "Quantity" ) ) {
103+ return new newTaskInputQuantity ( input . type , id , htmlInputs [ 0 ] . value , htmlInputs [ 1 ] . value , htmlInputs [ 2 ] . value , htmlInputs [ 3 ] . value , htmlInputs [ 4 ] . value , optional )
104+ }
105+ }
109106
110107 return { input : null , valid : false }
111108}
@@ -272,7 +269,7 @@ function readQuestionnaireResponseAnswersFromForm() {
272269 }
273270 }
274271 } )
275-
272+
276273 const practitionerIdentifierValue = document . querySelector ( '#practitionerIdentifierValue' ) ?. value
277274 if ( practitionerIdentifierValue !== undefined ) {
278275 questionnaireResponse . author . type = "Practitioner"
@@ -445,8 +442,8 @@ function newQuestionnaireResponseItemQuantity(text, id, comparator, value, unit,
445442 code : result . value . code
446443 }
447444 } ]
448- }
449- return { item : item , valid : true }
445+ }
446+ return { item : item , valid : true }
450447 } else
451448 return { input : null , valid : result . valid }
452449}
@@ -592,7 +589,7 @@ function validateString(errorListElement, value, optional, valueName) {
592589
593590function validateStringInList ( errorListElement , value , list , optional , valueName ) {
594591 const valueInList = s => list . includes ( s )
595- return validateType ( errorListElement , value , optional , valueName , valueInList , "not in [" + list . toString ( ) + "]" , v => v )
592+ return validateType ( errorListElement , value , optional , valueName , valueInList , "not in [" + list . toString ( ) + "]" , v => v )
596593}
597594
598595function validateInteger ( errorListElement , value , optional , valueName ) {
@@ -835,7 +832,7 @@ function getValueOfDifferential(differentials, path, property) {
835832}
836833
837834function modifyTaskInputRow ( definition ) {
838- const id = definition . typeSystem + "|" + definition . typeCode
835+ const id = definition . typeSystem + "|" + definition . typeCode + "|0"
839836 const row = document . querySelector ( `div.row[for="${ CSS . escape ( id ) } "]` )
840837
841838 if ( row ) {
@@ -879,22 +876,20 @@ function modifyQuestionnaireInputRow(item) {
879876 }
880877}
881878
879+ function toIdWithoutIndex ( id ) {
880+ return id . slice ( 0 , id . lastIndexOf ( '|' ) )
881+ }
882+
882883function appendInputRowAfter ( id ) {
883- const rows = document . querySelectorAll ( `div.row[for^="${ CSS . escape ( id ) } "]` ) . values ( ) . filter (
884- ( element ) => {
885- const idAttr = element . getAttribute ( "for" )
886- const idx = idAttr . lastIndexOf ( "|" )
887- const idNoIndex = idAttr . slice ( 0 , idx )
888- return id === idNoIndex
889- }
890- ) . toArray ( )
884+ id = toIdWithoutIndex ( id ) ;
885+
886+ const rows = document . querySelectorAll ( `div.row[for^="${ CSS . escape ( id ) } "]` ) . values ( ) . filter ( e => id === toIdWithoutIndex ( e . getAttribute ( "for" ) ) ) . toArray ( )
891887
892888 if ( rows . length <= 0 )
893889 return
894890
895- const idAttr = rows [ rows . length - 1 ] . getAttribute ( "for" )
896- const idx = idAttr . lastIndexOf ( "|" )
897- const index = parseInt ( idAttr . slice ( idx + 1 ) ) + 1
891+ const forAttr = rows [ rows . length - 1 ] . getAttribute ( "for" )
892+ const index = parseInt ( forAttr . slice ( forAttr . lastIndexOf ( "|" ) + 1 ) ) + 1
898893 const clone = rows [ 0 ] . cloneNode ( true )
899894
900895 clone . setAttribute ( "for" , id + "|" + index )
0 commit comments