@@ -33,7 +33,6 @@ import {
3333 postToOpenElisServer ,
3434 postToOpenElisServerJsonResponse ,
3535} from "../../utils/Utils.js" ;
36- import AutoComplete from "../../common/AutoComplete.js" ;
3736
3837const breadcrumbs = [
3938 { label : "home.label" , link : "/" } ,
@@ -60,8 +59,8 @@ function BatchTestReassignmentAndCancelation() {
6059 const [ batchTestPost , setBatchTestPost ] = useState ( null ) ;
6160 const [ sampleTypeListShow , setSampleTypeListShow ] = useState ( [ ] ) ;
6261 const [ sampleTypeToGetId , setSampleTypeToGetId ] = useState ( null ) ;
63- const [ sampleTypeToGetIdData , setSampleTypeToGetIdData ] = useState ( [ ] ) ;
64- const [ sampleTypeToGetIdDataTag , setSampleTypeToGetIdDataTag ] = useState ( [ ] ) ;
62+ const [ sampleTypeToGetIdData , setSampleTypeToGetIdData ] = useState ( { } ) ;
63+ const [ sampleTypeToGetIdDataTag , setSampleTypeToGetIdDataTag ] = useState ( { } ) ;
6564 const [ sampleTypeTestIdToGetIdPending , setSampleTestTypeToGetPending ] =
6665 useState ( null ) ;
6766 const [
@@ -113,14 +112,22 @@ function BatchTestReassignmentAndCancelation() {
113112 if ( ! res ) {
114113 setIsLoading ( true ) ;
115114 } else {
116- setSampleTypeToGetIdData ( res ) ;
115+ const extraCurrentTestObject = {
116+ name : "Select Current Test" ,
117+ id : "" ,
118+ isActive : "" ,
119+ } ;
120+ setSampleTypeToGetIdData ( ( prevSampleTypeToGetIdData ) => ( {
121+ ...prevSampleTypeToGetIdData ,
122+ tests : [ extraCurrentTestObject , ...( res . tests || [ ] ) ] ,
123+ } ) ) ;
117124 const extraObject = {
118125 name : "Select Multi Tests" ,
119126 id : "" ,
120127 isActive : "" ,
121128 } ;
122- setSampleTypeToGetIdDataTag ( ( sampleTypeToGetIdDataTag ) => ( {
123- ...sampleTypeToGetIdDataTag ,
129+ setSampleTypeToGetIdDataTag ( ( prevSampleTypeToGetIdDataTag ) => ( {
130+ ...prevSampleTypeToGetIdDataTag ,
124131 tests : [ extraObject , ...( res . tests || [ ] ) ] ,
125132 } ) ) ;
126133 }
@@ -348,6 +355,32 @@ function BatchTestReassignmentAndCancelation() {
348355 ) ;
349356 }
350357
358+ useEffect ( ( ) => {
359+ if (
360+ batchTestPost &&
361+ sampleTypeToGetIdDataTag &&
362+ sampleTypeToGetIdDataTag . tests &&
363+ sampleTypeListShow
364+ ) {
365+ const sampleTypeValue = batchTestPost . statusChangedSampleType || "" ;
366+ const currentTest = batchTestPost . statusChangedCurrentTest || "" ;
367+ const sampleTypeItem = sampleTypeListShow . find (
368+ ( item ) => item . id === sampleTypeValue . toString ( ) ,
369+ ) ;
370+ const sampleTypeValueToSet = sampleTypeItem ? sampleTypeItem . value : "" ;
371+ const currentTestItem = sampleTypeToGetIdDataTag . tests . find (
372+ ( test ) => test . id === currentTest . toString ( ) ,
373+ ) ;
374+ const currentTestNameToSet = currentTestItem ? currentTestItem . name : "" ;
375+
376+ setJsonWad ( ( prevJsonWad ) => ( {
377+ ...prevJsonWad ,
378+ sampleType : sampleTypeValueToSet ,
379+ current : currentTestNameToSet ,
380+ } ) ) ;
381+ }
382+ } , [ batchTestPost , sampleTypeToGetIdDataTag , sampleTypeListShow ] ) ;
383+
351384 if ( ! isLoading ) {
352385 return (
353386 < >
@@ -431,7 +464,9 @@ function BatchTestReassignmentAndCancelation() {
431464 id = { `selectSampleType1` }
432465 hideLabel = { true }
433466 defaultValue = {
434- sampleTypeToGetIdData ? sampleTypeToGetIdData [ 0 ] : ""
467+ sampleTypeToGetIdData && sampleTypeToGetIdData . tests
468+ ? sampleTypeToGetIdData . tests [ 0 ]
469+ : ""
435470 }
436471 onChange = { ( e ) => handleSampleTypeListSelectIdTest ( e ) }
437472 >
@@ -715,6 +750,10 @@ function BatchTestReassignmentAndCancelation() {
715750 disabled = { saveButton }
716751 onClick = { ( ) => {
717752 setChangesToShow ( true ) ;
753+ setBatchTestPost ( ( prevBatchTestPost ) => ( {
754+ ...prevBatchTestPost ,
755+ jsonWad : jsonWad ,
756+ } ) ) ;
718757 } }
719758 type = "button"
720759 >
@@ -752,6 +791,7 @@ function BatchTestReassignmentAndCancelation() {
752791 < hr />
753792 </ Column >
754793 < Column lg = { 4 } md = { 4 } sm = { 2 } >
794+ < br />
755795 < FormattedMessage id = "label.analysisNotStarted" />
756796 { jsonWad . changeNotStarted . map ( ( id ) => {
757797 const item =
@@ -770,6 +810,7 @@ function BatchTestReassignmentAndCancelation() {
770810 } ) }
771811 </ Column >
772812 < Column lg = { 4 } md = { 4 } sm = { 2 } >
813+ < br />
773814 < FormattedMessage id = "label.rejectedByTechnician" />
774815 { jsonWad . changeTechReject . map ( ( id ) => {
775816 const item =
@@ -788,6 +829,7 @@ function BatchTestReassignmentAndCancelation() {
788829 } ) }
789830 </ Column >
790831 < Column lg = { 4 } md = { 4 } sm = { 2 } >
832+ < br />
791833 < FormattedMessage id = "label.rejectedByBiologist" />
792834 { jsonWad . changeBioReject . map ( ( id ) => {
793835 const item =
@@ -806,6 +848,7 @@ function BatchTestReassignmentAndCancelation() {
806848 } ) }
807849 </ Column >
808850 < Column lg = { 4 } md = { 4 } sm = { 2 } >
851+ < br />
809852 < FormattedMessage id = "label.notValidated" />
810853 { jsonWad . changeNotValidated . map ( ( id ) => {
811854 const item =
@@ -833,6 +876,7 @@ function BatchTestReassignmentAndCancelation() {
833876 < br />
834877 </ Column >
835878 < Column lg = { 4 } md = { 4 } sm = { 2 } >
879+ < br />
836880 < FormattedMessage id = "label.analysisNotStarted" />
837881 { jsonWad . noChangeNotStarted . map ( ( id ) => {
838882 const item =
@@ -851,6 +895,7 @@ function BatchTestReassignmentAndCancelation() {
851895 } ) }
852896 </ Column >
853897 < Column lg = { 4 } md = { 4 } sm = { 2 } >
898+ < br />
854899 < FormattedMessage id = "label.rejectedByTechnician" />
855900 { jsonWad . noChangeTechReject . map ( ( id ) => {
856901 const item =
@@ -869,6 +914,7 @@ function BatchTestReassignmentAndCancelation() {
869914 } ) }
870915 </ Column >
871916 < Column lg = { 4 } md = { 4 } sm = { 2 } >
917+ < br />
872918 < FormattedMessage id = "label.rejectedByBiologist" />
873919 { jsonWad . noChangeBioReject . map ( ( id ) => {
874920 const item =
@@ -887,6 +933,7 @@ function BatchTestReassignmentAndCancelation() {
887933 } ) }
888934 </ Column >
889935 < Column lg = { 4 } md = { 4 } sm = { 2 } >
936+ < br />
890937 < FormattedMessage id = "label.notValidated" />
891938 { jsonWad . noChangeNotValidated . map ( ( id ) => {
892939 const item =
0 commit comments