Skip to content

Commit 2ec3ca9

Browse files
author
Adrian Clay
authored
NIAD-3211: Allow sending a MedicationStatement without a Participant (#939)
Having done some testing with other GP2GP implementations we've identified that other systems will accept this and optionally generate a fake placeholder Dr within their system when ingesting the record. While the GP Connect spec insists that a MedicationRequest has an recorder, it is preferable to send the GP2GP extract than fail the transfer completely.
1 parent c52523b commit 2ec3ca9

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
* When mapping a `Condition` without an `asserter`, omit the `Participant` element within the XML.
1212
Previously this would raise the error "EhrMapperException: Condition.asserter is required" and send a
1313
failure to the requesting system.
14+
* When mapping a `MedicationRequest` without a `recorder` or `requester`, omit the `Participant` element within the XML.
15+
Previously this would raise the error "MedicationRequest ... missing recorder of type Practitioner, PractitionerRole
16+
or Organization" and send a failure to the requesting system.
1417

1518
* When mapping a `DocumentReference` which contains a `NOPAT` `meta.security` or `NOPAT` `securityLabel` tag the resultant XML for that resource
1619
will contain a `NOPAT` `confidentialityCode` element.

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/MedicationStatementMapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ private String buildParticipant(MedicationRequest medicationRequest) {
299299
messageContext.getAgentDirectory().getAgentId(reference), ParticipantType.AUTHOR);
300300
}
301301
}
302-
throw new EhrMapperException("MedicationRequest " + medicationRequest.getId()
303-
+ " missing recorder of type Practitioner, PractitionerRole or Organization");
302+
return StringUtils.EMPTY;
304303
}
305304

306305
private static Predicate<Reference> buildPredicateReferenceIsA(@NonNull ResourceType type) {

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/MedicationStatementMapperTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public class MedicationStatementMapperTest {
134134
+ "medication-request-with-extension-status-reason-with-text.json";
135135
private static final String OUTPUT_XML_WITH_STATUS_REASON_TEXT = TEST_FILE_DIRECTORY
136136
+ "medication-statement-with-status-reason-text.xml";
137+
private static final String OUTPUT_XML_WITH_NO_PARTICIPANT = TEST_FILE_DIRECTORY
138+
+ "medication-statement-with-no-participant.xml";
137139
private static final String INPUT_JSON_WITH_REQUESTER_ON_BEHALF_OF = TEST_FILE_DIRECTORY
138140
+ "medication-request-with-requester-on-behalf-of.json";
139141
private static final String INPUT_JSON_WITH_REQUESTER = TEST_FILE_DIRECTORY
@@ -230,7 +232,9 @@ private static Stream<Arguments> resourceFileParams() {
230232
Arguments.of(INPUT_JSON_WITH_PLAN_NO_OPTIONAL_FIELDS, OUTPUT_XML_WITH_AUTHORISE_NO_OPTIONAL_FIELDS),
231233
Arguments.of(INPUT_JSON_WITH_PLAN_NO_STATUS_REASON_CODE, OUTPUT_XML_WITH_AUTHORISE_DEFAULT_STATUS_REASON_CODE),
232234
Arguments.of(INPUT_JSON_WITH_PLAN_NO_INFO_PRESCRIPTION_TEXT, OUTPUT_XML_WITH_AUTHORISE_REPEAT_PRESCRIPTION),
233-
Arguments.of(INPUT_JSON_WITH_EXTENSION_STATUS_REASON_TEXT, OUTPUT_XML_WITH_STATUS_REASON_TEXT)
235+
Arguments.of(INPUT_JSON_WITH_EXTENSION_STATUS_REASON_TEXT, OUTPUT_XML_WITH_STATUS_REASON_TEXT),
236+
Arguments.of(INPUT_JSON_WITH_NO_RECORDER_REFERENCE, OUTPUT_XML_WITH_NO_PARTICIPANT),
237+
Arguments.of(INPUT_JSON_WITH_INVALID_RECORDER_REFERENCE_TYPE, OUTPUT_XML_WITH_NO_PARTICIPANT)
234238
);
235239
}
236240

@@ -242,7 +246,7 @@ private void assertThatInputMapsToExpectedOutput(String inputJsonResourcePath, S
242246

243247
String outputMessage = medicationStatementMapper.mapMedicationRequestToMedicationStatement(parsedMedicationRequest);
244248

245-
assertThat(outputMessage).isEqualTo(expected);
249+
assertThat(outputMessage).isEqualToNormalizingWhitespace(expected);
246250
}
247251

248252
@SneakyThrows
@@ -293,9 +297,7 @@ private static List<String> resourceFileExpectException() {
293297
INPUT_JSON_WITH_NO_DOSAGE_INSTRUCTION,
294298
INPUT_JSON_WITH_NO_DISPENSE_REQUEST,
295299
INPUT_JSON_WITH_ORDER_NO_BASED_ON,
296-
INPUT_JSON_WITH_PLAN_STATUS_REASON_STOPPED_NO_DATE,
297-
INPUT_JSON_WITH_NO_RECORDER_REFERENCE,
298-
INPUT_JSON_WITH_INVALID_RECORDER_REFERENCE_TYPE
300+
INPUT_JSON_WITH_PLAN_STATUS_REASON_STOPPED_NO_DATE
299301
);
300302
}
301303

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<component typeCode="COMP">
2+
<MedicationStatement classCode="SBADM" moodCode="ORD">
3+
<id root="394559384658936"/>
4+
<statusCode code="ACTIVE"/>
5+
<effectiveTime>
6+
<low value="20171110000000"/><high value="20180815000000"/>
7+
</effectiveTime>
8+
<availabilityTime value="20171110000000"/>
9+
<consumable typeCode="CSM">
10+
<manufacturedProduct classCode="MANU">
11+
<manufacturedMaterial determinerCode="KIND" classCode="MMAT">
12+
<code code="430127000" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Oral Form Oxycodone (product)">
13+
</code>
14+
</manufacturedMaterial>
15+
</manufacturedProduct>
16+
</consumable>
17+
<component typeCode="COMP">
18+
<ehrSupplyPrescribe>
19+
<id root="394559384658936"/>
20+
<code code="394823007" displayName="NHS Prescription" codeSystem="2.16.840.1.113883.2.1.3.2.4.15"/>
21+
<statusCode code="ACTIVE"/>
22+
<availabilityTime value="20171110000000"/>
23+
<quantity value="1" unit="1">
24+
<translation value="1">
25+
<originalText>Unk UoM</originalText>
26+
</translation>
27+
</quantity>
28+
<inFulfillmentOf typeCode="FLFS">
29+
<priorMedicationRef moodCode="INT">
30+
<id root="394559384658936"/>
31+
</priorMedicationRef>
32+
</inFulfillmentOf>
33+
<pertinentInformation typeCode="PERT">
34+
<pertinentSupplyAnnotation>
35+
<text>Patient Instruction: Take in morning</text>
36+
</pertinentSupplyAnnotation>
37+
</pertinentInformation>
38+
</ehrSupplyPrescribe>
39+
</component>
40+
<pertinentInformation typeCode="PERT">
41+
<pertinentMedicationDosage classCode="SBADM" moodCode="RMD">
42+
<text>1 tablet once a day</text>
43+
</pertinentMedicationDosage>
44+
</pertinentInformation>
45+
</MedicationStatement>
46+
</component>

0 commit comments

Comments
 (0)