diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index 1e9decf63..000000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# Changelog
-Initial Changelog added (changes made by Amida).
-
-## [0.1.0] - 2019-05-10
-### Added
-- Cleaned up branches, documentation and commit history.
-- Incremented version number to indicate minor version.
-
-## [0.0.15] - 2019-04-26
-### Added
-- In bundle de-duplication for certain resources.
-- ifNoneExists parameter support.
-- Assorted FHIR Validation fixes.
-- Documentation updates.
-
-## [0.0.14] - 2019-04/24
-### Added
-- Various small fixes.
-- Version primarily incremented to run for FHIR validation errors.
-
-## [0.0.13] - 2019-04-15
-### Added
-- Added improved logging to flag unmapped OIDs and Sections.
-- Added tests for each adjustment from DSTU2 to STU3.
-- Added Jolt to comprehensively test each resource type.
-- Added utility to automatically generate unmapped CCD fields.
-- Fixed validation to use HAPI FHIR validation.
-- Implemented Device, Provenance, and referenceDocument resources for Provenance.
-- Removed DAF profile use in STU3.
-- Created integration test to automatically post bundles to HAPI FHIR server.
-- In bundle de-duplication for certain resources.
-- ifNoneExists parameter support.
-- References now show a common name for each reference.
-- May now dictate supported sections without removing code.
-- Added Device based authorship.
-- Added custom Epic observation field support.
\ No newline at end of file
diff --git a/LICENSE.md b/LICENSE.md
deleted file mode 100644
index 17d6f9d20..000000000
--- a/LICENSE.md
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright (C) 2016 SRDC Yazilim Arastirma ve Gelistirme ve Danismanlik Tic. A.S.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/README.md b/README.md
deleted file mode 100644
index 863917c4d..000000000
--- a/README.md
+++ /dev/null
@@ -1,221 +0,0 @@
-
-
-cda2fhir
-===
-[![License Info](http://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](https://github.com/srdc/cda2fhir/blob/master/LICENSE.txt)
-[![Jenkins CI](https://jenkins.amida.com/buildStatus/icon?job=CDA2FHIR%20Tests/)](https://jenkins.amida.com/job/CDA2FHIR%20Tests/)
-
-## Overview
-cda2fhir is a Java library to transform HL7 [CDA R2](https://www.hl7.org/implement/standards/product_brief.cfm?product_id=7) instances to HL7 [FHIR](https://www.hl7.org/fhir/) resources. More specifically, cda2fhir enables automatic transformation of
-Consolidated CDA (C-CDA) Release 2.1 compliant documents to corresponding FHIR STU3 resources. For this purpose, cda2fhir provides extensible
-document transformers, resource transformers, data type transformers and value set transformers.
-
-The current implementation provides a
-document transformer for the Continuity of Care Document (CCD) template, but further document transformers, e.g. for Discharge Summary or Referral Note,
-can be easily introduced by reusing the already existing section and entry transformers. Although the cda2fhir library expects C-CDA R2.1 compliant
-documents/entries, it has been tested as well with several older document instances compliant with earlier releases of C-CDA. The
-[HAPI FHIR Validator](http://hapifhir.io/doc_validation.html) is also integrated for automated validation of the generated FHIR resources.
-
-## Latest Updates
-The original cda2fhir library created by [SRDC](https://github.com/srdc/cda2fhir) mapped C-CDA resources to FHIR DSTU2-compliant resources. [Amida](https://www.amida.com) has created this fork of this library, incorporating the work of [CarthageKing](https://github.com/CarthageKing/cda2fhir), to instead map C-CDA resources to FHIR STU3-compliant resources. [Model Driven Health Tools (MDHT)](https://projects.eclipse.org/projects/modeling.mdht) is used for CDA manipulation and
-[HAPI](http://hapifhir.io/) is used for FHIR manipulation. This version of cda2fhir currently supports the following C-CDA Section to Resource mappings:
-
-|C-CDA Section | FHIR Resource(s) |
-|------------------|-----------------|
-|Medications |MedicationStatement, MedicationRequest, MedicationDispense, Medication|
-|Procedures |Procedure|
-|Immunizations |Immunization, Medication|
-|Results| DiagnosticReport, Observation|
-|Vital Signs| Observation|
-|Problems (Conditions)| Condition|
-|Allergies and Intolerances| AllergyIntolerance|
-|Encounters| Encounter|
-
-In addition to the above mappings, cda2fhir also uses and supports the Patient, Practitioner, PractitionerRole, Organization, Location, Device, DocumentReference, Composition, and Provenance FHIR Resources.
-
-**This version of the cda2fhir library implements several additional features not present in the SRDC version. These include:**
-
-* cda2fhir is now capable of generating "transactional" bundles.
-* cda2fhir now supports the generation of Provenance objects, optionally taking in an Identifier resource and string representation of the source file to generate the accompanying Device and DocumentReference resources respectively.
-* Bundles now de-duplicate against themselves for certain resources; this is done to prevent duplicate resources from being created in a FHIR server, and works together with the ifNoneExist parameters.
- * Medications are de-duplicated based on their encoding, and their manufacturing organization.
- * Organizations and Practitioners are de-duplicated based on identifier.
-* Bundles now use the "ifNoneExist" parameter to prevent duplicate resources from being created on a target FHIR server. This parameter uses the identifier field to prevent duplicates for all resources, with the exception of:
- * Medications are de-duplicated based on their encoding.
- * Provenance and Composition resources, which are not de-duplicated for attribution purposes.
- * DocumentReference resources are not de-duplicated, as there is no query accessor for the attachment hash field.
-* An integration test now uses Docker to automatically provision a HAPI FHIR server, post a transactional bundle to it, and.spot check for issues. Once complete this process will automatically de-provision the server.
-
-## Installation
-
-This project is built in Java, using version 1.8, and uses Apache Maven for dependency management. Please visit [Maven's website](http://maven.apache.org/) in order to install Maven on your system. To run the project's tests, your system will require Docker; please visit [Docker's website](https://www.docker.com/) for installation instructions.
-
-Under the root directory of the cda2fhir project run the following:
-
- $ cda2fhir> mvn install
-
-In order to make a clean install run the following:
-
- $ cda2fhir> mvn clean install
-
-These will build the cda2fhir library and also run a number of test cases, which will transform some C-CDA Continuity of Care Document (CCD) instances,
-and some manually crafted CDA artifacts (e.g. entry class instances) and datatype instances to corresponding FHIR resources.
-
-This project incrementally builds and releases files for use in maven projects, using the instructions provided [here](./doc/maven-instructions.md). To use, add the repository and dependency to your pom.xml like so, replacing the `X.Y.Z` with a version number.
-
-```
-
- amida-github
- github
- https://github.com/amida-tech/cda2fhir/raw/release
-
-...
-
- cda2fhir
- tr.com.srdc
- X.Y.Z
-
-```
-
-
-## Transforming a CDA document to a Bundle of FHIR resources
-
-The below code is an annotated example of a basic CCD document transformation, further code examples can be found in [CCDTransformerTest.java](./src/test/java/tr/com/srdc/cda2fhir/CCDTransformerTest.java) file. You may also review all implemented interfaces in the [CCDTransformerImpl.java](./src/main/java/tr/com/srdc/cda2fhir/transform/CCDTransformerImpl.java) file.
-
-The output of this operation will be located at: `src/test/resources/output/C-CDA_R2-1_CCD.json`.
-
-```java
-// Load MDHT CDA packages. Otherwise ContinuityOfCareDocument and similar documents will not be recognised.
-// This has to be called before loading the document; otherwise will have no effect.
-CDAUtil.loadPackages();
-
-// Read a Continuity of Care Document (CCD) instance, which is the official sample CCD instance
-// distributed with C-CDA 2.1 specs, with a few extensions for having a more complete document
-FileInputStream fis = new FileInputStream("src/test/resources/C-CDA_R2-1_CCD.xml");
-ClinicalDocument cda = CDAUtil.load(fis);
-
-// Init an object of CCDTransformerImpl class, which implements the generic ICDATransformer interface.
-// FHIR resource id generator can be either an incremental counter, or a UUID generator.
-// The default is UUID; here it is set as COUNTER.
-ICDATransformer ccdTransformer = new CCDTransformerImpl(IdGeneratorEnum.COUNTER);
-
-// Finally, the CCD document instance is transformed to a FHIR Bundle, where the first entry is
-// the Composition corresponding to the ClinicalDocument, and further entries are the ones referenced
-// from the Composition.
-Bundle bundle = ccdTransformer.transformDocument(cda);
-
-// Through HAPI library, the Bundle can easily be printed in JSON or XML format.
-FHIRUtil.printJSON(bundle, "src/test/resources/output/C-CDA_R2-1_CCD.json");
-```
-
-## Transforming a CDA document to a transactional bundle with Provenance
-```java
-// Load MDHT CDA packages. Otherwise ContinuityOfCareDocument and similar documents will not be recognised.
-// This has to be called before loading the document; otherwise will have no effect.
-CDAUtil.loadPackages();
-
-// Init an object of CCDTransformerImpl class, which implements the generic ICDATransformer interface.
-// FHIR resource id generator can be either an incremental counter, or a UUID generator.
-// The default is UUID; here it is set as COUNTER.
-ICDATransformer ccdTransformer = new CCDTransformerImpl(IdGeneratorEnum.COUNTER);
-
-// Create an identifier for the Provenance object identifying the running system.
-Identifier id = new Identifier();
-id.setValue("Data Processing Engine");
-
-//Create an OpenHealthTools CCD document object to pass into the library by parsing an input file (or stream).
-ContinuityOfCareDocument ccd = (ContinuityOfCareDocument) CDAUtil.loadAs(,
- ConsolPackage.eINSTANCE.getContinuityOfCareDocument());
-
-//Load your input file into memory as a string (logic for this is beyond the scope of this example).
-String rawDocument =
-
-// The CCD document instance is transformed to a FHIR Bundle, which creates the Composition, Provenance, and documentReference objects.
-Bundle bundle = ccdTransformer.transformDocument(cda, BundleType.TRANSACTION, null, rawDocument, identifier);
-
-// Through HAPI library, the Bundle can easily be printed in JSON or XML format.
-FHIRUtil.printJSON(bundle, "src/test/resources/output/C-CDA_R2-1_CCD.json");
-```
-
-
-## Transforming a CDA artifact (e.g. an entry class) to the corresponding FHIR resource(s)
-
-```java
-// Init an object of ResourceTransformerImpl class, which implements the IResourceTransformer
-// interface. When instantiated separately from the CDATransformer context, FHIR resources are
-// generated with UUID ids, and a default patient reference is added as "Patient/0"
-IResourceTransformer resTransformer = new ResourceTransformerImpl();
-
-// Assume we already have a CCD instance in the ccd object below (skipping CDA artifact creation from scratch)
-// Traverse all the sections of the CCD instance
-for(Section cdaSec: ccd.getSections()) {
- // Transform a CDA section to a FHIR Composition.Section backbone resource
- Composition.Section fhirSec = resTransformer.tSection2Section(cdaSec);
-
- // if a CDA section is instance of a Family History Section (as identified through its templateId)
- if(cdaSec instanceof FamilyHistorySection) {
- // cast the section to FamilyHistorySection
- FamilyHistorySection famSec = (FamilyHistorySection) cdaSec;
- // traverse the Family History Organizers within the Family History Section
- for(FamilyHistoryOrganizer fhOrganizer : famSec.getFamilyHistories()) {
- // Transform each C-CDA FamilyHistoryOrganizer instance to FHIR FamilyMemberHistory instance
- FamilyMemberHistory fmh = resTransformer.tFamilyHistoryOrganizer2FamilyMemberHistory(fhOrganizer);
- }
- }
-}
-
-// Again, any FHIR resource can be printed through FHIRUtil methods.
-FHIRUtil.printXML(fmh, "src/test/resources/output/family-member-history.xml");
-```
-
-It should be noted that most of the time, IResourceTransformer methods return a FHIR Bundle composed of a few FHIR resources,
-instead of a single FHIR resource as in the example above. For example, tProblemObservation2Condition method returns a Bundle
-that contains the corresponding Condition as the first entry, which can also include other referenced resources such as Encounter, Practitioner.
-
-Further examples can be found in [ResourceTransformerTest](./src/test/java/tr/com/srdc/cda2fhir/ResourceTransformerTest.java) class
-and [CCDTransformerImpl](./src/main/java/tr/com/srdc/cda2fhir/transform/CCDTransformerImpl.java) class.
-
-## Validating generated FHIR resources
-
-We have also integrated the [HAPI FHIR Validator](http://hapifhir.io/doc_validation.html) and have implemented a wrapper interface and a class on top of this validator: IValidator and ValidatorImpl. A resource can be validated individually, or a Bundle
-containing several resources as in the case of CDA transformation outcome can be validated at once. Validation outcome is provided as HTML within an OutputStream.
-
-```java
-// Init an object of ValidatorImpl class, which implements the IValidator interface.
-IValidator validator = new ValidatorImpl();
-
-// Assume we already have a Bundle object to be validated at hand. Call the validateBundle method
-// of the validator and get the validation outcome as HTML in a ByteArrayOutputStream.
-ByteArrayOutputStream valOutcomeOs = (ByteArrayOutputStream) validator.validateBundle(bundle);
-
-// The HTML can be printed to a file.
-FileOutputStream fos = new FileOutputStream(new File("src/test/resources/output/validation-result-w-profile-for-C-CDA_R2-1_CCD.html"));
-valOutcomeOs.writeTo(fos);
-
-// Close the streams
-valOutcomeOs.close();
-fos.close();
-```
-
-Further examples can be found in [ValidatorTest](./src/test/java/tr/com/srdc/cda2fhir/ValidatorTest.java) class.
-
-## Acknowledgement
-This research has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 689181,
-[C3-Cloud Project](http://www.c3-cloud.eu/) (A Federated Collaborative Care Cure Cloud Architecture for Addressing the Needs of Multi-morbidity and Managing Poly-pharmacy).
-
-This research has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 689444,
-[POWER2DM Project](http://www.power2dm.eu/) (Predictive model-based decision support for diabetes patient empowerment).
diff --git a/doc/maven-instructions.md b/doc/maven-instructions.md
deleted file mode 100644
index b8374cc07..000000000
--- a/doc/maven-instructions.md
+++ /dev/null
@@ -1,57 +0,0 @@
-Creating a Maven Build
-===
-This project incrementally builds and releases versions of this library for use in maven projects. These files are not hosted in the Maven Central Repository, but instead Github acts as the Maven Repository. These are the directions for building and releasing a version of this library, based on the instructions provided [here](https://gist.github.com/fernandezpablo85/03cf8b0cd2e7d8527063)
-
-Essentially, you make a new version of the CDA2FHIR repository, and build to it from the original repository on your desktop.
-
-#1 - Increment version number in `pom.xml` file in main project.
-
-`git checkout fhir-stu3`
-
-`X.Y.Z-SNAPSHOT` should be updated to reflect the intended version number of the release. Update CHANGELOG.md to reflect any changes made between this and the prior version.
-
-#2 - Commit changes directly to `fhir-stu3` branch.
-
-`git commit -m "incremented pom to version X.Y.Z"`
-
-#3 - Run mvn install
-
-`mvn install`
-
-This will build the .jar files in this repository that will be published to Github. You may optionally use the `-DskipTests` parameter to speed up the build.
-
-#3 - Clone main project to separate folder.
-
-`git clone git@github.com:amida/cda2fhir.git cda2fhir-release`
-
-#4 - Go into new folder and check out `release` branch.
-
-`git checkout release`
-
-#5 - Build the release
-
-Be sure increment the version number in `-Dversion` to match what is in the pom file, and reference the correct jar file in the `-Dfile` parameter, and update the absolute path(s) to reflect your directory structure.
-
-```mvn install:install-file -DgroupId=tr.com.srdc -DartifactId=cda2fhir -Dversion=X.Y.Z-SNAPSHOT -Dfile=/Users/matthew/Workspace/cda2fhir/target/cda2fhir-X.Y.Z-SNAPSHOT-jar-with-dependencies.jar -DpomFile=/Users/matthew/Workspace/cda2fhir/pom.xml -DlocalRepositoryPath=. -DcreateChecksum=true```
-
-#6 - Add all generated files, commit, and push up.
-
-`git add -A . && git commit -m "released version X.Y.Z"`
-
-`git push origin release`
-
-The newly commited maven file(s) may be accessed by adding the following to the pom file:
-
-```
-
- amida-github
- github
- https://github.com/amida-tech/cda2fhir/raw/release
-
-...
-
- cda2fhir
- tr.com.srdc
- X.Y.Z
-
-```
\ No newline at end of file
diff --git a/src/main/java/tr/com/srdc/cda2fhir/conf/Config.java b/src/main/java/tr/com/srdc/cda2fhir/conf/Config.java
deleted file mode 100644
index e6f9195ca..000000000
--- a/src/main/java/tr/com/srdc/cda2fhir/conf/Config.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package tr.com.srdc.cda2fhir.conf;
-
-import java.nio.charset.Charset;
-
-import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus;
-import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus;
-import org.hl7.fhir.dstu3.model.Coding;
-import org.hl7.fhir.dstu3.model.Composition.CompositionStatus;
-import org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus;
-import org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem;
-import org.hl7.fhir.dstu3.model.Encounter.EncounterStatus;
-import org.hl7.fhir.dstu3.model.Identifier.IdentifierUse;
-import org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/*
- * #%L
- * CDA to FHIR Transformer Library
- * %%
- * Copyright (C) 2016 SRDC Yazilim Arastirma ve Gelistirme ve Danismanlik Tic. A.S.
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.narrative.CustomThymeleafNarrativeGenerator;
-import ca.uhn.fhir.narrative.INarrativeGenerator;
-
-public class Config {
-
- private static FhirContext fhirCtx;
-
- // Default values for some mandatory attributes, which cannot be retrieved from
- // CDA document
- public static final String DEFAULT_COMMUNICATION_LANGUAGE_CODE_SYSTEM = "urn:ietf:bcp:47";
- public static final ConditionVerificationStatus DEFAULT_CONDITION_VERIFICATION_STATUS = ConditionVerificationStatus.CONFIRMED;
- public static final AllergyIntoleranceVerificationStatus DEFAULT_ALLERGY_VERIFICATION_STATUS = AllergyIntoleranceVerificationStatus.UNCONFIRMED;
- public static final AllergyIntoleranceClinicalStatus DEFAULT_ALLERGY_CLINICAL_STATUS = AllergyIntoleranceClinicalStatus.ACTIVE;
- public static final MedicationStatementStatus DEFAULT_MEDICATION_STATEMENT_STATUS = MedicationStatementStatus.ACTIVE;
- public static final CompositionStatus DEFAULT_COMPOSITION_STATUS = CompositionStatus.PRELIMINARY;
- public static final IdentifierUse DEFAULT_IDENTIFIER_USE = IdentifierUse.OFFICIAL;
- public static final ContactPointSystem DEFAULT_CONTACT_POINT_SYSTEM = ContactPointSystem.PHONE;
- public static final Coding DEFAULT_ENCOUNTER_PARTICIPANT_TYPE_CODE = new Coding()
- .setSystem("http://hl7.org/fhir/v3/ParticipationType").setCode("PART").setDisplay("Participation");
- public static final EncounterStatus DEFAULT_ENCOUNTER_STATUS = EncounterStatus.FINISHED;
- public static final Coding DEFAULT_DIAGNOSTICREPORT_PERFORMER_DATA_ABSENT_REASON_CODE = new Coding()
- .setSystem("http://hl7.org/fhir/data-absent-reason").setCode("unknown").setDisplay("Unknown");
- public static final boolean DEFAULT_IMMUNIZATION_REPORTED = false;
-
- public static final String NARRATIVE_PROPERTIES_FILE_PATH = "file:src/main/resources/narrative/customnarrative.properties";
-
- public static final String MEDICATION_CODE_SYSTEM = null;
-
- private static boolean generateNarrative = false;
- private static INarrativeGenerator narrativeGenerator;
-
- private static boolean generateDafProfileMetadata = false;
-
- private static final Logger logger = LoggerFactory.getLogger(Config.class);
-
- static {
- fhirCtx = FhirContext.forDstu3();
- narrativeGenerator = new CustomThymeleafNarrativeGenerator(NARRATIVE_PROPERTIES_FILE_PATH);
- if (generateNarrative)
- fhirCtx.setNarrativeGenerator(narrativeGenerator);
-
- logger.info("System file encoding is: " + Charset.defaultCharset().displayName());
- }
-
- public static FhirContext getFhirContext() {
- return fhirCtx;
- }
-
- public static void setGenerateNarrative(boolean generateNar) {
- generateNarrative = generateNar;
- if (generateNarrative)
- fhirCtx.setNarrativeGenerator(narrativeGenerator);
- else
- fhirCtx.setNarrativeGenerator(null);
- }
-
- public static boolean getGenerateNarrative() {
- return generateNarrative;
- }
-
- public static void setGenerateDafProfileMetadata(boolean generateDafProfileMeta) {
- generateDafProfileMetadata = generateDafProfileMeta;
- }
-
- public static boolean isGenerateDafProfileMetadata() {
- return generateDafProfileMetadata;
- }
-
-}
diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/CCDTransformerImpl.java b/src/main/java/tr/com/srdc/cda2fhir/transform/CCDTransformerImpl.java
deleted file mode 100644
index a0efb30b0..000000000
--- a/src/main/java/tr/com/srdc/cda2fhir/transform/CCDTransformerImpl.java
+++ /dev/null
@@ -1,449 +0,0 @@
-package tr.com.srdc.cda2fhir.transform;
-
-import java.io.FileInputStream;
-
-/*
- * #%L
- * CDA to FHIR Transformer Library
- * %%
- * Copyright (C) 2016 SRDC Yazilim Arastirma ve Gelistirme ve Danismanlik Tic. A.S.
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.commons.lang3.StringUtils;
-import org.hl7.fhir.dstu3.model.Bundle;
-import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
-import org.hl7.fhir.dstu3.model.Bundle.BundleType;
-import org.hl7.fhir.dstu3.model.Composition;
-import org.hl7.fhir.dstu3.model.Composition.SectionComponent;
-import org.hl7.fhir.dstu3.model.Identifier;
-import org.hl7.fhir.dstu3.model.Patient;
-import org.hl7.fhir.dstu3.model.Reference;
-import org.hl7.fhir.dstu3.model.Resource;
-import org.openhealthtools.mdht.uml.cda.Section;
-import org.openhealthtools.mdht.uml.cda.consol.ConsolPackage;
-import org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument;
-import org.openhealthtools.mdht.uml.cda.util.CDAUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import tr.com.srdc.cda2fhir.transform.entry.IEntryResult;
-import tr.com.srdc.cda2fhir.transform.section.CDASectionTypeEnum;
-import tr.com.srdc.cda2fhir.transform.section.ICDASection;
-import tr.com.srdc.cda2fhir.transform.section.ISectionResult;
-import tr.com.srdc.cda2fhir.transform.util.IDeferredReference;
-import tr.com.srdc.cda2fhir.transform.util.IIdentifierMap;
-import tr.com.srdc.cda2fhir.transform.util.IdentifierMapFactory;
-import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo;
-import tr.com.srdc.cda2fhir.transform.util.impl.BundleRequest;
-import tr.com.srdc.cda2fhir.transform.util.impl.ReferenceInfo;
-import tr.com.srdc.cda2fhir.util.EMFUtil;
-import tr.com.srdc.cda2fhir.util.FHIRUtil;
-import tr.com.srdc.cda2fhir.util.IdGeneratorEnum;
-
-public class CCDTransformerImpl implements ICDATransformer, Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private int counter;
- private IdGeneratorEnum idGenerator;
- private IResourceTransformer resTransformer;
- private Reference patientRef;
-
- private List supportedSectionTypes = new ArrayList();
-
- private final Logger logger = LoggerFactory.getLogger(CCDTransformerImpl.class);
-
- /**
- * Default constructor that initiates with a UUID resource id generator
- */
- public CCDTransformerImpl() {
- this.counter = 0;
- // The default resource id pattern is UUID
- this.idGenerator = IdGeneratorEnum.UUID;
- resTransformer = new ResourceTransformerImpl(this);
- this.patientRef = null; // TODO: Not thread safe?
-
- supportedSectionTypes.add(CDASectionTypeEnum.ALLERGIES_SECTION);
- supportedSectionTypes.add(CDASectionTypeEnum.IMMUNIZATIONS_SECTION);
- supportedSectionTypes.add(CDASectionTypeEnum.MEDICATIONS_SECTION);
- supportedSectionTypes.add(CDASectionTypeEnum.PROBLEM_SECTION);
- supportedSectionTypes.add(CDASectionTypeEnum.PROCEDURES_SECTION);
- supportedSectionTypes.add(CDASectionTypeEnum.ENCOUNTERS_SECTION);
- supportedSectionTypes.add(CDASectionTypeEnum.ENCOUNTERS_SECTION_ENTRIES_OPTIONAL);
- supportedSectionTypes.add(CDASectionTypeEnum.RESULTS_SECTION);
- supportedSectionTypes.add(CDASectionTypeEnum.VITAL_SIGNS_SECTION);
- }
-
- /**
- * Constructor that initiates with the provided resource id generator
- *
- * @param idGen The id generator enumeration to be set
- */
- public CCDTransformerImpl(IdGeneratorEnum idGen) {
- this();
- // Override the default resource id pattern
- this.idGenerator = idGen;
- }
-
- @Override
- public Reference getPatientRef() {
- return patientRef;
- }
-
- public void setPatientRef(Reference patientRef) {
- this.patientRef = patientRef;
- }
-
- public void setResourceTransformer(IResourceTransformer resTransformer) {
- this.resTransformer = resTransformer;
- }
-
- @Override
- public synchronized String getUniqueId() {
- switch (this.idGenerator) {
- case COUNTER:
- return Integer.toString(++counter);
- case UUID:
- default:
- return UUID.randomUUID().toString();
- }
- }
-
- @Override
- public void setIdGenerator(IdGeneratorEnum idGen) {
- this.idGenerator = idGen;
- }
-
- public void addSection(CDASectionTypeEnum sectionEnum) {
- supportedSectionTypes.add(sectionEnum);
- }
-
- public void setSection(CDASectionTypeEnum sectionEnum) {
- supportedSectionTypes.clear();
- supportedSectionTypes.add(sectionEnum);
- }
-
- /**
- * @param cda A Consolidated CDA (C-CDA) 2.1 Continuity of Care
- * Document (CCD) instance to be transformed
- * @param bundleType Desired type of the FHIR Bundle to be returned
- *
- * @param patientRef Patient Reference of the given CDA Document
- *
- * @param resourceProfileMap The mappings of default resource profiles to
- * desired resource profiles. Used to set profile
- * URI's of bundle entries or omit unwanted entries.
- * @return A FHIR Bundle that contains a Composition corresponding to the CCD
- * document and all other resources but Patient that are referenced
- * within the Composition.
- */
- public Bundle createTransactionBundle(Bundle bundle, Map resourceProfileMap, boolean addURLs) {
- Bundle resultBundle = new Bundle();
- resultBundle.setType(BundleType.TRANSACTION);
-
- for (BundleEntryComponent entry : bundle.getEntry()) {
- // Patient resource will not be added
- if (entry != null) {
- // Add request and fullUrl fields to entries
- BundleRequest.addRequestToEntry(entry);
- if (addURLs) {
- addFullUrlToEntry(entry);
- }
- // if resourceProfileMap is specified omit the resources with no profiles given
- // Empty profileUri means add with no change
- if (resourceProfileMap != null) {
- String profileUri = resourceProfileMap.get(entry.getResource().getResourceType().name());
- if (profileUri != null) {
- if (!profileUri.isEmpty()) {
- entry.getResource().getMeta().addProfile(profileUri);
- }
- resultBundle.addEntry(entry);
- }
- } else {
- resultBundle.addEntry(entry);
- }
- }
- }
-
- return resultBundle;
- }
-
- /**
- * Transforms a Consolidated CDA (C-CDA) 2.1 Continuity of Care Document (CCD)
- * instance to a Bundle of corresponding FHIR resources
- *
- * @param cda A Consolidated CDA (C-CDA) 2.1 Continuity of Care
- * Document (CCD) instance to be transformed
- * @param bundleType The type of bundle to create, currently only
- * supports transaction bundles.
- * @param resourceProfileMap The mappings of default resource profiles to
- * desired resource profiles. Used to set profile
- * URI's of bundle entries or omit unwanted entries.
- * @param documentBody The decoded documentBody of the document, to be
- * included in a provenance object.
- * @return A FHIR Bundle that contains a Composition corresponding to the CCD
- * document and all other resources that are referenced within the
- * Composition.
- * @throws Exception
- */
-
- public Bundle transformDocument(String filePath, BundleType bundleType, Map resourceProfileMap,
- String documentBody, Identifier assemblerDevice) throws Exception {
- ContinuityOfCareDocument cda = getClinicalDocument(filePath);
- Bundle bundle = transformDocument(cda, true);
- bundle.setType(bundleType);
- if (assemblerDevice != null && !StringUtils.isEmpty(documentBody)) {
- bundle = resTransformer.tProvenance(bundle, documentBody, assemblerDevice);
- }
-
- if (bundleType.equals(BundleType.TRANSACTION)) {
- return createTransactionBundle(bundle, resourceProfileMap, false);
- }
- return bundle;
- }
-
- /**
- * Transforms a Consolidated CDA (C-CDA) 2.1 Continuity of Care Document (CCD)
- * instance to a Bundle of corresponding FHIR resources
- *
- * @param filePath A file path string to a Consolidated CDA (C-CDA) 2.1
- * Continuity of Care Document (CCD) on file system
- * @return A FHIR Bundle that contains a Composition corresponding to the CCD
- * document and all other resources that are referenced within the
- * Composition.
- * @throws Exception
- */
- public Bundle transformDocument(String filePath) throws Exception {
- ContinuityOfCareDocument cda = getClinicalDocument(filePath);
- return transformDocument(cda, true);
- }
-
- /**
- * Transforms a Consolidated CDA (C-CDA) 2.1 Continuity of Care Document (CCD)
- * instance to a Bundle of corresponding FHIR resources
- *
- * @param cda A Consolidated CDA (C-CDA) 2.1 Continuity of Care
- * @param cda A Consolidated CDA (C-CDA) 2.1 Continuity of Care Document (CCD)
- * instance to be transformed
- * @return A FHIR Bundle that contains a Composition corresponding to the CCD
- * document and all other resources that are referenced within the
- * Composition.
- */
-
- public Bundle transformDocument(ContinuityOfCareDocument cda) {
- return transformDocument(cda, true);
- }
-
- /**
- * @param cda A Consolidated CDA (C-CDA) 2.1 Continuity of Care
- * fhir-stu3 Document (CCD) instance to be transformed
- * @param bundleType The type of bundle to create, currently only
- * supports transaction bundles.
- * @param resourceProfileMap The mappings of default resource profiles to
- * desired resource profiles. Used to set profile
- * URI's of bundle entries or omit unwanted entries.
- * @param documentBody The decoded base64 document that would be included
- * in the provenance object if provided.
- * @return A FHIR Bundle that contains a Composition corresponding to the CCD
- * document and all other resources that are referenced within the
- * Composition.
- * @throws Exception
- */
-
- @Override
- public Bundle transformDocument(ContinuityOfCareDocument cda, BundleType bundleType,
- Map resourceProfileMap, String documentBody, Identifier assemblerDevice) throws Exception {
- Bundle bundle = transformDocument(cda, true);
- bundle.setType(bundleType);
- if (assemblerDevice != null && !StringUtils.isEmpty(documentBody)) {
- bundle = resTransformer.tProvenance(bundle, documentBody, assemblerDevice);
- }
-
- if (bundleType.equals(BundleType.TRANSACTION)) {
- return createTransactionBundle(bundle, resourceProfileMap, false);
- }
- return bundle;
- }
-
- /**
- * Transforms a Consolidated CDA (C-CDA) 2.1 Continuity of Care Document (CCD)
- * instance to a Bundle of corresponding FHIR resources
- *
- * @param cda A Consolidated CDA (C-CDA) 2.1 Continuity of Care
- * Document (CCD) instance to be transformed.
- * @param documentBody The decoded base64 document that would be included in the
- * provenance object if provided.
- * @return A FHIR Bundle that contains a Composition corresponding to the CCD
- * document and all other resources that are referenced within the
- * Composition.
- */
- @Override
- public Bundle transformDocument(ContinuityOfCareDocument cda, String documentBody, Identifier assemblerDevice) {
- Bundle bundle = transformDocument(cda, true);
- if (assemblerDevice != null & !StringUtils.isEmpty(documentBody)) {
- bundle = resTransformer.tProvenance(bundle, documentBody, assemblerDevice);
- }
- return bundle;
- }
-
- private ICDASection findCDASection(Section section) {
- for (CDASectionTypeEnum sectionType : supportedSectionTypes) {
- if (sectionType.supports(section)) {
- return sectionType.toCDASection(section);
- }
- }
- logger.info("Encountered unsupported section: " + section.getTitle().getText());
- return null;
- }
-
- /**
- * Transforms a Consolidated CDA (C-CDA) 2.1 Continuity of Care Document (CCD)
- * instance to a Bundle of corresponding FHIR resources
- *
- * @param cda A Consolidated CDA (C-CDA) 2.1 Continuity of Care
- * Document (CCD) instance to be transformed
- * @param includeComposition Flag to include composition (required for document
- * type bundles)
- * @return A FHIR Bundle
- */
- public Bundle transformDocument(ContinuityOfCareDocument ccd, boolean includeComposition) { // TODO: Should be
- // bundle type based.
- if (ccd == null) {
- return null;
- }
-
- // init the global ccd bundle via a call to resource transformer, which handles
- // cda header data (in fact, all except the sections)
- IEntryResult entryResult = resTransformer.tClinicalDocument2Bundle(ccd, includeComposition);
- Bundle ccdBundle = entryResult.getBundle();
- if (ccdBundle == null) {
- ccdBundle = new Bundle();
- }
-
- // the first bundle entry is always the composition
- Composition ccdComposition = includeComposition ? (Composition) ccdBundle.getEntry().get(0).getResource()
- : null;
-
- // init the patient id reference if it is not given externally.
- if (patientRef == null) {
- List patients = FHIRUtil.findResources(ccdBundle, Patient.class);
- if (patients.size() > 0) {
- patientRef = new Reference(patients.get(0).getId());
- String referenceString = ReferenceInfo.getDisplay(patients.get(0));
- if (referenceString != null) {
- patientRef.setDisplay(referenceString);
- }
- }
- } else if (ccdComposition != null) { // Correct the subject at composition with given patient reference.
- ccdComposition.setSubject(patientRef);
- }
-
- BundleInfo bundleInfo = new BundleInfo(resTransformer);
- bundleInfo.updateFrom(entryResult);
- List deferredReferences = new ArrayList();
-
- // transform the sections
- for (Section cdaSec : ccd.getSections()) {
- ICDASection section = findCDASection(cdaSec);
- if (section != null) {
- SectionComponent fhirSec = resTransformer.tSection2Section(cdaSec);
-
- if (fhirSec == null) {
- continue;
- }
-
- if (ccdComposition != null) {
- ccdComposition.addSection(fhirSec);
- }
-
- // add text annotation lookups.
- if (cdaSec.getText() != null) {
- Map idedAnnotations = EMFUtil.findReferences(cdaSec.getText());
- bundleInfo.mergeIdedAnnotations(idedAnnotations);
- }
-
- ISectionResult sectionResult = section.transform(bundleInfo);
- if (sectionResult != null) {
- FHIRUtil.mergeBundle(sectionResult.getBundle(), ccdBundle);
- if (fhirSec != null) {
- List extends Resource> resources = sectionResult.getSectionResources();
-
- for (Resource resource : resources) {
- Reference ref = fhirSec.addEntry();
- ref.setReference(resource.getId());
- String referenceString = ReferenceInfo.getDisplay(resource);
- if (referenceString != null) {
- ref.setDisplay(referenceString);
- }
- }
- }
- if (sectionResult.hasDeferredReferences()) {
- deferredReferences.addAll(sectionResult.getDeferredReferences());
- }
- bundleInfo.updateFrom(sectionResult);
- }
- }
- }
-
- IIdentifierMap identifierMap = IdentifierMapFactory.bundleToIds(ccdBundle);
-
- // deferred references only present for procedure encounters.
- if (!deferredReferences.isEmpty()) {
- for (IDeferredReference dr : deferredReferences) {
- String id = identifierMap.get(dr.getFhirType(), dr.getIdentifier());
- if (id != null) {
- Reference reference = new Reference(id);
- String referenceString = ReferenceInfo.getDisplay(dr.getResource());
- if (referenceString != null) {
- reference.setDisplay(referenceString);
- }
- dr.resolve(reference);
- } else {
- String msg = String.format("%s %s is referred but not found", dr.getFhirType(),
- dr.getIdentifier().getValue());
- logger.error(msg);
- }
- }
- }
-
- return ccdBundle;
- }
-
- /**
- * Adds fullUrl field to the entry using it's resource id.
- *
- * @param entry Entry which fullUrl field to be added.
- */
- private void addFullUrlToEntry(BundleEntryComponent entry) {
- // entry.setFullUrl("urn:uuid:" + entry.getResource().getId().getIdPart());
- entry.setFullUrl("urn:uuid:" + entry.getResource().getIdElement().getIdPart());
- }
-
- private ContinuityOfCareDocument getClinicalDocument(String filePath) throws Exception {
- FileInputStream fis = new FileInputStream(filePath);
- // ClinicalDocument cda = CDAUtil.load(fis);
- ContinuityOfCareDocument cda = (ContinuityOfCareDocument) CDAUtil.loadAs(fis,
- ConsolPackage.eINSTANCE.getContinuityOfCareDocument());
- fis.close();
- return cda;
- }
-}
diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/DataTypesTransformerImpl.java b/src/main/java/tr/com/srdc/cda2fhir/transform/DataTypesTransformerImpl.java
deleted file mode 100644
index 985cf0da1..000000000
--- a/src/main/java/tr/com/srdc/cda2fhir/transform/DataTypesTransformerImpl.java
+++ /dev/null
@@ -1,1318 +0,0 @@
-package tr.com.srdc.cda2fhir.transform;
-
-/*
- * #%L
- * CDA to FHIR Transformer Library
- * %%
- * Copyright (C) 2016 SRDC Yazilim Arastirma ve Gelistirme ve Danismanlik Tic. A.S.
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;
-import org.eclipse.emf.ecore.util.BasicFeatureMap;
-import org.eclipse.emf.ecore.util.FeatureMap;
-import org.hl7.fhir.dstu3.model.Address;
-import org.hl7.fhir.dstu3.model.Attachment;
-import org.hl7.fhir.dstu3.model.Base64BinaryType;
-import org.hl7.fhir.dstu3.model.BaseDateTimeType;
-import org.hl7.fhir.dstu3.model.BooleanType;
-import org.hl7.fhir.dstu3.model.CodeableConcept;
-import org.hl7.fhir.dstu3.model.Coding;
-import org.hl7.fhir.dstu3.model.ContactPoint;
-import org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem;
-import org.hl7.fhir.dstu3.model.DateTimeType;
-import org.hl7.fhir.dstu3.model.DateType;
-import org.hl7.fhir.dstu3.model.DecimalType;
-import org.hl7.fhir.dstu3.model.HumanName;
-import org.hl7.fhir.dstu3.model.Identifier;
-import org.hl7.fhir.dstu3.model.Identifier.IdentifierUse;
-import org.hl7.fhir.dstu3.model.InstantType;
-import org.hl7.fhir.dstu3.model.IntegerType;
-import org.hl7.fhir.dstu3.model.Narrative;
-import org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus;
-import org.hl7.fhir.dstu3.model.Period;
-import org.hl7.fhir.dstu3.model.Quantity;
-import org.hl7.fhir.dstu3.model.Range;
-import org.hl7.fhir.dstu3.model.Ratio;
-import org.hl7.fhir.dstu3.model.Reference;
-import org.hl7.fhir.dstu3.model.SimpleQuantity;
-import org.hl7.fhir.dstu3.model.StringType;
-import org.hl7.fhir.dstu3.model.Timing;
-import org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent;
-import org.hl7.fhir.dstu3.model.UriType;
-import org.openhealthtools.mdht.uml.cda.StrucDocText;
-import org.openhealthtools.mdht.uml.hl7.datatypes.AD;
-import org.openhealthtools.mdht.uml.hl7.datatypes.ADXP;
-import org.openhealthtools.mdht.uml.hl7.datatypes.BIN;
-import org.openhealthtools.mdht.uml.hl7.datatypes.BL;
-import org.openhealthtools.mdht.uml.hl7.datatypes.CD;
-import org.openhealthtools.mdht.uml.hl7.datatypes.CV;
-import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory;
-import org.openhealthtools.mdht.uml.hl7.datatypes.ED;
-import org.openhealthtools.mdht.uml.hl7.datatypes.EN;
-import org.openhealthtools.mdht.uml.hl7.datatypes.ENXP;
-import org.openhealthtools.mdht.uml.hl7.datatypes.II;
-import org.openhealthtools.mdht.uml.hl7.datatypes.INT;
-import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ;
-import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS;
-import org.openhealthtools.mdht.uml.hl7.datatypes.PIVL_TS;
-import org.openhealthtools.mdht.uml.hl7.datatypes.PQ;
-import org.openhealthtools.mdht.uml.hl7.datatypes.PQR;
-import org.openhealthtools.mdht.uml.hl7.datatypes.REAL;
-import org.openhealthtools.mdht.uml.hl7.datatypes.RTO;
-import org.openhealthtools.mdht.uml.hl7.datatypes.ST;
-import org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS;
-import org.openhealthtools.mdht.uml.hl7.datatypes.TEL;
-import org.openhealthtools.mdht.uml.hl7.datatypes.TS;
-import org.openhealthtools.mdht.uml.hl7.datatypes.URL;
-import org.openhealthtools.mdht.uml.hl7.vocab.EntityNameUse;
-import org.openhealthtools.mdht.uml.hl7.vocab.PostalAddressUse;
-import org.openhealthtools.mdht.uml.hl7.vocab.TelecommunicationAddressUse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
-import ca.uhn.fhir.parser.DataFormatException;
-import tr.com.srdc.cda2fhir.conf.Config;
-import tr.com.srdc.cda2fhir.util.StringUtil;
-
-public class DataTypesTransformerImpl implements IDataTypesTransformer, Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private IValueSetsTransformer vst = new ValueSetsTransformerImpl();
-
- private final Logger logger = LoggerFactory.getLogger(DataTypesTransformerImpl.class);
-
- @Override
- public Address AD2Address(AD ad) {
- if (ad == null || ad.isSetNullFlavor())
- return null;
-
- Address address = new Address();
-
- // use -> use
- if (ad.getUses() != null && !ad.getUses().isEmpty()) {
- // We get the address.type and address.use from the list ad.uses
- for (PostalAddressUse postalAddressUse : ad.getUses()) {
- // If we catch a valid value for type or use, we assign it
- if (postalAddressUse == PostalAddressUse.PHYS || postalAddressUse == PostalAddressUse.PST) {
- address.setType(vst.tPostalAddressUse2AddressType(postalAddressUse));
- } else if (postalAddressUse == PostalAddressUse.H || postalAddressUse == PostalAddressUse.HP
- || postalAddressUse == PostalAddressUse.WP || postalAddressUse == PostalAddressUse.TMP
- || postalAddressUse == PostalAddressUse.BAD) {
- address.setUse(vst.tPostalAdressUse2AddressUse(postalAddressUse));
- }
- }
- }
-
- // text -> text
- if (ad.getText() != null && !ad.getText().isEmpty()) {
- address.setText(ad.getText());
- }
-
- // streetAddressLine -> line
- if (ad.getStreetAddressLines() != null && !ad.getStreetAddressLines().isEmpty()) {
- for (ADXP adxp : ad.getStreetAddressLines()) {
- if (adxp != null && !adxp.isSetNullFlavor() && adxp.getText() != null) {
- address.addLine(adxp.getText().trim());
- }
- }
- }
-
- // deliveryAddressLine -> line
- if (ad.getDeliveryAddressLines() != null && !ad.getDeliveryAddressLines().isEmpty()) {
- for (ADXP adxp : ad.getDeliveryAddressLines()) {
- if (adxp != null && !adxp.isSetNullFlavor()) {
- address.addLine(adxp.getText());
- }
- }
- }
-
- // city -> city
- if (ad.getCities() != null && !ad.getCities().isEmpty()) {
- for (ADXP adxp : ad.getCities()) {
- // Asserting that at most one city information exists
- if (adxp != null && !adxp.isSetNullFlavor()) {
- address.setCity(adxp.getText());
- }
- }
- }
-
- // county -> district
- if (ad.getCounties() != null && !ad.getCounties().isEmpty()) {
- for (ADXP adxp : ad.getCounties()) {
- // Asserting that at most one county information exists
- if (adxp != null && !adxp.isSetNullFlavor()) {
- address.setDistrict(adxp.getText());
- }
- }
-
- }
-
- // country -> country
- if (ad.getCountries() != null && !ad.getCountries().isEmpty()) {
- for (ADXP adxp : ad.getCountries()) {
- if (adxp != null && !adxp.isSetNullFlavor()) {
- address.setCountry(adxp.getText());
- }
- }
-
- }
-
- // state -> state
- if (ad.getStates() != null && !ad.getStates().isEmpty()) {
- for (ADXP adxp : ad.getStates()) {
- if (adxp != null && !adxp.isSetNullFlavor()) {
- address.setState(adxp.getText());
- }
- }
- }
-
- // postalCode -> postalCode
- if (ad.getPostalCodes() != null && !ad.getPostalCodes().isEmpty()) {
- for (ADXP adxp : ad.getPostalCodes()) {
- if (adxp != null && !adxp.isSetNullFlavor() && adxp.getText() != null) {
- address.setPostalCode(adxp.getText().trim());
- }
- }
- }
-
- // useablePeriods[0] -> start, usablePeriods[1] -> end
- if (ad.getUseablePeriods() != null && !ad.getUseablePeriods().isEmpty()) {
- Period period = new Period();
- int sxcmCounter = 0;
- for (SXCM_TS sxcmts : ad.getUseablePeriods()) {
- if (sxcmts != null && !sxcmts.isSetNullFlavor()) {
- if (sxcmCounter == 0) {
- period.setStartElement(tString2DateTime(sxcmts.getValue()));
- sxcmCounter++;
- } else if (sxcmCounter == 1) {
- period.setEndElement(tString2DateTime(sxcmts.getValue()));
- sxcmCounter++;
- }
- }
- }
- address.setPeriod(period);
- }
- return address;
- }
-
- @Override
- public Base64BinaryType tBIN2Base64Binary(BIN bin) {
- if (bin == null || bin.isSetNullFlavor())
- return null;
- if (bin.getRepresentation().getLiteral() != null) {
- // TODO: It doesn't seem convenient. There should be a way to get the value of
- // BIN.
- Base64BinaryType base64BinaryDt = new Base64BinaryType();
- base64BinaryDt.setValue(bin.getRepresentation().getLiteral().getBytes());
- return base64BinaryDt;
- } else {
- return null;
- }
-
- }
-
- @Override
- public BooleanType tBL2Boolean(BL bl) {
- return (bl == null || bl.isSetNullFlavor()) ? null : new BooleanType(bl.getValue());
- }
-
- @Override
- public String tED2Annotation(ED ed, Map idedAnnotations) {
-
- if (ed != null) {
-
- if (idedAnnotations != null) {
- // Try to pull the reference.
- TEL tel = ed.getReference();
- if (tel != null) {
- String value = tel.getValue();
- if (value != null && value.charAt(0) == '#') {
- String key = value.substring(1);
- return idedAnnotations.get(key);
- }
-
- }
- }
-
- // If not fall back on text value.
- String originalText = ed.getText().trim();
- if (!originalText.equals("")) {
- return originalText;
- }
-
- }
- return null;
- }
-
- @Override
- public CodeableConcept tCD2CodeableConcept(CD cd) {
- return tCD2CodeableConcept(cd, null);
- }
-
- @Override
- public CodeableConcept tCD2CodeableConcept(CD cd, Map idedAnnotations) {
- CodeableConcept myCodeableConcept = tCD2CodeableConceptExcludingTranslations(cd, idedAnnotations);
-
- if (myCodeableConcept == null)
- return null;
-
- // translation
- if (cd.getTranslations() != null && !cd.getTranslations().isEmpty()) {
- for (CD myCd : cd.getTranslations()) {
- Coding codingDt = new Coding();
- boolean isEmpty = true;
-
- // codeSystem -> system
- if (myCd.getCodeSystem() != null && !myCd.getCodeSystem().isEmpty()) {
- codingDt.setSystem(vst.tOid2Url(myCd.getCodeSystem()));
- isEmpty = false;
- }
-
- // code -> code
- if (myCd.getCode() != null && !myCd.getCode().isEmpty()) {
- codingDt.setCode(myCd.getCode());
- isEmpty = false;
- }
-
- // codeSystemVersion -> version
- if (myCd.getCodeSystemVersion() != null && !myCd.getCodeSystemVersion().isEmpty()) {
- codingDt.setVersion(myCd.getCodeSystemVersion());
- isEmpty = false;
- }
-
- // displayName -> display
- if (myCd.getDisplayName() != null && !myCd.getDisplayName().isEmpty()) {
- codingDt.setDisplay(myCd.getDisplayName());
- isEmpty = false;
- }
-
- if (isEmpty == false)
- myCodeableConcept.addCoding(codingDt);
- }
- }
-
- return myCodeableConcept;
- }
-
- @Override
- public CodeableConcept tCD2CodeableConceptExcludingTranslations(CD cd) {
- return tCD2CodeableConceptExcludingTranslations(cd, null);
- }
-
- @Override
- public CodeableConcept tCD2CodeableConceptExcludingTranslations(CD cd, Map idedAnnotations) {
- if (cd == null) {
- return null;
- }
-
- CodeableConcept myCodeableConcept = null;
-
- if (!cd.isSetNullFlavor()) {
- // .
- Coding codingDt = new Coding();
- boolean isEmpty = true;
-
- // codeSystem -> system
- if (cd.getCodeSystem() != null && !cd.getCodeSystem().isEmpty()) {
- codingDt.setSystem(vst.tOid2Url(cd.getCodeSystem()));
- isEmpty = false;
- }
-
- // code -> code
- if (cd.getCode() != null && !cd.getCode().isEmpty()) {
- codingDt.setCode(cd.getCode());
- isEmpty = false;
- }
-
- // codeSystemVersion -> version
- if (cd.getCodeSystemVersion() != null && !cd.getCodeSystemVersion().isEmpty()) {
- codingDt.setVersion(cd.getCodeSystemVersion());
- isEmpty = false;
- }
-
- // displayName -> display
- if (cd.getDisplayName() != null && !cd.getDisplayName().isEmpty()) {
- codingDt.setDisplay(cd.getDisplayName());
- isEmpty = false;
- }
-
- if (!isEmpty) {
- myCodeableConcept = new CodeableConcept();
- myCodeableConcept.addCoding(codingDt);
- }
- }
-
- String annotation = tED2Annotation(cd.getOriginalText(), idedAnnotations);
- if (annotation != null) {
- if (myCodeableConcept == null) {
- myCodeableConcept = new CodeableConcept();
- }
- myCodeableConcept.setText(annotation);
- }
-
- return myCodeableConcept;
- }
-
- @Override
- public Coding tCV2Coding(CV cv) {
- if (cv == null || cv.isSetNullFlavor())
- return null;
-
- Coding codingDt = new Coding();
-
- // codeSystem -> system
- if (cv.getCodeSystem() != null && !cv.getCodeSystem().isEmpty()) {
- codingDt.setSystem(cv.getCodeSystem());
- }
-
- // codeSystemVersion -> version
- if (cv.getCodeSystemVersion() != null && !cv.getCodeSystemVersion().isEmpty()) {
- codingDt.setVersion(cv.getCodeSystemVersion());
- }
-
- // code -> code
- if (cv.getCode() != null && !cv.getCode().isEmpty()) {
- codingDt.setCode(cv.getCode());
- }
-
- // displayName -> display
- if (cv.getDisplayName() != null && !cv.getDisplayName().isEmpty()) {
- codingDt.setDisplay(cv.getDisplayName());
- }
- return codingDt;
- }
-
- @Override
- public Attachment tED2Attachment(ED ed) {
- if (ed == null || ed.isSetNullFlavor())
- return null;
-
- Attachment attachmentDt = new Attachment();
-
- // mediaType -> contentType
- if (ed.isSetMediaType() && ed.getMediaType() != null && !ed.getMediaType().isEmpty()) {
- attachmentDt.setContentType(ed.getMediaType());
- }
-
- // language -> language
- if (ed.getLanguage() != null && !ed.getLanguage().isEmpty()) {
- attachmentDt.setLanguage(ed.getLanguage());
- }
-
- // text.bytes -> data
- if (ed.getText() != null && !ed.getText().isEmpty()) {
- if (ed.getText().getBytes() != null) {
- attachmentDt.setData(ed.getText().getBytes());
- }
- }
-
- // reference.value -> url
- if (ed.getReference() != null && !ed.getReference().isSetNullFlavor()) {
- if (ed.getReference().getValue() != null && !ed.getReference().getValue().isEmpty()) {
- attachmentDt.setUrl(ed.getReference().getValue());
- }
- }
-
- // integrityCheck -> hash
- if (ed.getIntegrityCheck() != null) {
- attachmentDt.setHash(ed.getIntegrityCheck());
- }
-
- return attachmentDt;
- }
-
- @Override
- public HumanName tEN2HumanName(EN en) {
- if (en == null || en.isSetNullFlavor())
- return null;
-
- HumanName myHumanName = new HumanName();
-
- // text -> text
- if (en.getText() != null && !en.getText().isEmpty()) {
- myHumanName.setText(en.getText());
- }
-
- // use -> use
- if (en.getUses() != null && !en.getUses().isEmpty()) {
- for (EntityNameUse entityNameUse : en.getUses()) {
- if (entityNameUse != null) {
- myHumanName.setUse(vst.tEntityNameUse2NameUse(entityNameUse));
- }
- }
- }
-
- // family -> family
- // TODO: FHIR DSTU2 supported multiple family names but STU3 only supports
- // one. Figure out how to handle this. For now, error out if there's multiple
- // family names from source
- if (en.getFamilies() != null && !en.getFamilies().isEmpty()) {
- boolean alreadySet = false;
- for (ENXP family : en.getFamilies()) {
- if (alreadySet) {
- throw new IllegalArgumentException("multiple family names found!");
- }
- // myHumanName.addFamily(family.getText());
- myHumanName.setFamily(family.getText());
- alreadySet = true;
- }
- }
-
- // given -> given
- if (en.getGivens() != null && !en.getGivens().isEmpty()) {
- for (ENXP given : en.getGivens()) {
- myHumanName.addGiven(given.getText());
- }
- }
-
- // prefix -> prefix
- if (en.getPrefixes() != null && !en.getPrefixes().isEmpty()) {
- for (ENXP prefix : en.getPrefixes()) {
- myHumanName.addPrefix(prefix.getText());
- }
- }
-
- // suffix -> suffix
- if (en.getSuffixes() != null && !en.getSuffixes().isEmpty()) {
- for (ENXP suffix : en.getSuffixes()) {
- myHumanName.addSuffix(suffix.getText());
- }
- }
-
- // validTime -> period
- if (en.getValidTime() != null && !en.getValidTime().isSetNullFlavor()) {
- myHumanName.setPeriod(tIVL_TS2Period(en.getValidTime()));
- }
-
- return myHumanName;
-
- }
-
- @Override
- public Identifier tII2Identifier(II ii) {
- if (ii == null || ii.isSetNullFlavor())
- return null;
-
- Identifier identifierDt = new Identifier();
-
- // default to official use
- IdentifierUse use = Config.DEFAULT_IDENTIFIER_USE;
- identifierDt.setUse(use);
-
- // if both root and extension are present, then
- // root -> system
- // extension -> value
- if (ii.getRoot() != null && !ii.getRoot().isEmpty() && ii.getExtension() != null
- && !ii.getExtension().isEmpty()) {
- // root is oid
- if (StringUtil.isOID(ii.getRoot()))
- identifierDt.setSystem("urn:oid:" + ii.getRoot());
- // root is uuid
- else if (StringUtil.isUUID(ii.getRoot()))
- identifierDt.setSystem("urn:uuid:" + ii.getRoot());
- else
- identifierDt.setSystem(ii.getRoot());
-
- identifierDt.setValue(ii.getExtension());
- }
- // else if only the root is present, then
- // root -> value
- else if (ii.getRoot() != null && !ii.getRoot().isEmpty())
- identifierDt.setValue(ii.getRoot());
- // this is not very likely but, if there is only the extension, then
- // extension -> value
- else if (ii.getExtension() != null && !ii.getExtension().isEmpty())
- identifierDt.setValue(ii.getExtension());
-
- if (ii.getAssigningAuthorityName() != null) {
- Reference ref = new Reference();
- ref.setDisplay(ii.getAssigningAuthorityName());
- identifierDt.setAssigner(ref);
- }
-
- return identifierDt;
-
- }
-
- @Override
- public IntegerType tINT2Integer(INT myInt) {
- return (myInt == null || myInt.isSetNullFlavor() || myInt.getValue() == null) ? null
- : new IntegerType(myInt.getValue().toString());
- }
-
- @Override
- public Range tIVL_PQ2Range(IVL_PQ ivlpq) {
- if (ivlpq == null || ivlpq.isSetNullFlavor())
- return null;
-
- Range rangeDt = new Range();
-
- // low -> low
- if (ivlpq.getLow() != null && !ivlpq.getLow().isSetNullFlavor()) {
- rangeDt.setLow(tPQ2SimpleQuantity(ivlpq.getLow()));
-
- }
-
- // high -> high
- if (ivlpq.getHigh() != null && !ivlpq.getHigh().isSetNullFlavor()) {
- rangeDt.setHigh(tPQ2SimpleQuantity(ivlpq.getHigh()));
- }
-
- // low is null, high is null and the value is carrying the low value
- // value -> low
- if (ivlpq.getLow() == null && ivlpq.getHigh() == null && ivlpq.getValue() != null) {
- SimpleQuantity low = new SimpleQuantity();
- low.setValue(ivlpq.getValue());
- rangeDt.setLow(low);
- }
-
- return rangeDt;
- }
-
- @Override
- public Period tIVL_TS2Period(IVL_TS ivlts) {
- if (ivlts == null || ivlts.isSetNullFlavor())
- return null;
-
- Period periodDt = new Period();
-
- // low -> start
- if (ivlts.getLow() != null && !ivlts.getLow().isSetNullFlavor()) {
- String date = ivlts.getLow().getValue();
- periodDt.setStartElement(tString2DateTime(date));
- }
-
- // high -> end
- if (ivlts.getHigh() != null && !ivlts.getHigh().isSetNullFlavor()) {
- String date = ivlts.getHigh().getValue();
- periodDt.setEndElement(tString2DateTime(date));
- }
-
- // low is null, high is null and the value is carrying the low value
- // value -> low
- if (ivlts.getLow() == null && ivlts.getHigh() == null && ivlts.getValue() != null
- && !ivlts.getValue().equals("")) {
- periodDt.setStartElement(tString2DateTime(ivlts.getValue()));
- }
-
- return periodDt;
- }
-
- @Override
- public Timing tPIVL_TS2Timing(PIVL_TS pivlts) {
- // http://wiki.hl7.org/images/c/ca/Medication_Frequencies_in_CDA.pdf
- // http://www.cdapro.com/know/24997
- if (pivlts == null || pivlts.isSetNullFlavor())
- return null;
-
- Timing timing = new Timing();
-
- // period -> period
- if (pivlts.getPeriod() != null && !pivlts.getPeriod().isSetNullFlavor()) {
- TimingRepeatComponent repeat = new TimingRepeatComponent();
- timing.setRepeat(repeat);
- // period.value -> repeat.period
- if (pivlts.getPeriod().getValue() != null)
- repeat.setPeriod(pivlts.getPeriod().getValue());
- // period.unit -> repeat.periodUnits
- if (pivlts.getPeriod().getUnit() != null)
- // repeat.setPeriodUnits(vst.tPeriodUnit2UnitsOfTimeEnum(pivlts.getPeriod().getUnit()));
- repeat.setPeriodUnit(vst.tPeriodUnit2UnitsOfTime(pivlts.getPeriod().getUnit()));
-
- // phase -> repeat.bounds
- if (pivlts.getPhase() != null && !pivlts.getPhase().isSetNullFlavor()) {
- repeat.setBounds(tIVL_TS2Period(pivlts.getPhase()));
- }
- }
- return timing;
- }
-
- @Override
- public Quantity tPQ2Quantity(PQ pq) {
- if (pq == null || pq.isSetNullFlavor())
- return null;
-
- Quantity quantityDt = new Quantity();
-
- // value -> value
- if (pq.getValue() != null) {
- quantityDt.setValue(pq.getValue());
- }
-
- // unit -> unit
- if (pq.getUnit() != null && !pq.getUnit().isEmpty()) {
- quantityDt.setUnit(pq.getUnit());
- }
-
- // translation -> system & code
- for (PQR pqr : pq.getTranslations()) {
- if (pqr != null && !pqr.isSetNullFlavor()) {
- // codeSystem -> system
- if (pqr.getCodeSystem() != null && !pqr.getCodeSystem().isEmpty()) {
- quantityDt.setSystem(pqr.getCodeSystem());
- }
-
- // code -> code
- if (pqr.getCode() != null && !pqr.getCode().isEmpty()) {
- quantityDt.setCode(pqr.getCode());
- }
- }
- }
- return quantityDt;
- }
-
- @Override
- public SimpleQuantity tPQ2SimpleQuantity(PQ pq) {
- if (pq == null || pq.isSetNullFlavor())
- return null;
-
- SimpleQuantity simpleQuantity = new SimpleQuantity();
-
- // value -> value
- if (pq.getValue() != null) {
- simpleQuantity.setValue(pq.getValue());
- }
-
- // unit -> unit
- if (pq.getUnit() != null && !pq.getUnit().isEmpty()) {
- simpleQuantity.setUnit(pq.getUnit());
- }
-
- // translation -> system and code
- if (pq.getTranslations() != null && !pq.getTranslations().isEmpty()) {
- for (org.openhealthtools.mdht.uml.hl7.datatypes.PQR pqr : pq.getTranslations()) {
- if (pqr != null && !pqr.isSetNullFlavor()) {
- // codeSystem -> system
- if (pqr.getCodeSystem() != null && !pqr.getCodeSystem().isEmpty()) {
- simpleQuantity.setSystem(vst.tOid2Url(pqr.getCodeSystem()));
- }
-
- // code -> code
- if (pqr.getCode() != null && !pqr.getCode().isEmpty()) {
- simpleQuantity.setCode(pqr.getCode());
- }
- }
- }
- }
- return simpleQuantity;
- }
-
- @Override
- public DecimalType tREAL2DecimalType(REAL real) {
- return (real == null || real.isSetNullFlavor() || real.getValue() == null) ? null
- : new DecimalType(real.getValue());
- }
-
- @Override
- public Quantity tREAL2Quantity(REAL real) {
- if (real == null || real.isSetNullFlavor() || real.getValue() == null) {
- return null;
- } else {
- Quantity quantity = new Quantity();
- quantity.setValue(real.getValue());
- return quantity;
- }
- }
-
- @Override
- public Ratio tRTO2Ratio(RTO rto) {
- if (rto == null || rto.isSetNullFlavor())
- return null;
- Ratio myRatio = new Ratio();
-
- // numerator -> numerator
- if (rto.getNumerator() != null && !rto.getNumerator().isSetNullFlavor()) {
- Quantity quantity = new Quantity();
- REAL numerator = (REAL) rto.getNumerator();
- if (numerator.getValue() != null) {
- quantity.setValue(numerator.getValue().doubleValue());
- myRatio.setNumerator(quantity);
- }
- }
-
- // denominator -> denominator
- if (!rto.getDenominator().isSetNullFlavor()) {
- Quantity quantity = new Quantity();
- REAL denominator = (REAL) rto.getDenominator();
- if (denominator.getValue() != null) {
- quantity.setValue(denominator.getValue().doubleValue());
- myRatio.setDenominator(quantity);
- }
- }
- return myRatio;
- }
-
- @Override
- public StringType tST2String(ST st) {
- return (st == null || st.isSetNullFlavor() || st.getText() == null) ? null : new StringType(st.getText());
- }
-
- @Override
- public DateTimeType tString2DateTime(String date) {
- TS ts = DatatypesFactory.eINSTANCE.createTS();
- ts.setValue(date);
- return tTS2DateTime(ts);
- }
-
- @Override
- public Narrative tStrucDocText2Narrative(StrucDocText sdt) {
- if (sdt != null) {
- Narrative narrative = new Narrative();
- String narrativeDivString = tStrucDocText2String(sdt);
-
- try {
- narrative.setDivAsString(narrativeDivString);
- } catch (DataFormatException e) {
- return null;
- }
- narrative.setStatus(NarrativeStatus.ADDITIONAL);
- return narrative;
- }
- return null;
- }
-
- @Override
- public ContactPoint tTEL2ContactPoint(TEL tel) {
- if (tel == null || tel.isSetNullFlavor())
- return null;
-
- ContactPoint contactPointDt = new ContactPoint();
-
- // value and system -> value
- if (tel.getValue() != null && !tel.getValue().isEmpty()) {
- String value = tel.getValue();
- String[] systemType = value.split(":");
-
- // for the values in form tel:+1(555)555-1000
- if (systemType.length > 1) {
- ContactPointSystem contactPointSystem = vst.tTelValue2ContactPointSystem(systemType[0]);
- // system
- if (contactPointSystem != null) {
- contactPointDt.setSystem(contactPointSystem);
- } else {
- contactPointDt.setSystem(Config.DEFAULT_CONTACT_POINT_SYSTEM);
- }
- // value
- contactPointDt.setValue(systemType[1]);
- }
- // for the values in form +1(555)555-5000
- else if (systemType.length == 1) {
- contactPointDt.setValue(systemType[0]);
- // configurable default system value
- contactPointDt.setSystem(Config.DEFAULT_CONTACT_POINT_SYSTEM);
- }
- }
-
- // useablePeriods -> period
- if (tel.getUseablePeriods() != null && !tel.getUseablePeriods().isEmpty()) {
- Period period = new Period();
- int sxcmCounter = 0;
- for (SXCM_TS sxcmts : tel.getUseablePeriods()) {
- if (sxcmts != null && !sxcmts.isSetNullFlavor()) {
- // useablePeriods[0] -> period.start
- // useablePeriods[1] -> period.end
- if (sxcmCounter == 0) {
- if (sxcmts.getValue() != null && !sxcmts.getValue().isEmpty()) {
- period.setStartElement(tString2DateTime(sxcmts.getValue()));
- }
- } else if (sxcmCounter == 1) {
- if (sxcmts.getValue() != null && !sxcmts.getValue().isEmpty()) {
- period.setEndElement(tString2DateTime(sxcmts.getValue()));
- }
- }
- sxcmCounter++;
- }
- }
- contactPointDt.setPeriod(period);
- }
-
- // use -> use
- if (tel.getUses() != null && !tel.getUses().isEmpty()) {
- for (TelecommunicationAddressUse telAddressUse : tel.getUses()) {
- if (telAddressUse != null) {
- contactPointDt.setUse(vst.tTelecommunicationAddressUse2ContactPointUse(telAddressUse));
- }
- }
- }
-
- return contactPointDt;
- }
-
- @Override
- public DateType tTS2Date(TS ts) {
- DateType date = (DateType) tTS2BaseDateTime(ts, DateType.class);
- if (date == null)
- return null;
-
- // TimeZone is NOT permitted
- if (date.getTimeZone() != null) {
- date.setTimeZone(null);
- }
-
- // precision should be YEAR, MONTH or DAY. otherwise, set it to DAY
- if (date.getPrecision() != TemporalPrecisionEnum.YEAR && date.getPrecision() != TemporalPrecisionEnum.MONTH
- && date.getPrecision() != TemporalPrecisionEnum.DAY) {
- date.setPrecision(TemporalPrecisionEnum.DAY);
- }
-
- return date;
- }
-
- @Override
- public DateTimeType tTS2DateTime(TS ts) {
- DateTimeType dateTime = (DateTimeType) tTS2BaseDateTime(ts, DateTimeType.class);
-
- if (dateTime == null)
- return null;
-
- // if the precision is not YEAR or MONTH, TimeZone SHALL be populated
- if (dateTime.getPrecision() != TemporalPrecisionEnum.YEAR
- && dateTime.getPrecision() != TemporalPrecisionEnum.MONTH) {
- if (dateTime.getTimeZone() == null) {
- dateTime.setTimeZone(TimeZone.getDefault());
- }
- }
-
- // if the precision is MINUTE, seconds SHALL be populated
- if (dateTime.getPrecision() == TemporalPrecisionEnum.MINUTE) {
- dateTime.setPrecision(TemporalPrecisionEnum.SECOND);
- dateTime.setSecond(0);
- }
-
- return dateTime;
- }
-
- @Override
- public InstantType tTS2Instant(TS ts) {
- InstantType instant = (InstantType) tTS2BaseDateTime(ts, InstantType.class);
- if (instant == null)
- return null;
-
- // if the precision is not SECOND or MILLI, convert its precision to SECOND
- if (instant.getPrecision() != TemporalPrecisionEnum.SECOND
- && instant.getPrecision() != TemporalPrecisionEnum.MILLI) {
- instant.setPrecision(TemporalPrecisionEnum.SECOND);
- }
-
- // if it doesn't include a timezone, add the local timezone
- if (instant.getTimeZone() == null) {
- instant.setTimeZone(TimeZone.getDefault());
- }
- return instant;
- }
-
- @Override
- public UriType tURL2Uri(URL url) {
- return (url == null || url.isSetNullFlavor() || url.getValue() == null) ? null : new UriType(url.getValue());
- }
-
- // Helper Methods
- /**
- * Extracts the attributes of an HTML element This method is the helper for the
- * method getTags, which is already a helper for tStrucDocText2String.
- *
- * @param entry A EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry
- * instance
- * @return A Java String list containing the attributes of an HTML element in
- * form: attributeName="attributeValue". Each element corresponds to
- * distinct attributes for the same tag
- */
- private List getAttributesHelperForTStructDocText2String(
- EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry entry) {
- if (entry == null)
- return null;
-
- List attributeList = new ArrayList();
- if (entry.getValue() instanceof org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl) {
- for (FeatureMap.Entry attribute : ((org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl) entry.getValue())
- .getAnyAttribute()) {
- String name = attribute.getEStructuralFeature().getName();
- String value = attribute.getValue().toString();
- if (name != null && !name.isEmpty()) {
- String attributeToAdd = "";
- // we may have attributes which doesn't have any value
- attributeToAdd = attributeToAdd + name;
- if (value != null && !value.isEmpty()) {
- attributeToAdd = attributeToAdd + "=\"" + value + "\"";
- }
- attributeList.add(attributeToAdd);
- }
- }
- }
- return attributeList;
- }
-
- /**
- * Extracts the tags and the attributes of an HTML element. Also, this method
- * transforms the CDA formatted tags to HTML formatted tags. This method is the
- * helper for the method tStrucDocText2String.
- *
- * @param entry A EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry
- * instance
- * @return A Java String list containing the start tag and end tag of an HTML
- * element in form: <tagName attribute="attributeValue">. While
- * first element of the list correspons to the start tag, second element
- * of the list corresponds to the end tag.
- */
- private List getTagsHelperForTStructDocText2String(
- org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry entry) {
- if (entry == null)
- return null;
- String startTag = "";
- String endTag = "";
- String tagName = entry.getEStructuralFeature().getName();
- if (tagName == null || tagName.equals(""))
- return null;
- List attributeList = getAttributesHelperForTStructDocText2String(entry);
- List tagList = new ArrayList();
-
- String attributeToRemove = null;
-
- // removing id attribute from the attributeList
- for (String attribute : attributeList) {
- if (attribute.toLowerCase().startsWith("id=\"", 0)) {
- attributeToRemove = attribute;
- }
- }
-
- if (attributeToRemove != null)
- attributeList.remove(attributeToRemove);
-
- // removing styleCode attribute from the attributeList
- for (String attribute : attributeList) {
- if (attribute.toLowerCase().startsWith("stylecode=\"", 0)) {
- attributeToRemove = attribute;
- }
- }
- if (attributeToRemove != null)
- attributeList.remove(attributeToRemove);
-
- // case tag.equals("list"). we need to transform it to "ul" or "ol"
- if (tagName.equals("list")) {
- // first, think of the situtation no attribute exists about ordered/unordered
- tagName = "ul";
- attributeToRemove = null;
- for (String attribute : attributeList) {
- // if the attribute is listType, make the transformation
- if (attribute.toLowerCase().contains("listtype")) {
- // notice that the string "unordered" also contains "ordered"
- // therefore, it is vital to check "unordered" firstly.
- // if "unordered" is not contained by the attribute, then we may check for
- // "ordered"
- if (attribute.toLowerCase().contains("unordered")) {
- tagName = "ul";
- } else if (attribute.toLowerCase().contains("ordered")) {
- tagName = "ol";
- }
- attributeToRemove = attribute;
- }
- }
- // if we found the "listType" attribute, we assigned it to attributeToRemove
- // from now on, we have nothing to do with this attribute. let's remove it from
- // the list.
- if (attributeToRemove != null) {
- attributeList.remove(attributeToRemove);
- }
- } else {
- switch (tagName.toLowerCase()) {
- case "paragraph":
- tagName = "p";
- break;
- case "content":
- tagName = "span";
- break;
- case "item":
- tagName = "li";
- break;
- case "linkhtml":
- tagName = "a";
- break;
- case "renderMultimedia":
- tagName = "img";
- break;
- case "list":
- tagName = "ul";
- break;
- default: // do nothing. let the tagName be as it is
- }
- }
-
- // now, it is time to prepare our tag by using tagName and attributes
- startTag = "<" + tagName;
- // adding attributes to the start tag
- for (String attribute : attributeList) {
- startTag += " " + attribute;
- }
- // closing the start tag
- startTag += ">";
- endTag = "" + tagName + ">";
-
- // 1st element of the returning list: startTag
- tagList.add(startTag);
- // 2nd element of the returning list: endTag
- tagList.add(endTag);
-
- return tagList;
- }
-
- /**
- * Transforms A CDA StructDocText instance to a Java String containing the
- * transformed text. Since the method is a recursive one and handles with
- * different types of object, parameter is taken as Object. However, parameters
- * of type StructDocText should be given by the caller.
- *
- * @param param A CDA StructDocText instance
- * @return A Java String containing the transformed text
- */
- private String tStrucDocText2String(Object param) {
- if (param instanceof org.openhealthtools.mdht.uml.cda.StrucDocText) {
- org.openhealthtools.mdht.uml.cda.StrucDocText paramStrucDocText = (org.openhealthtools.mdht.uml.cda.StrucDocText) param;
- return "