HL7 - FN DataType inside XCN DataType? - hl7

I'm taking a look in Caristix HL7 v2.5 - Segment PV1:
And when I click PV1.9 DataType it shows DataType fields:
In XCN.2 shows FN as DataType, and FN is not just a string:
So, how can I make an example of HL7 with PV1.9 having datatype XCN that has FN inside too? I don't get it
Trying to make an example
MSH|^~\&|SA|SF||R|201802201803^450||ADT^A01^ADT_A01|2018022018035210|P|2.2||||||
EVN|A01|201802201803|||SHE7|
PV1|1|E|||||||1^Surname&Own Surname Prefix&Own Surname&Surname Prefix From Partner/Spouse&Surname From Partner/Spouse^||||
But it seems like is not right :(

The XCN - Extended Composite ID Number and Name for Persons datatype holds identifier, name (separated by components) and some additional information. Note that most of the fields in datatype are O (optional), C (conditional) or B (for backward compatibility).
In XCN, as said above, you can hold XCN.2 - Family Name which holds the datatype FN - Family Name which is just a string.
This data type allows full specification of the surname of a person. Where appropriate, it differentiates the person's own surname from that of the person's partner or spouse, in cases where the person's name may contain elements from either name. It also permits messages to distinguish the surname prefix (such as "van" or "de") from the surname root.
So basically, its a string separated by components. Your value becomes something like below:
IdNumber^FamilyName^GivenName^SecondAndFurtherGivenNamesOrInitialsThereof^Suffix^Prefix
Your PV1 segment becomes something like below:
PV1|1|E|||||||IdNumber^FamilyName^GivenName^SecondAndFurtherGivenNamesOrInitialsThereof^Suffix^Prefix||||
You may further refer PV1 segment.
You are just confused due to deep hierarchy or nested datatypes. If you map those to your programming language, it becomes quite simple.

After testing the message with different parsers, the way HL7 works for subcomponents are like this:
MSH|^~\&|SA|SF||R|201802201803^450||ADT^A01^ADT_A01|2018022018035210|P|2.2||||||
EVN|A01|201802201803|||SHE7|
PV1|1|E|||||||1^Surname&Own Surname Prefix&Own Surname&Surname Prefix From Partner/Spouse&Surname From Partner/Spouse^||||
Using Subcomponent separator character (&)
Then, parsed items will be like this
PV1
|- PV1.1
| |- SI
| |- 1
|- PV1.2
| |- IS
| |- E
|- PV1.9
| |- PV1.9.1
| |- ST
| |- 1
| |- PV1.9.2
| |- XCN
| |- Surname
| |- Own Surname Prefix
| |- Surname Prefix From Partner/Spouse
| |- Surname Form Partner/Spouse
That's right.

Related

How to add the vertical pipes we see in Examples feature of the Scenario Outline in SpecFlow

I would like to add the vertical pipes so that I can have my data table down there under "Examples" feature in Specflow. Anyone to give me any tip so I can go through it?. My scenario outline looks like:
#mytag
Scenario Outline: Check Noun Words
Given Access the AnalyzeStateless URL
And language code
And content of <Sentence>
And the Expected KeyWord <Expected KeyWords>
And the Expected Family ID <Expected FID>
And the index <Index>
When return the XML response
Then the keyword should contain <FamilyID>
Examples:
| Index | Sentence | Expected KeyWords | Expected FID |
| 1 | I need a personal credit card | personal | 92289 |
The "Examples" feature has been manually entered in above case. I have a thousand of rows on an excel file, any appropriate way to get all of the values in one go?
Have you looked at Specflow.Excel which allows you to keep your examples in your excel files?

How do you find the list of wikidata (or freebase or DBpedia) topics that a text is about?

I am looking for a solution to extract the list of concepts that a text (or html) document is about. I'd like the concepts to be wikidata topics (or freebase or DBpedia).
For example "Bad is a song by Mikael Jackson" should return Michael Jackson (the artist, wikidata Q2831) and Bad (the song, wikidata Q275422). As this example shows, the system should be robust to spelling mistakes (Mikael) and ambiguity (Bad).
Ideally the system should work across multiple languages, it should work both on short texts and long texts, and when it is unsure it should return multiple topics (eg. Bad song + Bad album). Also, it should ideally be open source and have a python API.
Yes, that sounds like a list for Santa Claus. Any ideas?
Edit
I checked out a few solutions, but no silver bullet so far.
NLTK parses text and extract "named entities" (AFAIU, a part of a sentence that refers to a name), but it does not return Wikidata topics, just plain text. This means that it will likely not understand that "I shot the sheriff" is the name of a song by Bob Marley, it will instead treat this as a sentence.
OpenNLP does roughly the same.
Wikidata has a search API, but it's just one term at a time, and it does not handle disambiguation.
There are a few commercial services (OpenCalais, AlchemyAPI, CogitoAPI...) but none really shines, IMHO.
You can use Spacy to retrieve Named Entity then link them to WikiData using the search API.
For what remains of the sentence that is not matched as named entity by Spacy you can create a list of ngrams from the sentence starting with the biggest ngram you use the WikiData search API to lookup WikiData topics.
POS tagging can be put to good use, that said syntax parse informations is more powerful since you can know the relations between the words. For instance given the following output from link-grammar:
Found 8 linkages (8 had no P.P. violations)
Linkage 1, cost vector = (UNUSED=0 DIS= 0.15 LEN=9)
+-------------------------Xp-------------------------+
+----------->WV---------->+ |
+-------Wd------+ +---------Osn--------+ |
| +---G---+----Ss---+----Os----+ | |
| | | | | | |
LEFT-WALL Bob.m Marley[!] wrote.v-d Natural[!] Mystic[!] .
You can tell that the subject is “Bob Marley” because
“wrote” is connected to “Marley” with a S which connects subject nouns to finite verbs.
“Marley” is connected to “Bob” using a G which connects proper noun together.
So a “Bob Marley” is a good candidate for an entity (also it has both word capitalized).
Given the above parse "tree" it difficult to tell whether “Natural” and “Mystic” are related even if they are on the same side of the sentence.
The second parse provided by link grammar has the same cost vector and links together “Natural Mystic” with again a G.
Here is it:
Linkage 2, cost vector = (UNUSED=0 DIS= 0.15 LEN=9)
+-------------------------Xp-------------------------+
+----------->WV---------->+ |
+-------Wd------+ +---------Os---------+ |
| +---G---+----Ss---+ +----G----+ |
| | | | | | |
LEFT-WALL Bob.m Marley[!] wrote.v-d Natural[!] Mystic[!] .
So in my opinion “Bob Marley” and “Natural Mystic” are good candidate for a wikidata search.
That was the easy problem where grammar and spelling are correct.
Here is one parse out of 11 of the same sentence with lower cases:
Linkage 1, cost vector = (UNUSED=1 DIS= 0.15 LEN=14)
+------------------------Xp------------------------+
+----------------------Wa---------------------+ |
| +------------------AN-----------------+ |
| | +-------------AN-------------+ |
| | | +----AN---+ |
| | | | | |
LEFT-WALL Bob.m marley[?].n [wrote] natural.n mystic.n .
LG doesn't even recognize the verb.

Splitting examples in Given and Then for SpecFlow Scenario Outline

I am writing a specflow scenario with multiple input and output parameters (about 4-5 each). When using scenario outline, I need to write a wide table giving both input and output columns in the same row. Is there any way where I can specify the examples separately for the step definitions? This is for improved readability.
Current state
Given - State of the data
When I trigger action with parameters <input1> and <input2> and ...
Then my output should contain <output1> and <output2> ...
Examples:
| input1 | input2 |... | output1 | output2 |...
Can I do this?
Given - State of the data
When I trigger action with parameters <input1> and <input2> and ...
Examples of input
Then my output should contain <output1> and <output2> ...
Examples of output
No, unfortunately that (or anything similar) is not possible.
You could make your inputs and outputs more abstract and possibly merge a few columns. Example: instead of Country | PostalCode | City | Street | House | Firstname | Lastname | etc. you should have | Address | Job title | with values like "EU", "US, missing postal code", "HQ" for the address.
You can't have multiple Example tables for scenario outline but you can pass in data tables for regular scenarios.
The data table will be accessible only to the step that uses it, however you could save it in Scenario Context for subsequent steps.
Not sure if this will work for you if your scenario is complex and spans multiple lines but I thought I'd mention it.
Scenario: Checking outputs for inputs
Given - State of the data
When I trigger action with the following parameters
input1 | input2 | input3 |
data | data | data |
Then my output should contain the following outputs
output1 | output2 | output3 |
data | data | data |

How to pass spaces in table (specflow scenario)?

How to pass spaces in table ?
Background:
Given the following books
|Author |(here several spaces)Title(here several spaces)|
I would do this:
Given the following books
| Author | Title |
| "J. K. Rowling" | "Harry P " |
| " Isaac Asimov " | "Robots and Empire" |
Then your bindings can be made to strip the quotes if present, but retaining the spaces.
I think this is much preferable to the idea of adding spaces afterward, because that isn't very human readable - quotations will make the spaces visible to the human (stakeholder / coder) reading them.
You can work around it by adding an extra step. Something like:
Given the following books
|Author | Title |
Add append <5> spaces to book title
Edit:
A complete feature can look something like:
Scenario: Adding books with spaces in the title
Given the following book
| price | title |
And <5> spaces appended to a title
When book is saved
Then the title should be equals to <title without spaces>
I just faced same situation, my solution was this, added spaces in the step as follows:
Scenario: Adding books with spaces in the title
Given the following book ' <title> '
When book is saved
Then the title should be equals to '<title>'
| price | title |
| 50.00 | Working hard |

Scenario Outline: Placeholders with a restricted number of possible values

I am relatively new to BDD and I have a question regarding scenario outlines. When looking at samples over the internet I have the feeling that the placeholders can take any values. The number of elements in their domain is not restricted. Here is one example:
Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
The placeholder <start> for example can be any number so the number of values is infinite.
In my specs I have to deal with contracts which can have one of four states (planned, ongoing, paused, and closed). My specs say that I can edit planned contracts but I am not allowed to edit contracts which have one of the remaining three states.
I think I would write a scenario named "Updating a planned contract" and one scenario outline where the status of a contract is a placeholder.
Scenario: Update a planned contract
Given the list of contracts as follows
| name | status | some value |
| c1 | planned | 123 |
And I have edited contract c1 as follows
| field | value |
| name | c1 |
| some value | 456 |
When I save contract c1
Then the list of contracts should be as follows
| name | status | some value |
| c1 | planned | 456 |
Scenario Outline: Update contract
Given there is a <status> contract
And I have edited that contract
When I save that contract
Then I an error 'only planned contracts are allowed to change' should be displayed
Examples:
| status |
| ongoing |
| paused |
| closed |
Is that the right way? One expicit scenario and one parameterized? Or should I write the scenario outline as explicit scenarios for each possibility? I am not sure because the status of a contract is restricted by four possible values as opposed to the examples on the internet.
One thing I find that helps is to remember that Gherkin is just a syntax for Specification by Example. You are trying to provide the examples that make most sense to you in the business domains language.
As such, what you are proposing is perfectly valid. You have one example of a scenario that uses tables to define what happens when a planned contract is edited, and another set of examples that produce errors when contracts in other states. You could also do it explicitly by expanding the outline for each state. Both are valid, and you can always refactor your feature sepcifications as you would the codebase.
What you are aiming to do here however is to provide a grammar, a framework, a language, call it what you will, that you can use to have conversations with your business analysts. You want to be able to pull out this document and say "This is how the system works now, how do we change this to make it support your new feature?".
Personally, I'm avoiding tabular and outline forms in my features right now as I want to make it look as friendly as possible to all I show it to, and as yet, my features are still easy to describe.

Resources