Skip to content

Instantly share code, notes, and snippets.

@molsches
Created October 13, 2014 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molsches/5726163120035b88141e to your computer and use it in GitHub Desktop.
Save molsches/5726163120035b88141e to your computer and use it in GitHub Desktop.
{
"visit": {
"assessment_text": "Benign positional vertigo",
"clinic": {
"id": 52,
"name": "MN Test Clinic"
},
"clinical_protocol": {
"cpid": 3,
"description": "Motion Sickness"
},
"created_at": "2014-08-20 15:01:14 -0500",
"doctor": {
"full_name": "John Update",
"id": 3
},
"doctor_answers": {
"c12": "yes",
"c2": "no",
"patient_age": 26,
"patient_dob": "1988-04-25",
"patient_first_name": "Derek",
"patient_gender": "male",
"patient_name": "Derek",
"patient_type_text": "When asked the question \"Are you a clinic patient?\", Derek responded \"Yes\".",
"preparers_name": "Derek",
"promo_code": "no",
"q108": "no",
"q14": "motionsicknessprevention",
"q18": "true",
"q20": "yes",
"q216": "threedays",
"q22": "no",
"q224": "no",
"q226": "no",
"q234": "no",
"q238": "no",
"q24": "no",
"q254": "no",
"q26": "no",
"q28": "no",
"q280": "yes",
"q284": "no",
"q32": "no",
"q362": "true",
"q364": "no",
"q366": "no",
"q38": "true",
"q40": "yes",
"q42": "no",
"q426": "no",
"q428": "yes",
"q44": "no",
"q456": "no",
"q46": "no",
"q466": "no",
"q48": "no",
"q50": "no",
"q54": "no",
"q78": "no",
"q80": "no",
"q84": "no",
"q90": "no",
"q94": "no",
"sick_member_id": 1103
},
"finished_at": "2014-08-20 15:02:03 -0500",
"global_screen_out_accepted": "2014-08-20 15:01:23 -0500",
"icd_code": "386.11",
"id": 1634,
"patient_answers": {
"patient_age": 26,
"patient_dob": "1988-04-25",
"patient_first_name": "Derek",
"patient_gender": "male",
"patient_name": "Derek",
"patient_type_text": "When asked the question \"Are you a clinic patient?\", Derek responded \"Yes\".",
"preparers_name": "Derek",
"q108": "no",
"q14": "motionsicknessprevention",
"q18": "true",
"q20": "yes",
"q216": "threedays",
"q22": "no",
"q224": "no",
"q226": "no",
"q24": "no",
"q26": "no",
"q28": "no",
"q32": "no",
"q362": "true",
"q364": "no",
"q366": "no",
"q38": "true",
"q40": "yes",
"q42": "no",
"q428": "yes",
"q44": "no",
"q456": "no",
"q46": "no",
"q466": "no",
"q48": "no",
"q50": "no",
"q54": "no",
"q78": "no",
"q80": "no",
"q84": "no",
"q90": "no",
"q94": "no",
"sick_member_id": 1103
},
"patient_id": 1103,
"patient_name": "Derek Rockwell",
"prescriptions": [
{
"drug_description": "doxylamine/pyridoxine (Diclegis) 10-10mg oral tablet 10 tablets, 10 days supply. Take two tablets at bedtime days 1 and 2. may add 1 tab in am and 1 tab midafternoon up to max of 4 tablets per day. Refills: 0, Refill as needed: no, Allow substitutions: yes",
"id": 2620,
"pharmacy_id": null,
"send_to_pharmacy_on": null,
"visit_id": 1634
}
],
"promo_code_id": 1,
"reason_for_visit": "Motion sickness prevention",
"state": "prescriptions_unsent",
"sub_state": "active",
"submitted_at": "2014-08-20 15:02:37 -0500",
"tos_accepted": "2014-08-20 15:01:20 -0500",
"updated_at": "2014-08-20 15:02:48 -0500"
},
"report": {
"addenda": [],
"assessment_text": "Benign positional vertigo",
"created_at": "2014-08-20 15:02:37 -0500",
"doctor_summary": "Dear Derek , <p> Based upon the information you provided, you most likely have <b>Benign Positional Vertigo (another term for motion sickness)</b>. <p>I am prescribing: <p><b>Diclegis (doxylamine/ pyridoxine)</b>. Take 2 at bedtime days 1 and 2. May add 1 in am and 1 midafternoon up to max of 4 tabs per day.<br> <p>Once motions sickness symptoms start, it can take 36-72 hours to feel better, even if the motion has stopped. <p>It is easier to prevent motion sickness, than to relieve the symptoms after they start. For prevention or mild symptoms try the following:<ul><li>Eat a few dry soda crackers.</li><li>Sip on small amounts of clear, carbonated beverages such as ginger ale</li><li>Get fresh air</li><li>Lie down or keep your head still</li><li>Sit or lay in the most stable area of the vehicle. In a plane, try to sit over a wing. When in a car, you should be the driver. If you cannot drive, you should be the front seat passenger and concentrate on the horizon. When traveling by ship, the most stable area is near the middle, so try to book a cabin in that area. You should also stay on the deck looking at the horizon or lay down your cabin or in another area near the center of the ship.</li></ul> Do <b>NOT</b> combine over the counter motion-sickness medications with your prescription medications. <p>Please seek medical attention If you have taken steps to help prevent motion sickness, and you develop active motion sickness, your motion sickness does not resolve, you develop new or concerning symptoms (such as headache, weakness), or you develop nausea and vomiting and you are unable to keep down fluids.",
"icd_code": "386.11",
"id": 484,
"patient_info": "Derek is a 26 year old ( DOB: 1988-04-25 } male who initiated an eMedicine visit<b> for motion sickness prevention. </b> <p>He plans to travel by airplane. Treatment is requested for<b> 3-4 days</b>. During this time Derek expects to drive a car, boat, or jet ski.<p>Derek has not experienced motion sickness before. He does not have a history of migraines. Derek denies hypertension. <p>The patient denies taking potassium or vitamin c supplements. He also denies glaucoma, currently experiencing dizziness, nausea, a recent concussion or head injury, tinnitus, previous diagnosis or treatment for stroke or neurological disorder, and generally feeling ill on a regular basis. <p><h3>Current Medications:</h3><p><p><h3>Allergies:</h3><p>NKDA",
"prescriptions": [
"doxylamine/pyridoxine (Diclegis) 10-10mg oral tablet 10 tablets, 10 days supply. Take two tablets at bedtime days 1 and 2. may add 1 tab in am and 1 tab midafternoon up to max of 4 tablets per day. Refills: 0, Refill as needed: no, Allow substitutions: yes"
],
"updated_at": "2014-08-20 15:02:37 -0500"
},
"order_transaction": {
"action": "authorize",
"amount": 500,
"brand": "visa",
"description": "ZIP(visit) #1611 to MN Test Clinic",
"last_four": "8477",
"message": "This transaction has been approved.",
"params": {
"action": "AUTH_ONLY",
"authorization_code": "5YEYSB",
"avs_result_code": "Y",
"card_code": "P",
"cardholder_authentication_code": "2",
"response_code": 1,
"response_reason_code": "1",
"response_reason_text": "This transaction has been approved.",
"transaction_id": "2216716336"
},
"success": true,
"transaction_id": "2216716336",
"visit": {
"clinic_address": {
"address1": "2722 Pleasant Ave",
"address2": null,
"city": "Minneapolis",
"country": "USA",
"id": 53,
"latitude": 44.9528898,
"longitude": -93.2830037,
"phone": null,
"state": "MN",
"zip": "55408"
},
"clinic_name": "MN Test Clinic",
"created_at": "2014-07-22T12:53:44-05:00",
"customer_enterprise_name": "UAB",
"doctor_name": "John Update",
"doctor_title": "Dr",
"finished_at": "2014-07-22T12:55:35-05:00",
"id": 1611,
"patient_address": {
"address1": "2722 Pleasant Ave",
"address2": null,
"city": "Minneapolis",
"country": "USA",
"id": 19609,
"latitude": null,
"longitude": null,
"phone": null,
"state": "MN",
"zip": "55408"
},
"patient_name": "P\u00e9dra Rockwell",
"patient_phone": "15555555555",
"submitted_at": "2014-07-22T12:56:02-05:00",
"updated_at": "2014-07-25T13:55:21-05:00"
},
"visit_id": 1611
}
}
var json = JSON.parse(connectorMessage.getRawData());
var currentDate = DateUtil.getCurrentDate("yyyyMMddHHmmss");
//OK, duplicate for each field
channelMap.put("tmp", tmp);
//TODO: Placeholder for MRN/Zipnosis Patient ID
tmp['PID']['PID.2']['PID.2.1'];
tmp['PID']['PID.5']['PID.5.1'] = json.visit.doctor_answers.patient_name;
tmp['PID']['PID.5']['PID.5.2'] = json.visit.doctor_answers.patient_first_name;
tmp['PID']['PID.7']['PID.7.1'] = DateUtil.convertDate("yyyy-MM-dd","yyyyMMddHHmmss" , json.visit.doctor_answers.patient_dob);
//Before we parse gender, let's ensure it has a length
if (json.visit.doctor_answers.patient_gender.length >= 1){
var sex = json.visit.doctor_answers.patient_gender.charAt(0).toUpperCase();
if (sex == "F" || sex == "M" || sex == "O") {
tmp['PID']['PID.8']['PID.8.1'] = sex;
}
else {
tmp['PID']['PID.8']['PID.8.1'] = "O";
}
}
//Otherwise, assume that we don't know
else {
tmp['PID']['PID.8']['PID.8.1'] = "O"
}
//Address & Phone
tmp['PID']['PID.11']['PID.11.1'] = json.order_transaction.visit.patient_address.address1;
tmp['PID']['PID.11']['PID.11.2'] = json.order_transaction.visit.patient_address.address2;
tmp['PID']['PID.11']['PID.11.3'] = json.order_transaction.visit.patient_address.city;
tmp['PID']['PID.11']['PID.11.4'] = json.order_transaction.visit.patient_address.state;
tmp['PID']['PID.11']['PID.11.5'] = json.order_transaction.visit.patient_address.zip;
tmp['PID']['PID.14']['PID.14.1'] = json.order_transaction.visit.patient_phone;
//Just one entry in the PV1 field
tmp['PV1']['PV1.19']['PV1.19.1'] = json.visit.id;
tmp['TXA']['TXA.4']['TXA.4.1'] = DateUtil.convertDate("yyyy-MM-dd HH:mm:ss Z","yyyyMMddHHmmss" , json.visit.finished_at);
//Some string splitting. Separated JSON might be better if possible
tmp['TXA']['TXA.5']['TXA.5.3'] = json.visit.doctor.full_name.split(" ")[0];
tmp['TXA']['TXA.5']['TXA.5.2'] = json.visit.doctor.full_name.split(" ")[1];
tmp['TXA']['TXA.6']['TXA.6.1'] = DateUtil.convertDate("yyyy-MM-dd HH:mm:ss Z","yyyyMMddHHmmss" , json.visit.finished_at);
tmp['TXA']['TXA.7']['TXA.7.1'] = DateUtil.convertDate("yyyy-MM-dd HH:mm:ss Z","yyyyMMddHHmmss" , json.visit.finished_at);
tmp['TXA']['TXA.8']['TXA.8.1'] = DateUtil.convertDate("yyyy-MM-dd HH:mm:ss Z","yyyyMMddHHmmss" , json.visit.updated_at);
tmp['TXA']['TXA.5']['TXA.9.3'] = json.order_transaction.visit.doctor_name.split(" ")[0];
tmp['TXA']['TXA.5']['TXA.9.2'] = json.order_transaction.visit.doctor_name.split(" ")[1];
//TODO: How are you generating unique document number?
//Start assembling Note segments
tmp['OBX'][0]['OBX.5']['OBX.5.1'] = "Date: " + DateUtil.convertDate("yyyy-MM-dd HH:mm:ss Z","yyyyMMddHHmmss" , json.visit.finished_at);
tmp['OBX'][1]['OBX.5']['OBX.5.1'] = "Clinician: " + json.visit.doctor.full_name;
//TODO: NPI lookup
tmp['OBX'][2]['OBX.5']['OBX.5.1'] = "Clinician NPI: " + "";
tmp['OBX'][3]['OBX.5']['OBX.5.1'] = "Patient: " + json.visit.doctor_answers.patient_first_name;
tmp['OBX'][4]['OBX.5']['OBX.5.1'] = "Patient DOB" + json.visit.doctor_answers.patient_dob;
tmp['OBX'][5]['OBX.5']['OBX.5.1'] = "Patient Address: " + json.order_transaction.visit.patient_address.address1 + ", " + json.order_transaction.visit.patient_address.city + ", " + json.order_transaction.visit.patient_address.state + " " + json.order_transaction.visit.patient_address.zip;
tmp['OBX'][6]['OBX.5']['OBX.5.1'] = "Patient Phone: " + json.order_transaction.visit.patient_phone;
tmp['OBX'][7]['OBX.5']['OBX.5.1'] = "Visit Protocol: " + json.visit.clinical_protocol.description;
tmp['OBX'][8]['OBX.5']['OBX.5.1'] = "Patient Summary: " + json.report.patient_info;
tmp['OBX'][9]['OBX.5']['OBX.5.1'] = "Clinician Response: " + json.report.doctor_summary;
//I think assessment_text is a plain text Dx
tmp['OBX'][10]['OBX.5']['OBX.5.1'] = "Diagnosis: " + json.report.assessment_text;
tmp['OBX'][11]['OBX.5']['OBX.5.1'] = "Diagnosis ICD: " + json.report.icd_code;
//TODO: Where is this located?
tmp['OBX'][12]['OBX.5']['OBX.5.1'] = "Additional Clinician Notes: " + "";
for (i = 0; i < json.report.prescriptions.length; i++){
//We'll probably need to exlude OBX sections in the future when we do null checking
//For now, start the counter where it begins
var segmentNum = 13;
tmp['OBX'][segmentNum]['OBX.5']['OBX.5.1'] = "Prescription: " + json.report.prescriptions[i];
}
responseMap.put("values ", SerializerFactory.getSerializer('HL7V2').fromXML(tmp).toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment