Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date formats ("Geburtsdatum") differ from each other #5

Open
DavidStania opened this issue Dec 18, 2021 · 10 comments
Open

Date formats ("Geburtsdatum") differ from each other #5

DavidStania opened this issue Dec 18, 2021 · 10 comments

Comments

@DavidStania
Copy link

I'm using the Cherry SmartTerminal ST-1144 with the required library. But some card's are not readable. The most G2 cards working but G2.1 is not working. Do you have any ideas what could be the reason?
Best regards.
David

@Kaupisch-IT
Copy link
Owner

What does "are not readable" mean in detail?
Do you have any outputs available for cards that do not work?

@DavidStania
Copy link
Author

DavidStania commented Dec 20, 2021

Thank you for your answer.

After inserting some cards, nothing happens.
My code is from your example

CardResult result = CardTerminalClient.ReadCard("ctcym.dll"); if (result.Success) {...}

@Kaupisch-IT
Copy link
Owner

There should be some output written to the Debug output. What does it say?

@DavidStania
Copy link
Author

I will check that tomorrow. I have no card to check that yet.
Thank you.

@DavidStania
Copy link
Author

DavidStania commented Dec 20, 2021

I found the problem after checking the debug output.
There is a different dateformat with "Geburtstag" on PKV. In my case, one KV card got this format 'yyyyMMdd' and the other PK card returns 'ddMMyyyy'. And that was the reason why exception was thrown and I thought, the card was not readable,

The property 'Geschlecht' is missing in PkvResult.cs. I added this line
/// <summary> Gibt das Geschlecht des Versicherten an gemäß entsprechender Schlüsseltabelle. "M" = männlich, "W" = weiblich </summary> public string Geschlecht => this[0x8E];

@Kaupisch-IT
Copy link
Owner

Kaupisch-IT commented Jan 3, 2022

There is a different dateformat with "Geburtstag" on PKV. In my case, one KV card got this format 'yyyyMMdd' and the other PK card returns 'ddMMyyyy'. And that was the reason why exception was thrown and I thought, the card was not readable,

Interesting... I had a deeper look into the specs we have (basically those shown in #4 (comment)) where the KVK spec mentions "Das Geburtsdatum ist in der Ausprägung TTMMJJJJ zu codieren. Neben dem logisch richtigen Datum ist auch Tag = 0 zulässig (00MMJJJJ) und Tag+Monat = 0 (0000JJJJ).", while the PVK spec says "Codierung: mmttjjjj".

Edit (supplementary info):
For egK it's "Gibt das Geburtsdatum des Versicherten in dem Format YYYYMMDD (ISO-8601) an."


The property 'Geschlecht' is missing in PkvResult.cs. I added this line ...

Is there any offical specification for that? Neither KVP spec nor PVK spec has a field for Geschlecht.
0x8E is "PrüfSumme (XOR) über das gesamte VersichertenDatenTemplate" (length = 1) in both specs.

@Plattenpilger
Copy link

Also same problem here.
Cherry ST-1144 (ctcym.dll)
Cherry ST-2100 (ctpcsc32kv.dll)

It seems that there are at least 3 date format strings provided on different cards.
On EGK yyyymmdd
on PVK as in your comment above: mmddyyyy
on another PVK ddmmyyyy (card is from 01/2004)

Very confusing :(

@Kaupisch-IT
Copy link
Owner

Although this is confusing, this specific problem is not an issue of this library. The library itself does not convert any data nor does it throw any exceptions because of different date formats stored on an eGK/KVP/PVK-Card.

The only issue I see is that the documentation of the "Geburtsdatum" field is not specific enough.

@Kaupisch-IT
Copy link
Owner

There is a (new) property GeburtsdatumParsed that tries to take the different date formats into account:

/// <summary>
/// Gibt das in ein DateTime-Objekt umgewandelte Geburtsdatum des Versicherten an, das die unterschiedlichen Datumsformate (je nach Kartenart) berücksichtigt
/// </summary>
public DateTime? GeburtsdatumParsed
=> (DateTime.TryParseExact(this.PkvResult?.GeburtsDatum,"MMddyyyy",CultureInfo.InvariantCulture,DateTimeStyles.None,out DateTime result) ? result : (DateTime?)null)
?? (DateTime.TryParseExact(this.PkvResult?.GeburtsDatum,"ddMMyyyy",CultureInfo.InvariantCulture,DateTimeStyles.None,out result) ? result : (DateTime?)null)
?? (DateTime.TryParseExact(this.EgkResult?.PersoenlicheVersichertendaten?.Versicherter?.Person?.Geburtsdatum,"yyyyMMdd",CultureInfo.InvariantCulture,DateTimeStyles.None,out result) ? result : (DateTime?)null);

@DavidStania
Copy link
Author

Thank you!
I didn't saied, that there is an problem with this library. I only saied, that I got exceptions by reading the birthday. You did a great job by creating this library. Without your lib, i couldn't ready any card. And with you solution now, i hope other users will get less reading/interpretation problems by reading some cards. Thats github! Working together for making good code!
Best regards!

@Kaupisch-IT Kaupisch-IT changed the title G2.1 cards not working Data formats differ from each other Jan 25, 2022
@Kaupisch-IT Kaupisch-IT changed the title Data formats differ from each other Date formats ("Geburtsdatum") differ from each other Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants