Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIAD-2846: new RCMR_IN030000UK07 compatibility test #318

Merged
merged 23 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.nhs.adaptors.pss.translator;

import static org.assertj.core.api.Assertions.fail;
import static org.awaitility.Awaitility.await;
import static org.awaitility.Awaitility.waitAtMost;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import static uk.nhs.adaptors.common.util.FileUtil.readResourceAsString;
Expand All @@ -11,6 +11,7 @@

import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
Expand Down Expand Up @@ -47,6 +48,7 @@
@DirtiesContext
@AutoConfigureMockMvc
public class EhrExtractHandlingIT {

private static final boolean OVERWRITE_EXPECTED_JSON = false;
private static final int NHS_NUMBER_MIN_MAX_LENGTH = 10;
private static final String EBXML_PART_PATH = "/xml/RCMR_IN030000UK06/ebxml_part.xml";
Expand Down Expand Up @@ -96,6 +98,7 @@ public class EhrExtractHandlingIT {

private String patientNhsNumber;
private String conversationId;
static final int WAITING_TIME = 10;

@BeforeEach
public void setUp() {
Expand All @@ -107,10 +110,23 @@ public void setUp() {
@Test
public void handleEhrExtractFromQueue() throws JSONException {
// process starts with consuming a message from MHS queue
sendInboundMessageToQueue("/xml/RCMR_IN030000UK06/payload_part.xml");
sendInboundMessageToQueue("/xml/RCMR_IN030000UK06/payload_part.xml", EBXML_PART_PATH);

// wait until EHR extract is translated to bundle resource and saved to the DB
waitAtMost(Duration.ofSeconds(WAITING_TIME)).until(this::isEhrMigrationCompleted);
ole4ryb marked this conversation as resolved.
Show resolved Hide resolved

// verify generated bundle resource
verifyBundle("/json/expectedBundle.json");
}

@Test
public void handleEhrExtractWithConfidentialityCodeFromQueue() throws JSONException {
final String ebxmlPartPath = "/xml/RCMR_IN030000UK07/ebxml_part.xml";
// process starts with consuming a message from MHS queue
sendInboundMessageToQueue("/xml/RCMR_IN030000UK07/payload_part_with_confidentiality_code.xml", ebxmlPartPath);

// wait until EHR extract is translated to bundle resource and saved to the DB
await().until(this::isEhrMigrationCompleted);
waitAtMost(Duration.ofSeconds(WAITING_TIME)).until(this::isEhrMigrationCompleted);

// verify generated bundle resource
verifyBundle("/json/expectedBundle.json");
Expand All @@ -129,15 +145,15 @@ private String generateConversationId() {
return UUID.randomUUID().toString();
}

private void sendInboundMessageToQueue(String payloadPartPath) {
var inboundMessage = createInboundMessage(payloadPartPath);
private void sendInboundMessageToQueue(String payloadPartPath, String ebxmlPartPath) {
var inboundMessage = createInboundMessage(payloadPartPath, ebxmlPartPath);
mhsJmsTemplate.send(session -> session.createTextMessage(parseMessageToString(inboundMessage)));
}

private InboundMessage createInboundMessage(String payloadPartPath) {
private InboundMessage createInboundMessage(String payloadPartPath, String ebxmlPartPath) {
var inboundMessage = new InboundMessage();
var payload = readResourceAsString(payloadPartPath).replace(NHS_NUMBER_PLACEHOLDER, patientNhsNumber);
var ebXml = readResourceAsString(EBXML_PART_PATH).replace(CONVERSATION_ID_PLACEHOLDER, conversationId);
var ebXml = readResourceAsString(ebxmlPartPath).replace(CONVERSATION_ID_PLACEHOLDER, conversationId);
inboundMessage.setPayload(payload);
inboundMessage.setEbXML(ebXml);
return inboundMessage;
Expand Down Expand Up @@ -190,4 +206,4 @@ private void overwriteExpectJson(String newExpected) {
private String parseMessageToString(InboundMessage inboundMessage) {
return objectMapper.writeValueAsString(inboundMessage);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd" xmlns:hl7ebxml="urn:hl7-org:transport/ebxml/DSTUv1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3c.org/2001/XML-Schema-Instance">
<SOAP:Header>
<eb:MessageHeader SOAP:mustUnderstand="1" eb:version="2.0">
<eb:From>
<eb:PartyId eb:type="urn:nhs:names:partyType:ocs+serviceInstance">YGM24-820388</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="urn:nhs:names:partyType:ocs+serviceInstance">B86041-822103</eb:PartyId>
</eb:To>
<eb:CPAId>e06af803674408a9d8e8</eb:CPAId>
<eb:ConversationId>{{conversationId}}</eb:ConversationId>
<eb:Service>urn:nhs:names:services:gp2gp</eb:Service>
<eb:Action>RCMR_IN030000UK07</eb:Action>
<eb:MessageData>
<eb:MessageId>31FA3430-6E88-11EA-9384-E83935108FD5</eb:MessageId>
<eb:Timestamp>2020-03-25T11:03:02Z</eb:Timestamp>
<eb:TimeToLive>2020-03-25T15:13:02Z</eb:TimeToLive>
</eb:MessageData>
<eb:DuplicateElimination>always</eb:DuplicateElimination>
</eb:MessageHeader>
<eb:AckRequested SOAP:mustUnderstand="1" eb:version="2.0" eb:signed="false" SOAP:actor="urn:oasis:names:tc:ebxml-msg:actor:nextMSH" />
</SOAP:Header>
<SOAP:Body>
<eb:Manifest SOAP:mustUnderstand="1" eb:version="2.0">
<eb:Reference xlink:href="cid:[email protected]/SystmOne/GP2GP1.1A">
<eb:Schema eb:location="http://www.nhsia.nhs.uk/schemas/HL7-Message.xsd" eb:version="2.0" />
<hl7ebxml:Payload style="HL7" encoding="XML" version="3.0" />
</eb:Reference>
<eb:Reference xlink:href="cid:[email protected]" eb:id="_31B75ED0-6E88-11EA-9384-E83935108FD5">
<eb:Description xml:lang="en-gb">31B75ED0-6E88-11EA-9384-E83935108FD5_patient-attachment.txt.txt</eb:Description>
</eb:Reference>
</eb:Manifest>
</SOAP:Body>
</SOAP:Envelope>
Loading