Social security card information reading

Posted by daftdog on Fri, 12 Jun 2020 12:29:19 +0200

In recent years, with the popularization and development of medical intelligent self-service terminal, the unattended self-service terminal realizes the patient's independent appointment, registration, report query and other services. It is not only convenient for patients to see a doctor, but also improves patients' satisfaction. It also reduces the hospital's personnel investment in appointment, registration, report printing, query and other links, and improves the work efficiency.

Social security card reader is an important information collection device on the medical intelligent self-service terminal to realize patients' independent appointment, registration, report query and other businesses. In addition, the public can use the social security card to handle the functions of medical purchase, medical insurance settlement, hospitalization and so on. In short, social security card is not a medical insurance card, but it can be used as a medical insurance card. Social security card is the progress of social security system! It includes many contents, such as medical insurance, endowment insurance, unemployment insurance, maternity insurance, work-related injury insurance and so on. In addition, it has certain financial functions.

    The social security card reader is in line with the social security (personal) card reader specification formulated by the Ministry of labor and social security. When designing the social security card reader or the social security card reader module embedded in the self-service terminal equipment, it needs to meet the requirements of the social security (personal) card reader specification. At the same time, it also needs to be flexible to the equipment communication interface according to the actual application scenarios Extension. For example, some self-service terminal devices are Android and linux systems. This requires social security card reader manufacturers to provide corresponding API interface functions for driver and application development.

Here we take NTS-L7-2IN1 social security card reader as the development demonstration, in windows operating system, we use C ා development language to read social security card information. First of all, we need to understand the function and structure of social security card reader. The simple way is to read the product introduction.

L7-2IN1 has a contact smart card base that conforms to ISO7816 protocol standard, supports ISO14443A and B protocol contactless smart cards, and provides multiple operating system secondary development API interfaces. The L7-2IN1 dual interface smart card reader has two SAM card bases built in, which can confirm the identity security of the device and support the reading of social security card. Through RS232 interface or USB port to realize the connection with PC and related equipment. USB adopts non drive technology, which is convenient for users to install and use. It supports multi card operation, which can be used for security card issuing and high security requirements. The driver development package of various platforms is provided at random, and the accompanying demonstration program realizes all functions of accessing the RF card, with automatic card test operation.
L7-2IN1 smart card reader is a necessary front-end processing equipment for the development of IC card related products and system integration. Its rich and perfect interface functions can be easily applied to various smart card management application systems such as industrial and commercial, telecommunication, postal, tax, banking, insurance, medical, conference sign in, Internet bar management, oil filling station, parking lot, etc.

Comply with ISO7816 protocol, there are two PSAM card bases, hardware is satisfied.

Next, we develop and test according to the API provided by social security card reader.

/ / public information is stored in the social security card structure
  

 public struct SocialSecurityCardStruct
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        public byte[] szCardNo;//Only 9 characters
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        public byte[] szName;//Generally 4-8 characters, considering the number of special names
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        public byte[] szSSCNo;//Generally, the ID number is 18 characters
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
        public byte[] szSex;//Gender
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        public byte[] szNation;//Some ethnic names are a little long
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        public byte[] szBankNo;//Corresponding bank card number
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        public byte[] szSignedDate;//Date of issue
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        public byte[] szValidityEndDate;//Due date
    }

/**
* access 7816 for social security card number
         * @param nDeviceHandle
* @ param psttssocialsecuritycard information structure pointer
* @ return true = success
         */
        [DllImport("LotusCardDriver.dll", EntryPoint = "LotusCardGetSocialSecurityInfoBy7816", SetLastError = true,
             CharSet = CharSet.Auto, ExactSpelling = false,
             CallingConvention = CallingConvention.StdCall)] 

		public static extern int  LotusCardGetSocialSecurityInfoBy7816(int  nDeviceHandle, ref SocialSecurityCardStruct  psttSocialSecurityCard);

 

bResult =  CLotusCardDriver.LotusCardGetSocialSecurityInfoBy7816(nHandle, ref sttSocialSecurityCard);
			if(bResult!=1)
			{
				AddLog("Failed to get social security card information!");
				return;
			}
			AddLog("implement LotusCardGetSocialSecurityInfoBy7816 success!");
			AddLog("Social Security Card No:"+ Encoding.UTF8.GetString(sttSocialSecurityCard.szCardNo));
			AddLog("Social Security No:"+ Encoding.UTF8.GetString(sttSocialSecurityCard.szSSCNo));
			AddLog("full name:"+ Encoding.GetEncoding("GB2312").GetString(sttSocialSecurityCard.szName));
			strTmp = Encoding.UTF8.GetString(sttSocialSecurityCard.szSex).Trim();
			if("1".Equals(strTmp.Substring(0,1)))
			{
				AddLog("Gender: Male");
			}
			else
			{
				AddLog("Gender: Female");
			}
			AddLog("nation:"+ Encoding.GetEncoding("GB2312").GetString(sttSocialSecurityCard.szNation));
			AddLog("Date of issue:"+ Encoding.UTF8.GetString(sttSocialSecurityCard.szSignedDate));
			AddLog("due date:"+ Encoding.UTF8.GetString(sttSocialSecurityCard.szValidityEndDate));
		}

The card reading effect is as follows:

Here, only the social security card information is read. Because the PSAM card is not inserted in the machine, the PSAM card needs to be applied for. Therefore, there is no further interaction of PSAM card security information, no development test of transaction and deduction. Read the social security card information C ා example source code above to the resource center.

Topics: encoding Android Linux Windows