mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-06 21:08:11 +00:00
add test for multiple discriminators, and fix validator
This commit is contained in:
parent
9b84f331f2
commit
5653da8a27
@ -1161,5 +1161,9 @@ public class Utilities {
|
|||||||
return keys.toString();
|
return keys.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValidId(String id) {
|
||||||
|
return id.matches("[A-Za-z0-9\\-\\.]{1,64}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2537,9 +2537,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||||||
long t = System.nanoTime();
|
long t = System.nanoTime();
|
||||||
// GG: this approach is flawed because it treats discriminators individually rather than collectively
|
// GG: this approach is flawed because it treats discriminators individually rather than collectively
|
||||||
StringBuilder expression = new StringBuilder("true");
|
StringBuilder expression = new StringBuilder("true");
|
||||||
|
boolean anyFound = false;
|
||||||
|
Set<String> discriminators = new HashSet<>();
|
||||||
for (ElementDefinitionSlicingDiscriminatorComponent s : slicer.getSlicing().getDiscriminator()) {
|
for (ElementDefinitionSlicingDiscriminatorComponent s : slicer.getSlicing().getDiscriminator()) {
|
||||||
String discriminator = s.getPath();
|
String discriminator = s.getPath();
|
||||||
|
discriminators.add(discriminator);
|
||||||
|
|
||||||
List<ElementDefinition> criteriaElements = getCriteriaForDiscriminator(path, ed, discriminator, profile, s.getType() == DiscriminatorType.PROFILE);
|
List<ElementDefinition> criteriaElements = getCriteriaForDiscriminator(path, ed, discriminator, profile, s.getType() == DiscriminatorType.PROFILE);
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (ElementDefinition criteriaElement : criteriaElements) {
|
for (ElementDefinition criteriaElement : criteriaElements) {
|
||||||
@ -2592,8 +2595,14 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||||||
if (found)
|
if (found)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found)
|
if (found)
|
||||||
throw new DefinitionException("Could not match discriminator (" + discriminator + ") for slice " + ed.getId() + " in profile " + profile.getUrl() + " - does not have fixed value, binding or existence assertions");
|
anyFound = true;
|
||||||
|
}
|
||||||
|
if (!anyFound) {
|
||||||
|
if (slicer.getSlicing().getDiscriminator().size() > 1)
|
||||||
|
throw new DefinitionException("Could not match any discriminators (" + discriminators + ") for slice " + ed.getId() + " in profile " + profile.getUrl() + " - does not have fixed value, binding or existence assertions for any of the discriminators");
|
||||||
|
else
|
||||||
|
throw new DefinitionException("Could not match discriminator (" + discriminators + ") for slice " + ed.getId() + " in profile " + profile.getUrl() + " - does not have fixed value, binding or existence assertions");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -132,6 +132,14 @@
|
|||||||
"patient-lang3.json" : {
|
"patient-lang3.json" : {
|
||||||
"errorCount": 0,
|
"errorCount": 0,
|
||||||
"warningCount": 1
|
"warningCount": 1
|
||||||
|
},
|
||||||
|
"patient-au-5.json" : {
|
||||||
|
"errorCount": 0,
|
||||||
|
"warningCount": 0,
|
||||||
|
"profile" : {
|
||||||
|
"source" : "profile-patient-au.xml",
|
||||||
|
"errorCount": 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Xml": {
|
"Xml": {
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
{
|
||||||
|
"resourceType" : "Patient",
|
||||||
|
"id" : "au-5",
|
||||||
|
"text" : {
|
||||||
|
"status" : "generated",
|
||||||
|
"div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: example5</p><p><b>meta</b>: </p><p><b>identifier</b>: Medicare Number = 22968184811</p><p><b>name</b>: Sarah Simmons </p><p><b>telecom</b>: ph: (03) 4455 6677</p><p><b>gender</b>: female</p><p><b>birthDate</b>: Sep 7, 1977</p><p><b>address</b>: 55 Sarah Street Strahan TAS 7468 AU </p><p><b>generalPractitioner</b>: <a href=\"Practitioner-example3.html\">Generated Summary: id: example3; HPI-I = 8003611234567893; Francis Fernando </a></p><p><b>managingOrganization</b>: <a href=\"Organization-example3.html\">Generated Summary: id: example3; ABN = 51824754455; <span title=\"Codes: {http://hl7.org/fhir/organization-type prov}\">Healthcare Provider</span>; name: Devonport Family Medicine Clinic; reception@example.dfmc.com.au(WORK), fax: (03) 8543 5557(WORK), ph: (03) 8543 5556(WORK)</a></p><h3>Links</h3><table class=\"grid\"><tr><td>-</td><td><b>Other</b></td><td><b>Type</b></td></tr><tr><td>*</td><td><a href=\"RelatedPerson-example2.html\">Generated Summary: id: example2; Medicare Number = 22968184811; <span title=\"Codes: {http://hl7.org/fhir/v3/RoleCode MTH}\">mother</span>; Sarah Simmons ; ssimmons@example.amail.com.au(HOME), ph: (03) 4455 6677(HOME); gender: female; birthDate: Sep 7, 1977</a></td><td>seealso</td></tr></table></div>"
|
||||||
|
},
|
||||||
|
"identifier" : [
|
||||||
|
{
|
||||||
|
"type" : {
|
||||||
|
"coding" : [
|
||||||
|
{
|
||||||
|
"system" : "http://terminology.hl7.org/CodeSystem/v2-0203",
|
||||||
|
"code" : "MC",
|
||||||
|
"display" : "Patient's Medicare number"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"text" : "Medicare Number"
|
||||||
|
},
|
||||||
|
"system" : "http://ns.electronichealth.net.au/id/medicare-number",
|
||||||
|
"value" : "22968184811",
|
||||||
|
"period" : {
|
||||||
|
"end" : "2022-12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name" : [
|
||||||
|
{
|
||||||
|
"family" : "Simmons",
|
||||||
|
"given" : [
|
||||||
|
"Sarah"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"telecom" : [
|
||||||
|
{
|
||||||
|
"system" : "phone",
|
||||||
|
"value" : "(03) 4455 6677"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"gender" : "female",
|
||||||
|
"birthDate" : "1977-09-07",
|
||||||
|
"address" : [
|
||||||
|
{
|
||||||
|
"line" : [
|
||||||
|
"55 Sarah Street"
|
||||||
|
],
|
||||||
|
"city" : "Strahan",
|
||||||
|
"state" : "TAS",
|
||||||
|
"postalCode" : "7468",
|
||||||
|
"country" : "AU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"generalPractitioner" : [
|
||||||
|
{
|
||||||
|
"reference" : "Practitioner/example3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"managingOrganization" : {
|
||||||
|
"reference" : "Organization/example3"
|
||||||
|
},
|
||||||
|
"link" : [
|
||||||
|
{
|
||||||
|
"other" : {
|
||||||
|
"reference" : "RelatedPerson/example2"
|
||||||
|
},
|
||||||
|
"type" : "seealso"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user