|
16 | 16 | import org.mockito.junit.jupiter.MockitoExtension; |
17 | 17 | import org.mockito.junit.jupiter.MockitoSettings; |
18 | 18 | import org.mockito.quality.Strictness; |
| 19 | +import uk.nhs.adaptors.gp2gp.common.configuration.RedactionsContext; |
19 | 20 | import uk.nhs.adaptors.gp2gp.common.service.ConfidentialityService; |
20 | 21 | import uk.nhs.adaptors.gp2gp.common.service.FhirParseService; |
21 | 22 | import uk.nhs.adaptors.gp2gp.common.service.RandomIdGeneratorService; |
|
26 | 27 | import uk.nhs.adaptors.gp2gp.ehr.mapper.parameters.EhrExtractTemplateParameters; |
27 | 28 | import uk.nhs.adaptors.gp2gp.ehr.utils.BloodPressureValidator; |
28 | 29 | import uk.nhs.adaptors.gp2gp.gpc.GetGpcStructuredTaskDefinition; |
| 30 | +import uk.nhs.adaptors.gp2gp.transformjsontoxmltool.XmlSchemaValidator; |
29 | 31 | import uk.nhs.adaptors.gp2gp.utils.CodeableConceptMapperMockUtil; |
30 | 32 | import uk.nhs.adaptors.gp2gp.utils.ResourceTestFileUtils; |
31 | 33 |
|
|
36 | 38 | import static org.assertj.core.api.Assertions.assertThat; |
37 | 39 | import static org.mockito.ArgumentMatchers.any; |
38 | 40 | import static org.mockito.ArgumentMatchers.anyString; |
39 | | -import static org.mockito.Mockito.lenient; |
40 | | -import static org.mockito.Mockito.when; |
| 41 | +import static org.mockito.Mockito.*; |
41 | 42 |
|
42 | 43 | @ExtendWith(MockitoExtension.class) |
43 | 44 | @MockitoSettings(strictness = Strictness.LENIENT) |
@@ -109,123 +110,100 @@ class EhrExtractMapperComponentTest { |
109 | 110 | @BeforeEach |
110 | 111 | public void setUp() { |
111 | 112 | getGpcStructuredTaskDefinition = GetGpcStructuredTaskDefinition.builder() |
112 | | - .nhsNumber(TEST_NHS_NUMBER) |
113 | | - .conversationId(TEST_CONVERSATION_ID) |
114 | | - .requestId(TEST_REQUEST_ID) |
115 | | - .fromOdsCode(TEST_FROM_ODS_CODE) |
116 | | - .toOdsCode(TEST_TO_ODS_CODE) |
117 | | - .build(); |
| 113 | + .nhsNumber(TEST_NHS_NUMBER) |
| 114 | + .conversationId(TEST_CONVERSATION_ID) |
| 115 | + .requestId(TEST_REQUEST_ID) |
| 116 | + .fromOdsCode(TEST_FROM_ODS_CODE) |
| 117 | + .toOdsCode(TEST_TO_ODS_CODE) |
| 118 | + .build(); |
118 | 119 |
|
119 | 120 | when(randomIdGeneratorService.createNewId()).thenReturn(TEST_ID_1, TEST_ID_2, TEST_ID_3); |
120 | 121 | lenient().when(randomIdGeneratorService.createNewOrUseExistingUUID(anyString())) |
121 | | - .thenReturn(TEST_ID_3); |
| 122 | + .thenReturn(TEST_ID_3); |
122 | 123 |
|
123 | 124 | when(timestampService.now()).thenReturn(Instant.parse(TEST_DATE_TIME)); |
124 | | - when(codeableConceptCdMapper.mapCodeableConceptToCd(any(CodeableConcept.class))) |
125 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
126 | | - when(codeableConceptCdMapper.mapCodeableConceptForMedication(any(CodeableConcept.class))) |
127 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
128 | | - when(codeableConceptCdMapper.mapCodeableConceptToCdForTransformedActualProblemHeader(any(CodeableConcept.class))) |
129 | | - .thenReturn(CodeableConceptMapperMockUtil.ACTUAL_PROBLEM_CODE); |
130 | | - when(codeableConceptCdMapper.mapToNullFlavorCodeableConcept(any(CodeableConcept.class))) |
131 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
132 | | - when(codeableConceptCdMapper.mapCodeableConceptToCdForAllergy(any(CodeableConcept.class), |
133 | | - any(AllergyIntolerance.AllergyIntoleranceClinicalStatus.class))) |
134 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
135 | | - when(codeableConceptCdMapper.mapToNullFlavorCodeableConceptForAllergy(any(CodeableConcept.class), |
136 | | - any(AllergyIntolerance.AllergyIntoleranceClinicalStatus.class))) |
137 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
138 | | - when(codeableConceptCdMapper.getDisplayFromCodeableConcept(any(CodeableConcept.class))) |
139 | | - .thenCallRealMethod(); |
140 | | - when(codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(any(CodeableConcept.class))) |
141 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
142 | | - when(codeableConceptCdMapper.mapToCdForTopic(any(CodeableConcept.class))) |
143 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
144 | | - when(codeableConceptCdMapper.mapToCdForTopic(any(CodeableConcept.class), any(String.class))) |
145 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
146 | | - when(codeableConceptCdMapper.mapToCdForTopic(any(String.class))) |
147 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
148 | | - when(codeableConceptCdMapper.getCdForTopic()) |
149 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
150 | | - when(codeableConceptCdMapper.mapToCdForCategory(any(String.class))) |
151 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
152 | | - when(codeableConceptCdMapper.getCdForCategory()) |
153 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
154 | | - |
155 | 125 |
|
156 | 126 | messageContext = new MessageContext(randomIdGeneratorService); |
157 | 127 |
|
| 128 | + RedactionsContext redactionsContext = mock(RedactionsContext.class); // mock if necessary |
| 129 | + |
| 130 | + XmlSchemaValidator xmlSchemaValidator = new XmlSchemaValidator(redactionsContext); |
| 131 | + |
158 | 132 | ParticipantMapper participantMapper = new ParticipantMapper(); |
159 | 133 | StructuredObservationValueMapper structuredObservationValueMapper = new StructuredObservationValueMapper(); |
160 | 134 | ObservationMapper specimenObservationMapper = new ObservationMapper( |
161 | | - messageContext, structuredObservationValueMapper, codeableConceptCdMapper, |
162 | | - participantMapper, randomIdGeneratorService, confidentialityService); |
| 135 | + messageContext, structuredObservationValueMapper, codeableConceptCdMapper, |
| 136 | + participantMapper, randomIdGeneratorService, confidentialityService); |
163 | 137 | SpecimenMapper specimenMapper = new SpecimenMapper(messageContext, specimenObservationMapper, |
164 | | - randomIdGeneratorService, confidentialityService); |
| 138 | + randomIdGeneratorService, confidentialityService); |
165 | 139 | DocumentReferenceToNarrativeStatementMapper documentReferenceToNarrativeStatementMapper |
166 | | - = new DocumentReferenceToNarrativeStatementMapper( |
| 140 | + = new DocumentReferenceToNarrativeStatementMapper( |
167 | 141 | messageContext, new SupportedContentTypes(), participantMapper, confidentialityService); |
168 | 142 |
|
169 | 143 | EncounterComponentsMapper encounterComponentsMapper = new EncounterComponentsMapper( |
170 | | - messageContext, |
171 | | - new AllergyStructureMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService), |
172 | | - new BloodPressureMapper( |
173 | | - messageContext, randomIdGeneratorService, new StructuredObservationValueMapper(), |
174 | | - codeableConceptCdMapper, new ParticipantMapper(), confidentialityService), |
175 | | - new ConditionLinkSetMapper( |
176 | | - messageContext, randomIdGeneratorService, codeableConceptCdMapper, participantMapper, confidentialityService), |
177 | | - new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService), |
178 | | - documentReferenceToNarrativeStatementMapper, |
179 | | - new ImmunizationObservationStatementMapper( |
180 | | - messageContext, |
181 | | - codeableConceptCdMapper, |
182 | | - participantMapper, |
183 | | - confidentialityService |
184 | | - ), |
185 | | - new MedicationStatementMapper( |
186 | | - messageContext, |
187 | | - codeableConceptCdMapper, |
188 | | - participantMapper, |
189 | | - randomIdGeneratorService, |
190 | | - confidentialityService |
191 | | - ), |
192 | | - new ObservationToNarrativeStatementMapper(messageContext, participantMapper, confidentialityService), |
193 | | - new ObservationStatementMapper( |
194 | 144 | messageContext, |
195 | | - new StructuredObservationValueMapper(), |
196 | | - new PertinentInformationObservationValueMapper(), |
| 145 | + new AllergyStructureMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService), |
| 146 | + new BloodPressureMapper( |
| 147 | + messageContext, randomIdGeneratorService, new StructuredObservationValueMapper(), |
| 148 | + codeableConceptCdMapper, new ParticipantMapper(), confidentialityService), |
| 149 | + new ConditionLinkSetMapper( |
| 150 | + messageContext, randomIdGeneratorService, codeableConceptCdMapper, participantMapper, confidentialityService), |
| 151 | + new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService), |
| 152 | + documentReferenceToNarrativeStatementMapper, |
| 153 | + new ImmunizationObservationStatementMapper( |
| 154 | + messageContext, |
| 155 | + codeableConceptCdMapper, |
| 156 | + participantMapper, |
| 157 | + confidentialityService |
| 158 | + ), |
| 159 | + new MedicationStatementMapper( |
| 160 | + messageContext, |
| 161 | + codeableConceptCdMapper, |
| 162 | + participantMapper, |
| 163 | + randomIdGeneratorService, |
| 164 | + confidentialityService |
| 165 | + ), |
| 166 | + new ObservationToNarrativeStatementMapper(messageContext, participantMapper, confidentialityService), |
| 167 | + new ObservationStatementMapper( |
| 168 | + messageContext, |
| 169 | + new StructuredObservationValueMapper(), |
| 170 | + new PertinentInformationObservationValueMapper(), |
| 171 | + codeableConceptCdMapper, |
| 172 | + participantMapper, |
| 173 | + confidentialityService |
| 174 | + ), |
| 175 | + new RequestStatementMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService), |
| 176 | + new DiagnosticReportMapper( |
| 177 | + messageContext, specimenMapper, participantMapper, randomIdGeneratorService, confidentialityService |
| 178 | + ), |
| 179 | + new BloodPressureValidator(), |
197 | 180 | codeableConceptCdMapper, |
198 | | - participantMapper, |
199 | 181 | confidentialityService |
200 | | - ), |
201 | | - new RequestStatementMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService), |
202 | | - new DiagnosticReportMapper( |
203 | | - messageContext, specimenMapper, participantMapper, randomIdGeneratorService, confidentialityService |
204 | | - ), |
205 | | - new BloodPressureValidator(), |
206 | | - codeableConceptCdMapper, |
207 | | - confidentialityService |
208 | 182 | ); |
209 | 183 |
|
210 | 184 | AgentDirectoryMapper agentDirectoryMapper = new AgentDirectoryMapper( |
211 | | - messageContext, |
212 | | - new AgentPersonMapper(messageContext) |
| 185 | + messageContext, |
| 186 | + new AgentPersonMapper(messageContext) |
213 | 187 | ); |
214 | 188 |
|
215 | 189 | nonConsultationResourceMapper = new NonConsultationResourceMapper(messageContext, |
216 | | - randomIdGeneratorService, |
217 | | - encounterComponentsMapper, |
218 | | - new BloodPressureValidator() |
| 190 | + randomIdGeneratorService, |
| 191 | + encounterComponentsMapper, |
| 192 | + new BloodPressureValidator() |
219 | 193 | ); |
220 | 194 |
|
221 | | - ehrExtractMapper = new EhrExtractMapper(randomIdGeneratorService, |
222 | | - timestampService, |
223 | | - new EncounterMapper(messageContext, encounterComponentsMapper, confidentialityService), |
224 | | - nonConsultationResourceMapper, |
225 | | - agentDirectoryMapper, |
226 | | - messageContext); |
| 195 | + ehrExtractMapper = new EhrExtractMapper( |
| 196 | + randomIdGeneratorService, |
| 197 | + timestampService, |
| 198 | + new EncounterMapper(messageContext, encounterComponentsMapper, confidentialityService), |
| 199 | + nonConsultationResourceMapper, |
| 200 | + agentDirectoryMapper, |
| 201 | + messageContext, |
| 202 | + xmlSchemaValidator |
| 203 | + ); |
227 | 204 | } |
228 | 205 |
|
| 206 | + |
229 | 207 | @AfterEach |
230 | 208 | public void tearDown() { |
231 | 209 | messageContext.resetMessageContext(); |
|
0 commit comments