« Tooltips for the File… | Home | Login in FileMaker we… »

Read patient name from Swiss Health Card

Here a snippet from MBS Plugin training today. The health cards used by people in Switzerland (VVK 832.105 und eCH-0064) include various interesting values to identify the patient like his name, ID and the health insurance name. We can read the values via several standard readers. If you like, you can read various values from file 2F06 with birth date, name, card holder ID and 2F07 with insurancer name, card ID and expiration date. Here a short sample script to read the name of the patient:
 

# Initialize smart card:

Set Variable [ $$SmartCard ; Value: MBS( "SmartCard.Init" ) ] 

If [ MBS("IsError") ] 

Show Custom Dialog [ "Failed to initialize SmartCard" ; $$SmartCard ] 

Exit Script [ Text Result:    ] 

End If

# Connect to a reader

Set Variable [ $reader ; Value: "Identiv SCR3310 uTrust 2700 R" ] 

Set Variable [ $r ; Value: MBS( "SmartCard.Connect"; $$SmartCard; $Reader; "Shared"; "any" ) ] 

If [ MBS("IsError") ] 

Show Custom Dialog [ "Connect failed" ; $r ] 

Exit Script [ Text Result:    ] 

End If

# Read file from smartcard with APDU protocol.

# Read record with name

Set Variable [ $result ; Value: MBS( "SmartCard.ReadFile"; $$SmartCard; "2F06") ] 

If [ MBS("IsError") ] 

Set Field [ Card::Status ; $result ] 

Show Custom Dialog [ "Error" ; $result ] 

Exit Script [ Text Result:    ] 

End If

# Pick result

Set Variable [ $filedata ; Value: Middle ( $result ; 5; Length($result) ) ] 

# Split in values

Set Variable [ $json ; Value: MBS("SmartCard.SplitValues"; $FileData) ] 

# Get item 128, which is full name

Set Variable [ $name ; Value: JSONGetElement ( $json ; "128" ) ] 

Set Variable [ $NameList ; Value: Substitute($name; ", "; ¶) ] 

Set Variable [ $LastName ; Value: GetValue($nameList; 1) ] 

Set Variable [ $FirstName ; Value: GetValue($nameList; 2) ] 

Show Custom Dialog [ "Name" ; $FirstName & " " & $LastName ] 

Set Variable [ $r ; Value: MBS( "SmartCard.DisConnect"; $$SmartCard; "Eject") ] 


This connects to reader, reads the rigth file, decodes values and shows the name of the patient. Other values are available in the json object.
Claris FileMaker Plugin
08 03 19 - 15:07