How to deal with deafult namespace when searching using xpath in splunk? - xpath

So I have a valid xml file looking something like this:
<session xmlns="http://winscp.net/schema/session/1.0" name="mysession#10.0.0.22" start="2015-09-28T05:00:01.974Z">
<ls>
<destination value="/" />
<files>
<file>
<filename value="." />
<type value="d" />
<modification value="2015-09-28T05:44:14.000Z" />
<permissions value="rw-rw----" />
</file>
<file>
<filename value=".." />
<type value="d" />
<modification value="2015-09-28T05:44:14.000Z" />
<permissions value="rw-rw----" />
</file>
<file>
<filename value="55800379_150928_071525.zip" />
<type value="-" />
<size value="999124" />
<modification value="2015-09-28T05:36:08.000Z" />
<permissions value="rw-rw----" />
</file>
</files>
<result success="true" />
</ls>
<download>
<filename value="/55800379_150928_071525.zip" />
<destination value="C:\somefolder\55800478_150928_071525.zip" />
<result success="true" />
</download>
<rm>
<filename value="/55800379_150928_071525.zip" />
<result success="true" />
</rm>
</session>
I have added it as data in splunk and am trying to search using a query as below:
source="sample5.xml" host="dummy1" sourcetype="WinSCP XML" | xpath outfield=afield "//ls/files/file/filename/#value"
However, in this case the afield field is not getting populated (I was expecting the three values '.', '..' and '55800379_150928_071525.zip'). So I've got the error down to the xmlns in the session tag, when the first line looks like this (note: no xmlns attribute), the search does what I expect:
<session name="mysession#10.0.0.22" start="2015-09-28T05:00:01.974Z">
What do I have to put in my xpath to get the result I am looking for (I would very much prefer not to have to preprocess my logs to remove the XML namespace prior to import)?

Hmm, that looks like an unnamed namespace, which I can get at by registering a custom namespace prefix using my libxml2 wrapper program:
$ xpquery -n 'x:http://winscp.net/schema/session/1.0' '//x:ls/x:files/x:file/x:filename/#value' blah.xml
value="."
value=".."
value="55800379_150928_071525.zip"
$
Check whether your xpath program has support for the equivalent of libxml2 registerNs functionality?

Related

FHIR - Consent Resource - Giving Hl7.Fhir.Serialization.ComplexTypeReader error

I am not a techie but have assumed some responsibilities in someone's absence.
Trying to push below Consent FHIR Resource:
<Consent xmlns="http://hl7.org/fhir">
<id value="123" />
<status value="inactive" />
<scope>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/consentscope" />
<code value="patient-privacy" />
</coding>
</scope>
<category>
<coding>
<system value="http://loinc.org" />
<code value="59284-0" />
</coding>
</category>
<patient>
<reference value="Patient/41" />
<display value="John Stifiles" />
</patient>
<policyRule>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/consentpolicycodes" />
<code value="cric" />
</coding>
</policyRule>
<provision>
<type value="deny" />
<period>
<start value="2021-09-27" />
<end value="2021-09-27" />
</period>
</provision>
</Consent>
This is passed with no errors from inferno.healthit.gov/validator/ but when I run through my integrator (it hits HL7 validator), I get a variety of errors - Encountered unknown member 'Scope' or Encountered unknown member 'Patient', etc.
This is a Consent resource that conforms to FHIR version R4. Inferno runs FHIR R4 as well, so that works.
However, if you try and validate this resource against FHIR STU3, you will get the errors you mentioned, since the Consent resource structure significantly changed from STU3 to R4. Please check your integrator and make sure it runs FHIR R4 as well.

NLog is not logging on Oracle database, Please how can I get it right

I want to log into Oracle database table using NLog but nothing gets logged. Below is NLog.config file am using. Please what am I doing wrongly?
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwConfigExceptions="true"
internalLogLevel="info"
internalLogFile="Logtxt.txt">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<targets>
<target name="database" xsi:type="Database" keepConnection="false" useTransactions="true"
dbProvider="System.Data.OracleClient.OracleConnection,System.Data.OracleClient, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionString="Data Source=#####;User ID=######;password=******;Integrated Security=no;"
commandText="insert into DBO_ERRORLOGS(LOGID,LEVEL,CALLSITE,TYPE,MESSAGE,STACKTRACE,INNEREXCEPTION,ADDITINALINFO,LOGGEDONDATE,USERNAME) values('',:LEVEL,:CALLSITE,:TYPE,:MESSAGE,:STACKTRACE,:INNEREXCEPTION,:ADDITIONALINFO,:DATE,:USERNAME)">
<parameter name="LEVEL" layout="${Level}" />
<parameter name="CALLSITE" layout="${Callsite}" />
<parameter name="DATE" layout="${date}" />
<parameter name="TYPE" layout="${exception:format=Type}" />
<parameter name="MESSAGE" layout="${exception:format=Message}" />
<parameter name="STACKTRACE" layout="${exception:format=StackTrace}" />
<parameter name="INNEREXCEPTION" layout="${exception:format=:innerFormat=ShortType,Message,Method:MaxInnerExceptionLevel=1:InnerExceptionSeparator=}" />
<parameter name="ADDITIONALINFO" layout="${Message}" />
<parameter name="USERNAME" layout="${identity}" />
</target>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="database" />
</rules>
</nlog>
Without an error message (see below how to find it), it's a bit guessing. But I think it's an issue you are sending all the parameters as strings. So add the dbType to the parameters, like:
<parameter name="DATE" layout="${date}" dbType="DateTime" />
For the actual error, you should check the internal log. It should be there!
Check Logtxt.txt. See internalLogFile="Logtxt.txt". And you can't find it, change it to an absolute path, e.g. internalLogFile="C:\temp\Logtxt.txt"

Freeswitch: mod_xml_curl and call groups

I am currently switching from static configs to using mod_xml_curl and have encountered a problem with setting up call groups.
Inside my dialplan (served dynamically, working as expected) I am bridging to a group:
<action application="bridge" data="${group_call(call-group#domain-a.com)}"/>
Freeswitch is making a request with section=directory&action=group_call to the web server, to which I respond with a chunk of the directory containing the group and all relevant users:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
<section name="directory">
<domain name="domain-a.com">
<params>
<param name="dial-string" value="{presence_id=${dialed_user}#${dialed_domain}}${sofia_contact(${dialed_user}#${dialed_domain})}" />
</params>
<variables>
<variable name="user_context" value="domain-a.com" />
</variables>
<group name="call-group">
<users>
<user id="john" number-alias="1000">
<params>
<param name="password" value="1234" />
<param name="vm-password" value="1000" />
</params>
<variables>
<variable name="toll_allow" value="domestic,international,local" />
<variable name="accountcode" value="1000" />
<variable name="outbound_caller_id_name" value="John at domain-a.com" />
<variable name="outbound_caller_id_number" value="1234567" />
</variables>
</user>
<user id="lucy" number-alias="1001">
<params>
<param name="password" value="1234" />
<param name="vm-password" value="1000" />
</params>
<variables>
<variable name="toll_allow" value="domestic,international,local" />
<variable name="accountcode" value="1001" />
<variable name="outbound_caller_id_name" value="Lucy" />
<variable name="outbound_caller_id_number" value="12345678" />
</variables>
</user>
</users>
</group>
</domain>
</section>
</document>
However, group_call() seems to fail and in the logs I get ``:
2016-02-24 10:42:14.249534 [DEBUG] mod_dptools.c:1498 SET sofia/internal/michael#domain-a.com [call_timeout]=[15]
2016-02-24 10:42:14.529107 [CONSOLE] mod_xml_curl.c:323 XML response is in /tmp/2f772a8a-4c3a-46f2-834f-b9ba2c735feb.tmp.xml
EXECUTE sofia/internal/michael#domain-a.com bridge(error/NO_ROUTE_DESTINATION)
Perhaps anyone has experience setting up group calls with mod_xml_curl and could explain what exactly Freeswitch is expecting in the response?
After a little gnashing of teeth, I got this working. The clue was here underneath the group_call description:
Please note: If you need to have outgoing user variables set in leg B,
make sure you don't have dial-string and group-dial-string in your
domain or dialed group variables list; instead set dial-string or
group-dial-string in the default group of the user. This way
group_call will return user/101 and user/ would set all your user
variables to the leg B channel.
So, when you receive an action of type group_call, move the dial-string param to the group level, so instead of
<domain name="domain-a.com">
<params>
<param name="dial-string" value="{presence_id=${dialed_user}#${dialed_domain}}${sofia_contact(${dialed_user}#${dialed_domain})}" />
</params>
<variables>
<variable name="user_context" value="domain-a.com" />
</variables>
<group name="call-group">
<users>
<user id="john" number-alias="1000">
...
send this
<domain name="domain-a.com">
<variables>
<variable name="user_context" value="domain-a.com" />
</variables>
<group name="call-group">
<params>
<param name="dial-string" value="{presence_id=${dialed_user}#${dialed_domain}}${sofia_contact(${dialed_user}#${dialed_domain})}" />
</params>
<users>
<user id="john" number-alias="1000">
...
After I made that change, everything was hunky dory. Cheers!
It's related to your dialplan.It's not generated perfectly. just check the domain-a.com context in the dialplan.

