├── .classpath ├── .gitignore ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── README.md ├── bin └── com │ └── appliedinformatics │ └── cdaapi │ ├── CDAAPIHandler.class │ ├── CDAResource.class │ ├── TestClient.class │ ├── constructor │ └── parser │ ├── AllergyParser.class │ ├── CDAParser.class │ ├── CDAParserUtil.class │ ├── DemographicParser.class │ ├── MedicationParser.class │ ├── ProblemParser.class │ └── ResultParser.class ├── ccd_samples ├── PatientPortal8301.xml ├── PatientPortal8302.xml ├── PatientPortal8303.xml └── PatientPortal8304.xml ├── ext_lib ├── gson-2.2.3.jar ├── net.sourceforge.lpg.lpgjavaruntime_1.1.0.v200803061910.jar ├── org.apache.commons.lang_2.3.0.v201005080501.jar ├── org.eclipse.emf.common_2.5.0.v200906151043.jar ├── org.eclipse.emf.ecore.xmi_2.5.0.v200906151043.jar ├── org.eclipse.emf.ecore_2.5.0.v200906151043.jar ├── org.eclipse.ocl.ecore_1.3.0.v200905271400.jar ├── org.eclipse.ocl_1.3.0.v200905271400.jar ├── org.openhealthtools.mdht.emf.runtime_1.0.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.ccd.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.ccd_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.cdt.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.cdt_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.consol.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.consol_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.hitsp.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.hitsp_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.ihe.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.ihe_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.mu2consol.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.mu2consol_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.cda_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.hl7.datatypes.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.hl7.datatypes_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.hl7.rim.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.hl7.rim_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.hl7.vocab.source_1.2.0.201302191803.jar ├── org.openhealthtools.mdht.uml.hl7.vocab_1.2.0.201302191803.jar └── org.restlet.jar └── src └── com └── appliedinformatics └── cdaapi ├── CDAAPIHandler.java ├── CDAResource.java ├── TestClient.java ├── constructor ├── mu2parser ├── AllergyParser.java ├── CDAParser.java ├── CDAParserUtil.java ├── DateComparator.java ├── DemographicParser.java ├── MedicationParser.java ├── ProblemParser.java ├── ProcedureParser.java ├── ResultParser.java └── VitalSignParser.java └── parser ├── AllergyParser.java ├── CDAParser.java ├── CDAParserUtil.java ├── DemographicParser.java ├── MedicationParser.java ├── ProblemParser.java └── ResultParser.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .DS_Store 3 | CCDATest*.xml 4 | 1 5 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | cdaapi 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.6 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.6 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CCDA REST API 2 | ============= 3 | 4 | A CCDA REST API was developed to make it quick and super easy for developers to parse and retrieve information from CCDA documents. 5 | 6 | Here is the [demo site](http://ccdapi.appliedinformaticsinc.com/client_demo) 7 | 8 | API Operations 9 | -------------- 10 | 11 | 12 | **POST /bbplus** 13 | 14 | Add or update a patient record from a BlueButton+/CCDA file. 15 | 16 | *Parameters:* 17 | 18 | Inputs: 19 | 20 | * bbfile: An XML string representation of the BlueButton+ file in the CCDA format. If the same patient data is posted at a later date, the API updates the stored record with the updated information. The uniqueness is determined based on the MRN/Institution data in the XML (see example below). 21 | 22 | * op_format: Specify output format "xml" or "json" 23 | 24 | 25 | Output: 26 | 27 | * patient_id: An API-specific patient identifier token (string) that can be used to query further information for this patient. 28 | 29 | * status: The processing status of the XML ("processing", "completed", "failed"). 30 | 31 | 32 | **GET /bbplus/<patient_id>/<section>** 33 | 34 | Get specific section of the patient record 35 | 36 | 37 | *Parameters:* 38 | 39 | Input: 40 | 41 | * patient_id: The unique identifier of the patient record returned by the API on the POST of the BlueButton+ file. 42 | 43 | * section: The specific section to retrieve in the output. The section parameter can be any one of the following: 44 | 1. demographics 45 | 2. problems 46 | 3. medications 47 | 4. allergies 48 | 5. results 49 | 6. procedures [NotSupported] 50 | 7. encounters [NotSupported] 51 | 8. socialhistory [NotSupported] 52 | 53 | 54 | * op_format: Specify output format "xml" or "json" 55 | 56 | 57 | Output: 58 | 59 | * status: The processing status of the XML ("processing", "completed", "failed"). 60 | 61 | * patient_record: An XML or JSON representation of the requested section. The format of individual sections are described in the table. 62 | 63 | 64 | * * * 65 | 66 | Requirements 67 | ------------ 68 | - JDK 1.6 69 | - Eclipse Juno release or higher 70 | - Dependencies (included in the project) 71 | 72 | - MDHT Runtime 1.0.0.201302191803 73 | - Eclipse EMF Core 2.5 74 | - RESTlet 75 | - Gson 2.2.3 76 | 77 | 78 | * * * 79 | 80 | Installation/Set up 81 | ------------------- 82 | 1. Clone this repository onto your local 83 | 2. Import the directory as an Eclipse project. 84 | 3. Export as a "Runnable Jar" 85 | 4. Run the application as java -jar ccda-parser-runnable.jar 86 | 87 | 88 | * * * 89 | 90 | TODOs 91 | ----- 92 | - Add parsers for currently not supported sections 93 | - Add a creators to support creating a CCDA document using the REST query 94 | - Add authentication, rate throttling, logging capabilities 95 | 96 | 97 | * * * 98 | 99 | LICENSE 100 | ------- 101 | Copyright (c) 2013 by Applied Informatics Inc. Licensed under the [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) license. 102 | -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/CDAAPIHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/CDAAPIHandler.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/CDAResource.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/CDAResource.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/TestClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/TestClient.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/constructor/CDAConstructor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/constructor/CDAConstructor.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/parser/AllergyParser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/parser/AllergyParser.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/parser/CDAParser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/parser/CDAParser.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/parser/CDAParserUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/parser/CDAParserUtil.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/parser/DemographicParser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/parser/DemographicParser.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/parser/MedicationParser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/parser/MedicationParser.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/parser/ProblemParser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/parser/ProblemParser.class -------------------------------------------------------------------------------- /bin/com/appliedinformatics/cdaapi/parser/ResultParser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/bin/com/appliedinformatics/cdaapi/parser/ResultParser.class -------------------------------------------------------------------------------- /ccd_samples/PatientPortal8301.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | Good Health Clinic Continuity of Care Document 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Henry 19 | Levin 20 | the 7th 21 | 22 | 23 | 24 | 25 | 26 | 27 | Good Health Clinic 28 | 29 | 30 | 31 | 32 | 48 | 49 | 50 | 51 | 52 | 53 | Good Health Clinic 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | Good Health Clinic 62 | 63 | 64 | 65 | 66 | 76 | 77 | 78 | 79 | 80 | 17 Daws Rd. 81 | Blue Bell 82 | MA 83 | 02368 84 | 85 | 86 | 87 | 88 | Kenneth 89 | Ross 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | Henrietta 102 | Levin 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 119 | 120 | 121 | 122 | 123 | Dr. 124 | Robert 125 | Dolin 126 | 127 | 128 | 129 | 130 | Good Health Clinic 131 | 132 | 133 | 134 | 135 | 136 | 141 | 142 | 143 | 148 | 149 |
150 | 151 | 152 | 153 | Summary Purpose 154 | Transfer of care 155 |
156 |
157 | 162 | 163 |
164 | 165 | 166 | 167 | Payers 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 |
Payer namePolicy type / Coverage typeCovered party IDAuthorization(s)
Good Health InsuranceExtended healthcare / Self14d4a520-7aae-11db-9fe1-0800200c9a66Colonoscopy
187 |
188 |
189 |
190 | 195 | 196 |
197 | 198 | 199 | 200 | Advance Directives 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 217 | 218 | 221 | 222 | 223 |
DirectiveDescriptionVerificationSupporting Document(s)
Resuscitation status 215 | Do not resuscitate 216 | Dr. Robert Dolin, Nov 07, 1999 219 | Advance directive 220 |
224 |
225 |
226 |
227 | 232 | 233 |
234 | 235 | 236 | 237 | Functional Status 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 |
Functional ConditionEffective DatesCondition Status
Dependence on cane1998Active
Memory impairment1999Active
260 |
261 |
262 |
263 | 268 | 269 |
270 | 271 | 272 | 273 | Problems 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 |
ConditionEffective DatesCondition Status
Asthma1950Active
PneumoniaJan 1997Resolved
"Mar 1999Resolved
Myocardial InfarctionJan 1997Resolved
306 |
307 |
308 |
309 | 314 | 315 |
316 | 317 | 318 | 319 | Family history 320 | 321 | Father (deceased) 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 |
DiagnosisAge At Onset
Myocardial Infarction (cause of death)57
Hypertension40
340 | Mother (alive) 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 |
DiagnosisAge At Onset
Asthma30
355 |
356 |
357 |
358 | 363 | 364 |
365 | 366 | 367 | 368 | Social History 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 |
Social History ElementDescriptionEffective Dates
Cigarette smoking1 pack per day1947 - 1972
"None1973 -
Alcohol consumptionNone1973 -
396 |
397 |
398 |
399 | 404 | 405 |
406 | 407 | 408 | 409 | Allergies, Adverse Reactions, Alerts 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 |
SubstanceReactionStatus
PenicillinHivesActive
AspirinWheezingActive
CodeineNauseaActive
437 |
438 |
439 |
440 | 445 | 446 |
447 | 448 | 449 | 450 | Medications 451 | 452 | 453 | 454 | 455 | Medication: Albuterol inhalant
456 | Instructions: 2 puffs QID PRN wheezing
457 | Status: Active 458 |
459 |
460 | 461 | 462 | Medication: Clopidogrel (Plavix)
463 | Instructions: 75mg PO daily
464 | Status: Active 465 |
466 |
467 | 468 | 469 | Medication: Metoprolol
470 | Instructions: 25mg PO BID
471 | Status: Active 472 |
473 |
474 | 475 | 476 | Medication: Prednisone
477 | Instructions: 20mg PO daily
478 | Start Date: Mar 28, 2000
479 | Status: Active 480 |
481 |
482 | 483 | 484 | Medication: Cephalexin (Keflex)
485 | Instructions: 500mg PO QID x 7 days (for bronchitis)
486 | Start Date: Mar 28, 2000
487 | Status: No longer active 488 |
489 |
490 |
491 |
492 | 493 | 494 | 495 | 496 | 497 | Good Health Clinic 498 | 499 | 500 | 501 |
502 |
503 | 508 | 509 |
510 | 511 | 512 | 513 | Medical Equipment 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 |
Supply/DeviceDate Supplied
Automatic implantable cardioverter/defibrillatorNov 1999
Total hip replacement prosthesis1998
Wheelchair1999
537 |
538 |
539 |
540 | 545 | 546 |
547 | 548 | 549 | 550 | Immunizations 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 |
VaccineDateStatus
Influenza virus vaccine, IMNov 1999Completed
Influenza virus vaccine, IMDec 1998Completed
Pneumococcal polysaccharide vaccine, IMDec 1998Completed
Tetanus and diphtheria toxoids, IM1997Completed
583 |
584 |
585 |
586 | 591 | 592 |
593 | 594 | 595 | 596 | Vital Signs 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 |
Date / Time: Nov 14, 1999April 7, 2000
Height177 cm177 cm
Weight86 kg88 kg
Blood Pressure132/86 mmHg145/88 mmHg
624 |
625 |
626 |
627 | 632 | 633 |
634 | 635 | 636 | 637 | Results 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 |
 March 23, 2000April 06, 2000
650 | Hematology 651 |
HGB (M 13-18 g/dl; F 12-16 g/dl)13.2 
WBC (4.3-10.8 10+3/ul)6.7 
PLT (135-145 meq/l)123* 
670 | Chemistry 671 |
NA (135-145meq/l) 140
K (3.5-5.0 meq/l) 4.0
CL (98-106 meq/l) 102
HCO3 (18-23 meq/l) 35*
695 |
696 |
697 |
698 | 703 | 704 |
705 | 706 | 707 | 708 | Procedures 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 722 | 723 | 724 | 725 |
ProcedureDate
720 | Total hip replacement, left 721 | 1998
726 |
727 |
728 |
729 | 734 | 735 |
736 | 737 | 738 | 739 | Encounters 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 |
EncounterLocationDate
Checkup ExaminationGood Health ClinicApr 07, 2000
757 |
758 |
759 |
760 | 765 | 766 |
767 | 768 | 769 | 770 | Plan 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 |
Planned ActivityPlanned Date
Pulmonary function testApril 21, 2000
786 |
787 |
788 |
789 |
790 |
791 |
792 | -------------------------------------------------------------------------------- /ccd_samples/PatientPortal8302.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | Good Health Clinic Continuity of Care Document 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Henry 25 | Levin 26 | the 7th 27 | 28 | 29 | 30 | 31 | 32 | 33 | Good Health Clinic 34 | 35 | 36 | 37 | 38 | 54 | 55 | 56 | 57 | 58 | 59 | Good Health Clinic 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | Good Health Clinic 68 | 69 | 70 | 71 | 72 | 82 | 83 | 84 | 85 | 86 | 17 Daws Rd. 87 | Blue Bell 88 | MA 89 | 02368 90 | 91 | 92 | 93 | 94 | Kenneth 95 | Ross 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | Henrietta 108 | Levin 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 125 | 126 | 127 | 128 | 129 | Dr. 130 | Robert 131 | Dolin 132 | 133 | 134 | 135 | 136 | Good Health Clinic 137 | 138 | 139 | 140 | 141 | 142 | 147 | 148 | 149 | 154 | 155 |
156 | 157 | 158 | 159 | Summary Purpose 160 | Transfer of care 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 |
176 |
177 | 182 | 183 |
184 | 185 | 186 | 187 | Payers 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 |
Payer namePolicy type / Coverage typeCovered party IDAuthorization(s)
Good Health InsuranceExtended healthcare / Self14d4a520-7aae-11db-9fe1-0800200c9a66Colonoscopy
207 |
208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | Good Health Insurance 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 |
254 |
255 | 260 | 261 |
262 | 263 | 264 | 265 | Advance Directives 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 282 | 283 | 286 | 287 | 288 |
DirectiveDescriptionVerificationSupporting Document(s)
Resuscitation status 280 | Do not resuscitate 281 | Dr. Robert Dolin, Nov 07, 1999 284 | Advance directive 285 |
289 |
290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 |
333 |
334 | 339 | 340 |
341 | 342 | 343 | 344 | Functional Status 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 |
Functional ConditionEffective DatesCondition Status
Dependence on cane1998Active
Memory impairment1999Active
367 |
368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 |
429 |
430 | 435 | 436 |
437 | 438 | 439 | 440 | Problems 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 |
ConditionEffective DatesCondition Status
Asthma1950Active
PneumoniaJan 1997Resolved
"Mar 1999Resolved
Myocardial InfarctionJan 1997Resolved
473 |
474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 |
614 |
615 | 620 | 621 |
622 | 623 | 624 | 625 | Family history 626 | 627 | Father (deceased) 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 |
DiagnosisAge At Onset
Myocardial Infarction (cause of death)57
Hypertension40
646 | Mother (alive) 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 |
DiagnosisAge At Onset
Asthma30
661 |
662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 |
754 |
755 | 760 | 761 |
762 | 763 | 764 | 765 | Social History 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 |
Social History ElementDescriptionEffective Dates
Cigarette smoking1 pack per day1947 - 1972
"None1973 -
Alcohol consumptionNone1973 -
793 |
794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 1 pack per day 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | None 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | None 852 | 853 | 854 |
855 |
856 | 861 | 862 |
863 | 864 | 865 | 866 | Allergies, Adverse Reactions, Alerts 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 |
SubstanceReactionStatus
PenicillinHivesActive
AspirinWheezingActive
CodeineNauseaActive
894 |
895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 |
1025 |
1026 | 1031 | 1032 |
1033 | 1034 | 1035 | 1036 | Medications 1037 | 1038 | 1039 | 1040 | 1041 | Medication: Albuterol inhalant
1042 | Instructions: 2 puffs QID PRN wheezing
1043 | Status: Active 1044 |
1045 |
1046 | 1047 | 1048 | Medication: Clopidogrel (Plavix)
1049 | Instructions: 75mg PO daily
1050 | Status: Active 1051 |
1052 |
1053 | 1054 | 1055 | Medication: Metoprolol
1056 | Instructions: 25mg PO BID
1057 | Status: Active 1058 |
1059 |
1060 | 1061 | 1062 | Medication: Prednisone
1063 | Instructions: 20mg PO daily
1064 | Start Date: Mar 28, 2000
1065 | Status: Active 1066 |
1067 |
1068 | 1069 | 1070 | Medication: Cephalexin (Keflex)
1071 | Instructions: 500mg PO QID x 7 days (for bronchitis)
1072 | Start Date: Mar 28, 2000
1073 | Status: No longer active 1074 |
1075 |
1076 |
1077 |
1078 | 1079 | 1080 | 1081 | 1082 | 1083 | Good Health Clinic 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | Albuterol inhalant 1107 | 1108 | 1109 | Pro-Air Albuterol 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | Clopidogrel 1140 | 1141 | Plavix 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | Metoprolol 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | Prednisone 1194 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | Cephalexin 1223 | 1224 | Keflex 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1241 | 1242 | 1243 |
1244 |
1245 | 1250 | 1251 |
1252 | 1253 | 1254 | 1255 | Medical Equipment 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 |
Supply/DeviceDate Supplied
Automatic implantable cardioverter/defibrillatorNov 1999
Total hip replacement prosthesis1998
Wheelchair1999
1279 |
1280 | 1281 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 |
1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | 1299 | 1300 | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | 1307 |
1308 | 1309 | 1310 | 1311 | 1312 | 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | Good Health Prostheses Company 1320 | 1321 | 1322 | 1323 | 1324 | 1325 | 1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 |
1333 | 1334 | 1335 | 1336 | 1337 | 1338 | 1339 | 1340 | 1341 | 1342 | 1343 | 1344 | 1345 |
1346 |
1347 | 1352 | 1353 |
1354 | 1355 | 1356 | 1357 | Immunizations 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1365 | 1366 | 1367 | 1368 | 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 | 1379 | 1380 | 1381 | 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1389 |
VaccineDateStatus
Influenza virus vaccine, IMNov 1999Completed
Influenza virus vaccine, IMDec 1998Completed
Pneumococcal polysaccharide vaccine, IMDec 1998Completed
Tetanus and diphtheria toxoids, IM1997Completed
1390 |
1391 | 1392 | 1393 | 1394 | 1395 | 1396 | 1397 | 1398 |
1399 | 1400 | 1401 | 1402 | 1403 | 1404 | 1405 | 1406 | 1407 | Influenza virus vaccine 1408 | 1409 | 1410 | 1411 | 1412 | 1413 | 1414 | 1415 | 1416 | 1417 | 1418 | 1419 | 1420 | 1421 |
1422 | 1423 | 1424 | 1425 | 1426 | 1427 | 1428 | 1429 | 1430 | Influenza virus vaccine 1431 | 1432 | 1433 | 1434 | 1435 | 1436 | 1437 | 1438 | 1439 | 1440 | 1441 | 1442 | 1443 | 1444 |
1445 | 1446 | 1447 | 1448 | 1449 | 1450 | 1451 | 1452 | 1453 | Pneumococcal polysaccharide vaccine 1454 | 1455 | 1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | 1464 | 1465 | 1466 | 1467 |
1468 | 1469 | 1470 | 1471 | 1472 | 1473 | 1474 | 1475 | 1476 | Tetanus and diphtheria toxoids 1477 | 1478 | 1479 | 1480 | 1481 | 1482 | 1483 |
1484 |
1485 | 1490 | 1491 |
1492 | 1493 | 1494 | 1495 | Vital Signs 1496 | 1497 | 1498 | 1499 | 1500 | 1501 | 1502 | 1503 | 1504 | 1505 | 1506 | 1507 | 1508 | 1509 | 1510 | 1511 | 1512 | 1513 | 1514 | 1515 | 1516 | 1517 | 1518 | 1519 | 1520 | 1521 | 1522 |
Date / Time: Nov 14, 1999April 7, 2000
Height177 cm177 cm
Weight86 kg88 kg
Blood Pressure132/86 mmHg145/88 mmHg
1523 |
1524 | 1525 | 1526 | 1527 | 1528 | 1529 | 1530 | 1531 | 1532 | 1533 | 1534 | 1535 | 1536 | 1537 | 1538 | 1539 | 1540 | 1541 | 1542 | 1543 | 1544 | 1545 | 1546 | 1547 | 1548 | 1549 | 1550 | 1551 | 1552 | 1553 | 1554 | 1555 | 1556 | 1557 | 1558 | 1559 | 1560 | 1561 | 1562 | 1563 | 1564 | 1565 | 1566 | 1567 | 1568 | 1569 | 1570 | 1571 | 1572 | 1573 | 1574 | 1575 | 1576 | 1577 | 1578 | 1579 | 1580 | 1581 | 1582 | 1583 | 1584 | 1585 | 1586 | 1587 | 1588 | 1589 | 1590 | 1591 | 1592 | 1593 | 1594 | 1595 | 1596 | 1597 | 1598 | 1599 | 1600 | 1601 | 1602 | 1603 | 1604 | 1605 | 1606 | 1607 | 1608 | 1609 | 1610 | 1611 | 1612 | 1613 | 1614 | 1615 | 1616 | 1617 | 1618 | 1619 | 1620 | 1621 | 1622 | 1623 | 1624 | 1625 | 1626 | 1627 | 1628 | 1629 | 1630 | 1631 | 1632 |
1633 |
1634 | 1639 | 1640 |
1641 | 1642 | 1643 | 1644 | Results 1645 | 1646 | 1647 | 1648 | 1649 | 1650 | 1651 | 1652 | 1653 | 1654 | 1655 | 1656 | 1659 | 1660 | 1661 | 1662 | 1663 | 1664 | 1665 | 1666 | 1667 | 1668 | 1669 | 1670 | 1671 | 1672 | 1673 | 1674 | 1675 | 1676 | 1679 | 1680 | 1681 | 1682 | 1683 | 1684 | 1685 | 1686 | 1687 | 1688 | 1689 | 1690 | 1691 | 1692 | 1693 | 1694 | 1695 | 1696 | 1697 | 1698 | 1699 | 1700 | 1701 |
 March 23, 2000April 06, 2000
1657 | Hematology 1658 |
HGB (M 13-18 g/dl; F 12-16 g/dl)13.2 
WBC (4.3-10.8 10+3/ul)6.7 
PLT (135-145 meq/l)123* 
1677 | Chemistry 1678 |
NA (135-145meq/l) 140
K (3.5-5.0 meq/l) 4.0
CL (98-106 meq/l) 102
HCO3 (18-23 meq/l) 35*
1702 |
1703 | 1704 | 1705 | 1706 | 1707 | 1708 | 1709 | 1710 | 1711 | 1712 | 1713 | 1714 | 1715 | 1716 | 1717 | 1718 | 1719 | 1720 | 1721 | 1722 | 1723 | M 13-18 g/dl; F 12-16 g/dl 1724 | 1725 | 1726 | 1727 | 1728 | 1729 | 1730 | 1731 | 1732 | 1733 | 1734 | 1735 | 1736 | 1737 | 1738 | 1739 | 1740 | 1741 | 1742 | 1743 | 1744 | 1745 | 1746 | 1747 | 1748 | 1749 | 1750 | 1751 | 1752 | 1753 | 1754 | 1755 | 1756 | 1757 | 1758 | 1759 | 1760 | 1761 | 1762 | 1763 | 1764 | 1765 | 1766 | 1767 | 1768 | 1769 | 1770 | 1771 | 1772 | 1773 | 1774 | 1775 | 1776 | 1777 | 1778 | 1779 | 1780 | 1781 | 1782 | 1783 | 1784 | 1785 | 1786 | 1787 | 1788 | 1789 | 1790 | 1791 | 1792 | 1793 | 1794 | 1795 | 1796 | 1797 | 1798 | 1799 | 1800 | 1801 | 1802 | 1803 | 1804 | 1805 | 1806 | 1807 | 1808 | 1809 | 1810 | 1811 | 1812 | 1813 | 1814 | 1815 | 1816 | 1817 | 1818 | 1819 | 1820 | 1821 | 1822 | 1823 | 1824 | 1825 | 1826 | 1827 | 1828 | 1829 | 1830 | 1831 | 1832 | 1833 | 1834 | 1835 | 1836 | 1837 | 1838 | 1839 | 1840 | 1841 | 1842 | 1843 | 1844 | 1845 | 1846 | 1847 | 1848 | 1849 | 1850 | 1851 | 1852 | 1853 | 1854 | 1855 | 1856 | 1857 | 1858 | 1859 | 1860 |
1861 |
1862 | 1867 | 1868 |
1869 | 1870 | 1871 | 1872 | Procedures 1873 | 1874 | 1875 | 1876 | 1877 | 1878 | 1879 | 1880 | 1881 | 1882 | 1883 | 1886 | 1887 | 1888 | 1889 |
ProcedureDate
1884 | Total hip replacement, left 1885 | 1998
1890 |
1891 | 1892 | 1893 | 1894 | 1895 | 1896 | 1897 | 1898 | 1899 | 1900 | 1901 | 1902 | 1903 | 1904 | 1905 | 1906 | 1907 | 1908 | 1909 | 1910 | 1911 | 1912 | 1913 | 1914 | 1915 | 1916 |
1917 |
1918 | 1923 | 1924 |
1925 | 1926 | 1927 | 1928 | Encounters 1929 | 1930 | 1931 | 1932 | 1933 | 1934 | 1935 | 1936 | 1937 | 1938 | 1939 | 1940 | 1941 | 1942 | 1943 | 1944 | 1945 |
EncounterLocationDate
Checkup ExaminationGood Health ClinicApr 07, 2000
1946 |
1947 | 1948 | 1949 | 1950 | 1951 | 1952 | 1953 | Checkup Examination 1954 | 1955 | 1956 | 1957 | 1958 | 1959 | 1960 | 1961 | 1962 | Good Health Clinic 1963 | 1964 | 1965 | 1966 | 1967 | 1968 |
1969 |
1970 | 1975 | 1976 |
1977 | 1978 | 1979 | 1980 | Plan 1981 | 1982 | 1983 | 1984 | 1985 | 1986 | 1987 | 1988 | 1989 | 1990 | 1991 | 1992 | 1993 | 1994 | 1995 |
Planned ActivityPlanned Date
Pulmonary function testApril 21, 2000
1996 |
1997 | 1998 | 1999 | 2000 | 2001 | 2002 | 2003 | 2004 | 2005 |
2006 | 2007 | 2008 | 2009 |
2010 |
2011 |
2012 |
2013 |
2014 | -------------------------------------------------------------------------------- /ext_lib/gson-2.2.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/gson-2.2.3.jar -------------------------------------------------------------------------------- /ext_lib/net.sourceforge.lpg.lpgjavaruntime_1.1.0.v200803061910.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/net.sourceforge.lpg.lpgjavaruntime_1.1.0.v200803061910.jar -------------------------------------------------------------------------------- /ext_lib/org.apache.commons.lang_2.3.0.v201005080501.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.apache.commons.lang_2.3.0.v201005080501.jar -------------------------------------------------------------------------------- /ext_lib/org.eclipse.emf.common_2.5.0.v200906151043.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.eclipse.emf.common_2.5.0.v200906151043.jar -------------------------------------------------------------------------------- /ext_lib/org.eclipse.emf.ecore.xmi_2.5.0.v200906151043.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.eclipse.emf.ecore.xmi_2.5.0.v200906151043.jar -------------------------------------------------------------------------------- /ext_lib/org.eclipse.emf.ecore_2.5.0.v200906151043.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.eclipse.emf.ecore_2.5.0.v200906151043.jar -------------------------------------------------------------------------------- /ext_lib/org.eclipse.ocl.ecore_1.3.0.v200905271400.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.eclipse.ocl.ecore_1.3.0.v200905271400.jar -------------------------------------------------------------------------------- /ext_lib/org.eclipse.ocl_1.3.0.v200905271400.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.eclipse.ocl_1.3.0.v200905271400.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.emf.runtime_1.0.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.emf.runtime_1.0.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.ccd.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.ccd.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.ccd_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.ccd_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.cdt.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.cdt.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.cdt_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.cdt_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.consol.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.consol.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.consol_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.consol_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.hitsp.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.hitsp.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.hitsp_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.hitsp_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.ihe.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.ihe.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.ihe_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.ihe_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.mu2consol.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.mu2consol.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.mu2consol_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.mu2consol_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.cda_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.cda_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.hl7.datatypes.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.hl7.datatypes.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.hl7.datatypes_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.hl7.datatypes_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.hl7.rim.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.hl7.rim.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.hl7.rim_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.hl7.rim_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.hl7.vocab.source_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.hl7.vocab.source_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.openhealthtools.mdht.uml.hl7.vocab_1.2.0.201302191803.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.openhealthtools.mdht.uml.hl7.vocab_1.2.0.201302191803.jar -------------------------------------------------------------------------------- /ext_lib/org.restlet.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chintanop/ccda-rest-api/6573f6b4d9b986707e0a97e89497a5ca369b72d5/ext_lib/org.restlet.jar -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/CDAAPIHandler.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi; 2 | 3 | import java.util.HashMap; 4 | 5 | import org.restlet.Application; 6 | import org.restlet.Component; 7 | import org.restlet.Restlet; 8 | import org.restlet.data.Protocol; 9 | import org.restlet.routing.Filter; 10 | import org.restlet.routing.Router; 11 | 12 | /** 13 | * 14 | * @author Chintan Patel 15 | * 16 | * The API main runner. Takes input as specified port and runs on that port. 17 | * 18 | */ 19 | public class CDAAPIHandler extends Application{ 20 | 21 | //An in-memory store of patient records for retrieval on future requests 22 | public static HashMap patient_records = new HashMap(); 23 | 24 | /** 25 | * Creates a root Restlet that will receive all incoming calls. 26 | */ 27 | @Override 28 | public Restlet createInboundRoot() { 29 | // Create a router Restlet that routes each call to a 30 | // new instance of CDAResource 31 | 32 | Router router = new Router(getContext()); 33 | // Defines only one route 34 | // router.attachDefault(CDAResource.class); 35 | 36 | router.attach("/bbplus", CDAResource.class); 37 | router.attach("/bbplus/{patient_id}/{section}", CDAResource.class); 38 | return router; 39 | } 40 | 41 | 42 | /** 43 | * Adds a patient record to the inmemory store 44 | * @param id: The unique patient record id 45 | * @param record: The record 46 | */ 47 | public void addRecord(String id, HashMap record){ 48 | patient_records.put(id, record); 49 | } 50 | 51 | /** 52 | * Get the patient record associated with a given ID 53 | * @param id 54 | * @return HashMap: patient record elements 55 | */ 56 | public HashMap getRecord(String id){ 57 | return patient_records.get(id); 58 | } 59 | 60 | /** 61 | * The main entry point of the application, if no argument specified then starts 62 | * the server on default port of 8182 63 | * @param args 64 | */ 65 | public static void main(String[] args) { 66 | try { 67 | 68 | // Default Port 69 | int port = 8182; 70 | 71 | if (args.length == 1){ 72 | try{ 73 | port = Integer.parseInt(args[0]); 74 | }catch(NumberFormatException nfe){ 75 | System.out.println("Please enter a numeric argument for the port"); 76 | System.exit(0); 77 | } 78 | } 79 | 80 | // Create a new Component. 81 | Component component = new Component(); 82 | 83 | // Add a new HTTP server listening on port 84 | component.getServers().add(Protocol.HTTP, port); 85 | 86 | // Attach the sample application. 87 | component.getDefaultHost().attach(new CDAAPIHandler()); 88 | 89 | // Start the component. 90 | component.start(); 91 | } catch (Exception e) { 92 | // Something is wrong. 93 | e.printStackTrace(); 94 | } 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/CDAResource.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.FileInputStream; 5 | import java.io.FileNotFoundException; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | 11 | import org.openhealthtools.mdht.uml.cda.ClinicalDocument; 12 | import org.openhealthtools.mdht.uml.cda.Consumable; 13 | import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; 14 | import org.openhealthtools.mdht.uml.cda.Material; 15 | import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; 16 | import org.openhealthtools.mdht.uml.cda.ccd.CCDFactory; 17 | import org.openhealthtools.mdht.uml.cda.ccd.ContinuityOfCareDocument; 18 | import org.openhealthtools.mdht.uml.cda.ccd.MedicationsSection; 19 | import org.openhealthtools.mdht.uml.cda.util.CDAUtil; 20 | import org.openhealthtools.mdht.uml.cda.util.ValidationResult; 21 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 22 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; 23 | import org.openhealthtools.mdht.uml.hl7.datatypes.PIVL_TS; 24 | import org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS; 25 | import org.openhealthtools.mdht.uml.hl7.datatypes.impl.ENImpl; 26 | import org.restlet.Application; 27 | import org.restlet.Request; 28 | import org.restlet.data.Form; 29 | import org.restlet.data.MediaType; 30 | import org.restlet.data.Parameter; 31 | import org.restlet.engine.header.Header; 32 | import org.restlet.engine.header.HeaderConstants; 33 | import org.restlet.representation.Representation; 34 | import org.restlet.representation.StringRepresentation; 35 | import org.restlet.resource.Get; 36 | import org.restlet.resource.Options; 37 | import org.restlet.resource.Post; 38 | import org.restlet.resource.ResourceException; 39 | import org.restlet.resource.ServerResource; 40 | import org.restlet.util.Series; 41 | 42 | import com.appliedinformatics.cdaapi.mu2parser.CDAParser; 43 | import com.google.gson.Gson; 44 | 45 | /** 46 | * 47 | * CDAResource object. Exposes the API calls GET, POST on the CDA object 48 | * 49 | * @author Chintan Patel 50 | * 51 | */ 52 | public class CDAResource extends ServerResource{ 53 | 54 | /** 55 | * Handle the GET requests on the root 56 | * 57 | * @param patient_id: obtained from the POST request 58 | * @param section: The patient record section ["demographics","medications", "results", "allergies", "problems","vitalsigns","procedures"] 59 | * 60 | * @return JSON object of the requested section 61 | */ 62 | @Get 63 | public String represent() { 64 | Form queryParams = getRequest().getResourceRef().getQueryAsForm(); 65 | 66 | Request request = getRequest(); 67 | 68 | //String patientID = (String) queryParams.getFirstValue("patient"); 69 | // String section = (String) queryParams.getFirstValue("section"); 70 | 71 | String patientID = (String)request.getAttributes().get("patient_id"); 72 | String section = (String)request.getAttributes().get("section"); 73 | 74 | CDAAPIHandler app = (CDAAPIHandler)getApplication(); 75 | 76 | HashMap record = (HashMap)app.getRecord(patientID); 77 | 78 | //System.out.println("Patient ID:"+patientID); 79 | //System.out.println("Section:"+section); 80 | 81 | Gson gson = new Gson(); 82 | 83 | //TODO: handle XML op_format 84 | 85 | //To Handle cross-domain AJAX requests 86 | Series
responseHeaders = (Series
)getResponse().getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS); 87 | if (responseHeaders == null) { 88 | responseHeaders = new Series(Header.class); 89 | getResponse().getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,responseHeaders); 90 | } 91 | responseHeaders.add(new Header("Access-Control-Allow-Origin", "*")); 92 | 93 | //Handle JSONP 94 | String callback = (String) queryParams.getFirstValue("callback"); 95 | if (callback!=null){ 96 | return callback+"("+gson.toJson(record.get(section))+")"; 97 | } 98 | 99 | return gson.toJson(record.get(section)); 100 | 101 | } 102 | 103 | 104 | /** 105 | * Handle the POST requests. Takes a CDA document string as input and returns a unique 106 | * patient_id that can be used to make future GET requests for specific sections of patient record 107 | * 108 | * @param entity 109 | * @return patient_id, status of parsing, warnings, errors 110 | * @throws Exception 111 | */ 112 | @Post 113 | public String acceptRepresentation(Representation entity) throws Exception { 114 | // System.out.println(entity.getText()); 115 | 116 | Form queryParams = new Form(getRequest().getEntity()); 117 | 118 | String ccda_xml = (String)queryParams.getFirstValue("bbfile"); 119 | 120 | //System.out.println(ccda_xml); 121 | 122 | InputStream is = new ByteArrayInputStream(ccda_xml.getBytes("UTF-8")); 123 | 124 | //System.out.println("CCDA XML"+ccda_xml); 125 | 126 | //Create a cdaParser 127 | CDAParser cdaParser = new CDAParser(is); 128 | 129 | //Get demographics 130 | HashMap ptDemo = cdaParser.getDemographics(); 131 | 132 | String patient_id = (String)ptDemo.get("id"); 133 | 134 | //Get all sections 135 | HashMap record = new HashMap(); 136 | record.put("demographics", ptDemo); 137 | record.put("medications", cdaParser.getMedications()); 138 | record.put("results", cdaParser.getResults()); 139 | record.put("allergies", cdaParser.getAllergies()); 140 | record.put("problems", cdaParser.getProblems()); 141 | record.put("vitalsigns", cdaParser.getVitals()); 142 | record.put("procedures", cdaParser.getProcedures()); 143 | 144 | //Store the parsed sections into global application storage 145 | CDAAPIHandler app = (CDAAPIHandler)getApplication(); 146 | app.addRecord(patient_id, record); 147 | 148 | //Return JSON 149 | //TODO: handle XML op_format parameter 150 | HashMap ptid = new HashMap(); 151 | ptid.put("patient_id", patient_id); 152 | System.out.println(patient_id); 153 | 154 | HashMap recorda = (HashMap)app.getRecord(patient_id); 155 | 156 | System.out.println(recorda.get("demographics")); 157 | 158 | Gson gson = new Gson(); 159 | 160 | //To Handle cross-domain AJAX requests: TODO: CORS doesn't seem to be working with Jquery even though headers are returning correctly 161 | Series
responseHeaders = (Series
)getResponse().getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS); 162 | if (responseHeaders == null) { 163 | responseHeaders = new Series(Header.class); 164 | getResponse().getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,responseHeaders); 165 | } 166 | responseHeaders.add(new Header("Access-Control-Allow-Origin", "*")); 167 | 168 | //TODO: handle XML op_format 169 | 170 | //Handle JSONP - WORKS! 171 | String callback = (String) queryParams.getFirstValue("callback"); 172 | if (callback!=null){ 173 | return callback+"("+gson.toJson(ptid)+")"; 174 | } 175 | 176 | return gson.toJson(ptid); 177 | 178 | } 179 | 180 | @Override 181 | public Application getApplication() { 182 | return (Application) super.getApplication(); 183 | } 184 | 185 | @Options 186 | public void doOptions(Representation entity) { 187 | 188 | /* Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers"); 189 | if (responseHeaders == null) { 190 | responseHeaders = new Form(); 191 | getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders); 192 | } 193 | responseHeaders.add("Access-Control-Allow-Origin", "*"); 194 | responseHeaders.add("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); 195 | //responseHeaders.add("Access-Control-Allow-Headers", "Content-Type"); 196 | // responseHeaders.add("Access-Control-Allow-Credentials", "false"); 197 | responseHeaders.add("Access-Control-Max-Age", "60"); */ 198 | 199 | Series
responseHeaders = (Series
)getResponse().getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS); 200 | if (responseHeaders == null) { 201 | responseHeaders = new Series(Header.class); 202 | getResponse().getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,responseHeaders); 203 | } 204 | responseHeaders.add(new Header("Access-Control-Allow-Origin", "*")); 205 | 206 | } 207 | 208 | } 209 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/TestClient.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.FileReader; 5 | import java.io.IOException; 6 | 7 | import org.restlet.data.Form; 8 | import org.restlet.data.Reference; 9 | import org.restlet.representation.Representation; 10 | import org.restlet.representation.StringRepresentation; 11 | import org.restlet.resource.ClientResource; 12 | 13 | /** 14 | * Test Client on localhost. Reads test CDA_Samples and makes REST requests 15 | * 16 | * @author Chintan Patel 17 | * 18 | */ 19 | public class TestClient { 20 | 21 | public static void main(String[] args) throws IOException { 22 | ClientResource requestResource = new ClientResource("http://localhost:8182/bbplus"); 23 | String str = readFileAsString("/Users/aamirbhatt/workspace/pa_frontend/CCDATest5.xml"); 24 | //Add CDA XML by making a POST request on CDAResource 25 | Representation rep = new StringRepresentation(str); 26 | 27 | Form form = new Form(); 28 | form.add("bbfile",str); 29 | form.add("op_format", "json"); 30 | 31 | Representation reply = requestResource.post(form); 32 | 33 | System.out.println("JSON format:"); 34 | System.out.println(reply.getText()); 35 | 36 | //Get a section, make a GET Request on CDAResource 37 | requestResource = new ClientResource("http://localhost:8182/bbplus/12375680/demographics"); 38 | Reference ref = requestResource.getReference(); 39 | ref.addQueryParameter("patient", "996-756-495"); 40 | // ref.addQueryParameter("section", "problems"); 41 | //ref.addQueryParameter("section", "allergies"); 42 | //ref.addQueryParameter("section", "results"); 43 | ref.addQueryParameter("section", "demographics"); 44 | 45 | requestResource.setReference(ref); 46 | Representation res = requestResource.get(); 47 | 48 | //Print the output on the console 49 | System.out.println("DEMOGRAPHICS:"); 50 | System.out.println(res.getText()); 51 | System.out.println(res.toString()); 52 | } 53 | 54 | private static String readFileAsString(String filePath) throws IOException { 55 | StringBuffer fileData = new StringBuffer(); 56 | BufferedReader reader = new BufferedReader( 57 | new FileReader(filePath)); 58 | char[] buf = new char[1024]; 59 | int numRead=0; 60 | while((numRead=reader.read(buf)) != -1){ 61 | String readData = String.valueOf(buf, 0, numRead); 62 | fileData.append(readData); 63 | } 64 | reader.close(); 65 | return fileData.toString(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/constructor/CDAConstructor.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.constructor; 2 | 3 | public class CDAConstructor { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/AllergyParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.HashMap; 6 | 7 | import org.openhealthtools.mdht.uml.cda.Act; 8 | import org.openhealthtools.mdht.uml.cda.EntryRelationship; 9 | import org.openhealthtools.mdht.uml.cda.Observation; 10 | import org.openhealthtools.mdht.uml.cda.Participant2; 11 | import org.openhealthtools.mdht.uml.cda.Section; 12 | import org.openhealthtools.mdht.uml.cda.consol.AllergiesSection; 13 | import org.openhealthtools.mdht.uml.cda.consol.AllergyObservation; 14 | import org.openhealthtools.mdht.uml.cda.consol.AllergyProblemAct; 15 | import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; 16 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 17 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 18 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 19 | import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; 20 | 21 | import com.appliedinformatics.cdaapi.parser.CDAParserUtil; 22 | 23 | /** 24 | * 25 | * @author Chintan Patel 26 | * 27 | * AllergyParser: Parses the CDA section on Allergy into JSON objects 28 | * 29 | */ 30 | public class AllergyParser { 31 | 32 | AllergiesSection allergySection = null; 33 | 34 | public AllergyParser(AllergiesSection allergySection) { 35 | this.allergySection = allergySection; 36 | } 37 | 38 | public ArrayList parse(){ 39 | 40 | ArrayList allergyList = new ArrayList>(); 41 | 42 | if(this.allergySection == null){ 43 | return allergyList; 44 | } 45 | 46 | try{ 47 | for (AllergyProblemAct apa: this.allergySection.getAllergyProblemActs()){ 48 | HashMap amap = new HashMap(); 49 | 50 | 51 | for(AllergyObservation aobs: apa.getAllergyObservations()){ 52 | String allergy_status = ((CD)aobs.getAllergyStatusObservation().getValues().get(0)).getDisplayName(); 53 | 54 | 55 | String allergy_type = ((CD)aobs.getValues().get(0)).getDisplayName(); 56 | 57 | String allergy_reaction = ""; 58 | String allergy_severity = ""; 59 | String allergy_agent = ""; 60 | 61 | 62 | if (aobs.getSeverity()!=null && aobs.getSeverity().getValues().size()>0){ 63 | allergy_severity = ((CD)aobs.getSeverity().getValues().get(0)).getDisplayName(); 64 | 65 | } 66 | 67 | for(Participant2 p2 : aobs.getParticipants()){ 68 | allergy_agent = ((CE)p2.getParticipantRole().getPlayingEntity().getCode()).getDisplayName(); 69 | if (allergy_agent == null){ //Check if we have translations 70 | allergy_agent = CDAParserUtil.getTranslationDisplayName(p2.getParticipantRole().getPlayingEntity().getCode()); 71 | } 72 | } 73 | 74 | 75 | for(EntryRelationship oer : aobs.getEntryRelationships()){ 76 | Observation oer_obs = oer.getObservation(); 77 | if (oer.getTypeCode() == x_ActRelationshipEntryRelationship.MFST){ // 78 | allergy_reaction = ((CD)oer_obs.getValues().get(0)).getDisplayName(); 79 | 80 | if(allergy_reaction == null){ 81 | allergy_reaction = CDAParserUtil.getTranslationDisplayName(oer_obs.getValues().get(0)); 82 | } 83 | 84 | } 85 | 86 | if (oer.getTypeCode() == x_ActRelationshipEntryRelationship.SUBJ){ // look in to subj 87 | System.out.println("SCODE: "+oer_obs.getCode().getCode()); 88 | 89 | 90 | if(oer_obs.getCode().getCode().equals("SEV")){ // severity 91 | 92 | allergy_severity = ((CD)oer_obs.getValues().get(0)).getDisplayName(); 93 | if(allergy_severity == null){ 94 | allergy_severity = CDAParserUtil.getTranslationDisplayName(oer_obs.getValues().get(0)); 95 | } 96 | } 97 | } 98 | 99 | } 100 | 101 | //System.out.println("Agent: "+allergy_agent); 102 | //System.out.println("Reaction: "+allergy_reaction); 103 | //System.out.println("Severity: "+allergy_severity); 104 | 105 | 106 | amap.put("reaction", allergy_reaction); 107 | amap.put("status", allergy_status); 108 | amap.put("ts",CDAParserUtil.getTS(aobs.getEffectiveTime())); 109 | amap.put("type", allergy_type); 110 | amap.put("substance", allergy_agent); 111 | amap.put("severity", allergy_severity); 112 | allergyList.add(amap); 113 | } 114 | } 115 | 116 | Collections.sort(allergyList, new DateComparator()); 117 | 118 | }catch(Exception e){ 119 | System.out.println("Error Allergy Parsing:"); 120 | e.printStackTrace(); 121 | } 122 | return allergyList; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/CDAParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileNotFoundException; 6 | import java.io.InputStream; 7 | import java.lang.reflect.Field; 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | 11 | import org.eclipse.emf.common.util.Diagnostic; 12 | import org.eclipse.emf.common.util.EList; 13 | import org.eclipse.emf.ecore.EObject; 14 | import org.eclipse.emf.ecore.EStructuralFeature; 15 | import org.openhealthtools.mdht.uml.cda.Act; 16 | import org.openhealthtools.mdht.uml.cda.ClinicalDocument; 17 | import org.openhealthtools.mdht.uml.cda.Component4; 18 | import org.openhealthtools.mdht.uml.cda.Component5; 19 | import org.openhealthtools.mdht.uml.cda.Consumable; 20 | import org.openhealthtools.mdht.uml.cda.Entry; 21 | import org.openhealthtools.mdht.uml.cda.EntryRelationship; 22 | import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; 23 | import org.openhealthtools.mdht.uml.cda.Material; 24 | import org.openhealthtools.mdht.uml.cda.Observation; 25 | import org.openhealthtools.mdht.uml.cda.Organizer; 26 | import org.openhealthtools.mdht.uml.cda.Participant2; 27 | import org.openhealthtools.mdht.uml.cda.Precondition; 28 | import org.openhealthtools.mdht.uml.cda.ReferenceRange; 29 | import org.openhealthtools.mdht.uml.cda.Section; 30 | import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; 31 | import org.openhealthtools.mdht.uml.cda.ccd.CCDFactory; 32 | import org.openhealthtools.mdht.uml.cda.hitsp.DiagnosticResultsSection; 33 | import org.openhealthtools.mdht.uml.cda.ccd.ContinuityOfCareDocument; 34 | import org.openhealthtools.mdht.uml.cda.ccd.EpisodeObservation; 35 | import org.openhealthtools.mdht.uml.cda.consol.AllergiesSection; 36 | import org.openhealthtools.mdht.uml.cda.consol.ProceduresSection; 37 | import org.openhealthtools.mdht.uml.cda.consol.MedicationsSection; 38 | import org.openhealthtools.mdht.uml.cda.consol.MedicationActivity; 39 | import org.openhealthtools.mdht.uml.cda.consol.ProblemObservation; 40 | import org.openhealthtools.mdht.uml.cda.consol.ProblemSection; 41 | import org.openhealthtools.mdht.uml.cda.consol.ResultObservation; 42 | import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; 43 | import org.openhealthtools.mdht.uml.cda.consol.ResultsSection; 44 | import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSectionEntriesOptional; 45 | import org.openhealthtools.mdht.uml.cda.hitsp.HITSPPackage; 46 | import org.openhealthtools.mdht.uml.cda.hitsp.PatientSummary; 47 | import org.openhealthtools.mdht.uml.cda.util.CDAUtil; 48 | import org.openhealthtools.mdht.uml.cda.util.ValidationResult; 49 | import org.openhealthtools.mdht.uml.hl7.datatypes.AD; 50 | import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; 51 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 52 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 53 | import org.openhealthtools.mdht.uml.hl7.datatypes.ED; 54 | import org.openhealthtools.mdht.uml.hl7.datatypes.ENXP; 55 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; 56 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 57 | import org.openhealthtools.mdht.uml.hl7.datatypes.PIVL_TS; 58 | import org.openhealthtools.mdht.uml.hl7.datatypes.PN; 59 | import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; 60 | import org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS; 61 | import org.openhealthtools.mdht.uml.hl7.datatypes.impl.ENImpl; 62 | import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; 63 | import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; 64 | import org.openhealthtools.mdht.uml.cda.mu2consol.Mu2consolPackage; 65 | import org.openhealthtools.mdht.uml.cda.mu2consol.Mu2consolFactory; 66 | import org.openhealthtools.mdht.uml.cda.mu2consol.ClinicalOfficeVisitSummary; 67 | import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; 68 | /** 69 | * 70 | * @author Chintan Patel 71 | * 72 | * CDAParser - The core CDAParser that parses an input stream to parse a HITSP-32 or HITSP-83 document 73 | * 74 | */ 75 | public class CDAParser { 76 | 77 | //Initialize the document variables 78 | ClinicalDocument cd = null; 79 | MedicationsSection medicationsSection = null; 80 | ProblemSection problemSection = null; 81 | AllergiesSection allergySection = null; 82 | ResultsSection resultsSection = null; 83 | DiagnosticResultsSection diagnosticResultsSection = null; 84 | ProceduresSection proceduresSection = null; 85 | PatientSummary ps = null; //for HITSP 83 86 | ContinuityOfCareDocument ccd = null; //for HITSP 32 87 | Section VitalSection = null; 88 | public ClinicalOfficeVisitSummary covs = null; //for Mu2 C-CDA 89 | 90 | /** 91 | * Constructor for the CDA Parser. Accepts an InputStream of a CDA document in either 92 | * HITSP 32 (CCD) or HITSP 83 (CCDA) document 93 | * @param cda_input 94 | */ 95 | public CDAParser(InputStream cda_input){ 96 | // HITSPPackage.eINSTANCE.eClass(); 97 | // ContinuityOfCareDocument doc = CCDFactory.eINSTANCE.createContinuityOfCareDocument().init(); 98 | 99 | Mu2consolPackage.eINSTANCE.eClass(); 100 | 101 | ValidationResult result = new ValidationResult(); 102 | 103 | try { 104 | //cd = CDAUtil.load(cda_input, result); //Load CDA document and validate 105 | 106 | cd = CDAUtil.loadAs( 107 | cda_input, 108 | Mu2consolPackage.eINSTANCE.getClinicalOfficeVisitSummary(), 109 | result); 110 | 111 | } catch (FileNotFoundException e) { 112 | e.printStackTrace(); 113 | } catch (Exception e) { 114 | e.printStackTrace(); 115 | } 116 | System.out.println("Aamir"); 117 | System.out.println("Aamir"); 118 | //Output diagnostic error messages 119 | //TODO: return any errors to the client 120 | for (Diagnostic diagnostic : result.getErrorDiagnostics()) { 121 | System.out.println("ERROR: " + diagnostic.getMessage()); 122 | } 123 | for (Diagnostic diagnostic : result.getWarningDiagnostics()) { 124 | System.out.println("WARNING: " + diagnostic.getMessage()); 125 | } 126 | 127 | covs = (ClinicalOfficeVisitSummary)cd; 128 | System.out.println("NOT A CCDA or PATIENT SUMMARY!"); 129 | System.out.println(cd); 130 | System.out.println(covs); 131 | for(Section sec: covs.getAllSections()){ 132 | String r = sec.getClass().getName(); 133 | if (r == "org.openhealthtools.mdht.uml.cda.consol.impl.VitalSignsSectionEntriesOptionalImpl"){ 134 | VitalSection = sec ; 135 | } 136 | } 137 | 138 | 139 | medicationsSection = covs.getMedicationsSection(); 140 | problemSection = covs.getProblemSection(); 141 | allergySection = covs.getAllergiesSection(); 142 | //resultsSection = covs.getResultsSection(); 143 | proceduresSection = covs.getProceduresSection(); 144 | } 145 | 146 | 147 | 148 | /** 149 | * Get Medications from the CDA 150 | * @return ArrayList of parsed medications 151 | */ 152 | public ArrayList getMedications(){ 153 | return (new MedicationParser(medicationsSection)).parse(); 154 | } 155 | 156 | /** 157 | * Get Allergies from the CDA 158 | * @return ArrayList of parsed allergies 159 | */ 160 | public ArrayList getAllergies(){ 161 | return (new AllergyParser(allergySection)).parse(); 162 | } 163 | 164 | /** 165 | * Get results section from the CDA 166 | * @return ArrayList of parsed results 167 | */ 168 | public ArrayList getResults(){ 169 | //Decide between HITSP 32 versus 83 170 | if (ps!=null){ 171 | return (new ResultParser(diagnosticResultsSection)).parse(); 172 | }else{ 173 | return (new ResultParser(resultsSection)).parse(); 174 | } 175 | } 176 | 177 | /** 178 | * Get problems from the CDA 179 | * @return ArrayList of parsed problems 180 | */ 181 | public ArrayList getProblems(){ 182 | return (new ProblemParser(problemSection)).parse(); 183 | } 184 | 185 | public ArrayList getVitals(){ 186 | return (new VitalSignParser(VitalSection)).parse(); 187 | } 188 | 189 | public ArrayList getProcedures(){ 190 | return (new ProcedureParser(proceduresSection)).parse(); 191 | } 192 | 193 | /** 194 | * Get demographics from the CDA 195 | * @return HashMap/Dictionary of Demographics 196 | */ 197 | public HashMap getDemographics(){ 198 | return (new DemographicParser(cd)).parse(); 199 | } 200 | 201 | public static void main(String[] args) { 202 | InputStream is; 203 | try { 204 | is = new FileInputStream(new File("ccd_samples/1ccda.xml")); 205 | CDAParser cdaParser = new CDAParser(is); 206 | System.out.println("\n\n******* MEDICATIONS ************\n\n"); 207 | System.out.println(cdaParser.getMedications()); 208 | 209 | System.out.println(("\n\n****** RESULTS ***************\n\n")); 210 | System.out.println(cdaParser.getResults()); 211 | 212 | System.out.println(("\n\n****** ALLERGIES ***************\n\n")); 213 | System.out.println(cdaParser.getAllergies()); 214 | 215 | System.out.println(("\n\n****** PROBLEMS ***************\n\n")); 216 | System.out.println(cdaParser.getProblems()); 217 | 218 | System.out.println(("\n\n****** DEMOGRAPHICS ***************\n\n")); 219 | System.out.println(cdaParser.getDemographics()); 220 | 221 | System.out.println(("\n\n****** VITALS ***************\n\n")); 222 | System.out.println(cdaParser.getVitals()); 223 | 224 | System.out.println(("\n\n****** PROCEDURES ***************\n\n")); 225 | System.out.println(cdaParser.getProcedures()); 226 | 227 | 228 | 229 | } catch (FileNotFoundException e) { 230 | // TODO Auto-generated catch block 231 | e.printStackTrace(); 232 | } 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/CDAParserUtil.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.util.HashMap; 4 | 5 | import org.openhealthtools.mdht.uml.cda.ClinicalDocument; 6 | import org.openhealthtools.mdht.uml.cda.Section; 7 | import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; 8 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 9 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 10 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 11 | 12 | /** 13 | * 14 | * @author Chintan Patel 15 | * 16 | * Parsing utility Functions 17 | * 18 | */ 19 | public class CDAParserUtil { 20 | 21 | /** 22 | * Takes a IVL_TS time object and returns a simple low,high and center values 23 | * @param pTime 24 | * @return A dictionary/HashMap of low, high and center values of time stamp 25 | */ 26 | public static HashMap getTS(IVL_TS pTime){ 27 | HashMap ts = new HashMap(); 28 | ts.put("ts_low", ""); 29 | ts.put("ts_high", ""); 30 | ts.put("ts_center", ""); 31 | if (pTime!=null){ 32 | if (pTime.getLow()!=null){ 33 | //System.out.println("LOW:"+pTime.getLow().getValue()); 34 | ts.put("ts_low",pTime.getLow().getValue()); 35 | } 36 | if (pTime.getHigh()!=null){ 37 | //System.out.println("HIGH:"+pTime.getHigh().getValue()); 38 | ts.put("ts_high",pTime.getHigh().getValue()); 39 | } 40 | if (pTime.getCenter()!=null){ 41 | //System.out.println("CENTER:"+pTime.getCenter().getValue()); 42 | ts.put("ts_center",pTime.getCenter().getValue()); 43 | } 44 | } 45 | return ts; 46 | } 47 | 48 | /** 49 | * Takes a ANY object and checks if its a CD object or CE object and 50 | * returns a corresponding string of displayName 51 | * 52 | * TODO: Connect this to a terminlogy lookup service if no display name given by code given 53 | * 54 | * @param dt 55 | * @return String of the display name 56 | */ 57 | public static String getTranslationDisplayName(ANY dt){ 58 | 59 | //check if its CD instance 60 | if(dt instanceof CD){ 61 | CD cdt = (CD)dt; 62 | if(cdt.getTranslations().size()>0){ 63 | return cdt.getTranslations().get(0).getDisplayName(); 64 | } 65 | } 66 | 67 | //check if its CE instance 68 | if(dt instanceof CE){ 69 | CE cdt = (CE)dt; 70 | if(cdt.getTranslations().size()>0){ 71 | return cdt.getTranslations().get(0).getDisplayName(); 72 | } 73 | } 74 | return null; 75 | } 76 | 77 | /** 78 | * Gets a section with given template_id from a ClinicalDocument 79 | * @param cd 80 | * @param template_id 81 | * @return Section 82 | */ 83 | public static Section getSection(ClinicalDocument cd, String template_id){ 84 | if(cd.hasSectionTemplate(template_id)){ 85 | for(Section sec : cd.getSections()){ 86 | if(sec.hasTemplateId(template_id)){ 87 | return sec; 88 | } 89 | } 90 | } 91 | return null; 92 | } 93 | 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/DateComparator.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Comparator; 6 | import java.util.Date; 7 | import java.util.HashMap; 8 | 9 | public class DateComparator implements Comparator> { 10 | @Override 11 | public int compare(HashMap o1, HashMap o2) { 12 | 13 | HashMap st1 = (HashMap)o1.get("ts"); 14 | HashMap st2 = (HashMap)o2.get("ts"); 15 | 16 | String ts1 = getValidTS(st1); 17 | String ts2 = getValidTS(st2); 18 | 19 | 20 | Date d1 = getDate(ts1); 21 | Date d2 = getDate(ts2); 22 | 23 | if (d1 !=null && d2!=null){ 24 | return d2.compareTo(d1); 25 | }else{ 26 | return 0; 27 | } 28 | } 29 | 30 | public String getValidTS(HashMap st){ 31 | if (st.get("ts_center")!=null && st.get("ts_center")!=""){ 32 | return (String)st.get("ts_center"); 33 | }else if (st.get("ts_high")!=null && st.get("ts_high")!=""){ 34 | return (String)st.get("ts_high"); 35 | }else { 36 | return (String)st.get("ts_low"); 37 | } 38 | } 39 | 40 | public Date getDate(String ts){ 41 | try { 42 | if (ts==null){ 43 | return null; 44 | } 45 | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); 46 | return sdf.parse(ts); 47 | } catch (ParseException e) { 48 | e.printStackTrace(); 49 | } 50 | return null; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/DemographicParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | 6 | import org.eclipse.emf.common.util.EList; 7 | import org.openhealthtools.mdht.uml.cda.ClinicalDocument; 8 | import org.openhealthtools.mdht.uml.hl7.datatypes.AD; 9 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 10 | import org.openhealthtools.mdht.uml.hl7.datatypes.ENXP; 11 | import org.openhealthtools.mdht.uml.hl7.datatypes.PN; 12 | import org.openhealthtools.mdht.uml.cda.RecordTarget; 13 | 14 | /** 15 | * 16 | * @author Chintan Patel 17 | * 18 | * DemographicParser: Parses demographic fields from CDA into JSON 19 | * 20 | */ 21 | public class DemographicParser { 22 | 23 | ClinicalDocument cd = null; 24 | 25 | public DemographicParser(ClinicalDocument cd){ 26 | this.cd = cd; 27 | } 28 | 29 | public HashMap parse(){ 30 | HashMap ptInfo = new HashMap(); 31 | 32 | try{ 33 | RecordTarget recordTarget = cd.getRecordTargets().get(0); 34 | 35 | org.openhealthtools.mdht.uml.cda.Patient patient = recordTarget.getPatientRole().getPatient(); 36 | 37 | String id ="" ,first = "", last = "", birthTime = "", gender = "", marital_status = "", provider_org = "", languages = ""; 38 | String street = "", city = "", state = "", country = "", providerName=""; 39 | 40 | 41 | for(PN pname : patient.getNames()){ 42 | if(pname.getFamilies().size()>0){ 43 | last = ((ENXP)pname.getFamilies().get(0)).getText(); 44 | } 45 | if(pname.getGivens().size()>0){ 46 | first = ((ENXP)pname.getGivens().get(0)).getText(); 47 | } 48 | } 49 | 50 | if(patient.getBirthTime() != null){ 51 | birthTime = patient.getBirthTime().getValue(); 52 | } 53 | 54 | CE gcode = patient.getAdministrativeGenderCode(); 55 | if (gcode != null) 56 | gender = gcode.getDisplayName(); 57 | if(gender == null) 58 | gender = ""; 59 | 60 | CE mcode = patient.getMaritalStatusCode(); 61 | if (mcode != null) 62 | marital_status = mcode.getDisplayName(); 63 | 64 | for(org.openhealthtools.mdht.uml.cda.LanguageCommunication lc : patient.getLanguageCommunications()){ 65 | languages += lc.getLanguageCode().getDisplayName()+" "; 66 | } 67 | 68 | 69 | 70 | 71 | 72 | if(recordTarget.getPatientRole().getProviderOrganization()!=null) 73 | provider_org = recordTarget.getPatientRole().getProviderOrganization().getNames().get(0).getText(); 74 | 75 | for(AD ad: recordTarget.getPatientRole().getAddrs()){ 76 | 77 | if (ad.getStreetAddressLines().size()>0) 78 | street = ad.getStreetAddressLines().get(0).getText(); 79 | 80 | if (ad.getCities().size()>0) 81 | city = ad.getCities().get(0).getText(); 82 | 83 | if(ad.getStates().size()>0) 84 | state = ad.getStates().get(0).getText(); 85 | 86 | if(ad.getCountries().size()>0) 87 | country = ad.getCountries().get(0).getText(); 88 | } 89 | 90 | 91 | 92 | //get provider name 93 | String provider_last_name = "", provider_first_name = ""; 94 | 95 | EList names= cd.getDocumentationOfs().get(0).getServiceEvent().getPerformers().get(0).getAssignedEntity().getAssignedPerson().getNames(); 96 | if (names.get(0).getGivens().size()>0){ 97 | provider_first_name = ((ENXP)names.get(0).getGivens().get(0)).getText(); 98 | provider_last_name = ((ENXP)names.get(0).getFamilies().get(0)).getText(); 99 | } 100 | //get mrn 101 | id = recordTarget.getPatientRole().getIds().get(0).getExtension(); 102 | ptInfo.put("id", id); 103 | ptInfo.put("first", first.trim()); 104 | ptInfo.put("last", last.trim()); 105 | ptInfo.put("gender", gender); 106 | ptInfo.put("birth_time", birthTime.trim()); 107 | ptInfo.put("marital_status", marital_status.trim()); 108 | ptInfo.put("provider_org", provider_org.trim() ); 109 | ptInfo.put("provider_first", provider_first_name.trim()); 110 | ptInfo.put("provider_last", provider_last_name.trim()); 111 | ptInfo.put("languages", languages); 112 | ptInfo.put("street", street.trim()); 113 | ptInfo.put("city", city.trim() ); 114 | ptInfo.put("state", state.trim()); 115 | ptInfo.put("country", country.trim() ); 116 | }catch(Exception e){ 117 | e.printStackTrace(); 118 | } 119 | 120 | return ptInfo; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/MedicationParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.HashMap; 6 | 7 | import org.openhealthtools.mdht.uml.cda.Consumable; 8 | import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; 9 | import org.openhealthtools.mdht.uml.cda.Material; 10 | import org.openhealthtools.mdht.uml.cda.Observation; 11 | import org.openhealthtools.mdht.uml.cda.Precondition; 12 | import org.openhealthtools.mdht.uml.cda.Section; 13 | import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; 14 | import org.openhealthtools.mdht.uml.cda.consol.MedicationActivity; 15 | import org.openhealthtools.mdht.uml.cda.consol.MedicationsSection; 16 | import org.openhealthtools.mdht.uml.cda.consol.ProblemObservation; 17 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 18 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 19 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; 20 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 21 | import org.openhealthtools.mdht.uml.hl7.datatypes.PIVL_TS; 22 | import org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS; 23 | import org.openhealthtools.mdht.uml.hl7.datatypes.impl.ENImpl; 24 | 25 | /** 26 | * 27 | * @author Chintan Patel 28 | * 29 | * MedicationParser - Parses medications from a CDA into HashMap/Dictionary 30 | * 31 | */ 32 | public class MedicationParser { 33 | 34 | MedicationsSection medSection = null; 35 | 36 | public MedicationParser(MedicationsSection medSection) { 37 | this.medSection = medSection; 38 | } 39 | 40 | public ArrayList parse(){ 41 | ArrayList medList = new ArrayList(); 42 | 43 | if(this.medSection == null){ 44 | return medList; 45 | } 46 | 47 | int indx = 0; 48 | 49 | for (SubstanceAdministration sa : medSection.getSubstanceAdministrations()){ 50 | 51 | // for (SubstanceAdministration sa : medSection.getSubstanceAdministrations()) { 52 | 53 | HashMap med = new HashMap(); 54 | Consumable consumable = sa.getConsumable(); 55 | ManufacturedProduct manufacturedProduct = consumable.getManufacturedProduct(); 56 | Material mf = manufacturedProduct.getManufacturedMaterial(); 57 | ENImpl mname = (ENImpl) mf.getName(); 58 | 59 | String med_name = ""; 60 | if (mname != null) { 61 | med_name = mname.getText(); 62 | } else { 63 | med_name = mf.getCode().getDisplayName(); 64 | } 65 | 66 | //Dose + repeat number 67 | IVL_PQ dose = sa.getDoseQuantity(); 68 | 69 | 70 | String dosage = ""; 71 | if (dose!=null){ 72 | dosage = ""+dose.getValue(); 73 | } 74 | 75 | //Time 76 | String period_unit = ""; 77 | HashMap ts = null; 78 | 79 | for(SXCM_TS effectiveTime :sa.getEffectiveTimes()){ 80 | //System.out.println(effectiveTime); 81 | if (effectiveTime instanceof PIVL_TS){ 82 | PIVL_TS periodTS = (PIVL_TS)effectiveTime; 83 | period_unit += ""+periodTS.getPeriod().getValue()+" "+periodTS.getPeriod().getUnit(); 84 | } 85 | if (effectiveTime instanceof IVL_TS){ 86 | IVL_TS pTime = (IVL_TS)effectiveTime; 87 | ts = CDAParserUtil.getTS(pTime); 88 | } 89 | } 90 | 91 | //Route code 92 | CE routeCode = sa.getRouteCode(); 93 | String route = ""; 94 | if(routeCode!=null){ 95 | if(routeCode.getDisplayName()!=null){ 96 | route = routeCode.getDisplayName(); 97 | } 98 | if(routeCode.getOriginalText()!=null){ 99 | route = routeCode.getOriginalText().getText(); 100 | } 101 | } 102 | 103 | //administration unit 104 | String administration_unit = ""; 105 | CE aunit = sa.getAdministrationUnitCode(); 106 | if(aunit!=null){ 107 | administration_unit = aunit.getDisplayName(); 108 | } 109 | 110 | //status 111 | String status_code = sa.getStatusCode().getCode(); 112 | 113 | 114 | //related conditions 115 | ArrayList related_conditions = new ArrayList(); 116 | for(Precondition prec : sa.getPreconditions()){ 117 | //System.out.println(); 118 | 119 | HashMap rcond = new HashMap(); 120 | rcond.put("name", ((CE)prec.getCriterion().getValue()).getDisplayName()); 121 | related_conditions.add(rcond); 122 | } 123 | 124 | for(Observation os : sa.getObservations()){ 125 | 126 | if(os instanceof ProblemObservation){ 127 | ProblemObservation pobs = (ProblemObservation)os; 128 | String problem_name = ((CD)pobs.getValues().get(0)).getDisplayName(); 129 | //String problem_status = ((CD)pobs.getProblemStatus().getValues().get(0)).getDisplayName(); 130 | HashMap rcond = new HashMap(); 131 | rcond.put("name", problem_name); 132 | HashMap ots = CDAParserUtil.getTS(pobs.getEffectiveTime()); 133 | rcond.put("ts", ots); 134 | //rcond.put("status", problem_status); 135 | related_conditions.add(rcond); 136 | } 137 | } 138 | 139 | med.put("name", med_name); 140 | med.put("dose", dosage); 141 | med.put("route", route); 142 | med.put("status", status_code); 143 | med.put("administration_unit",administration_unit); //e.g puff, tablet etc 144 | med.put("period_unit", period_unit); 145 | med.put("ts",ts); 146 | med.put("related_conditions", related_conditions); 147 | medList.add(med); 148 | 149 | //indx = indx+1; 150 | 151 | } 152 | 153 | Collections.sort(medList, new DateComparator()); 154 | return medList; 155 | } 156 | 157 | 158 | } 159 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/ProblemParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.HashMap; 6 | 7 | import org.openhealthtools.mdht.uml.cda.Observation; 8 | import org.openhealthtools.mdht.uml.cda.consol.EpisodeObservation; 9 | import org.openhealthtools.mdht.uml.cda.consol.ProblemConcernAct; 10 | import org.openhealthtools.mdht.uml.cda.consol.ProblemObservation; 11 | import org.openhealthtools.mdht.uml.cda.consol.ProblemSection; 12 | import org.openhealthtools.mdht.uml.cda.consol.ProblemStatus; 13 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 14 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 15 | 16 | /** 17 | * 18 | * @author Chintan Patel 19 | * 20 | * ProblemParser - Parses problems/conditions from a CDA into HashMap/Dictionary 21 | * 22 | */ 23 | public class ProblemParser { 24 | 25 | ProblemSection problemSection = null; 26 | 27 | public ProblemParser(ProblemSection problemSection){ 28 | this.problemSection = problemSection; 29 | } 30 | 31 | public ArrayList parse(){ 32 | ArrayList condList = new ArrayList(); 33 | 34 | if(problemSection == null){ 35 | return condList; 36 | } 37 | 38 | try{ 39 | for(ProblemConcernAct problemAct: problemSection.getProblemConcerns()){ 40 | 41 | for(Observation obs : problemAct.getObservations()){ 42 | 43 | if(obs instanceof ProblemObservation){ 44 | 45 | HashMap cond = new HashMap(); 46 | ProblemObservation pobs = (ProblemObservation)obs; 47 | 48 | String problem_name = ((CD)pobs.getValues().get(0)).getDisplayName(); 49 | 50 | String problem_status = ""; 51 | 52 | if(pobs.getProblemStatus() !=null && pobs.getProblemStatus().getValues().size()>0){ 53 | 54 | problem_status = ((CD)pobs.getProblemStatus().getValues().get(0)).getDisplayName(); 55 | } 56 | //System.out.println(((CD)pobs.getValues().get(0)).getDisplayName()); 57 | //System.out.println("PHS:"+pobs.getProblemHealthStatus()); 58 | //System.out.println(((CD)pobs.getProblemStatus().getValues().get(0)).getDisplayName()); 59 | //System.out.println("PS:"+); 60 | 61 | IVL_TS pTime = pobs.getEffectiveTime(); 62 | //System.out.println(pobs.getCode()); 63 | String code = ((CD)pobs.getValues().get(0)).getCode(); 64 | //System.out.println((CD)pobs.getProblemStatus().getCode()); 65 | //System.out.println(((CD)pobs.getProblemStatus().getValues().get(0))); 66 | HashMap ts = CDAParserUtil.getTS(pTime); 67 | //cond.put("code1", pobs.getCode().getCode()); 68 | cond.put("name", problem_name); 69 | cond.put("status", problem_status); 70 | cond.put("ts", ts); 71 | cond.put("code", code); 72 | condList.add(cond); 73 | } 74 | if(obs instanceof EpisodeObservation){ 75 | EpisodeObservation eobs = (EpisodeObservation)obs; 76 | //E.g. clinical finding 77 | //System.out.println("EPISODE "+eobs.getValues()); 78 | } 79 | } 80 | 81 | } 82 | }catch(Exception ex){ 83 | System.out.println("Problem Parsing Exception:"); 84 | ex.printStackTrace(); 85 | } 86 | Collections.sort(condList,new DateComparator()); 87 | return condList; 88 | 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/ProcedureParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.HashMap; 6 | 7 | import org.openhealthtools.mdht.uml.cda.Procedure; 8 | import org.openhealthtools.mdht.uml.cda.consol.ProcedureActivityProcedure; 9 | import org.openhealthtools.mdht.uml.cda.consol.ProceduresSection; 10 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 11 | 12 | public class ProcedureParser { 13 | /** Parse procedures **/ 14 | 15 | ProceduresSection proceduresSection = null; 16 | 17 | public ProcedureParser(ProceduresSection proceduresSection){ 18 | this.proceduresSection = proceduresSection; 19 | } 20 | 21 | public ArrayList parse(){ 22 | ArrayList proc_parsed = new ArrayList>(); 23 | //ArrayList proc_parsed = new ArrayList(); 24 | try{ 25 | for (Procedure proc: this.proceduresSection.getProcedures()){ 26 | HashMap proc_map = new HashMap(); 27 | proc_map.put("code",proc.getCode().getCode()); 28 | proc_map.put("name", proc.getCode().getDisplayName()); 29 | proc_map.put("ts",CDAParserUtil.getTS(proc.getEffectiveTime())); 30 | proc_map.put("status",proc.getStatusCode().getCode()); 31 | proc_parsed.add(proc_map); 32 | } 33 | }catch(Exception ex){ 34 | System.out.println("Procedure Parsing Error:"); 35 | ex.printStackTrace(); 36 | } 37 | 38 | Collections.sort(proc_parsed, new DateComparator()); 39 | return proc_parsed; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/ResultParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | 6 | import org.openhealthtools.mdht.uml.cda.Organizer; 7 | import org.openhealthtools.mdht.uml.cda.ReferenceRange; 8 | import org.openhealthtools.mdht.uml.cda.consol.ResultObservation; 9 | import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; 10 | import org.openhealthtools.mdht.uml.cda.consol.ResultsSection; 11 | import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSection; 12 | import org.openhealthtools.mdht.uml.cda.hitsp.DiagnosticResultsSection; 13 | import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; 14 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 15 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; 16 | import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; 17 | 18 | /** 19 | * 20 | * @author Chintan Patel 21 | * 22 | * ResultParser - Parses results from a CDA into HashMap/Dictionary. It has 2 constuctors 23 | * each for CCD/HITSP-32 document and one for HITSP-83 document 24 | * 25 | */ 26 | 27 | public class ResultParser { 28 | 29 | ResultsSection resultsSection; 30 | DiagnosticResultsSection diagnosticResultsSection; 31 | VitalSignsSection vitalsignSection; 32 | 33 | public ResultParser(ResultsSection resultsSection){ 34 | this.resultsSection = resultsSection; 35 | } 36 | 37 | public ResultParser(DiagnosticResultsSection diagnosticResultsSection){ 38 | this.diagnosticResultsSection = diagnosticResultsSection; 39 | } 40 | public ResultParser(VitalSignsSection vitalsignSection){ 41 | this.vitalsignSection = vitalsignSection; 42 | } 43 | 44 | public ArrayList parse(){ 45 | if(resultsSection != null){ 46 | return parseH32(resultsSection); 47 | } 48 | if (diagnosticResultsSection!=null){ 49 | return parseH83(diagnosticResultsSection); 50 | } 51 | return null; 52 | } 53 | 54 | private ArrayList parseH32(ResultsSection resultsSection){ 55 | ArrayList resultsList = new ArrayList(); 56 | 57 | if(resultsSection == null){ 58 | return resultsList; 59 | } 60 | 61 | try{ 62 | 63 | for(ResultOrganizer rorg: resultsSection.getResultOrganizers()){ 64 | 65 | HashMap res_org = new HashMap(); 66 | String organizer_name = rorg.getCode().getDisplayName(); 67 | ArrayList res_items = new ArrayList(); 68 | 69 | for(ResultObservation robs : rorg.getResultObservations()){ 70 | 71 | HashMap res_item = new HashMap(); 72 | //result name 73 | String result_name = robs.getCode().getDisplayName(); 74 | String code = robs.getCode().getCode(); 75 | String code_system = robs.getCode().getCodeSystem(); 76 | String result_value = ""; 77 | String result_unit = ""; 78 | 79 | //result val 80 | ANY rval = robs.getValues().get(0); 81 | 82 | if(rval instanceof PQ){ 83 | PQ rpq = (PQ)rval; 84 | result_value = ""+rpq.getValue(); 85 | result_unit = ""+rpq.getUnit(); 86 | } 87 | 88 | //Get reference ranges 89 | String reference_range_text = ""; 90 | String reference_range_low = ""; 91 | String reference_range_high = ""; 92 | 93 | for(ReferenceRange rr : robs.getReferenceRanges()){ 94 | ANY rr_val = rr.getObservationRange().getValue(); 95 | if (rr_val instanceof IVL_PQ){ 96 | reference_range_low = ""+((IVL_PQ)rr_val).getLow().getValue(); 97 | reference_range_high = ""+((IVL_PQ)rr_val).getHigh().getValue(); 98 | } 99 | } 100 | 101 | //TimeStamp 102 | HashMap ts = CDAParserUtil.getTS(robs.getEffectiveTime()); 103 | 104 | //Interpretation 105 | String interpretation = ""; 106 | if (robs.getInterpretationCodes().size()>0){ 107 | interpretation = ((CE)robs.getInterpretationCodes().get(0)).getDisplayName(); 108 | } 109 | 110 | res_item.put("name", result_name); 111 | res_item.put("value", result_value); 112 | res_item.put("unit", result_unit); 113 | res_item.put("code", code); 114 | res_item.put("code_system", code_system); 115 | res_item.put("ref_low",reference_range_low); 116 | res_item.put("ref_high",reference_range_high); 117 | res_item.put("ts", ts); 118 | res_item.put("interpretation", interpretation); 119 | 120 | res_items.add(res_item); 121 | 122 | } 123 | res_org.put("category", organizer_name); 124 | res_org.put("results", res_items); 125 | 126 | resultsList.add(res_org); 127 | } 128 | }catch(Exception ex){ 129 | System.out.println("Result Parsing Exception:"); 130 | ex.printStackTrace(); 131 | } 132 | 133 | return resultsList; 134 | } 135 | 136 | 137 | private ArrayList parseH83(DiagnosticResultsSection diagnosticResultsSection){ 138 | ArrayList resultsList = new ArrayList(); 139 | 140 | if(diagnosticResultsSection == null){ 141 | return resultsList; 142 | } 143 | 144 | // System.out.println(diagnosticResultsSection.getOrganizers()); 145 | // System.out.println(diagnosticResultsSection.getDiagnosticProcedures()); 146 | 147 | for( Organizer org: diagnosticResultsSection.getOrganizers()){ 148 | 149 | ResultOrganizer rorg = (ResultOrganizer)org; 150 | //System.out.println(rorg); 151 | 152 | HashMap res_org = new HashMap(); 153 | String organizer_name = rorg.getCode().getDisplayName(); 154 | //System.out.println("PATI ORG"+organizer_name); 155 | ArrayList res_items = new ArrayList(); 156 | 157 | for(ResultObservation robs : rorg.getResultObservations()){ 158 | 159 | HashMap res_item = new HashMap(); 160 | //result name 161 | String result_name = robs.getCode().getDisplayName(); 162 | String code = robs.getCode().getCode(); 163 | String code_system = robs.getCode().getCodeSystem(); 164 | 165 | String result_value = ""; 166 | String result_unit = ""; 167 | 168 | //result val 169 | ANY rval = robs.getValues().get(0); 170 | 171 | if(rval instanceof PQ){ 172 | PQ rpq = (PQ)rval; 173 | result_value = rpq.getValue()+" "; 174 | result_unit = rpq.getUnit(); 175 | } 176 | 177 | //Get reference ranges 178 | String reference_range_text = ""; 179 | String reference_range_low = ""; 180 | String reference_range_high = ""; 181 | 182 | for(ReferenceRange rr : robs.getReferenceRanges()){ 183 | ANY rr_val = rr.getObservationRange().getValue(); 184 | if (rr_val instanceof IVL_PQ){ 185 | reference_range_low = ""+((IVL_PQ)rr_val).getLow().getValue(); 186 | reference_range_high = ""+((IVL_PQ)rr_val).getHigh().getValue(); 187 | } 188 | } 189 | 190 | //TimeStamp 191 | HashMap ts = CDAParserUtil.getTS(robs.getEffectiveTime()); 192 | 193 | //Interpretation 194 | String interpretation = ""; 195 | if (robs.getInterpretationCodes().size()>0){ 196 | interpretation = ((CE)robs.getInterpretationCodes().get(0)).getDisplayName(); 197 | } 198 | 199 | res_item.put("name", result_name); 200 | res_item.put("value", result_value); 201 | res_item.put("unit", result_unit); 202 | res_item.put("code", code); 203 | res_item.put("code_system", code_system); 204 | res_item.put("ref_low",reference_range_low); 205 | res_item.put("ref_high",reference_range_high); 206 | res_item.put("ts", ts); 207 | res_item.put("interpretation", interpretation); 208 | 209 | res_items.add(res_item); 210 | 211 | } 212 | res_org.put("category", organizer_name); 213 | res_org.put("results", res_items); 214 | 215 | resultsList.add(res_org); 216 | } 217 | 218 | return resultsList; 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/mu2parser/VitalSignParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.mu2parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.HashMap; 6 | 7 | import org.openhealthtools.mdht.uml.cda.ClinicalDocument; 8 | import org.openhealthtools.mdht.uml.cda.Component4; 9 | import org.openhealthtools.mdht.uml.cda.Entry; 10 | import org.openhealthtools.mdht.uml.cda.Observation; 11 | import org.openhealthtools.mdht.uml.cda.Organizer; 12 | import org.openhealthtools.mdht.uml.cda.Section; 13 | import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; 14 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 15 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 16 | import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; 17 | 18 | public class VitalSignParser { 19 | Section vitalSection = null; 20 | 21 | public VitalSignParser(Section vitalSection) { 22 | this.vitalSection = vitalSection; 23 | } 24 | 25 | 26 | public ArrayList parse(){ 27 | ArrayList vitalList = new ArrayList(); 28 | 29 | try{ 30 | for( Entry e:vitalSection.getEntries()){ 31 | Organizer k = e.getOrganizer(); 32 | HashMap vmap = new HashMap(); 33 | for (Component4 x : k.getComponents()){ 34 | Observation obs = x.getObservation(); 35 | CD co = obs.getCode(); 36 | String vital_name = co.getDisplayName(); 37 | IVL_TS pTime = obs.getEffectiveTime(); 38 | String tr = pTime.getValue(); 39 | HashMap ts = CDAParserUtil.getTS(pTime); 40 | vmap.put("date", tr); 41 | // System.out.println(ts); 42 | System.out.println(pTime); 43 | if (vital_name!=null && obs.getValues().size() > 0){ 44 | PQ kl = (PQ) obs.getValues().get(0); 45 | String value = kl.getValue() + ";" +kl.getUnit(); 46 | vmap.put(vital_name, value); 47 | 48 | } 49 | 50 | } 51 | if (vmap.size()>0){ 52 | vitalList.add(vmap); 53 | } 54 | } 55 | }catch(Exception ex){ 56 | System.out.println("Vitals Parsing Error"); 57 | ex.printStackTrace(); 58 | } 59 | System.out.println(vitalList); 60 | // Collections.sort(vitalList,new DateComparator()); 61 | return vitalList; 62 | 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/parser/AllergyParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | 6 | import org.openhealthtools.mdht.uml.cda.Act; 7 | import org.openhealthtools.mdht.uml.cda.EntryRelationship; 8 | import org.openhealthtools.mdht.uml.cda.Observation; 9 | import org.openhealthtools.mdht.uml.cda.Participant2; 10 | import org.openhealthtools.mdht.uml.cda.Section; 11 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 12 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 13 | import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; 14 | 15 | /** 16 | * 17 | * @author Chintan Patel 18 | * 19 | * AllergyParser: Parses the CDA section on Allergy into JSON objects 20 | * 21 | */ 22 | public class AllergyParser { 23 | 24 | Section allergySection = null; 25 | 26 | public AllergyParser(Section allergySection) { 27 | this.allergySection = allergySection; 28 | } 29 | 30 | public ArrayList parse(){ 31 | 32 | ArrayList allergyList = new ArrayList(); 33 | 34 | if(this.allergySection == null){ 35 | return allergyList; 36 | } 37 | 38 | for(Act act:allergySection.getActs()){ 39 | 40 | for(EntryRelationship entryR : act.getEntryRelationships()){ 41 | 42 | HashMap amap = new HashMap(); 43 | 44 | String allergy_type = "", allergy_agent = "", allergy_reaction = "", allergy_status = ""; 45 | 46 | Observation obs = entryR.getObservation(); 47 | if(obs!=null){ 48 | //System.out.println(obs.getValues()); 49 | //System.out.println(obs.getCode()); 50 | 51 | if (obs.getValues().size() > 0){ 52 | allergy_type = ((CD)obs.getValues().get(0)).getDisplayName(); 53 | } 54 | 55 | if(allergy_type == ""){ 56 | allergy_type = obs.getCode().getDisplayName(); 57 | } 58 | } 59 | 60 | for(Participant2 p2 : obs.getParticipants()){ 61 | System.out.println(); 62 | allergy_agent = ((CE)p2.getParticipantRole().getPlayingEntity().getCode()).getDisplayName(); 63 | 64 | if (allergy_agent == null){ //Check if we have translations 65 | allergy_agent = CDAParserUtil.getTranslationDisplayName(p2.getParticipantRole().getPlayingEntity().getCode()); 66 | } 67 | //System.out.println(((CS)p2.getRealmCodes().get(0)).getDisplayName()); 68 | } 69 | 70 | for(EntryRelationship oer : obs.getEntryRelationships()){ 71 | Observation oer_obs = oer.getObservation(); 72 | if (oer.getTypeCode() == x_ActRelationshipEntryRelationship.MFST){ // 73 | allergy_reaction = ((CD)oer_obs.getValues().get(0)).getDisplayName(); 74 | 75 | if(allergy_reaction == null){ 76 | allergy_reaction = CDAParserUtil.getTranslationDisplayName(oer_obs.getValues().get(0)); 77 | } 78 | 79 | } 80 | 81 | if (oer.getTypeCode() == x_ActRelationshipEntryRelationship.REFR){ // 82 | allergy_status = ((CE)oer_obs.getValues().get(0)).getDisplayName(); 83 | if(allergy_status == null){ 84 | allergy_status = CDAParserUtil.getTranslationDisplayName(oer_obs.getValues().get(0)); 85 | } 86 | } 87 | } 88 | 89 | amap.put("type", allergy_type); 90 | amap.put("substance", allergy_agent); 91 | amap.put("reaction", allergy_reaction); 92 | amap.put("status", allergy_status); 93 | allergyList.add(amap); 94 | } 95 | } 96 | 97 | return allergyList; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/parser/CDAParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.parser; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileNotFoundException; 5 | import java.io.InputStream; 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | 9 | import org.eclipse.emf.common.util.Diagnostic; 10 | import org.openhealthtools.mdht.uml.cda.Act; 11 | import org.openhealthtools.mdht.uml.cda.ClinicalDocument; 12 | import org.openhealthtools.mdht.uml.cda.Consumable; 13 | import org.openhealthtools.mdht.uml.cda.EntryRelationship; 14 | import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; 15 | import org.openhealthtools.mdht.uml.cda.Material; 16 | import org.openhealthtools.mdht.uml.cda.Observation; 17 | import org.openhealthtools.mdht.uml.cda.Organizer; 18 | import org.openhealthtools.mdht.uml.cda.Participant2; 19 | import org.openhealthtools.mdht.uml.cda.Precondition; 20 | import org.openhealthtools.mdht.uml.cda.ReferenceRange; 21 | import org.openhealthtools.mdht.uml.cda.Section; 22 | import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; 23 | import org.openhealthtools.mdht.uml.cda.ccd.CCDFactory; 24 | import org.openhealthtools.mdht.uml.cda.hitsp.DiagnosticResultsSection; 25 | import org.openhealthtools.mdht.uml.cda.ccd.ContinuityOfCareDocument; 26 | import org.openhealthtools.mdht.uml.cda.ccd.EpisodeObservation; 27 | import org.openhealthtools.mdht.uml.cda.ccd.MedicationsSection; 28 | import org.openhealthtools.mdht.uml.cda.ccd.ProblemAct; 29 | import org.openhealthtools.mdht.uml.cda.ccd.ProblemObservation; 30 | import org.openhealthtools.mdht.uml.cda.ccd.ProblemSection; 31 | import org.openhealthtools.mdht.uml.cda.ccd.ResultObservation; 32 | import org.openhealthtools.mdht.uml.cda.ccd.ResultOrganizer; 33 | import org.openhealthtools.mdht.uml.cda.ccd.ResultsSection; 34 | import org.openhealthtools.mdht.uml.cda.hitsp.HITSPPackage; 35 | import org.openhealthtools.mdht.uml.cda.hitsp.PatientSummary; 36 | import org.openhealthtools.mdht.uml.cda.util.CDAUtil; 37 | import org.openhealthtools.mdht.uml.cda.util.ValidationResult; 38 | import org.openhealthtools.mdht.uml.hl7.datatypes.AD; 39 | import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; 40 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 41 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 42 | import org.openhealthtools.mdht.uml.hl7.datatypes.ENXP; 43 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; 44 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 45 | import org.openhealthtools.mdht.uml.hl7.datatypes.PIVL_TS; 46 | import org.openhealthtools.mdht.uml.hl7.datatypes.PN; 47 | import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; 48 | import org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS; 49 | import org.openhealthtools.mdht.uml.hl7.datatypes.impl.ENImpl; 50 | import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; 51 | 52 | import org.openhealthtools.mdht.uml.cda.mu2consol.Mu2consolPackage; 53 | import org.openhealthtools.mdht.uml.cda.mu2consol.Mu2consolFactory; 54 | import org.openhealthtools.mdht.uml.cda.mu2consol.ClinicalOfficeVisitSummary; 55 | 56 | /** 57 | * 58 | * @author Chintan Patel 59 | * 60 | * CDAParser - The core CDAParser that parses an input stream to parse a HITSP-32 or HITSP-83 document 61 | * 62 | */ 63 | public class CDAParser { 64 | 65 | //Initialize the document variables 66 | ClinicalDocument cd = null; 67 | MedicationsSection medicationsSection = null; 68 | ProblemSection problemSection = null; 69 | Section allergySection = null; 70 | ResultsSection resultsSection = null; 71 | DiagnosticResultsSection diagnosticResultsSection = null; 72 | 73 | PatientSummary ps = null; //for HITSP 83 74 | ContinuityOfCareDocument ccd = null; //for HITSP 32 75 | 76 | /** 77 | * Constructor for the CDA Parser. Accepts an InputStream of a CDA document in either 78 | * HITSP 32 (CCD) or HITSP 83 (CCDA) document 79 | * @param cda_input 80 | */ 81 | public CDAParser(InputStream cda_input){ 82 | // HITSPPackage.eINSTANCE.eClass(); 83 | // ContinuityOfCareDocument doc = CCDFactory.eINSTANCE.createContinuityOfCareDocument().init(); 84 | 85 | Mu2consolPackage.eINSTANCE.eClass(); 86 | 87 | ValidationResult result = new ValidationResult(); 88 | 89 | try { 90 | //cd = CDAUtil.load(cda_input, result); //Load CDA document and validate 91 | 92 | cd = CDAUtil.loadAs( 93 | cda_input, 94 | Mu2consolPackage.eINSTANCE.getClinicalOfficeVisitSummary(), 95 | result); 96 | 97 | } catch (FileNotFoundException e) { 98 | e.printStackTrace(); 99 | } catch (Exception e) { 100 | e.printStackTrace(); 101 | } 102 | 103 | //Output diagnostic error messages 104 | //TODO: return any errors to the client 105 | for (Diagnostic diagnostic : result.getErrorDiagnostics()) { 106 | System.out.println("ERROR: " + diagnostic.getMessage()); 107 | } 108 | for (Diagnostic diagnostic : result.getWarningDiagnostics()) { 109 | System.out.println("WARNING: " + diagnostic.getMessage()); 110 | } 111 | 112 | String allergy_template_id = "2.16.840.1.113883.10.20.1.2"; 113 | 114 | if (cd instanceof ContinuityOfCareDocument){ 115 | ContinuityOfCareDocument ccd = (ContinuityOfCareDocument) cd; 116 | System.out.println("CCD"); 117 | medicationsSection = ccd.getMedicationsSection(); 118 | problemSection = ccd.getProblemSection(); 119 | allergySection = CDAParserUtil.getSection(cd, allergy_template_id); 120 | resultsSection = ccd.getResultsSection(); 121 | }else if (cd instanceof PatientSummary){ 122 | PatientSummary ps = (PatientSummary)cd; 123 | medicationsSection = ps.getMedicationsSection(); 124 | problemSection = ps.getProblemSection(); 125 | System.out.println("Patient Summary"); 126 | allergySection = ps.getAllergiesReactionsSection(); 127 | diagnosticResultsSection = ps.getDiagnosticResultsSection(); 128 | }else{ 129 | ClinicalOfficeVisitSummary covs = (ClinicalOfficeVisitSummary)cd; 130 | System.out.println("NOT A CCDA or PATIENT SUMMARY!"); 131 | System.out.println(cd); 132 | System.out.println(covs); 133 | medicationsSection = (MedicationsSection) covs.getMedicationsSection(); 134 | 135 | } 136 | } 137 | 138 | 139 | 140 | /** 141 | * Get Medications from the CDA 142 | * @return ArrayList of parsed medications 143 | */ 144 | public ArrayList getMedications(){ 145 | return (new MedicationParser(medicationsSection)).parse(); 146 | } 147 | 148 | /** 149 | * Get Allergies from the CDA 150 | * @return ArrayList of parsed allergies 151 | */ 152 | public ArrayList getAllergies(){ 153 | return (new AllergyParser(allergySection)).parse(); 154 | } 155 | 156 | /** 157 | * Get results section from the CDA 158 | * @return ArrayList of parsed results 159 | */ 160 | public ArrayList getResults(){ 161 | //Decide between HITSP 32 versus 83 162 | if (ps!=null){ 163 | return (new ResultParser(diagnosticResultsSection)).parse(); 164 | }else{ 165 | return (new ResultParser(resultsSection)).parse(); 166 | } 167 | } 168 | 169 | /** 170 | * Get problems from the CDA 171 | * @return ArrayList of parsed problems 172 | */ 173 | public ArrayList getProblems(){ 174 | return (new ProblemParser(problemSection)).parse(); 175 | } 176 | 177 | /** 178 | * Get demographics from the CDA 179 | * @return HashMap/Dictionary of Demographics 180 | */ 181 | public HashMap getDemographics(){ 182 | return (new DemographicParser(cd)).parse(); 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/parser/CDAParserUtil.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.parser; 2 | 3 | import java.util.HashMap; 4 | 5 | import org.openhealthtools.mdht.uml.cda.ClinicalDocument; 6 | import org.openhealthtools.mdht.uml.cda.Section; 7 | import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; 8 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 9 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 10 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 11 | 12 | /** 13 | * 14 | * @author Chintan Patel 15 | * 16 | * Parsing utility Functions 17 | * 18 | */ 19 | public class CDAParserUtil { 20 | 21 | /** 22 | * Takes a IVL_TS time object and returns a simple low,high and center values 23 | * @param pTime 24 | * @return A dictionary/HashMap of low, high and center values of time stamp 25 | */ 26 | public static HashMap getTS(IVL_TS pTime){ 27 | HashMap ts = new HashMap(); 28 | ts.put("ts_low", ""); 29 | ts.put("ts_high", ""); 30 | ts.put("ts_center", ""); 31 | if (pTime!=null){ 32 | if (pTime.getLow()!=null){ 33 | //System.out.println("LOW:"+pTime.getLow().getValue()); 34 | ts.put("ts_low",pTime.getLow().getValue()); 35 | } 36 | if (pTime.getHigh()!=null){ 37 | //System.out.println("HIGH:"+pTime.getHigh().getValue()); 38 | ts.put("ts_high",pTime.getHigh().getValue()); 39 | } 40 | if (pTime.getCenter()!=null){ 41 | //System.out.println("CENTER:"+pTime.getCenter().getValue()); 42 | ts.put("ts_center",pTime.getCenter().getValue()); 43 | } 44 | } 45 | return ts; 46 | } 47 | 48 | /** 49 | * Takes a ANY object and checks if its a CD object or CE object and 50 | * returns a corresponding string of displayName 51 | * 52 | * TODO: Connect this to a terminlogy lookup service if no display name given by code given 53 | * 54 | * @param dt 55 | * @return String of the display name 56 | */ 57 | public static String getTranslationDisplayName(ANY dt){ 58 | 59 | //check if its CD instance 60 | if(dt instanceof CD){ 61 | CD cdt = (CD)dt; 62 | if(cdt.getTranslations().size()>0){ 63 | return cdt.getTranslations().get(0).getDisplayName(); 64 | } 65 | } 66 | 67 | //check if its CE instance 68 | if(dt instanceof CE){ 69 | CE cdt = (CE)dt; 70 | if(cdt.getTranslations().size()>0){ 71 | return cdt.getTranslations().get(0).getDisplayName(); 72 | } 73 | } 74 | return null; 75 | } 76 | 77 | /** 78 | * Gets a section with given template_id from a ClinicalDocument 79 | * @param cd 80 | * @param template_id 81 | * @return Section 82 | */ 83 | public static Section getSection(ClinicalDocument cd, String template_id){ 84 | if(cd.hasSectionTemplate(template_id)){ 85 | for(Section sec : cd.getSections()){ 86 | if(sec.hasTemplateId(template_id)){ 87 | return sec; 88 | } 89 | } 90 | } 91 | return null; 92 | } 93 | 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/parser/DemographicParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.parser; 2 | 3 | import java.util.HashMap; 4 | 5 | import org.openhealthtools.mdht.uml.cda.ClinicalDocument; 6 | import org.openhealthtools.mdht.uml.hl7.datatypes.AD; 7 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 8 | import org.openhealthtools.mdht.uml.hl7.datatypes.ENXP; 9 | import org.openhealthtools.mdht.uml.hl7.datatypes.PN; 10 | import org.openhealthtools.mdht.uml.cda.RecordTarget; 11 | 12 | /** 13 | * 14 | * @author Chintan Patel 15 | * 16 | * DemographicParser: Parses demographic fields from CDA into JSON 17 | * 18 | */ 19 | public class DemographicParser { 20 | 21 | ClinicalDocument cd = null; 22 | 23 | public DemographicParser(ClinicalDocument cd){ 24 | this.cd = cd; 25 | } 26 | 27 | public HashMap parse(){ 28 | 29 | RecordTarget recordTarget = cd.getRecordTargets().get(0); 30 | 31 | HashMap ptInfo = new HashMap(); 32 | 33 | org.openhealthtools.mdht.uml.cda.Patient patient = recordTarget.getPatientRole().getPatient(); 34 | 35 | String id ="" ,first = "", last = "", birthTime = "", gender = "", marital_status = "", provider_org = "", languages = ""; 36 | String street = "", city = "", state = "", country = ""; 37 | 38 | 39 | for(PN pname : patient.getNames()){ 40 | if(pname.getFamilies().size()>0){ 41 | last = ((ENXP)pname.getFamilies().get(0)).getText(); 42 | } 43 | if(pname.getGivens().size()>0){ 44 | first = ((ENXP)pname.getGivens().get(0)).getText(); 45 | } 46 | } 47 | 48 | if(patient.getBirthTime() != null){ 49 | birthTime = patient.getBirthTime().getValue(); 50 | } 51 | 52 | CE gcode = patient.getAdministrativeGenderCode(); 53 | if (gcode != null) 54 | gender = gcode.getDisplayName(); 55 | if(gender == null) 56 | gender = ""; 57 | 58 | CE mcode = patient.getMaritalStatusCode(); 59 | if (mcode != null) 60 | marital_status = mcode.getDisplayName(); 61 | 62 | for(org.openhealthtools.mdht.uml.cda.LanguageCommunication lc : patient.getLanguageCommunications()){ 63 | languages += lc.getLanguageCode().getDisplayName()+" "; 64 | } 65 | 66 | 67 | if(recordTarget.getPatientRole().getProviderOrganization()!=null) 68 | provider_org = recordTarget.getPatientRole().getProviderOrganization().getNames().get(0).getText(); 69 | 70 | for(AD ad: recordTarget.getPatientRole().getAddrs()){ 71 | 72 | if (ad.getStreetAddressLines().size()>0) 73 | street = ad.getStreetAddressLines().get(0).getText(); 74 | 75 | if (ad.getCities().size()>0) 76 | city = ad.getCities().get(0).getText(); 77 | 78 | if(ad.getStates().size()>0) 79 | state = ad.getStates().get(0).getText(); 80 | 81 | if(ad.getCountries().size()>0) 82 | country = ad.getCountries().get(0).getText(); 83 | } 84 | 85 | id = recordTarget.getPatientRole().getIds().get(0).getExtension(); 86 | ptInfo.put("id", id); 87 | ptInfo.put("first", first.trim()); 88 | ptInfo.put("last", last.trim()); 89 | ptInfo.put("gender", gender); 90 | ptInfo.put("birth_time", birthTime.trim()); 91 | ptInfo.put("marital_status", marital_status.trim()); 92 | ptInfo.put("provider_org", provider_org.trim() ); 93 | ptInfo.put("languages", languages); 94 | ptInfo.put("street", street.trim()); 95 | ptInfo.put("city", city.trim() ); 96 | ptInfo.put("state", state.trim()); 97 | ptInfo.put("country", country.trim() ); 98 | return ptInfo; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/parser/MedicationParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | 6 | import org.openhealthtools.mdht.uml.cda.Consumable; 7 | import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; 8 | import org.openhealthtools.mdht.uml.cda.Material; 9 | import org.openhealthtools.mdht.uml.cda.Observation; 10 | import org.openhealthtools.mdht.uml.cda.Precondition; 11 | import org.openhealthtools.mdht.uml.cda.Section; 12 | import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; 13 | import org.openhealthtools.mdht.uml.cda.ccd.MedicationsSection; 14 | import org.openhealthtools.mdht.uml.cda.ccd.ProblemObservation; 15 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 16 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 17 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; 18 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 19 | import org.openhealthtools.mdht.uml.hl7.datatypes.PIVL_TS; 20 | import org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS; 21 | import org.openhealthtools.mdht.uml.hl7.datatypes.impl.ENImpl; 22 | 23 | /** 24 | * 25 | * @author Chintan Patel 26 | * 27 | * MedicationParser - Parses medications from a CDA into HashMap/Dictionary 28 | * 29 | */ 30 | public class MedicationParser { 31 | 32 | MedicationsSection medSection = null; 33 | 34 | public MedicationParser(MedicationsSection medSection) { 35 | this.medSection = medSection; 36 | } 37 | 38 | public ArrayList parse(){ 39 | ArrayList medList = new ArrayList(); 40 | 41 | if(this.medSection == null){ 42 | return medList; 43 | } 44 | 45 | int indx = 0; 46 | 47 | for (SubstanceAdministration sa : medSection.getSubstanceAdministrations()) { 48 | 49 | HashMap med = new HashMap(); 50 | Consumable consumable = sa.getConsumable(); 51 | ManufacturedProduct manufacturedProduct = consumable.getManufacturedProduct(); 52 | Material mf = manufacturedProduct.getManufacturedMaterial(); 53 | ENImpl mname = (ENImpl) mf.getName(); 54 | 55 | String med_name = ""; 56 | if (mname != null) { 57 | med_name = mname.getText(); 58 | } else { 59 | med_name = mf.getCode().getDisplayName(); 60 | } 61 | 62 | if (med_name == null){ 63 | med_name = CDAParserUtil.getTranslationDisplayName(sa.getCode()); 64 | } 65 | 66 | //Dose + repeat number 67 | IVL_PQ dose = sa.getDoseQuantity(); 68 | String dosage = ""+dose.getValue(); 69 | 70 | //Time 71 | String period_unit = ""; 72 | HashMap ts = null; 73 | 74 | for(SXCM_TS effectiveTime :sa.getEffectiveTimes()){ 75 | System.out.println(effectiveTime); 76 | if (effectiveTime instanceof PIVL_TS){ 77 | PIVL_TS periodTS = (PIVL_TS)effectiveTime; 78 | period_unit += ""+periodTS.getPeriod().getValue()+" "+periodTS.getPeriod().getUnit(); 79 | } 80 | if (effectiveTime instanceof IVL_TS){ 81 | IVL_TS pTime = (IVL_TS)effectiveTime; 82 | ts = CDAParserUtil.getTS(pTime); 83 | } 84 | } 85 | 86 | //Route code 87 | CE routeCode = sa.getRouteCode(); 88 | String route = ""; 89 | if(routeCode!=null){ 90 | if(routeCode.getDisplayName()!=null){ 91 | route = routeCode.getDisplayName(); 92 | } 93 | if(routeCode.getOriginalText()!=null){ 94 | route = routeCode.getOriginalText().getText(); 95 | } 96 | } 97 | 98 | //administration unit 99 | String administration_unit = ""; 100 | CE aunit = sa.getAdministrationUnitCode(); 101 | if(aunit!=null){ 102 | administration_unit = aunit.getDisplayName(); 103 | } 104 | 105 | //status 106 | String status_code = sa.getStatusCode().getCode(); 107 | 108 | 109 | //related conditions 110 | ArrayList related_conditions = new ArrayList(); 111 | for(Precondition prec : sa.getPreconditions()){ 112 | //System.out.println(); 113 | 114 | HashMap rcond = new HashMap(); 115 | rcond.put("name", ((CE)prec.getCriterion().getValue()).getDisplayName()); 116 | related_conditions.add(rcond); 117 | } 118 | 119 | for(Observation os : sa.getObservations()){ 120 | 121 | if(os instanceof ProblemObservation){ 122 | ProblemObservation pobs = (ProblemObservation)os; 123 | String problem_name = ((CD)pobs.getValues().get(0)).getDisplayName(); 124 | //String problem_status = ((CD)pobs.getProblemStatus().getValues().get(0)).getDisplayName(); 125 | HashMap rcond = new HashMap(); 126 | rcond.put("name", problem_name); 127 | HashMap ots = CDAParserUtil.getTS(pobs.getEffectiveTime()); 128 | rcond.put("ts", ots); 129 | //rcond.put("status", problem_status); 130 | related_conditions.add(rcond); 131 | } 132 | } 133 | 134 | med.put("name", med_name); 135 | med.put("dose", dosage); 136 | med.put("route", route); 137 | med.put("status", status_code); 138 | med.put("administration_unit",administration_unit); //e.g puff, tablet etc 139 | med.put("period_unit", period_unit); 140 | med.put("ts",ts); 141 | med.put("related_conditions", related_conditions); 142 | medList.add(med); 143 | 144 | //indx = indx+1; 145 | 146 | } 147 | return medList; 148 | } 149 | 150 | 151 | } 152 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/parser/ProblemParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | 6 | import org.openhealthtools.mdht.uml.cda.Observation; 7 | import org.openhealthtools.mdht.uml.cda.ccd.EpisodeObservation; 8 | import org.openhealthtools.mdht.uml.cda.ccd.ProblemAct; 9 | import org.openhealthtools.mdht.uml.cda.ccd.ProblemObservation; 10 | import org.openhealthtools.mdht.uml.cda.ccd.ProblemSection; 11 | import org.openhealthtools.mdht.uml.hl7.datatypes.CD; 12 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; 13 | 14 | /** 15 | * 16 | * @author Chintan Patel 17 | * 18 | * ProblemParser - Parses problems/conditions from a CDA into HashMap/Dictionary 19 | * 20 | */ 21 | public class ProblemParser { 22 | 23 | ProblemSection problemSection = null; 24 | 25 | public ProblemParser(ProblemSection problemSection){ 26 | this.problemSection = problemSection; 27 | } 28 | 29 | public ArrayList parse(){ 30 | ArrayList condList = new ArrayList(); 31 | 32 | if(problemSection == null){ 33 | return condList; 34 | } 35 | for(ProblemAct problemAct: problemSection.getProblemActs()){ 36 | 37 | for(Observation obs : problemAct.getObservations()){ 38 | 39 | if(obs instanceof ProblemObservation){ 40 | 41 | HashMap cond = new HashMap(); 42 | ProblemObservation pobs = (ProblemObservation)obs; 43 | 44 | String problem_name = ((CD)pobs.getValues().get(0)).getDisplayName(); 45 | 46 | String problem_status = ""; 47 | 48 | if(pobs.getProblemStatus() !=null && pobs.getProblemStatus().getValues().size()>0){ 49 | 50 | problem_status = ((CD)pobs.getProblemStatus().getValues().get(0)).getDisplayName(); 51 | } 52 | //System.out.println(((CD)pobs.getValues().get(0)).getDisplayName()); 53 | //System.out.println("PHS:"+pobs.getProblemHealthStatus()); 54 | //System.out.println(((CD)pobs.getProblemStatus().getValues().get(0)).getDisplayName()); 55 | //System.out.println("PS:"+); 56 | 57 | IVL_TS pTime = pobs.getEffectiveTime(); 58 | HashMap ts = CDAParserUtil.getTS(pTime); 59 | cond.put("name", problem_name); 60 | cond.put("status", problem_status); 61 | cond.put("ts", ts); 62 | condList.add(cond); 63 | } 64 | if(obs instanceof EpisodeObservation){ 65 | EpisodeObservation eobs = (EpisodeObservation)obs; 66 | //E.g. clinical finding 67 | //System.out.println("EPISODE "+eobs.getValues()); 68 | } 69 | } 70 | 71 | } 72 | 73 | return condList; 74 | 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/com/appliedinformatics/cdaapi/parser/ResultParser.java: -------------------------------------------------------------------------------- 1 | package com.appliedinformatics.cdaapi.parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | 6 | import org.openhealthtools.mdht.uml.cda.Organizer; 7 | import org.openhealthtools.mdht.uml.cda.ReferenceRange; 8 | import org.openhealthtools.mdht.uml.cda.ccd.ResultObservation; 9 | import org.openhealthtools.mdht.uml.cda.ccd.ResultOrganizer; 10 | import org.openhealthtools.mdht.uml.cda.ccd.ResultsSection; 11 | import org.openhealthtools.mdht.uml.cda.hitsp.DiagnosticResultsSection; 12 | import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; 13 | import org.openhealthtools.mdht.uml.hl7.datatypes.CE; 14 | import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; 15 | import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; 16 | 17 | /** 18 | * 19 | * @author Chintan Patel 20 | * 21 | * ResultParser - Parses results from a CDA into HashMap/Dictionary. It has 2 constuctors 22 | * each for CCD/HITSP-32 document and one for HITSP-83 document 23 | * 24 | */ 25 | 26 | public class ResultParser { 27 | 28 | ResultsSection resultsSection; 29 | DiagnosticResultsSection diagnosticResultsSection; 30 | 31 | public ResultParser(ResultsSection resultsSection){ 32 | this.resultsSection = resultsSection; 33 | } 34 | 35 | public ResultParser(DiagnosticResultsSection diagnosticResultsSection){ 36 | this.diagnosticResultsSection = diagnosticResultsSection; 37 | } 38 | 39 | public ArrayList parse(){ 40 | if(resultsSection != null){ 41 | return parseH32(resultsSection); 42 | } 43 | if (diagnosticResultsSection!=null){ 44 | return parseH83(diagnosticResultsSection); 45 | } 46 | return null; 47 | } 48 | 49 | private ArrayList parseH32(ResultsSection resultsSection){ 50 | ArrayList resultsList = new ArrayList(); 51 | 52 | if(resultsSection == null){ 53 | return resultsList; 54 | } 55 | 56 | for(ResultOrganizer rorg: resultsSection.getResultOrganizers()){ 57 | 58 | HashMap res_org = new HashMap(); 59 | String organizer_name = rorg.getCode().getDisplayName(); 60 | ArrayList res_items = new ArrayList(); 61 | 62 | for(ResultObservation robs : rorg.getResultObservations()){ 63 | 64 | HashMap res_item = new HashMap(); 65 | //result name 66 | String result_name = robs.getCode().getDisplayName(); 67 | String code = robs.getCode().getCode(); 68 | String code_system = robs.getCode().getCodeSystem(); 69 | String result_value = ""; 70 | String result_unit = ""; 71 | 72 | //result val 73 | ANY rval = robs.getValues().get(0); 74 | 75 | if(rval instanceof PQ){ 76 | PQ rpq = (PQ)rval; 77 | result_value = ""+rpq.getValue(); 78 | result_unit = ""+rpq.getUnit(); 79 | } 80 | 81 | //Get reference ranges 82 | String reference_range_text = ""; 83 | String reference_range_low = ""; 84 | String reference_range_high = ""; 85 | 86 | for(ReferenceRange rr : robs.getReferenceRanges()){ 87 | ANY rr_val = rr.getObservationRange().getValue(); 88 | if (rr_val instanceof IVL_PQ){ 89 | reference_range_low = ""+((IVL_PQ)rr_val).getLow().getValue(); 90 | reference_range_high = ""+((IVL_PQ)rr_val).getHigh().getValue(); 91 | } 92 | } 93 | 94 | //TimeStamp 95 | HashMap ts = CDAParserUtil.getTS(robs.getEffectiveTime()); 96 | 97 | //Interpretation 98 | String interpretation = ""; 99 | if (robs.getInterpretationCodes().size()>0){ 100 | interpretation = ((CE)robs.getInterpretationCodes().get(0)).getDisplayName(); 101 | } 102 | 103 | res_item.put("name", result_name); 104 | res_item.put("value", result_value); 105 | res_item.put("unit", result_unit); 106 | res_item.put("code", code); 107 | res_item.put("code_system", code_system); 108 | res_item.put("ref_low",reference_range_low); 109 | res_item.put("ref_high",reference_range_high); 110 | res_item.put("ts", ts); 111 | res_item.put("interpretation", interpretation); 112 | 113 | res_items.add(res_item); 114 | 115 | } 116 | res_org.put("category", organizer_name); 117 | res_org.put("results", res_items); 118 | 119 | resultsList.add(res_org); 120 | } 121 | 122 | return resultsList; 123 | } 124 | 125 | 126 | private ArrayList parseH83(DiagnosticResultsSection diagnosticResultsSection){ 127 | ArrayList resultsList = new ArrayList(); 128 | 129 | if(diagnosticResultsSection == null){ 130 | return resultsList; 131 | } 132 | 133 | // System.out.println(diagnosticResultsSection.getOrganizers()); 134 | // System.out.println(diagnosticResultsSection.getDiagnosticProcedures()); 135 | 136 | for( Organizer org: diagnosticResultsSection.getOrganizers()){ 137 | 138 | ResultOrganizer rorg = (ResultOrganizer)org; 139 | //System.out.println(rorg); 140 | 141 | HashMap res_org = new HashMap(); 142 | String organizer_name = rorg.getCode().getDisplayName(); 143 | //System.out.println("PATI ORG"+organizer_name); 144 | ArrayList res_items = new ArrayList(); 145 | 146 | for(ResultObservation robs : rorg.getResultObservations()){ 147 | 148 | HashMap res_item = new HashMap(); 149 | //result name 150 | String result_name = robs.getCode().getDisplayName(); 151 | String code = robs.getCode().getCode(); 152 | String code_system = robs.getCode().getCodeSystem(); 153 | 154 | String result_value = ""; 155 | String result_unit = ""; 156 | 157 | //result val 158 | ANY rval = robs.getValues().get(0); 159 | 160 | if(rval instanceof PQ){ 161 | PQ rpq = (PQ)rval; 162 | result_value = rpq.getValue()+" "; 163 | result_unit = rpq.getUnit(); 164 | } 165 | 166 | //Get reference ranges 167 | String reference_range_text = ""; 168 | String reference_range_low = ""; 169 | String reference_range_high = ""; 170 | 171 | for(ReferenceRange rr : robs.getReferenceRanges()){ 172 | ANY rr_val = rr.getObservationRange().getValue(); 173 | if (rr_val instanceof IVL_PQ){ 174 | reference_range_low = ""+((IVL_PQ)rr_val).getLow().getValue(); 175 | reference_range_high = ""+((IVL_PQ)rr_val).getHigh().getValue(); 176 | } 177 | } 178 | 179 | //TimeStamp 180 | HashMap ts = CDAParserUtil.getTS(robs.getEffectiveTime()); 181 | 182 | //Interpretation 183 | String interpretation = ""; 184 | if (robs.getInterpretationCodes().size()>0){ 185 | interpretation = ((CE)robs.getInterpretationCodes().get(0)).getDisplayName(); 186 | } 187 | 188 | res_item.put("name", result_name); 189 | res_item.put("value", result_value); 190 | res_item.put("unit", result_unit); 191 | res_item.put("code", code); 192 | res_item.put("code_system", code_system); 193 | res_item.put("ref_low",reference_range_low); 194 | res_item.put("ref_high",reference_range_high); 195 | res_item.put("ts", ts); 196 | res_item.put("interpretation", interpretation); 197 | 198 | res_items.add(res_item); 199 | 200 | } 201 | res_org.put("category", organizer_name); 202 | res_org.put("results", res_items); 203 | 204 | resultsList.add(res_org); 205 | } 206 | 207 | return resultsList; 208 | } 209 | } 210 | --------------------------------------------------------------------------------