Hi Kumart,
If you know the format of the messages you’re looking to parse it should be relatively straight forward to pull out the data you’re looking for.
My understanding is HL7 isn’t a very standardized “standard” two systems both using HL7 to pass messages wouldn’t be able to talk to each other unless they had a shared agreement on how to package data inside the message.
You should be able to create a new patient by inserting a new row with the data you pulled from the message into the patient_data table in the database. For medical coding, do you mean SNOMED, ICD, etc.? You’ll need to know the patient ID you just created and use that to add a new row to a different table with different values depending on what medical code is describing, medication, allergy, medical issue, surgery, etc. and provide the patient ID the medical issue is associated with.
Hope this helps