diff --git a/.gitignore b/.gitignore index 816f2294d..3c1889d06 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,4 @@ local.properties /release_batch_template.txt /org.hl7.fhir.r5/src/main/resources/graphql/*.out /zuliprc +/org.hl7.fhir.validation/src/test/resources/comparison/output/*.html diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java new file mode 100644 index 000000000..eb4d18419 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ProfileComparisonTests.java @@ -0,0 +1,72 @@ +package org.hl7.fhir.validation.tests; + +import java.awt.Desktop; +import java.io.File; + +import org.hl7.fhir.r5.conformance.ProfileComparer; +import org.hl7.fhir.r5.model.FhirPublication; +import org.hl7.fhir.r5.model.OperationOutcome; +import org.hl7.fhir.r5.model.StructureDefinition; +import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent; +import org.hl7.fhir.r5.validation.ValidationEngine; +import org.hl7.fhir.validation.tests.utilities.TestUtilities; +import org.junit.Assert; +import org.junit.Test; + +public class ProfileComparisonTests { + + private static final String DEF_TX = "http://tx.fhir.org"; + + @Test + public void testCurrentComparison() throws Exception { + if (!TestUtilities.silent) + System.out.println("Compare US Patient Core with AU Patient Base"); + ValidationEngine ve = new ValidationEngine("hl7.fhir.core#3.0.1", DEF_TX, null, FhirPublication.R4); + ve.loadIg("hl7.fhir.us.core#1.0.1"); + ve.loadIg("hl7.fhir.au.base#dev"); + + + String left = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient"; + String right = "http://hl7.org.au/fhir/StructureDefinition/au-patient"; + String dest = TestUtilities.resourceNameToFile("comparison", "output"); + + // ok now set up the comparison + StructureDefinition sdL = ve.getContext().fetchResource(StructureDefinition.class, left); + ProfileComparer pc = new ProfileComparer(ve.getContext()); + if (sdL == null) { + System.out.println("Unable to locate left profile " +left); + } else { + StructureDefinition sdR = ve.getContext().fetchResource(StructureDefinition.class, right); + if (sdR == null) { + System.out.println("Unable to locate right profile " +right); + } else { + System.out.println("Comparing "+left+" to "+right); + pc.compareProfiles(sdL, sdR); + System.out.println("Generating output..."); + File htmlFile = null; + try { + htmlFile = new File(pc.generate(dest)); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + Desktop.getDesktop().browse(htmlFile.toURI()); + System.out.println("Done"); + } + } + } + +// int e = errors(op); +// int w = warnings(op); +// int h = hints(op); +// if (!TestUtilities.silent) { +// System.out.println(" .. done: "+Integer.toString(e)+" errors, "+Integer.toString(w)+" warnings, "+Integer.toString(h)+" information messages"); +// for (OperationOutcomeIssueComponent iss : op.getIssue()) { +// System.out.println(" "+iss.getDetails().getText()); +// } +// } +// Assert.assertTrue(e == 0); +// Assert.assertTrue(w == 0); +// Assert.assertTrue(h == 0); +// } +} diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json b/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json index 6d935965b..dbbf1e4ff 100644 --- a/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json @@ -722,7 +722,25 @@ "profile": { "source": "slicing-example-uk.profile.xml", "errorCount": 19, - "errors-for-debugging" : "ERROR: Bundle.entry[4].resource.entry[1].resource.section[1].code.coding: unable to find code 886921000000105 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[1].resource.section[2].code.coding: unable to find code 1077881000000105 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[1].resource.section[3].code.coding: Concept not found (next char = "c", in "cons") at character 1\r\nERROR: Bundle.entry[4].resource.entry[1].resource.section[4].code.coding: Concept not found (next char = "e", in "eligcrit") at character 1\r\nERROR: Bundle.entry[4].resource.entry[1].resource.section[5].code.coding: unable to find code 886711000000101 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[1].resource.section[6].code.coding: unable to find code 717121000000105 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[1].resource.section[7].code.coding: unable to find code 1102181000000102 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[1].resource.section[8].code.coding: unable to find code 1052951000000105 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[1].resource.section[9].code.coding: unable to find code 886731000000109 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[1].resource.section[10].code.coding: unable to find code 1052891000000108 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[5].resource: Profile https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Patient-1, Element 'Bundle.entry[4].resource.entry[5].resource.name[official]': minimum required = 1, but only found 0\r\nERROR: Bundle.entry[4].resource.entry[5].resource.generalPractitioner: Unable to resolve the profile reference 'https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Organization-1'\r\nERROR: Bundle.entry[4].resource.entry[5].resource.generalPractitioner: Unable to resolve the profile reference 'https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Practitioner-1'\r\nERROR: Bundle.entry[4].resource.entry[5].resource.generalPractitioner: Invalid Resource target type. Found Practitioner, but expected one of ()\r\nERROR: Bundle.entry[4].resource.entry[5].resource.managingOrganization: Unable to resolve the profile reference 'https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Organization-1'\r\nERROR: Bundle.entry[4].resource.entry[5].resource.managingOrganization: Invalid Resource target type. Found Organization, but expected one of ()\r\nERROR: Bundle.entry[4].resource.entry[8].resource.extension.valueCodeableConcept.coding: unable to find code 822851000000102 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[8].resource.vaccineCode.coding: unable to find code 22704311000001109 in http://snomed.info/sct\r\nERROR: Bundle.entry[4].resource.entry[9].resource.code.coding: unable to find code 886921000000105 in http://snomed.info/sct" + "errors-for-debugging" : ["ERROR: Bundle.entry[4].resource.entry[1].resource.section[1].code.coding: unable to find code 886921000000105 in http://snomed.info/sct\r\n", +"ERROR: Bundle.entry[4].resource.entry[1].resource.section[2].code.coding: unable to find code 1077881000000105 in http://snomed.info/sct", +"ERROR: Bundle.entry[4].resource.entry[1].resource.section[3].code.coding: Concept not found (next char = "c", in "cons") at character 1", +"ERROR: Bundle.entry[4].resource.entry[1].resource.section[4].code.coding: Concept not found (next char = "e", in "eligcrit") at character 1", +"ERROR: Bundle.entry[4].resource.entry[1].resource.section[5].code.coding: unable to find code 886711000000101 in http://snomed.info/sct", +"ERROR: Bundle.entry[4].resource.entry[1].resource.section[6].code.coding: unable to find code 717121000000105 in http://snomed.info/sct", +"ERROR: Bundle.entry[4].resource.entry[1].resource.section[7].code.coding: unable to find code 1102181000000102 in http://snomed.info/sct", +"ERROR: Bundle.entry[4].resource.entry[1].resource.section[8].code.coding: unable to find code 1052951000000105 in http://snomed.info/sct", +"ERROR: Bundle.entry[4].resource.entry[1].resource.section[9].code.coding: unable to find code 886731000000109 in http://snomed.info/sct", +"ERROR: Bundle.entry[4].resource.entry[1].resource.section[10].code.coding: unable to find code 1052891000000108 in http://snomed.info/sct", +"ERROR: Bundle.entry[4].resource.entry[5].resource: Profile https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Patient-1, Element 'Bundle.entry[4].resource.entry[5].resource.name[official]': minimum required = 1, but only found 0", +"ERROR: Bundle.entry[4].resource.entry[5].resource.generalPractitioner: Unable to resolve the profile reference 'https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Organization-1'", +"ERROR: Bundle.entry[4].resource.entry[5].resource.generalPractitioner: Unable to resolve the profile reference 'https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Practitioner-1'", +"ERROR: Bundle.entry[4].resource.entry[5].resource.generalPractitioner: Invalid Resource target type. Found Practitioner, but expected one of ()", +"ERROR: Bundle.entry[4].resource.entry[5].resource.managingOrganization: Unable to resolve the profile reference 'https://fhir.hl7.org.uk/STU3/StructureDefinition/CareConnect-Organization-1'", +"ERROR: Bundle.entry[4].resource.entry[5].resource.managingOrganization: Invalid Resource target type. Found Organization, but expected one of ()", +"ERROR: Bundle.entry[4].resource.entry[8].resource.extension.valueCodeableConcept.coding: unable to find code 822851000000102 in http://snomed.info/sct", +"ERROR: Bundle.entry[4].resource.entry[8].resource.vaccineCode.coding: unable to find code 22704311000001109 in http://snomed.info/sct", +"ERROR: Bundle.entry[4].resource.entry[9].resource.code.coding: unable to find code 886921000000105 in http://snomed.info/sct"] } }, "patient-translated-codes.xml": {