web stats
JSON to CSV - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2018, 08:12 AM
srujanreddy srujanreddy is offline
What's HL7?
 
Join Date: Sep 2018
Posts: 2
srujanreddy is on a distinguished road
Default JSON to CSV

Dear Mirth,

I am trying to convert JSON to CSV. I have written the attached code (code.txt). which is giving me the attached output (output.zip) however i would like to get the output as (expectedoutput.zip).

Please help me to correct my code.

Input.

{
"resourceType": "Patient",
"text": {
"status": "generated"
},
"identifier": [
{
"use": "usual",
"type": {
"coding": [
{
"system": "http://hl7.org/fhir/v2/0203"
}
]
},
"value": "12345",
"period": {
"start": "2001-05-06"
},
"assigner": {
"display": "Acme Healthcare"
}
}
],
"active": true,
"name": [
{
"use": "official",
"family": "Chalmers",
"given": [
"Peter",
"James"
]
},
{
"use": "usual",
"given": [
"Jim"
]
},
{
"use": "maiden",
"family": "Windsor",
"given": [
"Peter",
"James"
],
"period": {
"end": "2002"
}
}
],
"telecom": [
{
"use": "home"
},
{
"system": "phone",
"value": "(03) 5555 6473",
"use": "work",
"rank": 1
},
{
"system": "phone",
"value": "(03) 5555 8834",
"use": "old",
"period": {
"end": "2014"
}
}
],
"gender": "male",
"_birthDate": {
"extension": [
{
"valueDateTime": "1974-12-25T14:35:45-05:00"
}
]
},


"managingOrganization": {
"reference": "Organization/1"
}
}
Attached Files
File Type: zip expectedoutput.zip (558 Bytes, 2 views)
File Type: zip output.zip (513 Bytes, 1 views)

Last edited by srujanreddy; 10-07-2018 at 10:23 PM.
Reply With Quote
  #2  
Old 10-05-2018, 02:02 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 476
agermano is on a distinguished road
Default

It's not possible to write generic code that will produce your expected results. You'll have to build a transformer and actually map things where you want them to go.
Reply With Quote
  #3  
Old 10-19-2018, 09:21 AM
srujanreddy srujanreddy is offline
What's HL7?
 
Join Date: Sep 2018
Posts: 2
srujanreddy is on a distinguished road
Default

@Agermano, Can you please share the channel mapping to build such transformer.
Reply With Quote
  #4  
Old 10-19-2018, 11:22 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 476
agermano is on a distinguished road
Default

You may want to start with the Mirth User Guide. You can get it from the downloads page.

https://www.nextgen.com/products-and...gine-Downloads
Reply With Quote
  #5  
Old 10-19-2018, 01:52 PM
Shamil Shamil is offline
OBX.3 Kenobi
 
Join Date: May 2013
Posts: 143
Shamil is on a distinguished road
Default

The easiest would be to put all elements that you'd like to appear in CSV into the channel map and list them in needed sequence in a File Writer Template field separating with the semicolon.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:23 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Mirth Corporation