| Algorithm 2. Mapping Algorithm (Transform JSON data to EMR format). |
| 1: Function void main () 2: Create Tables in MySQL database, once table for each resources type data and link these tables 3: Resource = Read (FHIR API resource) 4: Templet = Resource-Templet (Resource) 5: counter = Count(Temple) 6: while (counter > 0) do 7: If (Templet.Tag == Resource.Tag) then 8: Table. attribute = Resource.Tag.Value 9: end if 10: counter = counter − 1 11: end while 12: end function ** main function ** 13: ** This function used to compare Resource type ** 14: Function string Resource-Templet (Resource type) 15: ** Create one dimension array for all resources and stored their tags. This is pre-defined templet for all resources ** 16: define string Result 17: String Array List = [Patient, Condition, AllergyIntolerance, Practitioner, ServiceRequest, DiagnosticReport, Appointment, ………] 18: String Patient [] = [“identifier”, “name”, “telecom”, “address“, “gender” …………] 19: String Condition [] = [“identifier”, “clinical status”, “category”, “code” …………] 20: String AllergyIntolerance [] = [“identifier”, “clinical status”, “code”, …………] 21: String Practitioner [] = [“identifier”, “name”, “address”, “qualification”, …………] 22: String DiagnosticReport [] = [“identifier”, “baseOn” status”, “category”, “code”,…….…] 23: String ServiceRequest [] = [“identifier”, “baseOn” status”, “category”, “requester”,……] 24: String Appointment [] = [“identifier”, “status”, “appointmentType”, “priority”, …………] 25: If (type == Patient) then 26: Result = “Patient” 27: else if (type == Condition) then 28: Result = “Condition” 29: else if (type == AllergyIntolerance) then 30: Result = “AllergyIntolerance” 31: else if (type == Practitioner) then 32: Result = “Practitioner” 33: else if (type == DiagnosticReport) then 34: Result = ” DiagnosticReport” 35: else if (type == ServiceRequest) then 36: Result = “ServiceRequest” 37: else 38: Result = “Appointment” 39: end if 40: return (Result) 41: end function ** Resource-Templet function ** 42: ** This function used to count the total number of tags in the resource ** 43: Function int Count(String Templet) 44: int counter = Templet.length 45: return (counter) 46: end function ** Count function ** |