@@ -201,15 +201,17 @@ public void run() {
201201 String requestId = getRequestIdFromRequestJson (requestJson );
202202 LOG .info ("Extracting samples from request received: " + requestId );
203203 List <Map <String , Object >> samples = getSamplesFromRequestJson (requestJson );
204+ // get is cmo request for label generator
205+ Object isCmoRequest = getIsCmoRequestFromRequestJson (requestJson );
204206
205- // get existing samples for all patients in the request
207+ // get existing samples for all patients and alt ids in the request
206208 Map <String , List <CmoLabelParts >> patientSamplesMap = getPatientSamplesMap (samples );
207209 Map <String , List <CmoLabelParts >> altIdSamplesMap = getAltIdSamplesMap (samples );
208210
209211 // udpated samples list will store samples which had a label generated successfully
210212 for (int i = 0 ; i < samples .size (); i ++) {
211213 Map <String , Object > sampleMap = samples .get (i );
212- CmoLabelParts labelParts = new CmoLabelParts (sampleMap , requestId );
214+ CmoLabelParts labelParts = new CmoLabelParts (sampleMap , requestId , isCmoRequest );
213215
214216 Map <String , Object > statusMap = mapper .convertValue (
215217 sampleMap .get ("status" ), Map .class );
@@ -351,7 +353,7 @@ public void run() {
351353 Map <String , String > origSampleJsonMap = new HashMap <>();
352354 for (int i = 0 ; i < samples .size (); i ++) {
353355 Map <String , Object > sampleMap = samples .get (i );
354- CmoLabelParts labelParts = new CmoLabelParts (sampleMap , null );
356+ CmoLabelParts labelParts = new CmoLabelParts (sampleMap , null , null );
355357 origSampleJsonMap .put (labelParts .getPrimaryId (),
356358 labelParts .getOrigSampleJsonStr ());
357359
@@ -497,7 +499,7 @@ private Map<String, List<CmoLabelParts>> getPatientSamplesMap(List<Map<String, O
497499 Map <String , List <CmoLabelParts >> patientSamplesMap = new HashMap <>();
498500 for (Map <String , Object > sm : samples ) {
499501 // get or request existing patient samples and update patient sample mapping
500- CmoLabelParts sample = new CmoLabelParts (sm , null );
502+ CmoLabelParts sample = new CmoLabelParts (sm , null , null );
501503 if (StringUtils .isBlank (sample .getCmoPatientId ())
502504 || patientSamplesMap .containsKey (sample .getCmoPatientId ())) {
503505 continue ;
@@ -518,7 +520,7 @@ private List<CmoLabelParts> getExistingPatientSamples(String cmoPatientId) throw
518520 List <CmoLabelParts > samples = new ArrayList <>();
519521 for (Object s : sampleObjList ) {
520522 Map <String , Object > sm = mapper .convertValue (s , Map .class );
521- samples .add (new CmoLabelParts (sm , null ));
523+ samples .add (new CmoLabelParts (sm , null , null ));
522524 }
523525 return samples ;
524526 }
@@ -537,7 +539,7 @@ private List<CmoLabelParts> getSamplesByCmoLabel(String cmoLabel) throws Excepti
537539 List <CmoLabelParts > samples = new ArrayList <>();
538540 for (Object s : sampleObjList ) {
539541 Map <String , Object > sm = mapper .convertValue (s , Map .class );
540- samples .add (new CmoLabelParts (sm , null ));
542+ samples .add (new CmoLabelParts (sm , null , null ));
541543 }
542544 return samples ;
543545 }
@@ -547,7 +549,7 @@ private Map<String, List<CmoLabelParts>> getAltIdSamplesMap(List<Map<String, Obj
547549 Map <String , List <CmoLabelParts >> altIdSamplesMap = new HashMap <>();
548550 for (Map <String , Object > sm : samples ) {
549551 // get or request existing patient samples and update patient sample mapping
550- CmoLabelParts sample = new CmoLabelParts (sm , null );
552+ CmoLabelParts sample = new CmoLabelParts (sm , null , null );
551553 if (StringUtils .isBlank (sample .getAltId ())
552554 || altIdSamplesMap .containsKey (sample .getAltId ())) {
553555 continue ;
@@ -573,7 +575,7 @@ private List<CmoLabelParts> getSamplesByAltId(String altId) throws Exception {
573575 List <CmoLabelParts > samples = new ArrayList <>();
574576 for (Object s : sampleObjList ) {
575577 Map <String , Object > sm = mapper .convertValue (s , Map .class );
576- samples .add (new CmoLabelParts (sm , null ));
578+ samples .add (new CmoLabelParts (sm , null , null ));
577579 }
578580 return samples ;
579581 }
@@ -596,6 +598,11 @@ private String getRequestIdFromRequestJson(String requestJson) throws JsonProces
596598 return requestJsonMap .get ("requestId" ).toString ();
597599 }
598600
601+ private Object getIsCmoRequestFromRequestJson (String requestJson ) throws JsonProcessingException {
602+ Map <String , Object > requestJsonMap = mapper .readValue (requestJson , Map .class );
603+ return requestJsonMap .get ("isCmoRequest" );
604+ }
605+
599606 private List <Map <String , Object >> getSamplesFromRequestJson (String requestJson )
600607 throws JsonProcessingException {
601608 Map <String , Object > requestJsonMap = mapper .readValue (requestJson , Map .class );
@@ -775,7 +782,7 @@ public void onMessage(Message msg, Object message) {
775782 for (Object s : sampleObjList ) {
776783 Map <String , Object > sm = mapper .convertValue (s , Map .class );
777784 if (!sm .containsKey ("igoRequestId" )) {
778- CmoLabelParts labelParts = new CmoLabelParts (sm , null );
785+ CmoLabelParts labelParts = new CmoLabelParts (sm , null , null );
779786 sm .put ("igoRequestId" , labelParts .getIgoRequestId ());
780787 }
781788 sampleMetadataList .add (sm );
@@ -798,7 +805,7 @@ private String findNextAvailableCmoLabel(String primaryId, String cmoLabel,
798805 // in smile and is associated with a different sample
799806 // if diff alt ids then increment by sample counter otherwise increment nuc acid counter
800807 Map <String , Object > sm = mapper .convertValue (s , Map .class );
801- CmoLabelParts sample = new CmoLabelParts (sm , null );
808+ CmoLabelParts sample = new CmoLabelParts (sm , null , null );
802809 if (!sample .getPrimaryId ().equals (primaryId )) {
803810 String otherAltId = sample .getAltId ();
804811 if (!StringUtils .isBlank (altId ) && !StringUtils .isBlank (otherAltId )
0 commit comments