Announcement

Collapse
No announcement yet.

CCDA-JSON error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CCDA-JSON error

    I'm trying to parse CCDA to JSON without using MDHT libraries I'm facing an error in structure of JSON this is my code.

    if(msg['templateId'][0]['@root'].length()!=0 && msg['templateId'][0]['@root']=="2.16.840.1.113883.10.20.22.1.1")
    {
    var obj1={"Demographics":
    {"date":msg['effectiveTime']['@value'].toString()},
    {"title":msg['title'].toString()},
    {"author":{
    "name":{
    "prefix":msg['author']['assignedAuthor']['assignedPerson']['name']['prefix'].toString()},
    {"given":msg['author']['assignedAuthor']['assignedPerson']['name']['given'].toString()},
    {"family":msg['author']['assignedAuthor']['assignedPerson']['name']['family'].toString()},
    {"address":[
    "street":msg['author']['assignedAuthor']['addr']['streetAddressLine'].toString()],
    {"city":msg['author']['assignedAuthor']['addr']['city'].toString()},
    {"state":msg['author']['assignedAuthor']['addr']['state'].toString()},
    {"postalcode":msg['author']['assignedAuthor']['addr']['postalCode'].toString()},
    {"country":msg['author']['assignedAuthor']['addr']['country'].toString()},
    }

    }
    }
    }
    }
    var ob1= JSON.stringify(obj1);
    logger.info(ob1);


    Im getting the error in "Error on line 5: invalid property id" could anyone help me findout the problem?

    Mirth Interface Engineer
    AWS DevOps

  • #2
    You're creating that object incorrectly. Each property of an object needs to be given a proper ID. You're doing that correctly for "Demographics", but almost everything else after that is incorrect. Go here to learn about what JSON is and how it's used: http://json.org/. Although technically what you're creating is a JavaScript Object, not JSON, it will still help.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment

    Working...
    X