fix failing tests.

This commit is contained in:
Grahame Grieve 2022-03-10 11:18:03 +11:00
parent a34c33c0c0
commit 791f16a05d
4 changed files with 373 additions and 154 deletions

View File

@ -0,0 +1,189 @@
package org.hl7.fhir.convertors.misc;
import java.io.File;
import java.io.IOException;
import org.hl7.fhir.utilities.json.JsonTrackingParser;
import com.google.gson.JsonObject;
public class JsonProcessor {
public static void main(String[] args) throws Exception {
new JsonProcessor().process(args[0]);
}
private void process(String source) throws IOException {
JsonObject json = JsonTrackingParser.parseJsonFile(source);
process(json);
JsonTrackingParser.write(json, new File(source), true);
}
private void process(JsonObject json) {
process(json, "ActivityDefinition.status");
process(json, "CapabilityStatement.status");
process(json, "CodeSystem.status");
process(json, "CompartmentDefinition.status");
process(json, "ConceptMap.status");
process(json, "DataElement.status");
process(json, "ExpansionProfile.status");
process(json, "GraphDefinition.status");
process(json, "ImplementationGuide.status");
process(json, "Library.status");
process(json, "Measure.status");
process(json, "MessageDefinition.status");
process(json, "OperationDefinition.status");
process(json, "PlanDefinition.status");
process(json, "Questionnaire.status");
process(json, "SearchParameter.status");
process(json, "ServiceDefinition.status");
process(json, "StructureDefinition.status");
process(json, "StructureMap.status");
process(json, "TestScript.status");
process(json, "ValueSet.status");
process(json, "ActivityDefinition.experimental");
process(json, "CapabilityStatement.experimental");
process(json, "CodeSystem.experimental");
process(json, "CompartmentDefinition.experimental");
process(json, "ConceptMap.experimental");
process(json, "DataElement.experimental");
process(json, "ExpansionProfile.experimental");
process(json, "GraphDefinition.experimental");
process(json, "ImplementationGuide.experimental");
process(json, "Library.experimental");
process(json, "Measure.experimental");
process(json, "MessageDefinition.experimental");
process(json, "OperationDefinition.experimental");
process(json, "PlanDefinition.experimental");
process(json, "Questionnaire.experimental");
process(json, "SearchParameter.experimental");
process(json, "ServiceDefinition.experimental");
process(json, "StructureDefinition.experimental");
process(json, "StructureMap.experimental");
process(json, "TestScript.experimental");
process(json, "ValueSet.experimental");
process(json, "Identifier.use");
process(json, "Quantity.comparator");
process(json, "Address.use");
process(json, "ContactPoint.use");
process(json, "HumanName.use");
process(json, "BackboneElement.modifierExtension");
process(json, "DomainResource.modifierExtension");
process(json, "Resource.implicitRules");
process(json, "Account.status");
process(json, "AllergyIntolerance.clinicalStatus");
process(json, "AllergyIntolerance.verificationStatus");
process(json, "Appointment.status");
process(json, "AppointmentResponse.participantStatus");
process(json, "Basic.code");
process(json, "BodySite.active");
process(json, "CarePlan.status");
process(json, "CarePlan.intent");
process(json, "CarePlan.activity.detail.status");
process(json, "CarePlan.activity.detail.prohibited");
process(json, "CareTeam.status");
process(json, "ChargeItem.status");
process(json, "Claim.status");
process(json, "ClaimResponse.status");
process(json, "ClinicalImpression.status");
process(json, "Communication.status");
process(json, "Communication.notDone");
process(json, "CommunicationRequest.status");
process(json, "Composition.status");
process(json, "Composition.confidentiality");
process(json, "Composition.section.mode");
process(json, "ConceptMap.group.element.target.equivalence");
process(json, "Condition.clinicalStatus");
process(json, "Condition.verificationStatus");
process(json, "Consent.status");
process(json, "Contract.status");
process(json, "Coverage.status");
process(json, "DetectedIssue.status");
process(json, "Device.status");
process(json, "DeviceRequest.status");
process(json, "DeviceRequest.intent");
process(json, "DeviceUseStatement.status");
process(json, "DiagnosticReport.status");
process(json, "DocumentManifest.status");
process(json, "DocumentReference.status");
process(json, "DocumentReference.relatesTo");
process(json, "EligibilityRequest.status");
process(json, "EligibilityResponse.status");
process(json, "Encounter.status");
process(json, "Endpoint.status");
process(json, "EnrollmentRequest.status");
process(json, "EnrollmentResponse.status");
process(json, "EpisodeOfCare.status");
process(json, "ExplanationOfBenefit.status");
process(json, "FamilyMemberHistory.status");
process(json, "FamilyMemberHistory.notDone");
process(json, "FamilyMemberHistory.estimatedAge");
process(json, "Flag.status");
process(json, "Goal.status");
process(json, "Group.characteristic.exclude");
process(json, "GuidanceResponse.status");
process(json, "HealthcareService.active");
process(json, "Immunization.status");
process(json, "Immunization.notGiven");
process(json, "List.status");
process(json, "List.mode");
process(json, "List.entry.deleted");
process(json, "Location.status");
process(json, "Location.mode");
process(json, "MeasureReport.status");
process(json, "MedicationAdministration.status");
process(json, "MedicationAdministration.notGiven");
process(json, "MedicationDispense.status");
process(json, "MedicationRequest.status");
process(json, "MedicationRequest.intent");
process(json, "MedicationRequest.substitution.allowed");
process(json, "MedicationStatement.status");
process(json, "MedicationStatement.taken");
process(json, "NamingSystem.status");
process(json, "NutritionOrder.status");
process(json, "Observation.status");
process(json, "OperationOutcome.issue.severity");
process(json, "Organization.active");
process(json, "Patient.active");
process(json, "Patient.deceased[x]");
process(json, "Patient.animal");
process(json, "Patient.link");
process(json, "PaymentNotice.status");
process(json, "PaymentReconciliation.status");
process(json, "Person.active");
process(json, "Procedure.status");
process(json, "Procedure.notDone");
process(json, "ProcedureRequest.status");
process(json, "ProcedureRequest.intent");
process(json, "ProcedureRequest.doNotPerform");
process(json, "ProcessRequest.status");
process(json, "ProcessResponse.status");
process(json, "Questionnaire.item.enableWhen");
process(json, "QuestionnaireResponse.status");
process(json, "ReferralRequest.status");
process(json, "ReferralRequest.intent");
process(json, "RelatedPerson.active");
process(json, "RequestGroup.status");
process(json, "RequestGroup.intent");
process(json, "ResearchStudy.status");
process(json, "ResearchSubject.status");
process(json, "Schedule.active");
process(json, "Specimen.status");
process(json, "Subscription.status");
process(json, "SupplyDelivery.status");
process(json, "SupplyRequest.status");
process(json, "TestReport.status");
process(json, "ValueSet.compose.include.filter");
process(json, "VisionPrescription.status");
}
private void process(JsonObject json, String name) {
JsonObject j = json.getAsJsonObject(name);
if (j == null) {
System.out.println("Can't find "+name);
} else {
j.addProperty("modifier", true);
}
}
}

