it is possible to slice a string list, like the element line on the Address? I'm trying to do something like that: https://simplifier.net/redenacionaldedadosemsaude/brendereco, but when I generate my IG, my sample resource does not validate the lines.
my resourse example address element:
<address>
<use value="home"/>
<type value="physical"/>
<text value="1003 Healthcare Drive, Northfield MN" />
<line value="street"/>
<line value="Healthcare Drive"/>
<line value="1003"/>
<line value="neighborhood"/>
<city value="Northfield"/>
<state value="MN"/>
<postalCode value="12345123" />
<country value="Brasil" />
</address>
Errors I got on my IG:
When you slice and declare a discriminator, then every slice needs to establish a value for that discriminator. You sliced by Address.line.value by value. That means that each line slice needs to specify a required value set binding, a fixed value or a pattern. (And the constraints declared by each slice can't overlap.) You only declared a required binding on one of the slices. The street, number, complement and neighborhood slices are unconstrained. That's not allowed.
Given that, realistically, you can't define value sets (let alone fixed values or patterns) for those elements, I don't think slicing is going to be possible with just 'value'. If you need to distinguish between different repetitions of Address.line, you're going to need to put an extension on them that indicates what type of line they are.
Also, it's not clear that you're using 'line' correctly. An address line is a string of text that appears on a separate line. It's not just a distinct part of the address. Unless streetType, street, number, complement, etc. all need to appear on separate lines, you can't create separate repetitions of 'line' for them. If you want to break out the parts of the address, you need to use extensions. There are already standard extensions for most 'parts' of an address - you can see them here: https://build.fhir.org/datatypes-extras.html#Address
Related
Using XSD schema validation 1.0 I want to verify an element has at least one attribute specified.
For example, a simple element like this:
<foo a="1" b="2" c="3" />
I want to verify that at least attribute b or c is specified. But note that both can also be specified--they're not mutually exclusive.
I tried using a key along the lines of:
<xs:key name="AttributeSpecified">
<xs:selector xpath="." />
<xs:field xpath="#b|#c" />
</xs:key>
but it fails when both attributes are specified (because multiple results are returned).
Can it be done?
This is not possible in XSD 1.0. It might be possible in XSD 1.1.
I am a fan of XML Schema, but I would not choose it for this type of validation. You might be able to make it work using XSD1.1 but if your requirements became just a little more complex you could end up with some horrible-looking constraints.
On the other hand, an XPath expression can elegantly express any constraint you can think of, and you would not need to bend the language to make it work.
What does max/min mean on the root element of a resource or extension?
<element>
<path value="Patient" />
<min value="0" />
<max value="*" />
...snip...
</element>
The cardinality allowed in a containing structure like Bundle? Doesn't make sense to me....
For a resource, it doesn't mean anything. For an extension, it places constraints on what the cardinality is allowed to be for a slice instantiating that constraint in a profile. For example, if an extension has a cardinality of 1..5, then if that extension is referenced inside a profile, the minimum cardinality of that constraint element must be at least 1 and the maximum no more than 5. Most of the time this will just be used to indicate whether the extension will be allowed to repeat or not.
I'm trying to figure out how to fully specify a sliced element. If I'm reading the spec right, nameReference is the only place where a "sub element" of a slice can declare which slice it's "on".
So, if telecom is sliced by use and system and I want to specify a constraint on home phone, I have to fix use and system to those values and then add my constraints on that slice.
Consider:
Resource Example ElementDefinition attributes
================================ =====================================================================
<Patient> name="Patient"
... snip ...
<telecom> name="HomePhone"
<system value="phone" /> name="HomePhone.system", nameReference="HomePhone", fixedCode="phone"
<use value="home" /> name="HomePhone.use" , nameReference="HomePhone", fixedCode="home"
<value value="5551234567" /> name="HomePhone.value" , nameReference="HomePhone"
</telecom>
... snip ...
</Patient>
In most examples, it appears that a dotted notation of Name has been used (as I've placed in the example). But the specification doesn't require this and provides no format that could be reliably parsed.
The problem is: nameReference and fixed[x] are mutually exclusive. What's the correct way to handle this??
Repetitions in an instance don't "declare" what slice they're part of. They simply declare the appropriate value for what ever element(s) are the discriminator for the slicing process. nameReference isn't involved at all. On the definition side, association is simply handled by name. So HomePhone.system is associated with HomePhone simply by the name and by sequential proximity. The dot-notation is required. We could probably be a bit more explicit about that though, so feel free to submit a change request.
I am trying to make a regex check for my time input text and also I am trying to mask the input. I don't know if both can be done at the same time with this code:
<p:inputMask mask="99:99" size="5" maxlength="5" required="true" requiredMessage="#{account_req_txt}" value="#{user.accountNo}">
<f:validateRegex pattern="[01]?[0-9]|2[0-3]):[0-5][0-9]"/>
<p:ajax event="blur" update="sysMsg" />
</p:inputMask>
I am getting "must be a number consisting of one or more digits." error. What is wrong with above code?
How exactly is the "account number" as represented by #{user.accountNo} a time? That part is confusing. In any way, the error suggests that the accountNo is actually a Number like Integer, Long, etc, not a String.
Perhaps you meant to bind it to #{user.time} or something else. At least, the value must be bound to a String, otherwise you need to create a Converter to convert between a String in 99:99 representation to a number type in 9999 representation.
I am looking to find all attributes of an element that match a certain pattern.
So for an element
<element s2="1" name="aaaa" id="1" />
<element s3="1" name="aaaa" id="2" />
I would like to be able to find all attributes that start with 's' (returning the value of s1 for the first element and s3 for the value of the second element).
If this is outside of xpath's ability please let me know.
Use:
element/#*[starts-with(name(), 's')]
This XPath expression selects all atribute nodes whose name starts with the string 's' and that are attributes of elements named element that are children of the current node.
starts-with() is a standard function in XPath 1.0
element/#*[substring(name(), 1,1) = "s"]
will match any attribute that starts with 's'.
The function starts-with() might look better than using substring()
I've tested the given answers from both #Dimitre-Novatchev and #Ledhund, using lxml.html module in Python.
Both element/#*[starts-with(name(), 's')] and element/#*[substring(name(), 1,1) = "s"] return only the values of s2 and s3. You won't be able to know which value belong to which attribute.
I think in practice I would be more interested in finding the elements themselves that contain the attributes of names starting with specific characters rather than just their values.
To achieve that is very simple, just add /.. at the end,
element/#*[starts-with(name(), "s")]/..
or
element/#*[starts-with(name(), "s")]/parent::*
or
element/#*[starts-with(name(), "s")]/parent::node()
None from above worked for me.
So I did not some changes and it worked for me. :)
/*:UserCustomField[starts-with(#name, 'purchaseDate')]