@@ -216,6 +216,63 @@ void When_GpcResponseMissingResource_Expect_NackWithCode10() throws Exception {
216216 checkNhsNumberTriggersNackWithCode (NACK_CODE_FAILED_TO_GENERATE_EHR , NHS_NUMBER_RESPONSE_MISSING_PATIENT_RESOURCE );
217217 }
218218
219+ @ Test
220+ void When_ExtractRequestReceivedForPatientWithoutClinicalContent_Expect_ExtractStatusAndDocumentDataAddedToDbAndReturnCode10 () throws Exception {
221+ System .out .println ("Clearing EhrExtractStatus collection..." );
222+ Mongo .clearEhrExtractStatusCollection ();
223+
224+ String conversationId = UUID .randomUUID ().toString ();
225+ System .out .println ("Generated conversationId: " + conversationId );
226+
227+ String ehrExtractRequest = buildEhrExtractRequest (conversationId , NHS_NUMBER_NO_CLINICAL_CONTENT_STRUCTURE , FROM_ODS_CODE_1 );
228+ System .out .println ("Sending EHR Extract Request to MHS Inbound Queue..." );
229+ MessageQueue .sendToMhsInboundQueue (ehrExtractRequest );
230+
231+ System .out .println ("Waiting for request journal for conversationId: " + conversationId );
232+ var requestJournal = waitFor (() -> {
233+ try {
234+ return mhsMockRequestsJournal .getRequestsJournal (conversationId );
235+ } catch (IOException | InterruptedException e ) {
236+ throw new RuntimeException (e );
237+ }
238+ });
239+
240+ System .out .println ("Request journal size: " + (requestJournal != null ? requestJournal .size () : "null" ));
241+ if (requestJournal != null && !requestJournal .isEmpty ()) {
242+ System .out .println ("Request journal first payload: " + requestJournal .get (0 ).getPayload ());
243+ }
244+
245+ assertThat (requestJournal ).hasSize (1 );
246+
247+ System .out .println ("Waiting for EhrExtractStatus from Mongo..." );
248+ var ehrExtractStatus = waitFor (() -> {
249+ var status = Mongo .findEhrExtractStatus (conversationId );
250+ if (status != null ) {
251+ System .out .println ("Intermediate EhrExtractStatus from Mongo: " + status .toJson ());
252+ var error = status .get ("error" );
253+ if (error != null ) {
254+ System .out .println ("Found error field: " + error .toString ());
255+ return status ;
256+ }
257+ }
258+ return null ;
259+ });
260+
261+ System .out .println ("Final EhrExtractStatus retrieved: " + ehrExtractStatus .toJson ());
262+
263+ assertThatInitialRecordWasCreated (conversationId , ehrExtractStatus , NHS_NUMBER_NO_CLINICAL_CONTENT_STRUCTURE , FROM_ODS_CODE_1 );
264+
265+ var error = (Document ) ehrExtractStatus .get ("error" );
266+ System .out .println ("Error document contents: " + error .toJson ());
267+
268+ assertThat (error ).isNotEmpty ();
269+
270+ softly .assertThat (error .get ("code" )).isEqualTo (NACK_CODE_FAILED_TO_GENERATE_EHR );
271+
272+ System .out .println ("Test completed for conversationId: " + conversationId );
273+ }
274+
275+
219276 @ Test
220277 void When_ExtractRequestReceivedForPatientWithNormalEhrExtract_Expect_ExtractStatusAndDocumentDataAddedToDatabase () throws Exception {
221278 String conversationId = UUID .randomUUID ().toString ();
@@ -444,32 +501,7 @@ void When_ExtractRequestReceivedForMedicusPatientWithBasedOn_Expect_ExtractStatu
444501
445502 }
446503
447- @ Test
448- void When_ExtractRequestReceivedForPatientWithoutClinicalContent_Expect_ExtractStatusAndDocumentDataAddedToDbAndReturnCode10 () throws Exception {
449- Mongo .clearEhrExtractStatusCollection ();
450- String conversationId = UUID .randomUUID ().toString ();
451- String ehrExtractRequest = buildEhrExtractRequest (conversationId , NHS_NUMBER_NO_CLINICAL_CONTENT_STRUCTURE , FROM_ODS_CODE_1 );
452- MessageQueue .sendToMhsInboundQueue (ehrExtractRequest );
453- // Mongo.clearEhrExtractStatusCollection();
454-
455- var requestJournal = waitFor (() -> {
456- try {
457- return mhsMockRequestsJournal .getRequestsJournal (conversationId );
458- } catch (IOException | InterruptedException e ) {
459- throw new RuntimeException (e );
460- }
461- });
462-
463- assertThat (requestJournal ).hasSize (1 );
464- Thread .sleep (1000 );
465504
466- var ehrExtractStatus = waitFor (() -> Mongo .findEhrExtractStatus (conversationId ));
467- assertThatInitialRecordWasCreated (conversationId , ehrExtractStatus , NHS_NUMBER_NO_CLINICAL_CONTENT_STRUCTURE , FROM_ODS_CODE_1 );
468-
469- var error = (Document ) ehrExtractStatus .get ("error" );
470- assertThat (error ).isNotEmpty ();
471- softly .assertThat (error .get ("code" )).isEqualTo (NACK_CODE_FAILED_TO_GENERATE_EHR );
472- }
473505
474506 @ Test
475507 void When_ExtractRequestReceivedForEMISPWTP2_Expect_ExtractStatusAndDocumentDataAddedToDatabase () throws IOException , NamingException , JMSException {
0 commit comments