use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1 in project integration-adaptor-111 by nhsconnect.
the class AppointmentServiceTest method setUp.
@BeforeEach
public void setUp() {
clinicalDocument1 = mock(POCDMT000002UK01ClinicalDocument1.class);
POCDMT000002UK01Component2 component2 = mock(POCDMT000002UK01Component2.class);
POCDMT000002UK01StructuredBody structuredBody = mock(POCDMT000002UK01StructuredBody.class);
POCDMT000002UK01Component3 component3 = mock(POCDMT000002UK01Component3.class);
section = mock(POCDMT000002UK01Section.class);
patient = mock(Reference.class);
when(clinicalDocument1.getComponent()).thenReturn(component2);
when(component2.getStructuredBody()).thenReturn(structuredBody);
when(structuredBody.getComponentArray()).thenReturn(new POCDMT000002UK01Component3[] { component3 });
when(component3.getSection()).thenReturn(section);
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1 in project integration-adaptor-111 by nhsconnect.
the class EncounterMapper method getLocationComponents.
private List<EncounterLocationComponent> getLocationComponents(POCDMT000002UK01ClinicalDocument1 clinicalDocument1) {
List<EncounterLocationComponent> locations = new ArrayList<>();
if (clinicalDocument1.sizeOfRecordTargetArray() > 0) {
locations = stream(clinicalDocument1.getRecordTargetArray()).filter(recordTarget -> recordTarget.getPatientRole().getProviderOrganization() != null).map(recordTarget -> recordTarget.getPatientRole().getProviderOrganization()).map(locationMapper::mapOrganizationToLocationComponent).collect(Collectors.toList());
}
EncounterLocationComponent healthcareFacility = locationMapper.mapHealthcareFacilityToLocationComponent(clinicalDocument1);
if (healthcareFacility != null) {
locations.add(healthcareFacility);
}
return locations;
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1 in project integration-adaptor-111 by nhsconnect.
the class EncounterMapper method getEncounterParticipantComponents.
private List<EncounterParticipantComponent> getEncounterParticipantComponents(POCDMT000002UK01ClinicalDocument1 clinicalDocument, List<PractitionerRole> authorPractitionerRoles, Optional<PractitionerRole> responsibleParty, Encounter encounter) {
List<EncounterParticipantComponent> encounterParticipantComponents = stream(clinicalDocument.getParticipantArray()).filter(it -> !PARTCIPANT_TYPE_CODE_REFT.equals(it.getTypeCode())).map(participantMapper::mapEncounterParticipant).collect(Collectors.toList());
if (authorPractitionerRoles.size() > 0) {
authorPractitionerRoles.stream().map(it -> buildParticipantComponent(it, AUTHOR_PARTICIPANT_CODE, AUTHOR_PARTICIPANT_DISPLAY)).forEach(encounterParticipantComponents::add);
}
if (clinicalDocument.sizeOfInformantArray() > 0) {
stream(clinicalDocument.getInformantArray()).map(informantMapper::mapInformantIntoParticipantComponent).filter(Optional::isPresent).map(Optional::get).forEach(encounterParticipantComponents::add);
for (POCDMT000002UK01Informant12 informant : clinicalDocument.getInformantArray()) {
EncounterParticipantComponent encounterParticipantComponent = participantMapper.mapEncounterRelatedPerson(informant, encounter);
encounterParticipantComponents.add(encounterParticipantComponent);
}
}
if (clinicalDocument.isSetDataEnterer()) {
encounterParticipantComponents.add(dataEntererMapper.mapDataEntererIntoParticipantComponent(clinicalDocument.getDataEnterer()));
}
responsibleParty.ifPresent(it -> encounterParticipantComponents.add(buildParticipantComponent(it, RESPONSIBLE_PARTY_PARTICIPANT_CODE, RESPONSIBLE_PARTY_PARTICIPANT_DISPLAY)));
return encounterParticipantComponents;
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1 in project integration-adaptor-111 by nhsconnect.
the class ReportController method postReport.
@PostMapping(value = "/report", consumes = { APPLICATION_XML_VALUE, TEXT_XML_VALUE }, produces = TEXT_XML_VALUE)
@ResponseStatus(value = ACCEPTED)
public ResponseEntity<String> postReport(@RequestBody String reportXml) {
String toAddress = null;
String messageId;
try {
ReportItems reportItems = reportParserUtil.parseReportXml(reportXml);
itkValidator.checkItkConformance(reportItems);
soapValidator.checkSoapItkConformance(reportItems.getSoapHeader());
itkAddressValidator.checkItkOdsAndDosId(reportItems.getItkHeader());
ItkReportHeader headerValues = headerParserUtil.getHeaderValues(reportItems.getItkHeader());
toAddress = getValueOrDefaultAddress(reportItems.getSoapAddress());
LOGGER.info("ITK SOAP message received. MessageId: {}, ItkTrackingId: {}", reportItems.getMessageId(), headerValues.getTrackingId());
DistributionEnvelopeDocument distributionEnvelope = reportRequestUtils.extractDistributionEnvelope(reportItems.getDistributionEnvelope());
validate(distributionEnvelope);
POCDMT000002UK01ClinicalDocument1 clinicalDocument = reportRequestUtils.extractClinicalDocument(distributionEnvelope);
validate(clinicalDocument);
encounterReportService.transformAndPopulateToGP(clinicalDocument, reportItems.getMessageId(), headerValues);
return new ResponseEntity<>(itkResponseUtil.createSuccessResponseEntity(reportItems.getMessageId(), randomUUID().toString().toUpperCase()), OK);
} catch (SAXException e) {
LOGGER.error(e.getMessage(), e);
return new ResponseEntity<>(createErrorResponseBody(DEFAULT_ADDRESS, CLIENT_ERROR_CODE, FAULT_CODE_CLIENT, "This is not a valid XML message", e.getMessage()), INTERNAL_SERVER_ERROR);
} catch (XmlException e) {
LOGGER.error(e.getMessage(), e);
return new ResponseEntity<>(createErrorResponseBody(DEFAULT_ADDRESS, CLIENT_ERROR_CODE, FAULT_CODE_CLIENT, "schema validation failed", e.getMessage()), INTERNAL_SERVER_ERROR);
} catch (ItkXmlException e) {
LOGGER.error(e.getReason(), e);
return new ResponseEntity<>(createErrorResponseBody(DEFAULT_ADDRESS, CLIENT_ERROR_CODE, FAULT_CODE_CLIENT, e.getReason(), e.getMessage()), INTERNAL_SERVER_ERROR);
} catch (SoapClientException e) {
LOGGER.error(e.getReason(), e);
return new ResponseEntity<>(createErrorResponseBody(DEFAULT_ADDRESS, CLIENT_ERROR_CODE, FAULT_CODE_CLIENT, e.getReason(), e.getMessage()), INTERNAL_SERVER_ERROR);
} catch (SoapMustUnderstandException e) {
LOGGER.error(e.getReason(), e);
return new ResponseEntity<>(createErrorResponseBody(DEFAULT_ADDRESS, CLIENT_ERROR_CODE, FAULT_CODE_MUSTUNDERSTAND, e.getReason(), e.getMessage()), INTERNAL_SERVER_ERROR);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return new ResponseEntity<>(createErrorResponseBody(toAddress, INTERNAL_PROCESSING_ERROR_CODE, FAULT_CODE_CLIENT, INTERNAL_USER_ERROR_MESSAGE, INTERNAL_ERROR_MESSAGE), INTERNAL_SERVER_ERROR);
}
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1 in project integration-adaptor-111 by nhsconnect.
the class ObservationMapper method mapObservations.
public List<Observation> mapObservations(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter) {
List<Observation> observations = new ArrayList<>();
POCDMT000002UK01Component2 component = clinicalDocument.getComponent();
if (component.isSetStructuredBody()) {
POCDMT000002UK01Component3[] components = component.getStructuredBody().getComponentArray();
for (POCDMT000002UK01Component3 component3 : components) {
POCDMT000002UK01Section section = component3.getSection();
for (POCDMT000002UK01Component5 component5 : section.getComponentArray()) {
ST title = component5.getSection().getTitle();
if (nodeUtil.getNodeValueString(title).matches(PATIENTS_CONDITION_REGEXP)) {
StrucDocContent[] contentArray = component5.getSection().getText().getContentArray();
List<String> sectionText = stream(contentArray).map(it -> nodeUtil.getNodeValueString(it)).collect(toList());
observations.add(createObservation(encounter, sectionText));
}
}
}
}
return observations;
}
Aggregations