View File

@ -627,6 +627,7 @@ public class ProfileUtilities extends TranslatingUtilities {
}
derived.setUserData("profileutils.snapshot.generating", true);
snapshotStack.add(derived.getUrl());
try {
if (!Utilities.noString(webUrl) && !webUrl.endsWith("/"))
webUrl = webUrl + '/';
@ -662,9 +663,9 @@ public class ProfileUtilities extends TranslatingUtilities {
}
baseSnapshot = cloneSnapshot(baseSnapshot, base.getType(), derivedType);
}
// if (derived.getId().equals("2.16.840.1.113883.10.20.22.2.1.1")) {
// debug = true;
// }
// if (derived.getId().equals("2.16.840.1.113883.10.20.22.2.1.1")) {
// debug = true;
// }
processPaths("", derived.getSnapshot(), baseSnapshot, diff, baseCursor, diffCursor, baseSnapshot.getElement().size()-1,
derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size()-1 : -1, url, webUrl, derived.present(), null, null, false, base.getUrl(), null, false, null, null, new ArrayList<ElementRedirection>(), base);
checkGroupConstraints(derived);
@ -794,7 +795,10 @@ public class ProfileUtilities extends TranslatingUtilities {
derived.clearUserData("profileutils.snapshot.generating");
throw e;
}
} finally {
derived.clearUserData("profileutils.snapshot.generating");
snapshotStack.remove(derived.getUrl());
}
}
public void checkDifferentialBaseType(StructureDefinition derived) throws Error {
@ -1147,7 +1151,7 @@ public class ProfileUtilities extends TranslatingUtilities {
processPaths(indent+" ", result, base, differential, nbc, start, nbl-1, diffCursor-1, url, webUrl, profileName, tgt.getElement().getPath(), outcome.getPath(), trimDifferential, contextName, resultPathBase, false, null, null, redirectorStack(redirector, outcome, cpath), srcSD);
}
} else {
StructureDefinition dt = outcome.getType().size() > 1 ? context.fetchTypeDefinition("Element") : getProfileForDataType(outcome.getType().get(0));
StructureDefinition dt = outcome.getType().size() > 1 ? context.fetchTypeDefinition("Element") : getProfileForDataType(outcome.getType().get(0), webUrl);
if (dt == null) {
throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), cpath));
}
@ -1300,7 +1304,7 @@ public class ProfileUtilities extends TranslatingUtilities {
processPaths(indent+" ", result, base, differential, nbc, start - 1, nbl-1, diffCursor - 1, url, webUrl, profileName, tgt.getElement().getPath(), diffMatches.get(0).getPath(), trimDifferential, contextName, resultPathBase, false, null, null, redirectorStack(redirector, outcome, cpath), srcSD);
}
} else {
StructureDefinition dt = outcome.getType().size() == 1 ? getProfileForDataType(outcome.getType().get(0)) : getProfileForDataType("Element");
StructureDefinition dt = outcome.getType().size() == 1 ? getProfileForDataType(outcome.getType().get(0), webUrl) : getProfileForDataType("Element");
if (dt == null)
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__FOR_TYPE__IN_PROFILE__BUT_CANT_FIND_TYPE, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
contextName = dt.getUrl();
@ -1511,7 +1515,7 @@ public class ProfileUtilities extends TranslatingUtilities {
if (baseHasChildren(base, currentBase)) { // not a new type here
throw new Error("This situation is not yet handled (constrain slicing to 1..1 and fix base slice for inline structure - please report issue to grahame@fhir.org along with a test case that reproduces this error (@ "+cpath+" | "+currentBase.getPath()+")");
} else {
StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome);
StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome, webUrl);
contextName = dt.getUrl();
diffCursor++;
start = diffCursor;
@ -1577,7 +1581,7 @@ public class ProfileUtilities extends TranslatingUtilities {
processPaths(indent+" ", result, base, differential, baseCursor+1, diffCursor, baseLimit, diffLimit, url, webUrl, profileName, contextPathSrc, contextPathDst, trimDifferential, contextName, resultPathBase, false, null, null, redirector, srcSD);
baseCursor = indexOfFirstNonChild(base, currentBase, baseCursor, baseLimit);
} else {
StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome);
StructureDefinition dt = getTypeForElement(differential, diffCursor, profileName, diffMatches, outcome, webUrl);
contextName = dt.getUrl();
int start = diffCursor;
while (differential.getElement().size() > diffCursor && pathStartsWith(differential.getElement().get(diffCursor).getPath(), cpath+"."))
@ -1778,7 +1782,7 @@ public class ProfileUtilities extends TranslatingUtilities {
if (base.getElement().get(baseCursor).getType().size() != 1) {
throw new Error(context.formatMessage(I18nConstants.DIFFERENTIAL_WALKS_INTO____BUT_THE_BASE_DOES_NOT_AND_THERE_IS_NOT_A_SINGLE_FIXED_TYPE_THE_TYPE_IS__THIS_IS_NOT_HANDLED_YET, cpath, diffMatches.get(0).toString(), base.getElement().get(baseCursor).typeSummary()));
}
StructureDefinition dt = getProfileForDataType(base.getElement().get(baseCursor).getType().get(0));
StructureDefinition dt = getProfileForDataType(base.getElement().get(baseCursor).getType().get(0), webUrl);
if (dt == null) {
throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath()));
}
@ -1894,7 +1898,7 @@ public class ProfileUtilities extends TranslatingUtilities {
diffCursor - 1, url, webUrl, profileName+pathTail(diffMatches, 0), base.getElement().get(0).getPath(), base.getElement().get(0).getPath(), trimDifferential, contextName, resultPathBase, false, null, null, redirector, srcSD);
} else {
StructureDefinition dt = getProfileForDataType(outcome.getType().get(0));
StructureDefinition dt = getProfileForDataType(outcome.getType().get(0), webUrl);
// if (t.getCode().equals("Extension") && t.hasProfile() && !t.getProfile().contains(":")) {
// lloydfix dt =
// }
@ -1946,7 +1950,7 @@ public class ProfileUtilities extends TranslatingUtilities {
}
public StructureDefinition getTypeForElement(StructureDefinitionDifferentialComponent differential, int diffCursor, String profileName,
List<ElementDefinition> diffMatches, ElementDefinition outcome) {
List<ElementDefinition> diffMatches, ElementDefinition outcome, String webUrl) {
if (outcome.getType().size() == 0) {
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_NO_CHILDREN__AND_NO_TYPES_IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), profileName));
}
@ -1956,7 +1960,7 @@ public class ProfileUtilities extends TranslatingUtilities {
throw new DefinitionException(context.formatMessage(I18nConstants._HAS_CHILDREN__AND_MULTIPLE_TYPES__IN_PROFILE_, diffMatches.get(0).getPath(), differential.getElement().get(diffCursor).getPath(), typeCode(outcome.getType()), profileName));
}
}
StructureDefinition dt = getProfileForDataType(outcome.getType().get(0));
StructureDefinition dt = getProfileForDataType(outcome.getType().get(0), webUrl);
if (dt == null)
throw new DefinitionException(context.formatMessage(I18nConstants.UNKNOWN_TYPE__AT_, outcome.getType().get(0), diffMatches.get(0).getPath()));
return dt;
@ -2428,13 +2432,14 @@ public class ProfileUtilities extends TranslatingUtilities {
return s;
}
private StructureDefinition getProfileForDataType(TypeRefComponent type) {
private StructureDefinition getProfileForDataType(TypeRefComponent type, String webUrl) {
StructureDefinition sd = null;
if (type.hasProfile()) {
sd = context.fetchResource(StructureDefinition.class, type.getProfile().get(0).getValue());
if (sd == null) {
if (xver != null && xver.matchingUrl(type.getProfile().get(0).getValue()) && xver.status(type.getProfile().get(0).getValue()) == XVerExtensionStatus.Valid) {
sd = xver.makeDefinition(type.getProfile().get(0).getValue());
generateSnapshot(context.fetchTypeDefinition("Extension"), sd, sd.getUrl(), webUrl, sd.getName());
}
}
if (sd == null)

View File

@ -0,0 +1,25 @@
package org.hl7.fhir.utilities.tests;
import java.io.IOException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class RegexTests {
@Test
public void testPath1() throws IOException {
Assertions.assertFalse("http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1".matches("Library"));
}
@Test
public void testPath2() throws IOException {
Assertions.assertTrue("http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1".matches(".*Library.*"));
}
@Test
public void testPath3() throws IOException {
Assertions.assertTrue("http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1".matches("(?s).*Library.*"));
}
}

View File

@ -19,7 +19,7 @@
<properties>
<hapi_fhir_version>5.4.0</hapi_fhir_version>
<validator_test_case_version>1.1.92</validator_test_case_version>
<validator_test_case_version>1.1.93-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.7.1</junit_jupiter_version>
<junit_platform_launcher_version>1.7.1</junit_platform_launcher_version>
<maven_surefire_version>3.0.0-M5</maven_surefire_version>