Can a FHIR extension be defined within the StructureDefinition of a profiled resource?

Does a FHIR extension always have to be defined in its own StructureDefinition before it can be used in a resource profile?
Or can its definition exist solely within the StructureDefinition of a profiled resource?
E.g.
<StructureDefinition xmlns="http://hl7.org/fhir">
<base value="http://hl7.org/fhir/StructureDefinition/Order" />
<name value="Order" />
...
<differential>
<element>
<path value="Order.extension" />
<name value="type" />
<label value="Type" />
<short value="BookAppointment | TelephonePatient | PatientNote | Note | Other" />
<definition value="Order type" />
<min value="1" />
<max value="1" />
<type>
<code value="code" />
</type>
<binding>
<strength value="required" />
<valueSetReference>
<reference value="http://test.org/fhir/ValueSet/task-type" />
</valueSetReference>
</binding>
</element>
...
Is the above valid?
No, that's not valid - because Order.extension can't have a type of "code". You could, in theory, slice extension and constrain the value[x] type to be valueCode with the specified properties. You'd also have to constrain the URL to a specified fixed value. The tricky part is that the URL you indicate as the fixed value is supposed to resolve to a StructureDefinition that defines the extension. So you really won't have saved yourself any work. Sending an instance where any immediate receiver can't discover the extension definition would make you automatically non-conformant.

FHIR: Slicing extensions

Slicing of DataElements is defined once per path (only one set of discriminators per unique path). This works for built-in elements, but extension is (and must be) sliced only by url. As a result, it appears that further (more detailed) slicing of an extension isn't possible.
For example, consider an extension to Patient for research authorizations, ext url "http://example.com/DataElement/researchAuth".
It has an extension sub-element "authorizationType" (http://example.com/DataElement/researchAuth.type) of type Code. Here are two instances of this extension (one type "local", one "national").
<extension url="http://example.com/DataElement/researchAuth">
<extension url="http://example.com/DataElement/researchAuth.type">
<valueCode value="local" />
</extension>
<extension url="http://example.com/DataElement/researchAuth.flag>
<valueBoolean value="true" />
</extension>
</extension>
<extension url="http://example.com/DataElement/researchAuth">
<extension url="http://example.com/DataElement/researchAuth.type">
<valueCode value="national" />
</extension>
<extension url="http://example.com/DataElement/researchAuth.flag>
<valueBoolean value="false" />
</extension>
</extension>
The StructureDefinition for this would include (from Patient):
...snip...
<element>
<path value="Patient.extension" />
<slicing>
<discriminator value="url" />
</slicing>
</element>
I could add an element for researchAuthorization by using type.Profile to define the extension URL, but can I add a slicing as shown?
<element>
<path value="Patient.extension" />
<slicing>
<discriminator value="url" />
</slicing>
</element>
<element>
<path value="Patient.extension" />
<name value="researchAuthorization" />
<slicing>
<discriminator value="url" />
<discriminator value="extension["http://example.com/DataElement/researchAuth.type"].code" />
</slicing>
<type>
<profile value="http://example.com/DataElement/researchAuth" />
</type>
</element>
The second is now legal since it "satisfies" the first slicing via type.profile.#value being fixed?
It's possible for a set of sliced data to have multiple discriminators. Whether the existing tooling will support this for extensions is a different question. You may need to manually author your profile.

Resources