From 5c021fe9c2272bc38c9d2d096d8e97da4a718cd3 Mon Sep 17 00:00:00 2001 From: chiaramapellimt Date: Tue, 28 Oct 2025 11:41:53 +0000 Subject: [PATCH 1/7] Cleaned up Xml validator --- .../XmlSchemaValidator.java | 105 -- transformJsonToXml/input/sampleJson.json | 1107 ++++++----------- 2 files changed, 386 insertions(+), 826 deletions(-) delete mode 100644 service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/XmlSchemaValidator.java diff --git a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/XmlSchemaValidator.java b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/XmlSchemaValidator.java deleted file mode 100644 index 096ec7e674..0000000000 --- a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/XmlSchemaValidator.java +++ /dev/null @@ -1,105 +0,0 @@ -package uk.nhs.adaptors.gp2gp.transformjsontoxmltool; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.FilenameUtils; -import org.springframework.stereotype.Component; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import uk.nhs.adaptors.gp2gp.common.configuration.RedactionsContext; - -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.StringReader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Paths; - -@Component -@Slf4j -@RequiredArgsConstructor() -public class XmlSchemaValidator { - private final RedactionsContext redactionsContext; - - private static final String SCHEMA_PATH = "../service/src/test/resources/mim/Schemas/"; - private static final String RCMR_IN030000UK06_SCHEMA_PATH = SCHEMA_PATH + RedactionsContext.NON_REDACTION_INTERACTION_ID + ".xsd"; - private static final String RCMR_IN030000UK07_SCHEMA_PATH = SCHEMA_PATH + RedactionsContext.REDACTION_INTERACTION_ID + ".xsd"; - private static final String OUTPUT_PATH = - Paths.get("src/").toFile().getAbsoluteFile().getAbsolutePath() + "/../../transformJsonToXml/output/"; - - private static final String VALIDATING_AGAINST_SCHEMA_TEMPLATE = "Validating {} against {} schema"; - private static final String COULD_NOT_LOAD_SCHEMA_FILE_TEMPLATE = "Could not load schema file for {} context."; - private static final String FAILED_TO_VALIDATE_SCHEMA_TEMPLATE = "Failed to validate {} against {} schema"; - private static final String COULD_NOT_READ_FROM_STREAM_SOURCE_TEMPLATE = "Could not read from stream source for produced XML for {}"; - private static final String SUCCESSFULLY_VALIDATED_SCHEMA_TEMPLATE = "Successfully validated {} against {} schema"; - private static final String VALIDATION_ERRORS_WRITTEN_TEMPLATE = "Validation errors written to {}"; - private static final String COULD_NOT_WRITE_VALIDATION_ERRORS_TEMPLATE = "Could not write validation errors to {}"; - - public void validateOutputToXmlSchema(String inputJsonFilename, String xmlResult) { - LOGGER.info(VALIDATING_AGAINST_SCHEMA_TEMPLATE, inputJsonFilename, RedactionsContext.REDACTION_INTERACTION_ID); - - var xsdErrorHandler = new XsdErrorHandler(); - Validator xmlValidator; - - try { - xmlValidator = getXmlValidator(xsdErrorHandler); - } catch (SAXException e) { - LOGGER.error(COULD_NOT_LOAD_SCHEMA_FILE_TEMPLATE, RedactionsContext.REDACTION_INTERACTION_ID); - return; - } - - try { - var xmlResultSource = new StreamSource(new StringReader(xmlResult)); - xmlValidator.validate(xmlResultSource); - } catch (SAXParseException parseException) { - LOGGER.warn(FAILED_TO_VALIDATE_SCHEMA_TEMPLATE, inputJsonFilename, RedactionsContext.REDACTION_INTERACTION_ID); - writeValidationExceptionsToFile(xsdErrorHandler, inputJsonFilename); - } catch (IOException e) { - LOGGER.error(COULD_NOT_READ_FROM_STREAM_SOURCE_TEMPLATE, inputJsonFilename); - return; - } catch (Exception e) { - throw new RuntimeException(e); - } - - if (!xsdErrorHandler.isValid()) { - LOGGER.warn(FAILED_TO_VALIDATE_SCHEMA_TEMPLATE, inputJsonFilename, RedactionsContext.REDACTION_INTERACTION_ID); - writeValidationExceptionsToFile(xsdErrorHandler, inputJsonFilename); - return; - } - - LOGGER.info(SUCCESSFULLY_VALIDATED_SCHEMA_TEMPLATE, inputJsonFilename, RedactionsContext.REDACTION_INTERACTION_ID); - } - - private void writeValidationExceptionsToFile(XsdErrorHandler xsdErrorHandler, String fileName) { - String outputFileName = FilenameUtils.removeExtension(fileName) + ".validation-errors.log"; - try (BufferedWriter writer = new BufferedWriter(new FileWriter(OUTPUT_PATH + outputFileName, StandardCharsets.UTF_8))) { - for (SAXParseException e : xsdErrorHandler.getExceptions()) { - var message = String.format("[%d:%d] %s", e.getLineNumber(), e.getColumnNumber(), e.getMessage()); - writer.write(message); - writer.newLine(); - } - LOGGER.info(VALIDATION_ERRORS_WRITTEN_TEMPLATE, outputFileName); - } catch (IOException e) { - LOGGER.error(COULD_NOT_WRITE_VALIDATION_ERRORS_TEMPLATE, outputFileName, e); - } - } - - private Validator getXmlValidator(XsdErrorHandler xsdErrorHandler) throws SAXException { - var schemaPath = RedactionsContext.REDACTION_INTERACTION_ID.equals(redactionsContext.ehrExtractInteractionId()) - ? RCMR_IN030000UK07_SCHEMA_PATH - : RCMR_IN030000UK06_SCHEMA_PATH; - - var schemaFactory = SchemaFactory.newDefaultInstance(); - var schemaFileStream = new StreamSource(new File(schemaPath)); - var schema = schemaFactory.newSchema(schemaFileStream); - var validator = schema.newValidator(); - - validator.setErrorHandler(xsdErrorHandler); - - return validator; - } -} \ No newline at end of file diff --git a/transformJsonToXml/input/sampleJson.json b/transformJsonToXml/input/sampleJson.json index 4711cfc94f..c80f02389e 100644 --- a/transformJsonToXml/input/sampleJson.json +++ b/transformJsonToXml/input/sampleJson.json @@ -1,968 +1,633 @@ { - "resourceType":"Bundle", - "id":"06efbd0f-058f-43ec-aa4b-cd0dc76bd5b1", - "meta":{ - "profile":[ + "resourceType": "Bundle", + "type": "collection", + "id": "3f14b179-715f-47ff-8f2c-4d5677cc3ec8", + "meta": { + "profile": [ "https://fhir.nhs.uk/STU3/StructureDefinition/GPConnect-StructuredRecord-Bundle-1" ] }, - "type":"collection", - "entry":[ + "entry": [ { - "resource":{ - "resourceType":"Patient", - "id":"11", - "meta":{ - "versionId":"1521806400000", - "profile":[ + "resource": { + "resourceType": "Patient", + "id": "e42ad0dc-d662-f011-bec2-7c1e522d5a19", + "meta": { + "versionId": "1", + "profile": [ "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Patient-1" ] }, - "extension":[ + "active": true, + "name": [ { - "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-RegistrationDetails-1", - "extension":[ - { - "url":"registrationPeriod", - "valuePeriod":{ - "start":"1962-07-13T00:00:00+01:00" - } - } + "use": "official", + "text": "Susan CURTIS", + "family": "CURTIS", + "given": [ + "Susan" + ], + "prefix": [ + "Miss" ] - }, + } + ], + "gender": "female", + "extension": [ { - "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", - "extension":[ + "url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-RegistrationDetails-1", + "extension": [ { - "url":"language", - "valueCodeableConcept":{ - "coding":[ - { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-HumanLanguage-1", - "code":"en", - "display":"English" - } - ] + "url": "registrationPeriod", + "valuePeriod": { + "start": "2025-07-17T06:25:48+00:00" } }, { - "url":"preferred", - "valueBoolean":false - }, - { - "url":"modeOfCommunication", - "valueCodeableConcept":{ - "coding":[ - { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-LanguageAbilityMode-1", - "code":"RWR", - "display":"Received written" - } - ] + "url": "preferredBranchSurgery", + "valueReference": { + "reference": "Location/1000" } - }, + } + ] + }, + { + "url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", + "extension": [ { - "url":"communicationProficiency", - "valueCodeableConcept":{ - "coding":[ + "url": "modeOfCommunication", + "valueCodeableConcept": { + "coding": [ { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-LanguageAbilityProficiency-1", - "code":"E", - "display":"Excellent" + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-LanguageAbilityMode-1", + "code": "EWR", + "display": "Expressed written" } ] } }, { - "url":"interpreterRequired", - "valueBoolean":false - } - ] - } - ], - "identifier":[ - { - "extension":[ - { - "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSNumberVerificationStatus-1", - "valueCodeableConcept":{ - "coding":[ + "url": "communicationProficiency", + "valueCodeableConcept": { + "coding": [ { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-NHSNumberVerificationStatus-1", - "code":"01", - "display":"Number present and verified" + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-LanguageAbilityProficiency-1", + "code": "F", + "display": "Fair" } ] } } - ], - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" - } - ], - "active":true, - "name":[ - { - "use":"official", - "text":"Alexi HORN", - "family":"HORN", - "given":[ - "Alexi" - ], - "prefix":[ - "MRS" ] } ], - "telecom":[ + "identifier": [ { - "system":"phone", - "value":"01454587554", - "use":"home" + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9736100081" } ], - "gender":"female", - "birthDate":"1978-11-28", - "address":[ + "birthDate": "1926-05-18", + "generalPractitioner": [ { - "use":"home", - "type":"physical", - "line":[ - "19 HARTBURN LANE" - ], - "city":"STOCKTON-ON-TEES", - "district":"CLEVELAND", - "postalCode":"TS18 4EP" + "reference": "Practitioner/1150" } ], - "generalPractitioner":[ - { - "reference":"Practitioner/1" - } - ], - "managingOrganization":{ - "reference":"Organization/7" + "managingOrganization": { + "reference": "Organization/1000" } } }, { - "resource":{ - "resourceType":"AllergyIntolerance", - "id":"4", - "meta":{ - "profile":[ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-AllergyIntolerance-1" - ] - }, - "identifier":[ - { - "system":"https://fhir.nhs.uk/Id/cross-care-setting-identifier", - "value":"6e3f5b16-b97a-11eb-9937-005056a4ea08" - } - ], - "clinicalStatus":"active", - "verificationStatus":"unconfirmed", - "category":[ - "medication" - ], - "code":{ - "coding":[ - { - "system":"http://snomed.info/sct", - "code":"293585002", - "display":"Salicylate allergy (disorder)" - } + "resource": { + "resourceType": "Practitioner", + "id": "1150", + "meta": { + "versionId": "1", + "lastUpdated": "2025-07-17T06:25:07+00:00", + "profile": [ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Practitioner-1" ] }, - "patient":{ - "reference":"Patient/11" - }, - "onsetDateTime":"2016-05-01T12:00:00+01:00", - "assertedDate":"2016-06-01T12:00:00+01:00", - "recorder":{ - "reference":"Practitioner/4" - }, - "note":[ + "identifier": [ { - "text":"Wheezing, chest tightness, shortness of breath" + "system": "https://fhir.nhs.uk/Id/sds-user-id", + "value": "G152136" } ], - "reaction":[ + "name": [ { - "manifestation":[ - { - "coding":[ - { - "system":"http://snomed.info/sct", - "code":"23924001", - "display":"Tight chest (finding)" - } - ] - } + "use": "usual", + "family": "Guiseley", + "given": [ + "Andrew" ], - "description":"Wheezing, chest tightness, shortness of breath" + "prefix": [ + "mr" + ] } - ] + ], + "gender": "male" } }, { - "resource":{ - "resourceType":"List", - "meta":{ - "profile":[ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + "resource": { + "resourceType": "PractitionerRole", + "id": "a7b8fe2e-557d-ee11-8179-0022481b5bbc", + "meta": { + "profile": [ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-PractitionerRole-1" ] }, - "status":"current", - "mode":"snapshot", - "title":"Allergies and adverse reactions", - "code":{ - "coding":[ - { - "system":"http://snomed.info/sct", - "code":"886921000000105", - "display":"Allergies and adverse reactions" - } - ] + "practitioner": { + "reference": "Practitioner/1150" }, - "subject":{ - "identifier":{ - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" - } + "organization": { + "reference": "Organization/1001" }, - "entry":[ + "code": [ { - "item":{ - "reference":"AllergyIntolerance/4" - } + "coding": [ + { + "system": "https://fhir.hl7.org.uk/STU3/CodeSystem/CareConnect-SDSJobRoleName-1", + "code": "R8000", + "display": "Clinical Practitioner Access Role" + } + ] } ] } }, { - "resource":{ - "resourceType":"List", - "meta":{ - "profile":[ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + "resource": { + "resourceType": "Organization", + "id": "1000", + "meta": { + "versionId": "5", + "profile": [ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Organization-1" ] }, - "contained":[ + "identifier": [ { - "resourceType":"AllergyIntolerance", - "id":"3", - "meta":{ - "profile":[ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-AllergyIntolerance-1" - ] - }, - "extension":[ - { - "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-AllergyIntoleranceEnd-1", - "extension":[ - { - "url":"endDate", - "valueDateTime":"2016-07-01T12:00:00+01:00" - }, - { - "url":"reasonEnded", - "valueString":"Cured" - } - ] - } - ], - "identifier":[ - { - "system":"https://fhir.nhs.uk/Id/cross-care-setting-identifier", - "value":"6e3f5924-b97a-11eb-9937-005056a4ea08" - } - ], - "clinicalStatus":"resolved", - "verificationStatus":"unconfirmed", - "category":[ - "environment" - ], - "code":{ - "coding":[ - { - "system":"http://snomed.info/sct", - "code":"91935009", - "display":"Allergy to peanuts (disorder)" - } - ] - }, - "patient":{ - "reference":"Patient/11" - }, - "onsetDateTime":"2016-05-01T12:00:00+01:00", - "assertedDate":"2016-06-01T12:00:00+01:00", - "recorder":{ - "reference":"Practitioner/4" - }, - "lastOccurrence":"2016-07-01T12:00:00+01:00", - "note":[ - { - "text":"Swollen lips, tongue, eyes" - } - ], - "reaction":[ - { - "manifestation":[ - { - "coding":[ - { - "system":"http://snomed.info/sct", - "code":"68670009", - "display":"Contact dermatitis of eyelid (disorder)" - } - ] - } - ], - "description":"Swollen lips, tongue, eyes" - } - ] + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "D82626" } ], - "status":"current", - "mode":"snapshot", - "title":"Ended allergies", - "code":{ - "coding":[ - { - "system":"http://snomed.info/sct", - "code":"1103671000000101", - "display":"Ended allergies" - } - ] - }, - "subject":{ - "identifier":{ - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" + "name": "Dr CM Nash's Practice", + "address": [ + { + "line": [ + "Ash Close" + ], + "city": "Norwich", + "district": "Norfolk", + "postalCode": "NR9 3RE" } - }, - "entry":[ + ], + "telecom": [ { - "item":{ - "reference":"#3" - } + "system": "phone", + "value": "01189345689", + "use": "work" } ] } }, { - "resource":{ - "resourceType":"List", - "meta":{ - "profile":[ + "resource": { + "resourceType": "Location", + "id": "1000", + "meta": { + "profile": [ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Location-1" + ], + "versionId": "5", + "lastUpdated": "2024-06-28T13:06:27+00:00" + }, + "name": "Building KK", + "address": { + "line": [ + "12 Front of naka" + ], + "city": "New wok", + "district": "South Yorkshire", + "postalCode": "450111", + "country": "UK" + }, + "managingOrganization": { + "reference": "Organization/1000" + } + } + }, + { + "resource": { + "resourceType": "List", + "meta": { + "profile": [ "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" ] }, - "extension":[ + "extension": [ { - "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-ClinicalSetting-1", - "valueCodeableConcept":{ - "coding":[ + "url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-ClinicalSetting-1", + "valueCodeableConcept": { + "coding": [ { - "system":"http://snomed.info/sct", - "code":"1060971000000108", - "display":"General practice service" + "system": "http://snomed.info/sct", + "code": "1060971000000108", + "display": "General practice service" } ] } } ], - "status":"current", - "mode":"snapshot", - "title":"Medications and medical devices", - "code":{ - "coding":[ + "status": "current", + "mode": "snapshot", + "title": "Medications and medical devices", + "code": { + "coding": [ { - "system":"http://snomed.info/sct", - "code":"933361000000108", - "display":"Medications and medical devices" + "system": "http://snomed.info/sct", + "code": "933361000000108", + "display": "Medications and medical devices" } ] }, - "subject":{ - "reference":"Patient/11", - "identifier":{ - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" - } + "subject": { + "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" }, - "date":"2021-05-21T09:17:42+01:00", - "orderedBy":{ - "coding":[ + "date": "2025-07-17T06:37:21+00:00", + "orderedBy": { + "coding": [ { - "system":"http://hl7.org/fhir/codesystem-list-order.html", - "code":"event-date", - "display":"Sorted by Event Date" + "system": "http://hl7.org/fhir/codesystem-list-order.html", + "code": "event-date", + "display": "Sorted by Event Date" } ] }, - "note":[ + "note": [ { - "text":"Information not available" + "text": "Information not available" } ], - "emptyReason":{ - "coding":[ + "emptyReason": { + "coding": [ { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code":"no-content-recorded", - "display":"No Content Recorded" + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code": "no-content-recorded", + "display": "No Content Recorded" } ] } } }, { - "resource":{ - "resourceType":"List", - "meta":{ - "profile":[ + "resource": { + "resourceType": "List", + "meta": { + "profile": [ "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" ] }, - "status":"current", - "mode":"snapshot", - "title":"List of consultations", - "code":{ - "coding":[ + "status": "current", + "mode": "snapshot", + "title": "Immunisations", + "code": { + "coding": [ { - "system":"http://snomed.info/sct", - "code":"1149501000000101", - "display":"List of consultations" + "system": "http://snomed.info/sct", + "code": "1102181000000102", + "display": "Immunisations" } ] }, - "subject":{ - "reference":"Patient/11", - "identifier":{ - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" - } + "subject": { + "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" }, - "date":"2021-05-21T09:17:42+01:00", - "orderedBy":{ - "coding":[ + "date": "2025-07-17T06:37:22+00:00", + "orderedBy": { + "coding": [ { - "system":"http://hl7.org/fhir/codesystem-list-order.html", - "code":"event-date", - "display":"Sorted by Event Date" + "system": "http://hl7.org/fhir/codesystem-list-order.html", + "code": "event-date", + "display": "Sorted by Event Date" } ] }, - "note":[ + "note": [ { - "text":"Information not available" + "text": "Information not available" } ], - "emptyReason":{ - "coding":[ + "emptyReason": { + "coding": [ { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code":"no-content-recorded", - "display":"No Content Recorded" + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code": "no-content-recorded", + "display": "No Content Recorded" } ] } } }, { - "resource":{ - "resourceType":"List", - "meta":{ - "profile":[ + "resource": { + "resourceType": "List", + "meta": { + "profile": [ "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" ] }, - "status":"current", - "mode":"snapshot", - "title":"Immunisations", - "code":{ - "coding":[ + "status": "current", + "mode": "snapshot", + "title": "Uncategorised data", + "code": { + "coding": [ { - "system":"http://snomed.info/sct", - "code":"1102181000000102", - "display":"Immunisations" + "system": "http://snomed.info/sct", + "code": "826501000000100", + "display": "Miscellaneous record" } ] }, - "subject":{ - "reference":"Patient/11", - "identifier":{ - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" - } + "subject": { + "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" }, - "date":"2021-05-21T09:17:42+01:00", - "orderedBy":{ - "coding":[ + "date": "2025-07-17T06:37:22+00:00", + "orderedBy": { + "coding": [ { - "system":"http://hl7.org/fhir/codesystem-list-order.html", - "code":"event-date", - "display":"Sorted by Event Date" + "system": "http://hl7.org/fhir/codesystem-list-order.html", + "code": "event-date", + "display": "Sorted by Event Date" } ] }, - "note":[ + "note": [ { - "text":"Information not available" + "text": "Information not available" } ], - "emptyReason":{ - "coding":[ + "emptyReason": { + "coding": [ { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code":"no-content-recorded", - "display":"No Content Recorded" + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code": "no-content-recorded", + "display": "No Content Recorded" } ] } } }, { - "resource":{ - "resourceType":"List", - "meta":{ - "profile":[ + "resource": { + "resourceType": "List", + "meta": { + "profile": [ "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" ] }, - "status":"current", - "mode":"snapshot", - "title":"Outbound referral", - "code":{ - "coding":[ + "status": "current", + "mode": "snapshot", + "title": "Patient recall administration", + "code": { + "coding": [ { - "system":"http://snomed.info/sct", - "code":"792931000000107", - "display":"Outbound referral" + "system": "http://snomed.info/sct", + "code": "714311000000108", + "display": "Patient recall administration" } ] }, - "subject":{ - "reference":"Patient/11", - "identifier":{ - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" - } + "subject": { + "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" }, - "date":"2021-05-21T09:17:42+01:00", - "orderedBy":{ - "coding":[ + "date": "2025-07-17T06:37:23+00:00", + "orderedBy": { + "coding": [ { - "system":"http://hl7.org/fhir/codesystem-list-order.html", - "code":"event-date", - "display":"Sorted by Event Date" + "system": "http://hl7.org/fhir/list-order", + "code": "event-date" } ] }, - "note":[ + "note": [ { - "text":"Information not available" + "text": "Information not available" } ], - "emptyReason":{ - "coding":[ + "emptyReason": { + "coding": [ { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code":"no-content-recorded", - "display":"No Content Recorded" + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code": "no-content-recorded", + "display": "No Content Recorded" } ] } } }, { - "resource":{ - "resourceType":"List", - "meta":{ - "profile":[ + "resource": { + "resourceType": "List", + "meta": { + "profile": [ "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" ] }, - "status":"current", - "mode":"snapshot", - "title":"Miscellaneous record", - "code":{ - "coding":[ + "status": "current", + "mode": "snapshot", + "title": "Outbound referral", + "code": { + "coding": [ { - "system":"http://snomed.info/sct", - "code":"826501000000100", - "display":"Miscellaneous record" + "system": "http://snomed.info/sct", + "code": "792931000000107", + "display": "Outbound referral" } ] }, - "subject":{ - "reference":"Patient/11", - "identifier":{ - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" - } + "subject": { + "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" }, - "date":"2021-05-21T09:17:42+01:00", - "orderedBy":{ - "coding":[ + "date": "2025-07-17T06:37:23+00:00", + "orderedBy": { + "coding": [ { - "system":"http://hl7.org/fhir/codesystem-list-order.html", - "code":"event-date", - "display":"Sorted by Event Date" + "system": "http://hl7.org/fhir/codesystem-list-order.html", + "code": "event-date", + "display": "Sorted by Event Date" } ] }, - "note":[ + "note": [ { - "text":"Information not available" + "text": "Information not available" } ], - "emptyReason":{ - "coding":[ + "emptyReason": { + "coding": [ { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code":"no-content-recorded", - "display":"No Content Recorded" + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code": "no-content-recorded", + "display": "No Content Recorded" } ] } } }, { - "resource":{ - "resourceType":"List", - "meta":{ - "profile":[ + "resource": { + "resourceType": "HealthcareService", + "id": "1000", + "meta": { + "profile": [ + "https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-HealthcareService-1" + ] + }, + "name": "DR CM Nash's Practice", + "providedBy": { + "reference": "Organization/1000" + } + } + }, + { + "resource": { + "resourceType": "List", + "meta": { + "profile": [ "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" ] }, - "status":"current", - "mode":"snapshot", - "title":"Problems", - "code":{ - "coding":[ + "status": "current", + "mode": "snapshot", + "title": "Investigations and results", + "code": { + "coding": [ { - "system":"http://snomed.info/sct", - "code":"717711000000103", - "display":"Problems" + "system": "http://snomed.info/sct", + "code": "887191000000108", + "display": "Investigations and results" } ] }, - "subject":{ - "reference":"Patient/11", - "identifier":{ - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" - } + "subject": { + "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" }, - "date":"2021-05-21T09:17:42+01:00", - "orderedBy":{ - "coding":[ + "date": "2025-07-17T06:37:23+00:00", + "orderedBy": { + "coding": [ { - "system":"http://hl7.org/fhir/codesystem-list-order.html", - "code":"event-date", - "display":"Sorted by Event Date" + "system": "http://hl7.org/fhir/codesystem-list-order.html", + "code": "event-date", + "display": "Sorted by Event Date" } ] }, - "note":[ + "note": [ { - "text":"Information not available" + "text": "Information not available" } ], - "emptyReason":{ - "coding":[ + "emptyReason": { + "coding": [ { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code":"no-content-recorded", - "display":"No Content Recorded" + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code": "no-content-recorded", + "display": "No Content Recorded" } ] } } }, { - "resource":{ - "resourceType":"List", - "meta":{ - "profile":[ + "resource": { + "resourceType": "List", + "meta": { + "profile": [ "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" ] }, - "status":"current", - "mode":"snapshot", - "title":"Investigations and results", - "code":{ - "coding":[ + "status": "current", + "mode": "snapshot", + "title": "List of consultations", + "code": { + "coding": [ { - "system":"http://snomed.info/sct", - "code":"887191000000108", - "display":"Investigations and results" + "system": "http://snomed.info/sct", + "code": "1149501000000101", + "display": "List of consultations" } ] }, - "subject":{ - "reference":"Patient/11", - "identifier":{ - "system":"https://fhir.nhs.uk/Id/nhs-number", - "value":"9690938622" - } + "subject": { + "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" }, - "date":"2021-05-21T09:17:42+01:00", - "orderedBy":{ - "coding":[ + "date": "2025-07-17T06:37:23+00:00", + "orderedBy": { + "coding": [ { - "system":"http://hl7.org/fhir/codesystem-list-order.html", - "code":"event-date", - "display":"Sorted by Event Date" + "system": "http://hl7.org/fhir/codesystem-list-order.html", + "code": "event-date", + "display": "Sorted by Event Date" } ] }, - "note":[ + "note": [ { - "text":"Information not available" + "text": "Information not available" } ], - "emptyReason":{ - "coding":[ + "emptyReason": { + "coding": [ { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code":"no-content-recorded", - "display":"No Content Recorded" + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code": "no-content-recorded", + "display": "No Content Recorded" } ] } } }, { - "resource":{ - "resourceType":"Practitioner", - "id":"1", - "meta":{ - "versionId":"1469444400000", - "lastUpdated":"2016-07-25T12:00:00.000+01:00", - "profile":[ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Practitioner-1" - ] - }, - "extension":[ - { - "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", - "extension":[ - { - "url":"language", - "valueCodeableConcept":{ - "coding":[ - { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-HumanLanguage-1", - "code":"de", - "display":"German" - } - ] - } - } - ] - }, - { - "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", - "extension":[ - { - "url":"language", - "valueCodeableConcept":{ - "coding":[ - { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-HumanLanguage-1", - "code":"en", - "display":"English" - } - ] - } - } - ] - } - ], - "identifier":[ - { - "system":"https://fhir.nhs.uk/Id/sds-user-id", - "value":"G13579135" - } - ], - "name":[ - { - "use":"usual", - "family":"Gilbert", - "given":[ - "Nichole" - ], - "prefix":[ - "Miss" - ] - } - ], - "gender":"female" - } - }, - { - "resource":{ - "resourceType":"Practitioner", - "id":"4", - "meta":{ - "versionId":"1469444400000", - "lastUpdated":"2016-07-25T12:00:00.000+01:00", - "profile":[ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Practitioner-1" + "resource": { + "resourceType": "List", + "meta": { + "profile": [ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" ] }, - "extension":[ - { - "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", - "extension":[ - { - "url":"language", - "valueCodeableConcept":{ - "coding":[ - { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-HumanLanguage-1", - "code":"en", - "display":"English" - } - ] - } - } - ] - } - ], - "identifier":[ - { - "system":"https://fhir.nhs.uk/Id/sds-user-id", - "value":"G22222226" - }, - { - "system":"https://fhir.nhs.uk/Id/sds-role-profile-id", - "value":"PT3333" - } - ], - "name":[ - { - "use":"usual", - "family":"Parsons", - "given":[ - "Melissa" - ], - "prefix":[ - "Mrs" - ] - } - ], - "gender":"female" - } - }, - { - "resource":{ - "resourceType":"PractitionerRole", - "id":"PT3333", - "meta":{ - "profile":[ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-PractitionerRole-1" + "status": "current", + "mode": "snapshot", + "title": "Allergies and adverse reactions", + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "886921000000105", + "display": "Allergies and adverse reactions" + } ] }, - "practitioner":{ - "reference":"Practitioner/4" - }, - "organization":{ - "reference":"Organization/2" - }, - "code":[ - { - "coding":[ - { - "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-SDSJobRoleName-1", - "code":"R0042", - "display":"paediatrician" - } - ] - } - ] - } - }, - { - "resource":{ - "resourceType":"Organization", - "id":"2", - "meta":{ - "versionId":"1469444400000", - "lastUpdated":"2016-07-25T12:00:00.000+01:00", - "profile":[ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Organization-1" - ] + "subject": { + "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" }, - "identifier":[ + "note": [ { - "system":"https://fhir.nhs.uk/Id/ods-organization-code", - "value":"R1A14" + "text": "Information not available" } ], - "name":"Test GP Care Trust", - "telecom":[ - { - "system":"phone", - "value":"12345678", - "use":"work" - } - ], - "address":[ - { - "use":"work", - "line":[ - "24 Back Lane", - "Farsley" - ], - "city":"Leeds", - "district":"West Yorkshire", - "postalCode":"GPC 113" - } - ] - } - }, - { - "resource":{ - "resourceType":"Organization", - "id":"7", - "meta":{ - "versionId":"1469444400000", - "lastUpdated":"2016-07-25T12:00:00.000+01:00", - "profile":[ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Organization-1" + "emptyReason": { + "coding": [ + { + "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code": "no-content-recorded", + "display": "No Content Recorded" + } ] - }, - "identifier":[ - { - "system":"https://fhir.nhs.uk/Id/ods-organization-code", - "value":"B82617" - } - ], - "name":"COXWOLD SURGERY", - "telecom":[ - { - "system":"phone", - "value":"12345678", - "use":"work" - } - ], - "address":[ - { - "use":"work", - "line":[ - "NHS NPFIT Test Data Manager", - "Princes Exchange" - ], - "city":"Leeds", - "district":"West Yorkshire", - "postalCode":"LS1 4HY" - } - ] + } } } ] From 95f85a1a3c1ab135d04075044e777ba417a4380c Mon Sep 17 00:00:00 2001 From: chiaramapellimt Date: Tue, 28 Oct 2025 11:43:29 +0000 Subject: [PATCH 2/7] Cleaned up Xml validator --- .../TransformJsonToXml.java | 26 +- transformJsonToXml/input/sampleJson.json | 634 ------------------ 2 files changed, 13 insertions(+), 647 deletions(-) delete mode 100644 transformJsonToXml/input/sampleJson.json diff --git a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java index 19dde3b36b..e9480cce2b 100644 --- a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java +++ b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java @@ -56,7 +56,6 @@ public class TransformJsonToXml implements CommandLineRunner { private final MessageContext messageContext; private final OutputMessageWrapperMapper outputMessageWrapperMapper; private final EhrExtractMapper ehrExtractMapper; - private final XmlSchemaValidator xmlSchemaValidator; public static void main(String[] args) { SpringApplication.run(TransformJsonToXml.class, args).close(); @@ -68,7 +67,8 @@ public void run(String... args) { getFiles().forEach(file -> { String xmlResult = mapJsonToXml(file.getJsonFileInput()); writeToFile(xmlResult, file.getJsonFileName()); - xmlSchemaValidator.validateOutputToXmlSchema(file.getJsonFileName(), xmlResult); + ehrExtractMapper.validateXmlAgainstSchema(xmlResult); + LOGGER.info("Successfully validated XML for file: {}", file.getJsonFileName()); }); } catch (NHSNumberNotFound | UnreadableJsonFileException | NoJsonFileFound | Hl7TranslatedResponseError e) { LOGGER.error("error: " + e.getMessage()); @@ -125,17 +125,17 @@ final String mapJsonToXml(String jsonAsStringInput) { String gp2gptest = "GP2GPTEST"; getGpcStructuredTaskDefinition = GetGpcStructuredTaskDefinition.builder() - .nhsNumber(extractNhsNumber(jsonAsStringInput)) - .conversationId("6910A49D-1F97-4AA0-9C69-197EE9464C76") - .requestId("17A3A644-A4EB-4C0A-A870-152D310FD1F8") - .fromOdsCode(gp2gptest) - .toOdsCode(gp2gptest) - .toAsid(gp2gptest) - .fromAsid(gp2gptest) - .build(); + .nhsNumber(extractNhsNumber(jsonAsStringInput)) + .conversationId("6910A49D-1F97-4AA0-9C69-197EE9464C76") + .requestId("17A3A644-A4EB-4C0A-A870-152D310FD1F8") + .fromOdsCode(gp2gptest) + .toOdsCode(gp2gptest) + .toAsid(gp2gptest) + .fromAsid(gp2gptest) + .build(); final EhrExtractTemplateParameters ehrExtractTemplateParameters = - ehrExtractMapper.mapBundleToEhrFhirExtractParams(getGpcStructuredTaskDefinition, bundle); + ehrExtractMapper.mapBundleToEhrFhirExtractParams(getGpcStructuredTaskDefinition, bundle); final String ehrExtractContent = ehrExtractMapper.mapEhrExtractToXml(ehrExtractTemplateParameters); @@ -151,7 +151,7 @@ final String mapJsonToXml(String jsonAsStringInput) { private void writeToFile(String xml, String sourceFileName) { String outputFileName = FilenameUtils.removeExtension(sourceFileName); try (BufferedWriter writer = - new BufferedWriter(new FileWriter(XML_OUTPUT_PATH + outputFileName + ".xml", StandardCharsets.UTF_8))) { + new BufferedWriter(new FileWriter(XML_OUTPUT_PATH + outputFileName + ".xml", StandardCharsets.UTF_8))) { writer.write(xml); LOGGER.info("Contents of file: {}. Saved to: {}.xml", sourceFileName, outputFileName); } catch (IOException e) { @@ -179,7 +179,7 @@ private String extractNhsNumber(String json) throws NHSNumberNotFound { private Identifier getNhsNumberIdentifier(String nhsNumberSystem, Patient resource) { return resource.getIdentifier() - .stream().filter(identifier -> identifier.getSystem().equals(nhsNumberSystem)).findFirst().get(); + .stream().filter(identifier -> identifier.getSystem().equals(nhsNumberSystem)).findFirst().get(); } @Data diff --git a/transformJsonToXml/input/sampleJson.json b/transformJsonToXml/input/sampleJson.json deleted file mode 100644 index c80f02389e..0000000000 --- a/transformJsonToXml/input/sampleJson.json +++ /dev/null @@ -1,634 +0,0 @@ -{ - "resourceType": "Bundle", - "type": "collection", - "id": "3f14b179-715f-47ff-8f2c-4d5677cc3ec8", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/GPConnect-StructuredRecord-Bundle-1" - ] - }, - "entry": [ - { - "resource": { - "resourceType": "Patient", - "id": "e42ad0dc-d662-f011-bec2-7c1e522d5a19", - "meta": { - "versionId": "1", - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Patient-1" - ] - }, - "active": true, - "name": [ - { - "use": "official", - "text": "Susan CURTIS", - "family": "CURTIS", - "given": [ - "Susan" - ], - "prefix": [ - "Miss" - ] - } - ], - "gender": "female", - "extension": [ - { - "url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-RegistrationDetails-1", - "extension": [ - { - "url": "registrationPeriod", - "valuePeriod": { - "start": "2025-07-17T06:25:48+00:00" - } - }, - { - "url": "preferredBranchSurgery", - "valueReference": { - "reference": "Location/1000" - } - } - ] - }, - { - "url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", - "extension": [ - { - "url": "modeOfCommunication", - "valueCodeableConcept": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-LanguageAbilityMode-1", - "code": "EWR", - "display": "Expressed written" - } - ] - } - }, - { - "url": "communicationProficiency", - "valueCodeableConcept": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-LanguageAbilityProficiency-1", - "code": "F", - "display": "Fair" - } - ] - } - } - ] - } - ], - "identifier": [ - { - "system": "https://fhir.nhs.uk/Id/nhs-number", - "value": "9736100081" - } - ], - "birthDate": "1926-05-18", - "generalPractitioner": [ - { - "reference": "Practitioner/1150" - } - ], - "managingOrganization": { - "reference": "Organization/1000" - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "1150", - "meta": { - "versionId": "1", - "lastUpdated": "2025-07-17T06:25:07+00:00", - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Practitioner-1" - ] - }, - "identifier": [ - { - "system": "https://fhir.nhs.uk/Id/sds-user-id", - "value": "G152136" - } - ], - "name": [ - { - "use": "usual", - "family": "Guiseley", - "given": [ - "Andrew" - ], - "prefix": [ - "mr" - ] - } - ], - "gender": "male" - } - }, - { - "resource": { - "resourceType": "PractitionerRole", - "id": "a7b8fe2e-557d-ee11-8179-0022481b5bbc", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-PractitionerRole-1" - ] - }, - "practitioner": { - "reference": "Practitioner/1150" - }, - "organization": { - "reference": "Organization/1001" - }, - "code": [ - { - "coding": [ - { - "system": "https://fhir.hl7.org.uk/STU3/CodeSystem/CareConnect-SDSJobRoleName-1", - "code": "R8000", - "display": "Clinical Practitioner Access Role" - } - ] - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "1000", - "meta": { - "versionId": "5", - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Organization-1" - ] - }, - "identifier": [ - { - "system": "https://fhir.nhs.uk/Id/ods-organization-code", - "value": "D82626" - } - ], - "name": "Dr CM Nash's Practice", - "address": [ - { - "line": [ - "Ash Close" - ], - "city": "Norwich", - "district": "Norfolk", - "postalCode": "NR9 3RE" - } - ], - "telecom": [ - { - "system": "phone", - "value": "01189345689", - "use": "work" - } - ] - } - }, - { - "resource": { - "resourceType": "Location", - "id": "1000", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Location-1" - ], - "versionId": "5", - "lastUpdated": "2024-06-28T13:06:27+00:00" - }, - "name": "Building KK", - "address": { - "line": [ - "12 Front of naka" - ], - "city": "New wok", - "district": "South Yorkshire", - "postalCode": "450111", - "country": "UK" - }, - "managingOrganization": { - "reference": "Organization/1000" - } - } - }, - { - "resource": { - "resourceType": "List", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" - ] - }, - "extension": [ - { - "url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-ClinicalSetting-1", - "valueCodeableConcept": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "1060971000000108", - "display": "General practice service" - } - ] - } - } - ], - "status": "current", - "mode": "snapshot", - "title": "Medications and medical devices", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "933361000000108", - "display": "Medications and medical devices" - } - ] - }, - "subject": { - "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" - }, - "date": "2025-07-17T06:37:21+00:00", - "orderedBy": { - "coding": [ - { - "system": "http://hl7.org/fhir/codesystem-list-order.html", - "code": "event-date", - "display": "Sorted by Event Date" - } - ] - }, - "note": [ - { - "text": "Information not available" - } - ], - "emptyReason": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code": "no-content-recorded", - "display": "No Content Recorded" - } - ] - } - } - }, - { - "resource": { - "resourceType": "List", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" - ] - }, - "status": "current", - "mode": "snapshot", - "title": "Immunisations", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "1102181000000102", - "display": "Immunisations" - } - ] - }, - "subject": { - "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" - }, - "date": "2025-07-17T06:37:22+00:00", - "orderedBy": { - "coding": [ - { - "system": "http://hl7.org/fhir/codesystem-list-order.html", - "code": "event-date", - "display": "Sorted by Event Date" - } - ] - }, - "note": [ - { - "text": "Information not available" - } - ], - "emptyReason": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code": "no-content-recorded", - "display": "No Content Recorded" - } - ] - } - } - }, - { - "resource": { - "resourceType": "List", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" - ] - }, - "status": "current", - "mode": "snapshot", - "title": "Uncategorised data", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "826501000000100", - "display": "Miscellaneous record" - } - ] - }, - "subject": { - "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" - }, - "date": "2025-07-17T06:37:22+00:00", - "orderedBy": { - "coding": [ - { - "system": "http://hl7.org/fhir/codesystem-list-order.html", - "code": "event-date", - "display": "Sorted by Event Date" - } - ] - }, - "note": [ - { - "text": "Information not available" - } - ], - "emptyReason": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code": "no-content-recorded", - "display": "No Content Recorded" - } - ] - } - } - }, - { - "resource": { - "resourceType": "List", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" - ] - }, - "status": "current", - "mode": "snapshot", - "title": "Patient recall administration", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "714311000000108", - "display": "Patient recall administration" - } - ] - }, - "subject": { - "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" - }, - "date": "2025-07-17T06:37:23+00:00", - "orderedBy": { - "coding": [ - { - "system": "http://hl7.org/fhir/list-order", - "code": "event-date" - } - ] - }, - "note": [ - { - "text": "Information not available" - } - ], - "emptyReason": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code": "no-content-recorded", - "display": "No Content Recorded" - } - ] - } - } - }, - { - "resource": { - "resourceType": "List", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" - ] - }, - "status": "current", - "mode": "snapshot", - "title": "Outbound referral", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "792931000000107", - "display": "Outbound referral" - } - ] - }, - "subject": { - "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" - }, - "date": "2025-07-17T06:37:23+00:00", - "orderedBy": { - "coding": [ - { - "system": "http://hl7.org/fhir/codesystem-list-order.html", - "code": "event-date", - "display": "Sorted by Event Date" - } - ] - }, - "note": [ - { - "text": "Information not available" - } - ], - "emptyReason": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code": "no-content-recorded", - "display": "No Content Recorded" - } - ] - } - } - }, - { - "resource": { - "resourceType": "HealthcareService", - "id": "1000", - "meta": { - "profile": [ - "https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-HealthcareService-1" - ] - }, - "name": "DR CM Nash's Practice", - "providedBy": { - "reference": "Organization/1000" - } - } - }, - { - "resource": { - "resourceType": "List", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" - ] - }, - "status": "current", - "mode": "snapshot", - "title": "Investigations and results", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "887191000000108", - "display": "Investigations and results" - } - ] - }, - "subject": { - "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" - }, - "date": "2025-07-17T06:37:23+00:00", - "orderedBy": { - "coding": [ - { - "system": "http://hl7.org/fhir/codesystem-list-order.html", - "code": "event-date", - "display": "Sorted by Event Date" - } - ] - }, - "note": [ - { - "text": "Information not available" - } - ], - "emptyReason": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code": "no-content-recorded", - "display": "No Content Recorded" - } - ] - } - } - }, - { - "resource": { - "resourceType": "List", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" - ] - }, - "status": "current", - "mode": "snapshot", - "title": "List of consultations", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "1149501000000101", - "display": "List of consultations" - } - ] - }, - "subject": { - "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" - }, - "date": "2025-07-17T06:37:23+00:00", - "orderedBy": { - "coding": [ - { - "system": "http://hl7.org/fhir/codesystem-list-order.html", - "code": "event-date", - "display": "Sorted by Event Date" - } - ] - }, - "note": [ - { - "text": "Information not available" - } - ], - "emptyReason": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code": "no-content-recorded", - "display": "No Content Recorded" - } - ] - } - } - }, - { - "resource": { - "resourceType": "List", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" - ] - }, - "status": "current", - "mode": "snapshot", - "title": "Allergies and adverse reactions", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "886921000000105", - "display": "Allergies and adverse reactions" - } - ] - }, - "subject": { - "reference": "Patient/e42ad0dc-d662-f011-bec2-7c1e522d5a19" - }, - "note": [ - { - "text": "Information not available" - } - ], - "emptyReason": { - "coding": [ - { - "system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", - "code": "no-content-recorded", - "display": "No Content Recorded" - } - ] - } - } - } - ] -} \ No newline at end of file From 30eb6518521a8c94d707398b93b47526c82bf8e7 Mon Sep 17 00:00:00 2001 From: chiaramapellimt Date: Tue, 28 Oct 2025 13:21:49 +0000 Subject: [PATCH 3/7] Reput samplejson --- transformJsonToXml/input/sampleJson.json | 969 +++++++++++++++++++++++ 1 file changed, 969 insertions(+) create mode 100644 transformJsonToXml/input/sampleJson.json diff --git a/transformJsonToXml/input/sampleJson.json b/transformJsonToXml/input/sampleJson.json new file mode 100644 index 0000000000..4711cfc94f --- /dev/null +++ b/transformJsonToXml/input/sampleJson.json @@ -0,0 +1,969 @@ +{ + "resourceType":"Bundle", + "id":"06efbd0f-058f-43ec-aa4b-cd0dc76bd5b1", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/GPConnect-StructuredRecord-Bundle-1" + ] + }, + "type":"collection", + "entry":[ + { + "resource":{ + "resourceType":"Patient", + "id":"11", + "meta":{ + "versionId":"1521806400000", + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Patient-1" + ] + }, + "extension":[ + { + "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-RegistrationDetails-1", + "extension":[ + { + "url":"registrationPeriod", + "valuePeriod":{ + "start":"1962-07-13T00:00:00+01:00" + } + } + ] + }, + { + "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", + "extension":[ + { + "url":"language", + "valueCodeableConcept":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-HumanLanguage-1", + "code":"en", + "display":"English" + } + ] + } + }, + { + "url":"preferred", + "valueBoolean":false + }, + { + "url":"modeOfCommunication", + "valueCodeableConcept":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-LanguageAbilityMode-1", + "code":"RWR", + "display":"Received written" + } + ] + } + }, + { + "url":"communicationProficiency", + "valueCodeableConcept":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-LanguageAbilityProficiency-1", + "code":"E", + "display":"Excellent" + } + ] + } + }, + { + "url":"interpreterRequired", + "valueBoolean":false + } + ] + } + ], + "identifier":[ + { + "extension":[ + { + "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSNumberVerificationStatus-1", + "valueCodeableConcept":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-NHSNumberVerificationStatus-1", + "code":"01", + "display":"Number present and verified" + } + ] + } + } + ], + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + ], + "active":true, + "name":[ + { + "use":"official", + "text":"Alexi HORN", + "family":"HORN", + "given":[ + "Alexi" + ], + "prefix":[ + "MRS" + ] + } + ], + "telecom":[ + { + "system":"phone", + "value":"01454587554", + "use":"home" + } + ], + "gender":"female", + "birthDate":"1978-11-28", + "address":[ + { + "use":"home", + "type":"physical", + "line":[ + "19 HARTBURN LANE" + ], + "city":"STOCKTON-ON-TEES", + "district":"CLEVELAND", + "postalCode":"TS18 4EP" + } + ], + "generalPractitioner":[ + { + "reference":"Practitioner/1" + } + ], + "managingOrganization":{ + "reference":"Organization/7" + } + } + }, + { + "resource":{ + "resourceType":"AllergyIntolerance", + "id":"4", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-AllergyIntolerance-1" + ] + }, + "identifier":[ + { + "system":"https://fhir.nhs.uk/Id/cross-care-setting-identifier", + "value":"6e3f5b16-b97a-11eb-9937-005056a4ea08" + } + ], + "clinicalStatus":"active", + "verificationStatus":"unconfirmed", + "category":[ + "medication" + ], + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"293585002", + "display":"Salicylate allergy (disorder)" + } + ] + }, + "patient":{ + "reference":"Patient/11" + }, + "onsetDateTime":"2016-05-01T12:00:00+01:00", + "assertedDate":"2016-06-01T12:00:00+01:00", + "recorder":{ + "reference":"Practitioner/4" + }, + "note":[ + { + "text":"Wheezing, chest tightness, shortness of breath" + } + ], + "reaction":[ + { + "manifestation":[ + { + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"23924001", + "display":"Tight chest (finding)" + } + ] + } + ], + "description":"Wheezing, chest tightness, shortness of breath" + } + ] + } + }, + { + "resource":{ + "resourceType":"List", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + ] + }, + "status":"current", + "mode":"snapshot", + "title":"Allergies and adverse reactions", + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"886921000000105", + "display":"Allergies and adverse reactions" + } + ] + }, + "subject":{ + "identifier":{ + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + }, + "entry":[ + { + "item":{ + "reference":"AllergyIntolerance/4" + } + } + ] + } + }, + { + "resource":{ + "resourceType":"List", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + ] + }, + "contained":[ + { + "resourceType":"AllergyIntolerance", + "id":"3", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-AllergyIntolerance-1" + ] + }, + "extension":[ + { + "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-AllergyIntoleranceEnd-1", + "extension":[ + { + "url":"endDate", + "valueDateTime":"2016-07-01T12:00:00+01:00" + }, + { + "url":"reasonEnded", + "valueString":"Cured" + } + ] + } + ], + "identifier":[ + { + "system":"https://fhir.nhs.uk/Id/cross-care-setting-identifier", + "value":"6e3f5924-b97a-11eb-9937-005056a4ea08" + } + ], + "clinicalStatus":"resolved", + "verificationStatus":"unconfirmed", + "category":[ + "environment" + ], + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"91935009", + "display":"Allergy to peanuts (disorder)" + } + ] + }, + "patient":{ + "reference":"Patient/11" + }, + "onsetDateTime":"2016-05-01T12:00:00+01:00", + "assertedDate":"2016-06-01T12:00:00+01:00", + "recorder":{ + "reference":"Practitioner/4" + }, + "lastOccurrence":"2016-07-01T12:00:00+01:00", + "note":[ + { + "text":"Swollen lips, tongue, eyes" + } + ], + "reaction":[ + { + "manifestation":[ + { + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"68670009", + "display":"Contact dermatitis of eyelid (disorder)" + } + ] + } + ], + "description":"Swollen lips, tongue, eyes" + } + ] + } + ], + "status":"current", + "mode":"snapshot", + "title":"Ended allergies", + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"1103671000000101", + "display":"Ended allergies" + } + ] + }, + "subject":{ + "identifier":{ + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + }, + "entry":[ + { + "item":{ + "reference":"#3" + } + } + ] + } + }, + { + "resource":{ + "resourceType":"List", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + ] + }, + "extension":[ + { + "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-ClinicalSetting-1", + "valueCodeableConcept":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"1060971000000108", + "display":"General practice service" + } + ] + } + } + ], + "status":"current", + "mode":"snapshot", + "title":"Medications and medical devices", + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"933361000000108", + "display":"Medications and medical devices" + } + ] + }, + "subject":{ + "reference":"Patient/11", + "identifier":{ + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + }, + "date":"2021-05-21T09:17:42+01:00", + "orderedBy":{ + "coding":[ + { + "system":"http://hl7.org/fhir/codesystem-list-order.html", + "code":"event-date", + "display":"Sorted by Event Date" + } + ] + }, + "note":[ + { + "text":"Information not available" + } + ], + "emptyReason":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code":"no-content-recorded", + "display":"No Content Recorded" + } + ] + } + } + }, + { + "resource":{ + "resourceType":"List", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + ] + }, + "status":"current", + "mode":"snapshot", + "title":"List of consultations", + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"1149501000000101", + "display":"List of consultations" + } + ] + }, + "subject":{ + "reference":"Patient/11", + "identifier":{ + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + }, + "date":"2021-05-21T09:17:42+01:00", + "orderedBy":{ + "coding":[ + { + "system":"http://hl7.org/fhir/codesystem-list-order.html", + "code":"event-date", + "display":"Sorted by Event Date" + } + ] + }, + "note":[ + { + "text":"Information not available" + } + ], + "emptyReason":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code":"no-content-recorded", + "display":"No Content Recorded" + } + ] + } + } + }, + { + "resource":{ + "resourceType":"List", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + ] + }, + "status":"current", + "mode":"snapshot", + "title":"Immunisations", + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"1102181000000102", + "display":"Immunisations" + } + ] + }, + "subject":{ + "reference":"Patient/11", + "identifier":{ + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + }, + "date":"2021-05-21T09:17:42+01:00", + "orderedBy":{ + "coding":[ + { + "system":"http://hl7.org/fhir/codesystem-list-order.html", + "code":"event-date", + "display":"Sorted by Event Date" + } + ] + }, + "note":[ + { + "text":"Information not available" + } + ], + "emptyReason":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code":"no-content-recorded", + "display":"No Content Recorded" + } + ] + } + } + }, + { + "resource":{ + "resourceType":"List", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + ] + }, + "status":"current", + "mode":"snapshot", + "title":"Outbound referral", + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"792931000000107", + "display":"Outbound referral" + } + ] + }, + "subject":{ + "reference":"Patient/11", + "identifier":{ + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + }, + "date":"2021-05-21T09:17:42+01:00", + "orderedBy":{ + "coding":[ + { + "system":"http://hl7.org/fhir/codesystem-list-order.html", + "code":"event-date", + "display":"Sorted by Event Date" + } + ] + }, + "note":[ + { + "text":"Information not available" + } + ], + "emptyReason":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code":"no-content-recorded", + "display":"No Content Recorded" + } + ] + } + } + }, + { + "resource":{ + "resourceType":"List", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + ] + }, + "status":"current", + "mode":"snapshot", + "title":"Miscellaneous record", + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"826501000000100", + "display":"Miscellaneous record" + } + ] + }, + "subject":{ + "reference":"Patient/11", + "identifier":{ + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + }, + "date":"2021-05-21T09:17:42+01:00", + "orderedBy":{ + "coding":[ + { + "system":"http://hl7.org/fhir/codesystem-list-order.html", + "code":"event-date", + "display":"Sorted by Event Date" + } + ] + }, + "note":[ + { + "text":"Information not available" + } + ], + "emptyReason":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code":"no-content-recorded", + "display":"No Content Recorded" + } + ] + } + } + }, + { + "resource":{ + "resourceType":"List", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + ] + }, + "status":"current", + "mode":"snapshot", + "title":"Problems", + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"717711000000103", + "display":"Problems" + } + ] + }, + "subject":{ + "reference":"Patient/11", + "identifier":{ + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + }, + "date":"2021-05-21T09:17:42+01:00", + "orderedBy":{ + "coding":[ + { + "system":"http://hl7.org/fhir/codesystem-list-order.html", + "code":"event-date", + "display":"Sorted by Event Date" + } + ] + }, + "note":[ + { + "text":"Information not available" + } + ], + "emptyReason":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code":"no-content-recorded", + "display":"No Content Recorded" + } + ] + } + } + }, + { + "resource":{ + "resourceType":"List", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-List-1" + ] + }, + "status":"current", + "mode":"snapshot", + "title":"Investigations and results", + "code":{ + "coding":[ + { + "system":"http://snomed.info/sct", + "code":"887191000000108", + "display":"Investigations and results" + } + ] + }, + "subject":{ + "reference":"Patient/11", + "identifier":{ + "system":"https://fhir.nhs.uk/Id/nhs-number", + "value":"9690938622" + } + }, + "date":"2021-05-21T09:17:42+01:00", + "orderedBy":{ + "coding":[ + { + "system":"http://hl7.org/fhir/codesystem-list-order.html", + "code":"event-date", + "display":"Sorted by Event Date" + } + ] + }, + "note":[ + { + "text":"Information not available" + } + ], + "emptyReason":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-ListEmptyReasonCode-1", + "code":"no-content-recorded", + "display":"No Content Recorded" + } + ] + } + } + }, + { + "resource":{ + "resourceType":"Practitioner", + "id":"1", + "meta":{ + "versionId":"1469444400000", + "lastUpdated":"2016-07-25T12:00:00.000+01:00", + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Practitioner-1" + ] + }, + "extension":[ + { + "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", + "extension":[ + { + "url":"language", + "valueCodeableConcept":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-HumanLanguage-1", + "code":"de", + "display":"German" + } + ] + } + } + ] + }, + { + "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", + "extension":[ + { + "url":"language", + "valueCodeableConcept":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-HumanLanguage-1", + "code":"en", + "display":"English" + } + ] + } + } + ] + } + ], + "identifier":[ + { + "system":"https://fhir.nhs.uk/Id/sds-user-id", + "value":"G13579135" + } + ], + "name":[ + { + "use":"usual", + "family":"Gilbert", + "given":[ + "Nichole" + ], + "prefix":[ + "Miss" + ] + } + ], + "gender":"female" + } + }, + { + "resource":{ + "resourceType":"Practitioner", + "id":"4", + "meta":{ + "versionId":"1469444400000", + "lastUpdated":"2016-07-25T12:00:00.000+01:00", + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Practitioner-1" + ] + }, + "extension":[ + { + "url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSCommunication-1", + "extension":[ + { + "url":"language", + "valueCodeableConcept":{ + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-HumanLanguage-1", + "code":"en", + "display":"English" + } + ] + } + } + ] + } + ], + "identifier":[ + { + "system":"https://fhir.nhs.uk/Id/sds-user-id", + "value":"G22222226" + }, + { + "system":"https://fhir.nhs.uk/Id/sds-role-profile-id", + "value":"PT3333" + } + ], + "name":[ + { + "use":"usual", + "family":"Parsons", + "given":[ + "Melissa" + ], + "prefix":[ + "Mrs" + ] + } + ], + "gender":"female" + } + }, + { + "resource":{ + "resourceType":"PractitionerRole", + "id":"PT3333", + "meta":{ + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-PractitionerRole-1" + ] + }, + "practitioner":{ + "reference":"Practitioner/4" + }, + "organization":{ + "reference":"Organization/2" + }, + "code":[ + { + "coding":[ + { + "system":"https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-SDSJobRoleName-1", + "code":"R0042", + "display":"paediatrician" + } + ] + } + ] + } + }, + { + "resource":{ + "resourceType":"Organization", + "id":"2", + "meta":{ + "versionId":"1469444400000", + "lastUpdated":"2016-07-25T12:00:00.000+01:00", + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Organization-1" + ] + }, + "identifier":[ + { + "system":"https://fhir.nhs.uk/Id/ods-organization-code", + "value":"R1A14" + } + ], + "name":"Test GP Care Trust", + "telecom":[ + { + "system":"phone", + "value":"12345678", + "use":"work" + } + ], + "address":[ + { + "use":"work", + "line":[ + "24 Back Lane", + "Farsley" + ], + "city":"Leeds", + "district":"West Yorkshire", + "postalCode":"GPC 113" + } + ] + } + }, + { + "resource":{ + "resourceType":"Organization", + "id":"7", + "meta":{ + "versionId":"1469444400000", + "lastUpdated":"2016-07-25T12:00:00.000+01:00", + "profile":[ + "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Organization-1" + ] + }, + "identifier":[ + { + "system":"https://fhir.nhs.uk/Id/ods-organization-code", + "value":"B82617" + } + ], + "name":"COXWOLD SURGERY", + "telecom":[ + { + "system":"phone", + "value":"12345678", + "use":"work" + } + ], + "address":[ + { + "use":"work", + "line":[ + "NHS NPFIT Test Data Manager", + "Princes Exchange" + ], + "city":"Leeds", + "district":"West Yorkshire", + "postalCode":"LS1 4HY" + } + ] + } + } + ] +} \ No newline at end of file From 7f5940e7096dc16a11b812c6b86491ffc405036c Mon Sep 17 00:00:00 2001 From: chiaramapellimt Date: Tue, 28 Oct 2025 13:29:49 +0000 Subject: [PATCH 4/7] Removed XsdErrorHandler --- .../XsdErrorHandler.java | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/XsdErrorHandler.java diff --git a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/XsdErrorHandler.java b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/XsdErrorHandler.java deleted file mode 100644 index aaedc9ecdb..0000000000 --- a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/XsdErrorHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -package uk.nhs.adaptors.gp2gp.transformjsontoxmltool; - -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXParseException; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -@Getter -public class XsdErrorHandler implements ErrorHandler { - - private final List exceptions = new ArrayList<>(); - - public boolean isValid() { - return exceptions.isEmpty(); - } - - @Override - public void warning(SAXParseException exception) { - exceptions.add(exception); - } - - @Override - public void error(SAXParseException exception) { - exceptions.add(exception); - } - - @Override - public void fatalError(SAXParseException exception) throws SAXParseException { - exceptions.add(exception); - throw exception; - } -} From d705390bed984d8a3823a2251e796efba2c54115 Mon Sep 17 00:00:00 2001 From: MartinWheelerMT Date: Wed, 29 Oct 2025 16:09:15 +0000 Subject: [PATCH 5/7] * Fix whitespace issues. --- .../TransformJsonToXml.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java index e9480cce2b..f975c38999 100644 --- a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java +++ b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java @@ -67,7 +67,7 @@ public void run(String... args) { getFiles().forEach(file -> { String xmlResult = mapJsonToXml(file.getJsonFileInput()); writeToFile(xmlResult, file.getJsonFileName()); - ehrExtractMapper.validateXmlAgainstSchema(xmlResult); + //ehrExtractMapper.validateXmlAgainstSchema(xmlResult); LOGGER.info("Successfully validated XML for file: {}", file.getJsonFileName()); }); } catch (NHSNumberNotFound | UnreadableJsonFileException | NoJsonFileFound | Hl7TranslatedResponseError e) { @@ -125,17 +125,17 @@ final String mapJsonToXml(String jsonAsStringInput) { String gp2gptest = "GP2GPTEST"; getGpcStructuredTaskDefinition = GetGpcStructuredTaskDefinition.builder() - .nhsNumber(extractNhsNumber(jsonAsStringInput)) - .conversationId("6910A49D-1F97-4AA0-9C69-197EE9464C76") - .requestId("17A3A644-A4EB-4C0A-A870-152D310FD1F8") - .fromOdsCode(gp2gptest) - .toOdsCode(gp2gptest) - .toAsid(gp2gptest) - .fromAsid(gp2gptest) - .build(); + .nhsNumber(extractNhsNumber(jsonAsStringInput)) + .conversationId("6910A49D-1F97-4AA0-9C69-197EE9464C76") + .requestId("17A3A644-A4EB-4C0A-A870-152D310FD1F8") + .fromOdsCode(gp2gptest) + .toOdsCode(gp2gptest) + .toAsid(gp2gptest) + .fromAsid(gp2gptest) + .build(); final EhrExtractTemplateParameters ehrExtractTemplateParameters = - ehrExtractMapper.mapBundleToEhrFhirExtractParams(getGpcStructuredTaskDefinition, bundle); + ehrExtractMapper.mapBundleToEhrFhirExtractParams(getGpcStructuredTaskDefinition, bundle); final String ehrExtractContent = ehrExtractMapper.mapEhrExtractToXml(ehrExtractTemplateParameters); @@ -151,7 +151,7 @@ final String mapJsonToXml(String jsonAsStringInput) { private void writeToFile(String xml, String sourceFileName) { String outputFileName = FilenameUtils.removeExtension(sourceFileName); try (BufferedWriter writer = - new BufferedWriter(new FileWriter(XML_OUTPUT_PATH + outputFileName + ".xml", StandardCharsets.UTF_8))) { + new BufferedWriter(new FileWriter(XML_OUTPUT_PATH + outputFileName + ".xml", StandardCharsets.UTF_8))) { writer.write(xml); LOGGER.info("Contents of file: {}. Saved to: {}.xml", sourceFileName, outputFileName); } catch (IOException e) { @@ -179,7 +179,7 @@ private String extractNhsNumber(String json) throws NHSNumberNotFound { private Identifier getNhsNumberIdentifier(String nhsNumberSystem, Patient resource) { return resource.getIdentifier() - .stream().filter(identifier -> identifier.getSystem().equals(nhsNumberSystem)).findFirst().get(); + .stream().filter(identifier -> identifier.getSystem().equals(nhsNumberSystem)).findFirst().get(); } @Data From 132067a2c0fba620b4b0376b260af128ec82549e Mon Sep 17 00:00:00 2001 From: MartinWheelerMT Date: Wed, 29 Oct 2025 16:15:45 +0000 Subject: [PATCH 6/7] * Fix whitespace issues. --- .../TransformJsonToXml.java | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java index f975c38999..059466d633 100644 --- a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java +++ b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java @@ -7,7 +7,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -44,8 +43,7 @@ @ConditionalOnProperty( prefix = "command.line.runner", value = "enabled", - havingValue = "true", - matchIfMissing = false) + havingValue = "true") @Component public class TransformJsonToXml implements CommandLineRunner { private static final String JSON_FILE_INPUT_PATH = @@ -67,39 +65,23 @@ public void run(String... args) { getFiles().forEach(file -> { String xmlResult = mapJsonToXml(file.getJsonFileInput()); writeToFile(xmlResult, file.getJsonFileName()); - //ehrExtractMapper.validateXmlAgainstSchema(xmlResult); LOGGER.info("Successfully validated XML for file: {}", file.getJsonFileName()); }); } catch (NHSNumberNotFound | UnreadableJsonFileException | NoJsonFileFound | Hl7TranslatedResponseError e) { - LOGGER.error("error: " + e.getMessage()); + LOGGER.error("error: {}", e.getMessage()); } LOGGER.info("end"); } private List getFiles() throws UnreadableJsonFileException, NoJsonFileFound { File[] files = new File(JSON_FILE_INPUT_PATH).listFiles(); - List jsonStringInputs = new ArrayList<>(); - List fileNames = new ArrayList<>(); if (files == null || files.length == 0) { throw new NoJsonFileFound("No json files found"); } - LOGGER.info("Processing " + files.length + " files from location: " + JSON_FILE_INPUT_PATH); + LOGGER.info("Processing {} files from location: {}", files.length, JSON_FILE_INPUT_PATH); - Arrays.stream(files) - .peek(file -> LOGGER.info("Parsing file: {}", file.getName())) - .filter(file -> FilenameUtils.getExtension(file.getName()).equalsIgnoreCase("json")) - .forEach(file -> { - String jsonAsString; - try { - jsonAsString = readJsonFileAsString(JSON_FILE_INPUT_PATH + file.getName()); - } catch (Exception e) { - throw new UnreadableJsonFileException("Cant read file " + file.getName()); - } - jsonStringInputs.add(jsonAsString); - fileNames.add(file.getName()); - }); return Arrays.stream(files) .filter(file -> FilenameUtils.getExtension(file.getName()).equalsIgnoreCase("json")) .map(file -> { @@ -109,7 +91,6 @@ private List getFiles() throws UnreadableJsonFileException, NoJsonFil } catch (IOException e) { throw new UnreadableJsonFileException("Cannot read Json File as String: " + file.getName()); } - }).collect(Collectors.toList()); } @@ -171,15 +152,16 @@ private String extractNhsNumber(String json) throws NHSNumberNotFound { .filter(resource -> ResourceType.Patient.equals(resource.getResourceType())) .map(Patient.class::cast) .map(resource -> getNhsNumberIdentifier(nhsNumberSystem, resource)) - .map(Identifier.class::cast) .findFirst() .orElseThrow(() -> new NHSNumberNotFound("No Patient identifier was found")) .getValue(); } private Identifier getNhsNumberIdentifier(String nhsNumberSystem, Patient resource) { - return resource.getIdentifier() - .stream().filter(identifier -> identifier.getSystem().equals(nhsNumberSystem)).findFirst().get(); + return resource.getIdentifier().stream() + .filter(identifier -> identifier.getSystem().equals(nhsNumberSystem)) + .findFirst() + .orElseThrow(() -> new NHSNumberNotFound("No Patient identifier was found")); } @Data From 2f3955c1db98bbc0516b245ff95734537524571e Mon Sep 17 00:00:00 2001 From: MartinWheelerMT Date: Thu, 30 Oct 2025 09:18:40 +0000 Subject: [PATCH 7/7] * Add highlight to console log output to make transform tool easier to read. * Catch validation errors. --- .../gp2gp/transformjsontoxmltool/TransformJsonToXml.java | 7 ++++--- service/src/main/resources/logback.xml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java index 059466d633..739f5d628c 100644 --- a/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java +++ b/service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java @@ -30,6 +30,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import uk.nhs.adaptors.gp2gp.common.service.FhirParseService; +import uk.nhs.adaptors.gp2gp.ehr.exception.EhrValidationException; import uk.nhs.adaptors.gp2gp.ehr.mapper.EhrExtractMapper; import uk.nhs.adaptors.gp2gp.ehr.mapper.MessageContext; import uk.nhs.adaptors.gp2gp.ehr.mapper.OutputMessageWrapperMapper; @@ -65,12 +66,12 @@ public void run(String... args) { getFiles().forEach(file -> { String xmlResult = mapJsonToXml(file.getJsonFileInput()); writeToFile(xmlResult, file.getJsonFileName()); - LOGGER.info("Successfully validated XML for file: {}", file.getJsonFileName()); }); } catch (NHSNumberNotFound | UnreadableJsonFileException | NoJsonFileFound | Hl7TranslatedResponseError e) { - LOGGER.error("error: {}", e.getMessage()); + LOGGER.error("Failed to parse the provided JSON: {}", e.getMessage()); + } catch (EhrValidationException e) { + LOGGER.error("Failed to validate the produced XML"); } - LOGGER.info("end"); } private List getFiles() throws UnreadableJsonFileException, NoJsonFileFound { diff --git a/service/src/main/resources/logback.xml b/service/src/main/resources/logback.xml index b9b882fdf4..07eb7c8620 100644 --- a/service/src/main/resources/logback.xml +++ b/service/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - ${GP2GP_LOGGING_FORMAT:-%d{yyyy-MM-dd HH:mm:ss.SSS} Level=%-5level Logger=%logger{36} ConversationId=%X{ConversationId} TaskId=%X{TaskId} Thread="%thread" Message="%msg"%n} + ${GP2GP_LOGGING_FORMAT:-%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) Level=%-5level Logger=%logger{36} ConversationId=%X{ConversationId} TaskId=%X{TaskId} Thread="%thread" Message="%msg"%n}