web stats
response transformer msg processing - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-06-2016, 04:51 PM
rutledj rutledj is offline
Mirth Guru
 
Join Date: Nov 2010
Location: North Carolina
Posts: 399
rutledj is on a distinguished road
Default response transformer msg processing

Could someone show me how to parse a jason message that has repeating fields in a response transformer? I'm basically trying to understand the equivalent of iterating over all segments.
Reply With Quote
  #2  
Old 02-10-2016, 03:47 AM
mcalKno mcalKno is offline
 
Join Date: Apr 2015
Location: Pennsylvania
Posts: 247
mcalKno is on a distinguished road
Default

Quote:
Originally Posted by rutledj View Post
Could someone show me how to parse a jason message that has repeating fields in a response transformer? I'm basically trying to understand the equivalent of iterating over all segments.
example message you need to parse through?
Reply With Quote
  #3  
Old 02-11-2016, 07:25 PM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 255
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

It really depends on the response message, but if this is your JSON:

Code:
{
"result_count":3, "results":[
{
    "addresses": [
        {
            "address_1": "2840 LONG BEACH BLVD", 
            "address_2": "#440", 
            "address_purpose": "LOCATION", 
            "address_type": "DOM", 
            "city": "LONG BEACH", 
            "country_code": "US", 
            "country_name": "United States", 
            "fax_number": "562-988-0309", 
            "postal_code": "908061590", 
            "state": "CA", 
            "telephone_number": "562-424-9444"
        }, 
        {
            "address_1": "3521 LOMITA BLVD STE 103", 
            "address_2": "", 
            "address_purpose": "MAILING", 
            "address_type": "DOM", 
            "city": "TORRANCE", 
            "country_code": "US", 
            "country_name": "United States", 
            "fax_number": "310-534-9132", 
            "postal_code": "905055041", 
            "state": "CA", 
            "telephone_number": "310-534-9131"
        }
    ], 
    "basic": {
        "credential": "M.D.", 
        "enumeration_date": "2005-05-27", 
        "first_name": "RONALD", 
        "gender": "M", 
        "last_name": "SMITH", 
        "last_updated": "2012-10-17", 
        "middle_name": "W", 
        "name": "SMITH RONALD", 
        "name_prefix": "DR.", 
        "sole_proprietor": "YES", 
        "status": "A"
    }, 
    "created_epoch": 1117152000, 
    "enumeration_type": "NPI-1", 
    "identifiers": [
        {
            "code": "08", 
            "desc": "MEDICARE PIN", 
            "identifier": "AV793Z", 
            "issuer": "", 
            "state": "CA"
        }, 
        {
            "code": "05", 
            "desc": "MEDICAID", 
            "identifier": "00A228781", 
            "issuer": "", 
            "state": "CA"
        }, 
        {
            "code": "08", 
            "desc": "MEDICARE PIN", 
            "identifier": "WA22878D", 
            "issuer": "", 
            "state": "CA"
        }
    ], 
    "last_updated_epoch": 1350432000, 
    "number": 1801899398, 
    "other_names": [], 
    "taxonomies": [
        {
            "code": "207XX0004X", 
            "desc": "Orthopaedic Surgery Foot and Ankle Surgery", 
            "license": "A82278", 
            "primary": true, 
            "state": "CA"
        }
    ]
},{
    "addresses": [
        {
            "address_1": "1212 S MAIN ST", 
            "address_2": "", 
            "address_purpose": "LOCATION", 
            "address_type": "DOM", 
            "city": "SALINAS", 
            "country_code": "US", 
            "country_name": "United States", 
            "postal_code": "939012260", 
            "state": "CA", 
            "telephone_number": "831-422-7777"
        }, 
        {
            "address_1": "PO BOX 2300", 
            "address_2": "", 
            "address_purpose": "MAILING", 
            "address_type": "DOM", 
            "city": "SALINAS", 
            "country_code": "US", 
            "country_name": "United States", 
            "postal_code": "939022300", 
            "state": "CA", 
            "telephone_number": "831-622-8400"
        }
    ], 
    "basic": {
        "credential": "MD", 
        "enumeration_date": "2005-05-31", 
        "first_name": "LINDA", 
        "gender": "F", 
        "last_name": "SMITH", 
        "last_updated": "2007-07-08", 
        "name": "SMITH LINDA", 
        "sole_proprietor": "NO", 
        "status": "A"
    }, 
    "created_epoch": 1117497600, 
    "enumeration_type": "NPI-1", 
    "identifiers": [
        {
            "code": "02", 
            "desc": "MEDICARE UPIN", 
            "identifier": "A53675", 
            "issuer": "", 
            "state": "CA"
        }, 
        {
            "code": "04", 
            "desc": "MEDICARE ID-Type Unspecified", 
            "identifier": "00G62080", 
            "issuer": "", 
            "state": "CA"
        }
    ], 
    "last_updated_epoch": 1183852800, 
    "number": 1508869983, 
    "other_names": [], 
    "taxonomies": [
        {
            "code": "207R00000X", 
            "desc": "Internal Medicine", 
            "license": "G62080", 
            "primary": true, 
            "state": "CA"
        }
    ]
},{
    "addresses": [
        {
            "address_1": "57463 TWENTY-NINE PALMS HIGHWAY", 
            "address_2": "SUITE 203", 
            "address_purpose": "LOCATION", 
            "address_type": "DOM", 
            "city": "YUCCA VALLEY", 
            "country_code": "US", 
            "country_name": "United States", 
            "fax_number": "760-228-1897", 
            "postal_code": "92284", 
            "state": "CA", 
            "telephone_number": "760-228-1855"
        }, 
        {
            "address_1": "57463 TWENTY-NINE PALMS HIGHWAY", 
            "address_2": "SUITE 203", 
            "address_purpose": "MAILING", 
            "address_type": "DOM", 
            "city": "YUCCA VALLEY", 
            "country_code": "US", 
            "country_name": "United States", 
            "fax_number": "760-228-1897", 
            "postal_code": "92284", 
            "state": "CA", 
            "telephone_number": "760-228-1855"
        }
    ], 
    "basic": {
        "credential": "M.D.", 
        "enumeration_date": "2005-06-01", 
        "first_name": "ELDENE", 
        "gender": "M", 
        "last_name": "SMITH", 
        "last_updated": "2013-02-14", 
        "middle_name": "ARNE", 
        "name": "SMITH ELDENE", 
        "name_prefix": "DR.", 
        "sole_proprietor": "YES", 
        "status": "A"
    }, 
    "created_epoch": 1117584000, 
    "enumeration_type": "NPI-1", 
    "identifiers": [
        {
            "code": "04", 
            "desc": "MEDICARE ID-Type Unspecified", 
            "identifier": "00A389440", 
            "issuer": "", 
            "state": "CA"
        }, 
        {
            "code": "02", 
            "desc": "MEDICARE UPIN", 
            "identifier": "A28767", 
            "issuer": "", 
            "state": "CA"
        }, 
        {
            "code": "05", 
            "desc": "MEDICAID", 
            "identifier": "00A389440", 
            "issuer": "", 
            "state": "CA"
        }
    ], 
    "last_updated_epoch": 1360800000, 
    "number": 1164424479, 
    "other_names": [], 
    "taxonomies": [
        {
            "code": "174400000X", 
            "desc": "Specialist", 
            "license": "A38944", 
            "primary": true, 
            "state": "CA"
        }
    ]
}
]}
You can use a transformer like this to get the array of repeating "first_name" in "results":

Code:
for (var i = 0; i < msg['results'].length; i++) 
	{
	logger.info("num: " + i + " : " + msg['results'][i]['basic']['first_name']);
	}
Maybe not the most perfect example ever, but hope it helps! Like mcalKno said, if you post your specific JSON, maybe we can get you closer!
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

Last edited by jackwhaines; 02-11-2016 at 07:55 PM. Reason: Used NPI data
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 10:11 PM.


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