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 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 = ""; - - // 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 "
" + tStrucDocText2String(paramStrucDocText.getMixed()) + "
"; - } else if (param instanceof BasicFeatureMap) { - String returnValue = ""; - for (Object object : (BasicFeatureMap) param) { - String pieceOfReturn = tStrucDocText2String(object); - if (pieceOfReturn != null && !pieceOfReturn.isEmpty()) { - returnValue = returnValue + pieceOfReturn; - } - } - return returnValue; - } else if (param instanceof EStructuralFeatureImpl.SimpleFeatureMapEntry) { - String elementBody = ((EStructuralFeatureImpl.SimpleFeatureMapEntry) param).getValue().toString(); - // deletion of unnecessary content (\n, \t) - elementBody = elementBody.replaceAll("\n", "").replaceAll("\t", ""); - - // replacement of special characters - elementBody = elementBody.replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&"); - // if there was a well-formed char sequence "&", after replacement it will - // transform to &amp; - // the following line of code will remove these type of typos - elementBody = elementBody.replaceAll("&amp;", "&"); - - String typeName = ((EStructuralFeatureImpl.SimpleFeatureMapEntry) param).getEStructuralFeature().getName(); - typeName = typeName.toLowerCase(); - if (typeName.equals("comment")) { - return ""; - } else if (typeName.equals("text")) { - return elementBody; - } else { - logger.warn( - "Unknown element type was found while transforming a StrucDocText instance to Narrative. Returning the value of the element"); - return elementBody; - } - } else if (param instanceof EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) { - EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry entry = (EStructuralFeatureImpl.ContainmentUpdatingFeatureMapEntry) param; - List tagList = getTagsHelperForTStructDocText2String(entry); - return tagList.get(0) + tStrucDocText2String(entry.getValue()) + tagList.get(1); - } else if (param instanceof org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl) { - // since the name and the attributes are taken already, we just send the mixed - // of anyTypeImpl - return tStrucDocText2String(((org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl) param).getMixed()); - } else { - logger.warn("Parameter for the method tStrucDocText2String is unknown. Returning null", param.getClass()); - return null; - } - } - - /** - * Transforms a CDA TS instance or a string including the date information in - * CDA format to a FHIR BaseDateTimeType primitive datatype instance. Since - * BaseDateTimeType is an abstract class, the second parameter of this method - * (Class<?> classOfReturningObject) determines the class that initiates - * the BaseDateTimeType object the method is to return. - * - * @param tsObject A CDA TS instance or a Java String including - * the date information in CDA format - * @param classOfReturningObject A FHIR class that determines the initiater for - * the BaseDateTimeType object the method is to - * return. DateType.class, DateTimeType.class or - * InstantType.class are expected. - * @return A FHIR BaseDateTimeType primitive datatype instance - */ - private BaseDateTimeType tTS2BaseDateTime(Object tsObject, Class classOfReturningObject) { - if (tsObject == null) - return null; - - String dateString; - // checking the type of tsObject, assigning dateString accordingly - if (tsObject instanceof TS) { - // null-flavor check - if (((TS) tsObject).isSetNullFlavor() || ((TS) tsObject).getValue() == null) { - return null; - } else { - dateString = ((TS) tsObject).getValue(); - } - } else if (tsObject instanceof String) { - dateString = (String) tsObject; - } else { - // unexpected situtation - // 1st parameter of this method should be either an instanceof TS or String - return null; - } - - BaseDateTimeType date; - // initializing date - if (classOfReturningObject == DateType.class) { - date = new DateType(); - } else if (classOfReturningObject == DateTimeType.class) { - date = new DateTimeType(); - } else if (classOfReturningObject == InstantType.class) { - date = new InstantType(); - } else { - // unexpected situtation - // caller of this method must have a need of DateType, DateTimeType or - // InstantType - // otherwise, the returning object will be of type DateType - date = new DateType(); - } - - /* - * Possible date forms YYYY: year YYYYMM: year month YYYYMMDD: year month day - * YYYYMMDDHHMM: year month day hour minute YYYYMMDDHHMMSS.S: year month day - * hour minute second YYYYMMDDHHMM+TIZO: year month day hour minute timezone - */ - - TemporalPrecisionEnum precision = null; - TimeZone timeZone = null; - - // getting the timezone - // once got the timezone, crop the timezone part from the string - if (dateString.contains("+")) { - timeZone = TimeZone.getTimeZone("GMT" + dateString.substring(dateString.indexOf('+'))); - dateString = dateString.substring(0, dateString.indexOf('+')); - } else if (dateString.contains("-")) { - timeZone = TimeZone.getTimeZone("GMT" + dateString.substring(dateString.indexOf('-'))); - dateString = dateString.substring(0, dateString.indexOf('-')); - } - - // determining precision - switch (dateString.length()) { - case 4: // yyyy - precision = TemporalPrecisionEnum.YEAR; - break; - case 6: // yyyymm - precision = TemporalPrecisionEnum.MONTH; - break; - case 8: // yyyymmdd - precision = TemporalPrecisionEnum.DAY; - break; - case 12: // yyyymmddhhmm - precision = TemporalPrecisionEnum.MINUTE; - break; - case 14: // yyyymmddhhmmss - precision = TemporalPrecisionEnum.SECOND; - break; - case 16: // yyyymmddhhmmss.s - case 17: // yyyymmddhhmmss.ss - case 18: // yyyymmddhhmmss.sss - case 19: // yyyymmddhhmmss.ssss - precision = TemporalPrecisionEnum.MILLI; - break; - default: - precision = null; - } - - // given string may include up to four digits of fractions of a second - // therefore, there may be cases where the length of the string is 17,18 or 19 - // and the precision is MILLI. - // for those of cases where the length causes conflicts, let's check if dot(.) - // exists in the string - - // setting precision - if (precision != null) { - date.setPrecision(precision); - } else { - // incorrect format - return null; - } - - // if timeZone is present, setting it - if (timeZone != null) { - date.setTimeZone(timeZone); - } - - if (precision == TemporalPrecisionEnum.MILLI) { - // get the integer starting from the dot(.) char 'till the end of the string as - // the millis - int millis = new Integer(dateString.substring(dateString.indexOf('.') + 1)); - // if millis is given as .4 , it corresponds to 400 millis. - // therefore, we need a conversion. - if (millis > 0 && millis < 1000) { - while (millis * 10 < 1000) { - millis *= 10; - } - } else if (millis >= 1000) { - // unexpected situtation - millis = 999; - } else { - // unexpected situtation - millis = 0; - } - - // setting millis - date.setMillis(millis); - - // setting second, minute, hour, day, month, year.. - date.setSecond(new Integer(dateString.substring(12, 14))); - date.setMinute(new Integer(dateString.substring(10, 12))); - date.setHour(new Integer(dateString.substring(8, 10))); - date.setDay(new Integer(dateString.substring(6, 8))); - date.setMonth(new Integer(dateString.substring(4, 6)) - 1); - date.setYear(new Integer(dateString.substring(0, 4))); - - } else { - // since there are strange situtations where the index changes upon the - // precision, we set every value in its precision block - switch (precision) { - case SECOND: - date.setSecond(new Integer(dateString.substring(12, 14))); - case MINUTE: - date.setMinute(new Integer(dateString.substring(10, 12))); - date.setHour(new Integer(dateString.substring(8, 10))); - date.setDay(new Integer(dateString.substring(6, 8))); - date.setMonth(new Integer(dateString.substring(4, 6)) - 1); - date.setYear(new Integer(dateString.substring(0, 4))); - break; - case DAY: - date.setDay(new Integer(dateString.substring(6, 8))); - date.setMonth(new Integer(dateString.substring(4, 6)) - 1); - date.setYear(new Integer(dateString.substring(0, 4))); - break; - case MONTH: - date.setMonth(new Integer(dateString.substring(4, 6))); - date.setYear(new Integer(dateString.substring(0, 4))); - break; - case YEAR: - date.setYear(new Integer(dateString.substring(0, 4)) + 1); - break; - default: - date = null; - } - } - return date; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/ICDATransformer.java b/src/main/java/tr/com/srdc/cda2fhir/transform/ICDATransformer.java deleted file mode 100644 index 21dbd1237..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/ICDATransformer.java +++ /dev/null @@ -1,92 +0,0 @@ -package tr.com.srdc.cda2fhir.transform; - -import java.util.Map; - -/* - * #%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 org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleType; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Reference; -import org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument; - -import tr.com.srdc.cda2fhir.util.IdGeneratorEnum; - -public interface ICDATransformer { - /** - * Returns a Reference for the patient of the CDA document - * - * @return A Reference that references the patient (i.e. - * recordTarget/patientRole) of the document - */ - Reference getPatientRef(); - - /** - * A consistent unique resource id generator - * - * @return a unique resource id - */ - String getUniqueId(); - - /** - * Sets the resource id generator format, which is either an incremental COUNTER - * or UUID - * - * @param idGen The id generator enumeration to be set - */ - void setIdGenerator(IdGeneratorEnum idGen); - - /** - * Transforms a Clinical Document Architecture (CDA) instance to a Bundle of - * corresponding FHIR resources - * - * @param cda A ContinuityOfCareDocument (CDA) instance to be - * transformed - * @param documentBody The base64 decoded body from the original document - * @param assemblerDevice An identifier with the name of the device doing the - * - * @return A FHIR Bundle that contains a Composition corresponding to the CDA - * document and all other resources that are referenced within the - * Composition. - */ - Bundle transformDocument(ContinuityOfCareDocument cda, String documentBody, Identifier assemblerDevice); - - /** - * Transforms a Clinical Document Architecture (CDA) instance to a Bundle of - * corresponding FHIR resources - * - * @param cda A ContinuityOfCareDocument (CDA) instance to be - * transformed - * @param bundleType The type of bundle being transformed, currently - * only supports transactional bundles - * @param resourceProfileMap Map of resources used in DAF assignment, no longer - * actively supported but left in API. - * @param documentBody The String body from the original document. - * @param assemblerDevice An identifier object for the Device responsible for - * the transformation. - * - * @return A FHIR Bundle that contains a Composition corresponding to the CDA - * document and all other resources that are referenced within the - * Composition. - */ - Bundle transformDocument(ContinuityOfCareDocument cda, BundleType bundleType, - Map resourceProfileMap, String documentBody, Identifier assemblerDevice) throws Exception; -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/IDataTypesTransformer.java b/src/main/java/tr/com/srdc/cda2fhir/transform/IDataTypesTransformer.java deleted file mode 100644 index 607cbc623..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/IDataTypesTransformer.java +++ /dev/null @@ -1,330 +0,0 @@ -package tr.com.srdc.cda2fhir.transform; - -import java.util.Map; - -/* - * #%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 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.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.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.InstantType; -import org.hl7.fhir.dstu3.model.IntegerType; -import org.hl7.fhir.dstu3.model.Narrative; -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.SimpleQuantity; -import org.hl7.fhir.dstu3.model.StringType; -import org.hl7.fhir.dstu3.model.Timing; -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.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.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.EN; -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.REAL; -import org.openhealthtools.mdht.uml.hl7.datatypes.RTO; -import org.openhealthtools.mdht.uml.hl7.datatypes.ST; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.datatypes.TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.URL; - -public interface IDataTypesTransformer { - - /** - * Transforms a CDA AD instance to a FHIR Address composite datatype instance. - * - * @param ad A CDA AD instance - * @return An Address composite datatype instance - */ - Address AD2Address(AD ad); - - /** - * Transforms a CDA BIN instance to a FHIR Base64BinaryType primitive datatype - * instance. - * - * @param bin A CDA BIN instance - * @return A Base64BinaryType primitive datatype instance - */ - Base64BinaryType tBIN2Base64Binary(BIN bin); - - /** - * Transforms a CDA BL instance to a FHIR BooleanType primitive datatype - * instance. - * - * @param bl A CDA BL instance - * @return A BooleanType primitive datatype instance - */ - BooleanType tBL2Boolean(BL bl); - - /** - * Transforms a CDA ED instance to a String based on ided annotations from - * section text. - * - * @param ed A CDA ED instance - * @idedAnnotations A id to value map for annotation - * @return A String - */ - String tED2Annotation(ED ed, Map idedAnnotations); - - /** - * Transforms a CDA CD instance to a FHIR CodeableConcept composite datatype - * instance. Translations and original text of the CD instance are also - * included. - * - * @param cd A CDA CD instance - * @param A id to value map of annotations that maybe referred from - * originalText - * @return A CodeableConcept composite datatype instance - */ - CodeableConcept tCD2CodeableConcept(CD cd, Map idedAnnotations); - - /** - * Transforms a CDA CD instance to a FHIR CodeableConcept composite datatype - * instance. Translations of the CD instance are also included. - * - * @param cd A CDA CD instance - * @return A CodeableConcept composite datatype instance - */ - CodeableConcept tCD2CodeableConcept(CD cd); - - /** - * Transforms a CDA CD instance to a FHIR CodeableConcept composite datatype - * instance. Translations of the CD instance are excluded but original text is - * included. - * - * @param cd A CDA CD instance - * @param A id to value map of annotations that maybe referred from - * originalText - * @return A CodeableConcept composite datatype instance - */ - CodeableConcept tCD2CodeableConceptExcludingTranslations(CD cd, Map idedAnnotations); - - /** - * Transforms a CDA CD instance to a FHIR CodeableConcept composite datatype - * instance. Translations of the CD instance are excluded. - * - * @param cd A CDA CD instance - * @return A CodeableConcept composite datatype instance - */ - CodeableConcept tCD2CodeableConceptExcludingTranslations(CD cd); - - /** - * Transforms a CDA CV instance to a FHIR Coding composite datatype instance. - * - * @param cv A CDA CV instance - * @return A Coding composite datatype instance - */ - Coding tCV2Coding(CV cv); - - /** - * Transforms a CDA ED instance to a FHIR Attachment composite datatype - * instance. - * - * @param ed A CDA ED instance - * @return An Attachment composite datatype instance - */ - Attachment tED2Attachment(ED ed); - - /** - * Transforms a CDA EN instance to a FHIR HumanName composite datatype instance. - * - * @param en A CDA EN instance - * @return A HumanName composite datatype instance - */ - HumanName tEN2HumanName(EN en); - - /** - * Transforms a CDA II instance to a FHIR Identifier composite datatype - * instance. - * - * @param ii A CDA II instance - * @return A Identifier composite datatype instance - */ - Identifier tII2Identifier(II ii); - - /** - * Transforms a CDA INT instance to a FHIR IntegerType primitive datatype - * instance. - * - * @param myInt A CDA INT instance - * @return A IntegerType primitive datatype instance - */ - IntegerType tINT2Integer(INT myInt); - - /** - * Transforms a CDA IVL_PQ instance to a FHIR Range composite datatype instance. - * - * @param ivlpq A CDA IVL_PQ instance - * @return A Range composite datatype instance - */ - Range tIVL_PQ2Range(IVL_PQ ivlpq); - - /** - * Transforms a CDA IVL_TS instance to a FHIR Period composite datatype - * instance. - * - * @param ivlts A CDA IVL_TS instance - * @return A Period composite datatype instance - */ - Period tIVL_TS2Period(IVL_TS ivlts); - - /** - * Transforms a CDA PIVL_TS instance to a FHIR Timing composite datatype - * instance. - * - * @param pivlts A CDA PIVL_TS instance - * @return A Timing composite datatype instance - */ - Timing tPIVL_TS2Timing(PIVL_TS pivlts); - - /** - * Transforms a CDA PQ instance to a FHIR Quantity composite datatype instance. - * - * @param pq A CDA PQ instance - * @return A Quantity composite datatype instance - */ - Quantity tPQ2Quantity(PQ pq); - - /** - * Transforms a CDA PQ instance to a FHIR SimpleQuantity composite datatype - * instance. - * - * @param pq A CDA PQ instance - * @return A SimpleQuantity composite datatype instance - */ - SimpleQuantity tPQ2SimpleQuantity(PQ pq); - - /** - * Transforms a CDA REAL instance to a FHIR DecimalType primitive datatype - * instance. - * - * @param real A CDA REAL instance - * @return A DecimalType primitive datatype instance - */ - DecimalType tREAL2DecimalType(REAL real); - - /** - * Transforms a CDA REAL instance to a FHIR quantity datatype instance. - * - * @param real a CDA REAL instance - * @return A FHIR quantity datatype instance - */ - Quantity tREAL2Quantity(REAL real); - - /** - * Transforms a CDA RTO instance to a FHIR Ratio composite datatype instance. - * - * @param rto A CDA RTO instance - * @return A Ratio composite datatype instance - */ - Ratio tRTO2Ratio(RTO rto); - - /** - * Transforms a CDA ST instance to a FHIR StringType primitive datatype - * instance. - * - * @param st A CDA ST instance - * @return A StringType datatype - */ - StringType tST2String(ST st); - - /** - * Transforms a String that includes a date in CDA format to a FHIR DateTimeType - * primitive datatype instance. - * - * @param date A String that includes a date in CDA format - * @return A DateTimeType primitive datatype instance - */ - DateTimeType tString2DateTime(String date); - - /** - * Transforms a CDA StrucDocText instance to a FHIR Narrative composite datatype - * instance. - * - * @param sdt A CDA StrucDocText instance - * @return A Narrative composite datatype instance - */ - Narrative tStrucDocText2Narrative(StrucDocText sdt); - - /** - * Transforms a CDA TEL instance to a FHIR ContactPoint composite datatype - * instance. - * - * @param tel A CDA TEL instance - * @return A ContactPoint composite datatype instance - */ - ContactPoint tTEL2ContactPoint(TEL tel); - - /** - * Transforms a CDA TS instance to a FHIR DateType primitive datatype instance. - * - * @param ts A CDA TS instance - * @return A DateType primitive datatype instance - */ - DateType tTS2Date(TS ts); - - /** - * Transforms a CDA TS instance to a FHIR DateTimeType primitive datatype - * instance. - * - * @param ts A CDA TS instance - * @return A DateTimeType primitive datatype instance - */ - DateTimeType tTS2DateTime(TS ts); - - /** - * Transforms a CDA TS instance to a FHIR InstantType primitive datatype - * instance. - * - * @param ts A CDA TS instance - * @return A InstantType primitive datatype instance - */ - InstantType tTS2Instant(TS ts); - - /** - * Transforms a CDA URL instance to a FHIR UriType primitive datatype instance. - * - * @param url A CDA URL instance - * @return A UriType primitive datatype instance - */ - UriType tURL2Uri(URL url); - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/IResourceTransformer.java b/src/main/java/tr/com/srdc/cda2fhir/transform/IResourceTransformer.java deleted file mode 100644 index 2609a3e01..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/IResourceTransformer.java +++ /dev/null @@ -1,565 +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 org.hl7.fhir.dstu3.model.Age; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Composition.SectionComponent; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.FamilyMemberHistory; -import org.hl7.fhir.dstu3.model.Group; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent; -import org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.dstu3.model.Resource; -import org.hl7.fhir.dstu3.model.Substance; -import org.openhealthtools.mdht.uml.cda.AssignedAuthor; -import org.openhealthtools.mdht.uml.cda.AssignedEntity; -import org.openhealthtools.mdht.uml.cda.ClinicalDocument; -import org.openhealthtools.mdht.uml.cda.Consumable; -import org.openhealthtools.mdht.uml.cda.Entity; -import org.openhealthtools.mdht.uml.cda.LanguageCommunication; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.ParticipantRole; -import org.openhealthtools.mdht.uml.cda.PatientRole; -import org.openhealthtools.mdht.uml.cda.Performer2; -import org.openhealthtools.mdht.uml.cda.Product; -import org.openhealthtools.mdht.uml.cda.Section; -import org.openhealthtools.mdht.uml.cda.consol.AllergyProblemAct; -import org.openhealthtools.mdht.uml.cda.consol.FamilyHistoryOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationActivity; -import org.openhealthtools.mdht.uml.cda.consol.Indication; -import org.openhealthtools.mdht.uml.cda.consol.MedicationActivity; -import org.openhealthtools.mdht.uml.cda.consol.MedicationInformation; -import org.openhealthtools.mdht.uml.cda.consol.MedicationSupplyOrder; -import org.openhealthtools.mdht.uml.cda.consol.ProblemConcernAct; -import org.openhealthtools.mdht.uml.cda.consol.ProblemObservation; -import org.openhealthtools.mdht.uml.cda.consol.ReactionObservation; -import org.openhealthtools.mdht.uml.cda.consol.ResultObservation; -import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.ServiceDeliveryLocation; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignObservation; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; - -import tr.com.srdc.cda2fhir.transform.entry.IEntityResult; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntryResult; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public interface IResourceTransformer { - - /** - * Transforms a CDA AgeObservation instance to a FHIR Age composite datatype - * instance - * - * @param cdaAgeObservation A CDA AgeObservation instance - * @return A FHIR Age composite datatype instance - */ - Age tAgeObservation2Age(org.openhealthtools.mdht.uml.cda.consol.AgeObservation cdaAgeObservation); - - /** - * Transforms a CDA AllergyProblemAct instance to a FHIR AllergyIntolerance - * resource. - * - * @param cdaAllergyProblemAct A CDA AllergyProblemAct instance - * @param bundleInfo A BundleInfo object which acts as a context for - * the current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tAllergyProblemAct2AllergyIntolerance(AllergyProblemAct cdaAllergyProblemAct, IBundleInfo bundleInfo); - - /** - * Transforms a CDA AssignedAuthor instance to a FHIR Practitioner resource. - * - * @param cdaAssignedAuthor A CDA AssignedAuthor instance - * @param bundleInfo A BundleInfo object which acts as a context for the - * current transformation bundle. - * @return A result object that might include FHIR Bundle and/or a reference to - * a Practitioner - */ - IEntityResult tAssignedAuthor2Practitioner(AssignedAuthor cdaAssignedAuthor, IBundleInfo bundleInfo); - - /** - * Transforms a CDA AssignedAuthor instance to a FHIR Device resource. - * - * @param cdaAssignedAuthor A CDA AssignedAuthor instance - * @param bundleInfo A BundleInfo object which acts as a context for the - * current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntityResult tAssignedAuthor2Device(AssignedAuthor cdaAssignedAuthor, IBundleInfo bundleInfo); - - /** - * Transforms a CDA AssignedEntity instance to a FHIR Practitioner resource. - * - * @param cdaAssignedEntity A CDA AssignedEntity instance - * @param bundleInfo A BundleInfo object which acts as a context for the - * current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntityResult tAssignedEntity2Practitioner(AssignedEntity cdaAssignedEntity, IBundleInfo bundleInfo); - - /** - * Transforms a CDA Author instance to a FHIR Practitioner resource. - * - * @param cdaAuthor A CDA Author instance - * @param bundleInfo A BundleInfo object which acts as a context for the current - * transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntityResult tAuthor2Practitioner(org.openhealthtools.mdht.uml.cda.Author cdaAuthor, IBundleInfo bundleInfo); - - /** - * Transforms a CDA CD instance to a FHIR Substance resource. - * - * @param cdaSubstanceCode A CDA CD instance - * @return A FHIR Substance resource - */ - Substance tCD2Substance(CD cdaSubstanceCode); - - /** - * Transforms a CDA ClicinalDocument instance to a FHIR Composition resource. - * - * @param cdaClinicalDocument A CDA ClicinalDocument instance - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tClinicalDocument2Composition(ClinicalDocument cdaClinicalDocument); - - /** - * Transforms a CDA ClicinalDocument instance to a FHIR Bundle resource. - * - * @param cdaClinicalDocument A CDA ClicinalDocument instance - * @param includeComposition Include composition resource or not - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - - IEntryResult tClinicalDocument2Bundle(ClinicalDocument cdaClinicalDocument, boolean includeComposition); - - /** - * Transforms a CDA CustodianOrganization instance to a FHIR Organization - * resource. - * - * @param cdaCustodianOrganization A CDA CustodianOrganization instance - * @param bundleInfo A BundleInfo object which acts as a context - * for the current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tCustodianOrganization2Organization( - org.openhealthtools.mdht.uml.cda.CustodianOrganization cdaCustodianOrganization, IBundleInfo bundleInfo); - - /** - * Transforms a CDA EncounterActivity instance to a FHIR Encounter resource. - * - * @param cdaEncounterActivity A CDA EncounterActivity instance - * @param bundleInfo A BundleInfo object which acts as a context for - * the current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tEncounterActivity2Encounter( - org.openhealthtools.mdht.uml.cda.consol.EncounterActivities cdaEncounterActivity, IBundleInfo bundleInfo); - - /** - * Transforms a CDA Entity instance to a FHIR Group resource. - * - * @param cdaEntity A CDA Entity instance - * @return A FHIR Group resource - */ - Group tEntity2Group(Entity cdaEntity); - - /** - * Transforms a CDA FamilyHistoryOrganizer instance to a FHIR - * FamilyMemberHistory resource. - * - * @param cdaFamilyHistoryOrganizer A CDA FamilyHistoryOrganizer instance - * @return A FHIR FamilyMemberHistory resource - */ - FamilyMemberHistory tFamilyHistoryOrganizer2FamilyMemberHistory(FamilyHistoryOrganizer cdaFamilyHistoryOrganizer); - - /** - * Transforms a CDA Observation instance that is included in Functional Status - * Section to a FHIR Observation resource. - * - * @param cdaObservation A CDA Observation instance that is included in - * Functional Status Section - * @param bundleInfo A BundleInfo object which acts as a context for the - * current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tFunctionalStatus2Observation(org.openhealthtools.mdht.uml.cda.Observation cdaObservation, - IBundleInfo bundleInfo); - - /** - * Transforms a CDA Guardian instance to a FHIR Patient.Contact resource. - * - * @param cdaGuardian A CDA Guardian instance - * @return A FHIR Patient.Contact resource - */ - org.hl7.fhir.dstu3.model.Patient.ContactComponent tGuardian2Contact( - org.openhealthtools.mdht.uml.cda.Guardian cdaGuardian); - - /** - * Transforms a CDA ImmunizationActivity instance to a FHIR Immunization - * resource. - * - * @param cdaImmunizationActivity A CDA ImmunizationActivity instance - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tImmunizationActivity2Immunization(ImmunizationActivity cdaImmunizationActivity, - IBundleInfo bundleInfo); - - /** - * Transforms a CDA LanguageCommunication instance to a FHIR Communication - * resource. - * - * @param cdaLanguageCommunication A CDA LanguageCommunication instance - * @return A FHIR Communication resource - */ - PatientCommunicationComponent tLanguageCommunication2Communication(LanguageCommunication cdaLanguageCommunication); - - /** - * Transforms a CDA ManufacturedProduct instance to a FHIR Medication resource. - * - * @param cdaManufacturedProduct A CDA ManufacturedProduct instance - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tManufacturedProduct2Medication(ManufacturedProduct cdaManufacturedProduct, IBundleInfo bundleInfo); - - /** - * Transforms a CDA MedicationActivity instance to a FHIR MedicationStatement - * resource. - * - * @param cdaMedicationActivity A CDA MedicationActivity instance - * @param bundleInfo A BundleInfo object which acts as a context for - * the current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tMedicationActivity2MedicationStatement(MedicationActivity cdaMedicationActivity, - IBundleInfo bundleInfo); - - /** - * Transforms a CDA MedicationDispense instance to a FHIR MedicationDispense - * resource. - * - * @param cdaMedicationDispense A CDA MedicationDispense instance - * @param bundleInfo A BundleInfo object which acts as a context for - * the current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tMedicationDispense2MedicationDispense( - org.openhealthtools.mdht.uml.cda.consol.MedicationDispense cdaMedicationDispense, IBundleInfo bundleInfo); - - /** - * Transforms a CDA MedicationInformation instance to a FHIR Medication - * resource. - * - * @param cdaMedicationInformation A CDA MedicationInformation instance - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tMedicationInformation2Medication(MedicationInformation cdaMedicationInformation, - IBundleInfo bundleInfo); - - /** - * Transforms a CDA Observation instance to a FHIR Observation resource. - * - * @param cdaObservation A CDA Observation instance - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tObservation2Observation(org.openhealthtools.mdht.uml.cda.Observation cdaObservation, - IBundleInfo bundleInfo); - - /** - * Transforms a CDA Organization instance to a FHIR Organization resource. - * - * @param cdaOrganization A CDA Organization instance - * @param bundleInfo A BundleInfo object which acts as a context for the - * current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - * - */ - IEntryResult tOrganization2Organization(org.openhealthtools.mdht.uml.cda.Organization cdaOrganization, - IBundleInfo bundleInfo); - - /** - * Transforms a CDA ParticipantRole instance to a FHIR Location resource. - * - * @param cdaParticipantRole A CDA ParticipantRole instance - * @return A FHIR Location Resource - */ - org.hl7.fhir.dstu3.model.Location tParticipantRole2Location(ParticipantRole cdaParticipantRole); - - /** - * Transforms a CDA PatientRole instance to a FHIR Patient resource. - * - * @param cdaPatientRole A CDA PatientRole instance * @param bundleInfo A - * BundleInfo object which acts as a context for the - * current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tPatientRole2Patient(PatientRole cdaPatientRole, IBundleInfo bundleInfo); - - /** - * Transforms a CDA Performer2 instance to a FHIR Practitioner resource. - * - * @param cdaPerformer2 A CDA Performer2 instance - * @param bundleInfo A BundleInfo object which acts as a context for the - * current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources. - */ - IEntityResult tPerformer22Practitioner(Performer2 cdaPerformer2, IBundleInfo bundleInfo); - - /** - * Transforms a CDA ProblemConcernAct instance to FHIR Condition resource(s). A - * ProblemConcernAct might include several Problem Observations, and each - * Problem Observation corresponds to a FHIR Condition. Therefore, the returning - * Bundle can contain several FHIR Conditions. - * - * @param cdaProblemConcernAct A CDA ProblemConcernAct instance - * @param bundleInfo A BundleInfo object which acts as a context for - * the current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources. - */ - IEntryResult tProblemConcernAct2Condition(ProblemConcernAct cdaProblemConcernAct, IBundleInfo bundleInfo); - - /** - * Transforms a CDA ProblemObservation instance to FHIR Condition resource. - * - * @param cdaProbObs A CDA ProblemObservation instance - * @param bundleInfo A BundleInfo object which acts as a context for the current - * transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Condition as the first entry, as well as other referenced resources - * such as Encounter, Practitioner - */ - IEntryResult tProblemObservation2Condition(ProblemObservation cdaProbObs, IBundleInfo bundleInfo); - - /** - * Transforms a CDA Procedure instance to a FHIR Procedure and supporting - * resources. - * - * @param cdaProcedure A CDA Procedure instance - * @param idedAnnotations Annotations that can be referenced - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources. - */ - IEntryResult tProcedure2Procedure(org.openhealthtools.mdht.uml.cda.Procedure cdaProcedure, IBundleInfo bundleInfo); - - /** - * Transforms a CDA ReactionObservation instance to a FHIR Observation resource. - * - * @param cdaReactionObservation A CDA ReactionObservation instance - * @param bundleInfo A BundleInfo object which acts as a context for - * the current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tReactionObservation2Observation(ReactionObservation cdaReactionObservation, IBundleInfo bundleInfo); - - /** - * Transforms a CDA ReferenceRange instance to a FHIR - * ObservationReferenceRangeComponent resource. - * - * @param cdaReferenceRange A CDA ReferenceRange instance - * @return A FHIR ObservationReferenceRangeComponent resource - */ - ObservationReferenceRangeComponent tReferenceRange2ReferenceRange( - org.openhealthtools.mdht.uml.cda.ReferenceRange cdaReferenceRange); - - /** - * Transforms a CDA ResultObservation instance to a FHIR Observation resource. - * - * @param cdaResultObservation A CDA ResultObservation instance - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tResultObservation2Observation(ResultObservation cdaResultObservation, IBundleInfo bundleInfo); - - /** - * Transforms a CDA ResultOrganizer instance to a FHIR DiagnosticReport - * resource. - * - * @param cdaResultOrganizer A CDA ResultOrganizer instance - * @param bundleInfo A BundleInfo object which acts as a context for the - * current transformation bundle. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tResultOrganizer2DiagnosticReport(ResultOrganizer cdaResultOrganizer, IBundleInfo bundleInfo); - - /** - * Transforms a CDA Section instance to a FHIR SectionComponent resource. - * - * @param cdaSection A CDA Section instance - * @return A FHIR SectionComponent resource - */ - SectionComponent tSection2Section(Section cdaSection); - - /** - * Transforms a CDA ServiceDeliveryLocation instance to a FHIR Location - * resource. - * - * @param cdaSDLOC A CDA ServiceDeliveryLocation instance - * @return A FHIR Location resource - */ - org.hl7.fhir.dstu3.model.Location tServiceDeliveryLocation2Location(ServiceDeliveryLocation cdaSDLOC); - - /** - * Transforms a CDA Supply instance to a FHIR Device resource. - * - * @param cdaSupply A CDA Supply instance - * @return A FHIR Device resource - */ - org.hl7.fhir.dstu3.model.Device tSupply2Device(org.openhealthtools.mdht.uml.cda.Supply cdaSupply); - - /** - * Transforms a CDA VitalSignObservation to a FHIR Observation resource. - * - * @param cdaVitalSignObservation A CDA VitalSignObservation instance - * @param bundleInfo A BundleInfo object which acts as a context - * for the current transformation bundle. - * @return An EntryResult object containing a FHIR Bundle with the Observation - * as the first entry, which can also include other referenced resources - * such as Encounter, Practitioner - */ - IEntryResult tVitalSignObservation2Observation(VitalSignObservation cdaVitalSignObservation, - IBundleInfo bundleInfo); - - /** - * - * @param resource A fhir resource for which a reference is needed - * @return a reference to the fhir resource parameter - */ - Reference getReference(Resource resource); - - /** - * - * Transforms a CDA MedicationSupplyOrder to a FHIR MedicationRequest - * resource.** - * - * @param supply A CDA MedicationSupplyOrder instance* - * - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - **/ - - IEntryResult medicationSupplyOrder2MedicationRequest(MedicationSupplyOrder supply, IBundleInfo bundleInfo); - - /** - * Provides a provenance file to store the targeted references. - * - * @param bundle The built bundle, needed to parse for references. - * @param encodedBody A string with the encoded document body. - * @param assemblerDevice An Identifier of the original assembling device. - * @return Bundle, updated with a provenance object, and entries for binary and - * device. - */ - Bundle tProvenance(Bundle bundle, String encodedBody, Identifier assemblerDevice); - - /** - * Creates a FHIR Condition object of category problem-list-item from a CDA - * Indication object. - * - * @param cdaIndication a CDA Indication object - * @param bundleInfo A BundleInfo object which acts as a context for the - * current transformation. - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tIndication2ConditionProblemListItem(Indication cdaIndication, IBundleInfo bundleInfo); - - /** - * Creates a FHIR Condition object of category encounter-diagnosis from a CDA - * Indication object. - * - * @param cdaIndication a CDA Indication object - * - * @return An EntryResult object which contains FHIR Bundle that with the - * Resource as the first entry, as well as other referenced resources - * and maps. - */ - IEntryResult tIndication2ConditionEncounter(Indication cdaIndication, IBundleInfo bundleInfo); - - /** - * Turns a CDA manufactured product object into a FHIR medication. - * - * @param cdaProduct CDA Product object. - * @param bundleInfo A BundleInfo object which acts as a context for the current - * transformation. - * @return An Entry result that contains a FHIR Bundle with the Medication, - * which can also include other referenced resources such as - * Practitioner. - */ - IEntryResult tManufacturedProduct2Medication(Product cdaProduct, IBundleInfo bundleInfo); - - /** - * Turns a CDA manufactured product object into a FHIR medication. - * - * @param cdaProduct CDA Product object. - * @param bundleInfo A BundleInfo object which acts as a context for the current - * transformation. - * @return An Entry result that contains a FHIR Bundle with the Medication, - * which can also include other referenced resources such as - * Practitioner. - */ - IEntryResult tManufacturedProduct2Medication(Consumable cdaConsumable, IBundleInfo bundleInfo); - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/IValueSetsTransformer.java b/src/main/java/tr/com/srdc/cda2fhir/transform/IValueSetsTransformer.java deleted file mode 100644 index affaf3cd1..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/IValueSetsTransformer.java +++ /dev/null @@ -1,362 +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 org.hl7.fhir.dstu3.model.Address.AddressType; -import org.hl7.fhir.dstu3.model.Address.AddressUse; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus; -import org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus; -import org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem; -import org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse; -import org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus; -import org.hl7.fhir.dstu3.model.Encounter.EncounterStatus; -import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender; -import org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus; -import org.hl7.fhir.dstu3.model.Group.GroupType; -import org.hl7.fhir.dstu3.model.HumanName.NameUse; -import org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus; -import org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus; -import org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus; -import org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus; -import org.hl7.fhir.dstu3.model.Observation.ObservationStatus; -import org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus; -import org.hl7.fhir.dstu3.model.Timing.UnitsOfTime; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.vocab.EntityClassRoot; -import org.openhealthtools.mdht.uml.hl7.vocab.EntityNameUse; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; -import org.openhealthtools.mdht.uml.hl7.vocab.PostalAddressUse; -import org.openhealthtools.mdht.uml.hl7.vocab.TelecommunicationAddressUse; - -public interface IValueSetsTransformer { - - /** - * Transforms a CDA AdministrativeGenderCode string to a FHIR - * AdministrativeGender. - * - * @param cdaAdministrativeGenderCode A CDA AdministrativeGenderCode string - * @return A value from the FHIR valueset AdministrativeGender - */ - AdministrativeGender tAdministrativeGenderCode2AdministrativeGender(String cdaAdministrativeGenderCode); - - /** - * Transforms a CDA AgeObservationUnit string to a FHIR AgeUnit string. - * - * @param cdaAgeObservationUnit A CDA AgeObservationUnit string - * @return A FHIR AgeUnit string - */ - String tAgeObservationUnit2AgeUnit(String cdaAgeObservationUnit); - - /** - * Transforms a CDA AllergyCategoryCode string to a FHIR - * AllergyIntoleranceCategory. - * - * @param cdaAllergyCategoryCode A CDA AllergyCategoryCode string - * @return A value from the FHIR valueset AllergyIntoleranceCategory - */ - AllergyIntoleranceCategory tAllergyCategoryCode2AllergyIntoleranceCategory(String cdaAllergyCategoryCode); - - /** - * Transforms a CDA AllergyCategoryCode string to a FHIR AllergyIntoleranceType. - * - * @param cdaAllergyCategoryCode A CDA AllergyCategoryCode string - * @return A value from the FHIR valueset AllergyIntoleranceType - */ - AllergyIntoleranceType tAllergyCategoryCode2AllergyIntoleranceType(String cdaAllergyCategoryCode); - - /** - * Transforms a CDA CriticalityObservation's value's code string to a FHIR - * AllergyIntoleranceCriticality. - * - * @param cdaCriticalityObservationValue A CDA CriticalityObservation's value's - * code string - * @return A value from the FHIR valueset AllergyIntolerancecriticalityEnum - */ - AllergyIntoleranceCriticality tCriticalityObservationValue2AllergyIntoleranceCriticality( - String cdaCriticalityObservationValue); - - /** - * Transforms a CDA EncounterCode string to a FHIR Coding. - * - * @param cdaEncounterCode A CDA EncounterCode string - * @return A value from the FHIR valueset Coding - */ - Coding tEncounterCode2EncounterCode(String cdaEncounterCode); - - /** - * Transforms a CDA EntityClassRoot vocable to a value from the FHIR valueset - * GroupType. - * - * @param cdaEntityClassRoot A CDA EntityClassRoot vocable - * @return A value from the FHIR valueset GroupType - */ - GroupType tEntityClassRoot2GroupType(EntityClassRoot cdaEntityClassRoot); - - /** - * Transforms a CDA EntityNameUse vocable to a value from the FHIR valueset - * NameUse. - * - * @param cdaEntityNameUse A CDA EntityNameUse vocable - * @return A value from the FHIR valueset NameUse - */ - NameUse tEntityNameUse2NameUse(EntityNameUse cdaEntityNameUse); - - /** - * Transforms a CDA FamilyHistoryOrganizerStatusCode string to a value from the - * FHIR valueset FamilyHistoryStatus. - * - * @param cdaFamilyHistoryOrganizerStatusCode A CDA - * FamilyHistoryOrganizerStatusCode - * string - * @return A value from the FHIR valueset FamilyHistoryStatus - */ - FamilyHistoryStatus tFamilyHistoryOrganizerStatusCode2FamilyHistoryStatus( - String cdaFamilyHistoryOrganizerStatusCode); - - /** - * Transforms a CDA MaritalStatusCode string to a value from the FHIR valueset - * Coding. - * - * @param cdaMaritalStatusCode A CDA MaritalStatusCode string - * @return A value from the FHIR valueset Coding - */ - Coding tMaritalStatusCode2MaritalStatusCode(String cdaMaritalStatusCode); - - /** - * Transforms a CDA NullFlavor vocable to a FHIR Coding composite datatype which - * includes the code about DataAbsentReason. - * - * @param cdaNullFlavor A CDA NullFlavor vocable - * @return A FHIR Coding composite datatype which includes the code about - * DataAbsentReason. - */ - Coding tNullFlavor2DataAbsentReasonCode(NullFlavor cdaNullFlavor); - - /** - * Transforms a CDA Observation Interpretation Code to a FHIR CodeableConcept - * composite datatype which includes the code about Observation Interpretation. - * - * @param cdaObservationInterpretationCode A CDA Observation Interpretation Code - * @return A FHIR CodeableConcept composite datatype which includes the code - * about Observation Interpretation - */ - CodeableConcept tObservationInterpretationCode2ObservationInterpretationCode(CD cdaObservationInterpretationCode); - - /** - * Transforms a CDA ObservationStatusCode string to a value from the FHIR - * valueset ObservationStatus. - * - * @param cdaObservationStatusCode A CDA ObservationStatusCode string - * @return A value from the FHIR valueset ObservationStatus - */ - ObservationStatus tObservationStatusCode2ObservationStatus(String cdaObservationStatusCode); - - /** - * Transforms a CodeSystem string to a URL string. - * - * @param codeSystem a CodeSystem string - * @return A URL string - */ - String tOid2Url(String codeSystem); - - /** - * Transforms a CDA ParticipationType vocable to a FHIR Coding composite - * datatype which includes the code about ParticipationType. - * - * @param cdaParticipationType A CDA ParticipationType vocable - * @return A FHIR Coding composite datatype which includes the code about - * ParticipationType - */ - Coding tParticipationType2ParticipationTypeCode( - org.openhealthtools.mdht.uml.hl7.vocab.ParticipationType cdaParticipationType); - - /** - * Transforms a CDA PeriodUnit string to a value from the FHIR valueset - * UnitsOfTime. - * - * @param cdaPeriodUnit A CDA PeriodUnit string - * @return A value from the FHIR valueset UnitsOfTime. - */ - UnitsOfTime tPeriodUnit2UnitsOfTime(String cdaPeriodUnit); - - /** - * Transforms a CDA PostalAddressUse vocable to a value from the FHIR valueset - * AddressType. - * - * @param cdaPostalAddressUse A CDA PostalAddressUse vocable - * @return A value from the FHIR valueset AddressType - */ - AddressType tPostalAddressUse2AddressType(PostalAddressUse cdaPostalAddressUse); - - /** - * Transforms a CDA PostalAddressUse vocable to a value from the FHIR valueset - * AddressUse. - * - * @param cdaPostalAddressUse A CDA PostalAddressUse vocable - * @return A value from the FHIR valueset AddressUse - */ - AddressUse tPostalAdressUse2AddressUse(PostalAddressUse cdaPostalAddressUse); - - /** - * Transforms a CDA ProblemType string to a value from the FHIR valuset Coding. - * - * @param cdaProblemType A CDA ProblemType string - * @return A value from the FHIR valuset Coding - */ - Coding tProblemType2ConditionCategoryCodes(String cdaProblemType); - - /** - * Transforms a CDA ResultOrganizer StatusCode string to a value from the FHIR - * valueset DiagnosticReportStatus - * - * @param cdaResultOrganizerStatusCode A CDA ResultOrganizer StatusCode string - * @return A value from the FHIR valueset DiagnosticReportStatus - */ - DiagnosticReportStatus tResultOrganizerStatusCode2DiagnosticReportStatus(String cdaResultOrganizerStatusCode); - - /** - * Transforms a CDA RoleCode string to a FHIR Coding composite datatype which - * includes the code about PatientContactRelationship. - * - * @param cdaRoleCode A CDA RoleCode string - * @return A FHIR Coding composite datatype which includes the code about - * PatientContactRelationship - */ - Coding tRoleCode2PatientContactRelationshipCode(String cdaRoleCode); - - /** - * Transforms a CDA SeverityCode string to a value from the FHIR valueset - * AllergyIntoleranceSeverity. - * - * @param cdaSeverityCode A CDA SeverityCode string - * @return A value from the FHIR valueset AllergyIntoleranceSeverity. - */ - AllergyIntoleranceSeverity tSeverityCode2AllergyIntoleranceSeverity(String cdaSeverityCode); - - /** - * Transforms a CDA StatusCode string to a value from the FHIR valueset - * AllergyIntoleranceVerificationStatus. - * - * @param cdaStatusCode A CDA StatusCode string - * @return A value from the FHIR valueset AllergyIntoleranceVerificationStatus - */ - AllergyIntoleranceVerificationStatus tStatusCode2AllergyIntoleranceVerificationStatus(String cdaStatusCode); - - /** - * Transforms a CDA StatusCode string to a value from the FHIR valueset - * ConditionVerificationStatus. - * - * @param cdaStatusCode A CDA StatusCode string - * @return A value from the FHIR valueset ConditionVerificationStatus - */ - ConditionVerificationStatus tStatusCode2ConditionVerificationStatus(String cdaStatusCode); - - /** - * Transforms a CDA StatusCode string to a value from the FHIR valueset - * EncounterStatus. - * - * @param cdaStatusCode A CDA StatusCode string - * @return A value from the FHIR valueset EncounterStatus - */ - EncounterStatus tStatusCode2EncounterStatusEnum(String cdaStatusCode); - - /** - * Transforms a CDA StatusCode string to a value from the FHIR valueset - * MedicationDispenseStatus. - * - * @param cdaStatusCode A CDA StatusCode string - * @return A value from the FHIR valueset MedicationDispenseStatus - */ - MedicationDispenseStatus tStatusCode2MedicationDispenseStatus(String cdaStatusCode); - - /** - * Transforms a CDA StatusCode string to a value from the FHIR valueset - * MedicationStatementStatus. - * - * @param cdaStatusCode A CDA StatusCode string - * @return A value from the FHIR valueset MedicationStatementStatus - */ - MedicationStatementStatus tStatusCode2MedicationStatementStatus(String cdaStatusCode); - - /** - * Transforms a CDA StatusCode string to a value from the FHIR valueset - * ImmunizationStatus. - * - * @param cdaStatusCode A CDA StatusCode string - * @return A value from the FHIR ImmunizationStatus - */ - ImmunizationStatus tStatusCode2ImmunizationStatus(String cdaStatusCode); - - /** - * Transforms a CDA StatusCode string to a value from the FHIR valueset - * ProcedureStatus. - * - * @param cdaStatusCode A CDA StatusCode string - * @return A value from the FHIR valueset ProcedureStatus - */ - ProcedureStatus tStatusCode2ProcedureStatus(String cdaStatusCode); - - /** - * Transforms a CDA TelecommunicationAddressUse vocable to a value from the FHIR - * valueset ContactPointUse. - * - * @param cdaTelecommunicationAddressUse A CDA TelecommunicationAddressUse - * vocable - * @return A value from the FHIR valueset ContactPointUse - */ - ContactPointUse tTelecommunicationAddressUse2ContactPointUse( - TelecommunicationAddressUse cdaTelecommunicationAddressUse); - - /** - * Transforms a CDA TelValue string to a value from the FHIR valueset - * ContactPointSystem. - * - * @param cdaTelValue A CDA TelValue string - * @return A value from the FHIR valueset ContactPointSystem. - */ - ContactPointSystem tTelValue2ContactPointSystem(String cdaTelValue); - - /** - * Transforms a CDA ProblemStatus code to a AllergyIntoleranceClinicalStatus - * - * @param code ProblemStatus code - * @return A value from the FHIR AllergyIntoleranceClinicalStatus - */ - AllergyIntoleranceClinicalStatus tProblemStatus2AllergyIntoleranceClinicalStatus(String code); - - /** - * Transforms a CDA ProblemStatus code to a COnditionClinicalStatus - * - * @param code ProblemStatus code - * @return A value from the FHIR ConditionClinicalStatus - */ - ConditionClinicalStatus tProblemStatus2ConditionClinicalStatus(String code); - - MedicationRequestStatus tActStatus2MedicationRequestStatus(String string); -} \ No newline at end of file diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/ResourceTransformerImpl.java b/src/main/java/tr/com/srdc/cda2fhir/transform/ResourceTransformerImpl.java deleted file mode 100644 index 16996be52..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/ResourceTransformerImpl.java +++ /dev/null @@ -1,3825 +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.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.xml.type.internal.DataValue.Base64; -import org.hl7.fhir.dstu3.model.Age; -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus; -import org.hl7.fhir.dstu3.model.Annotation; -import org.hl7.fhir.dstu3.model.Attachment; -import org.hl7.fhir.dstu3.model.Base64BinaryType; -import org.hl7.fhir.dstu3.model.BooleanType; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Composition; -import org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode; -import org.hl7.fhir.dstu3.model.Composition.CompositionAttesterComponent; -import org.hl7.fhir.dstu3.model.Composition.CompositionEventComponent; -import org.hl7.fhir.dstu3.model.Composition.DocumentConfidentiality; -import org.hl7.fhir.dstu3.model.Composition.SectionComponent; -import org.hl7.fhir.dstu3.model.Composition.SectionMode; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus; -import org.hl7.fhir.dstu3.model.Device; -import org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus; -import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.hl7.fhir.dstu3.model.DocumentReference; -import org.hl7.fhir.dstu3.model.DocumentReference.DocumentReferenceContentComponent; -import org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent; -import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender; -import org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus; -import org.hl7.fhir.dstu3.model.FamilyMemberHistory; -import org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent; -import org.hl7.fhir.dstu3.model.Group; -import org.hl7.fhir.dstu3.model.Group.GroupType; -import org.hl7.fhir.dstu3.model.IdType; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.Immunization.ImmunizationPractitionerComponent; -import org.hl7.fhir.dstu3.model.Immunization.ImmunizationReactionComponent; -import org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus; -import org.hl7.fhir.dstu3.model.MedicationRequest; -import org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestDispenseRequestComponent; -import org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestIntent; -import org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestRequesterComponent; -import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus; -import org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementTaken; -import org.hl7.fhir.dstu3.model.Narrative; -import org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus; -import org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Patient; -import org.hl7.fhir.dstu3.model.Patient.ContactComponent; -import org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent; -import org.hl7.fhir.dstu3.model.Period; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent; -import org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus; -import org.hl7.fhir.dstu3.model.Provenance; -import org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent; -import org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent; -import org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole; -import org.hl7.fhir.dstu3.model.Quantity; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.dstu3.model.Resource; -import org.hl7.fhir.dstu3.model.SimpleQuantity; -import org.hl7.fhir.dstu3.model.Substance; -import org.hl7.fhir.dstu3.model.Timing; -import org.hl7.fhir.dstu3.model.codesystems.ProvenanceAgentRole; -import org.hl7.fhir.dstu3.model.codesystems.ProvenanceAgentType; -import org.hl7.fhir.exceptions.FHIRException; -import org.openhealthtools.mdht.uml.cda.Act; -import org.openhealthtools.mdht.uml.cda.AssignedAuthor; -import org.openhealthtools.mdht.uml.cda.AssignedEntity; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.ClinicalDocument; -import org.openhealthtools.mdht.uml.cda.Consumable; -import org.openhealthtools.mdht.uml.cda.DocumentationOf; -import org.openhealthtools.mdht.uml.cda.Entity; -import org.openhealthtools.mdht.uml.cda.EntryRelationship; -import org.openhealthtools.mdht.uml.cda.Guardian; -import org.openhealthtools.mdht.uml.cda.LanguageCommunication; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.Material; -import org.openhealthtools.mdht.uml.cda.Observation; -import org.openhealthtools.mdht.uml.cda.Participant2; -import org.openhealthtools.mdht.uml.cda.ParticipantRole; -import org.openhealthtools.mdht.uml.cda.PatientRole; -import org.openhealthtools.mdht.uml.cda.Performer1; -import org.openhealthtools.mdht.uml.cda.Performer2; -import org.openhealthtools.mdht.uml.cda.Product; -import org.openhealthtools.mdht.uml.cda.RecordTarget; -import org.openhealthtools.mdht.uml.cda.Section; -import org.openhealthtools.mdht.uml.cda.ServiceEvent; -import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; -import org.openhealthtools.mdht.uml.cda.consol.AllergyObservation; -import org.openhealthtools.mdht.uml.cda.consol.AllergyProblemAct; -import org.openhealthtools.mdht.uml.cda.consol.AllergyStatusObservation; -import org.openhealthtools.mdht.uml.cda.consol.CommentActivity; -import org.openhealthtools.mdht.uml.cda.consol.FamilyHistoryOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationActivity; -import org.openhealthtools.mdht.uml.cda.consol.Indication; -import org.openhealthtools.mdht.uml.cda.consol.Instructions; -import org.openhealthtools.mdht.uml.cda.consol.MedicationActivity; -import org.openhealthtools.mdht.uml.cda.consol.MedicationDispense; -import org.openhealthtools.mdht.uml.cda.consol.MedicationInformation; -import org.openhealthtools.mdht.uml.cda.consol.MedicationSupplyOrder; -import org.openhealthtools.mdht.uml.cda.consol.NonMedicinalSupplyActivity; -import org.openhealthtools.mdht.uml.cda.consol.ProblemConcernAct; -import org.openhealthtools.mdht.uml.cda.consol.ProblemObservation; -import org.openhealthtools.mdht.uml.cda.consol.ProductInstance; -import org.openhealthtools.mdht.uml.cda.consol.ReactionObservation; -import org.openhealthtools.mdht.uml.cda.consol.ResultObservation; -import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.ServiceDeliveryLocation; -import org.openhealthtools.mdht.uml.cda.consol.SeverityObservation; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignObservation; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; -import org.openhealthtools.mdht.uml.hl7.datatypes.BL; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.EN; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -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.IVXB_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.ON; -import org.openhealthtools.mdht.uml.hl7.datatypes.PIVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.PN; -import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; -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.vocab.ActClass; -import org.openhealthtools.mdht.uml.hl7.vocab.ActClassObservation; -import org.openhealthtools.mdht.uml.hl7.vocab.EntityDeterminer; -import org.openhealthtools.mdht.uml.hl7.vocab.ParticipationType; -import org.openhealthtools.mdht.uml.hl7.vocab.RoleClassRoot; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActMoodDocumentObservation; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; -import org.openhealthtools.mdht.uml.hl7.vocab.x_DocumentSubstanceMood; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import tr.com.srdc.cda2fhir.conf.Config; -import tr.com.srdc.cda2fhir.transform.entry.IEntityInfo; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.entry.IMedicationsInformation; -import tr.com.srdc.cda2fhir.transform.entry.impl.DeferredProcedureEncounterReference; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntityInfo; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntityResult; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntryResult; -import tr.com.srdc.cda2fhir.transform.entry.impl.MedicationsInformation; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.IDeferredReference; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.LocalBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.ReferenceInfo; -import tr.com.srdc.cda2fhir.util.Constants; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class ResourceTransformerImpl implements IResourceTransformer, Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - private IDataTypesTransformer dtt; - private IValueSetsTransformer vst; - private ICDATransformer cdat; - private Reference defaultPatientRef; - - private final Logger logger = LoggerFactory.getLogger(ResourceTransformerImpl.class); - - public ResourceTransformerImpl() { - dtt = new DataTypesTransformerImpl(); - vst = new ValueSetsTransformerImpl(); - cdat = null; - // This is a default patient reference to be used when IResourceTransformer is - // not initiated with a ICDATransformer - defaultPatientRef = new Reference(new IdType("Patient", "0")); - } - - public ResourceTransformerImpl(ICDATransformer cdaTransformer) { - this(); - cdat = cdaTransformer; - } - - protected String getUniqueId() { - if (cdat != null) - return cdat.getUniqueId(); - else - return UUID.randomUUID().toString(); - } - - protected Reference getPatientRef() { - if (cdat != null) - return cdat.getPatientRef(); - else - return defaultPatientRef; - } - - private List tIIs2Identifiers(EList iis) { - if (!iis.isEmpty()) { - List result = new ArrayList(); - for (II ii : iis) { - if (ii != null && !ii.isSetNullFlavor()) { - Identifier identifier = dtt.tII2Identifier(ii); - result.add(identifier); - } - } - return result; - } - return null; - } - - @Override - public Reference getReference(Resource resource) { - Reference reference = new Reference(resource.getId()); - String referenceString = ReferenceInfo.getDisplay(resource); - if (referenceString != null) { - reference.setDisplay(referenceString); - } - reference.setResource(resource); - return reference; - } - - @Override - public Age tAgeObservation2Age(org.openhealthtools.mdht.uml.cda.consol.AgeObservation cdaAgeObservation) { - if (cdaAgeObservation == null || cdaAgeObservation.isSetNullFlavor()) - return null; - - Age fhirAge = new Age(); - - // value-> age - if (cdaAgeObservation != null && !cdaAgeObservation.getValues().isEmpty()) { - for (ANY value : cdaAgeObservation.getValues()) { - if (value != null && !value.isSetNullFlavor()) { - if (value instanceof PQ) { - if (((PQ) value).getValue() != null) { - // value.value -> value - fhirAge.setValue(((PQ) value).getValue()); - // value.unit -> unit - fhirAge.setUnit(((PQ) value).getUnit()); - fhirAge.setSystem("http://unitsofmeasure.org"); - } - } - } - } - } - - return fhirAge; - } - - @Override - public EntryResult tAllergyProblemAct2AllergyIntolerance(AllergyProblemAct cdaAllergyProbAct, - IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaAllergyProbAct == null || cdaAllergyProbAct.isSetNullFlavor()) { - return result; - } - - AllergyIntolerance fhirAllergyIntolerance = new AllergyIntolerance(); - result.addResource(fhirAllergyIntolerance); - - // resource id - IdType resourceId = new IdType("AllergyIntolerance", getUniqueId()); - fhirAllergyIntolerance.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirAllergyIntolerance.getMeta().addProfile(Constants.PROFILE_DAF_ALLERGY_INTOLERANCE); - - // id -> identifier - for (II ii : cdaAllergyProbAct.getIds()) { - if (!ii.isSetNullFlavor()) { - fhirAllergyIntolerance.addIdentifier(dtt.tII2Identifier(ii)); - } - } - - // patient - fhirAllergyIntolerance.setPatient(getPatientRef()); - - // statusCode -> verificationStatus - if (cdaAllergyProbAct.getStatusCode() != null && !cdaAllergyProbAct.getStatusCode().isSetNullFlavor()) { - if (cdaAllergyProbAct.getStatusCode().getCode() != null - && !cdaAllergyProbAct.getStatusCode().getCode().isEmpty()) { - AllergyIntoleranceVerificationStatus allergyIntoleranceStatusEnum = vst - .tStatusCode2AllergyIntoleranceVerificationStatus(cdaAllergyProbAct.getStatusCode().getCode()); - if (allergyIntoleranceStatusEnum != null) { - fhirAllergyIntolerance.setVerificationStatus(allergyIntoleranceStatusEnum); - } else { - fhirAllergyIntolerance.setVerificationStatus(Config.DEFAULT_ALLERGY_VERIFICATION_STATUS); - } - } else { - fhirAllergyIntolerance.setVerificationStatus(Config.DEFAULT_ALLERGY_VERIFICATION_STATUS); - } - } else { - fhirAllergyIntolerance.setVerificationStatus(Config.DEFAULT_ALLERGY_VERIFICATION_STATUS); - } - - // effectiveTime -> asserted - if (cdaAllergyProbAct.getEffectiveTime() != null && !cdaAllergyProbAct.getEffectiveTime().isSetNullFlavor()) { - - // low(if not exists, value) -> asserted - if (cdaAllergyProbAct.getEffectiveTime().getLow() != null - && !cdaAllergyProbAct.getEffectiveTime().getLow().isSetNullFlavor()) { - fhirAllergyIntolerance - .setAssertedDateElement(dtt.tTS2DateTime(cdaAllergyProbAct.getEffectiveTime().getLow())); - } else if (cdaAllergyProbAct.getEffectiveTime().getValue() != null - && !cdaAllergyProbAct.getEffectiveTime().getValue().isEmpty()) { - fhirAllergyIntolerance - .setAssertedDateElement(dtt.tString2DateTime(cdaAllergyProbAct.getEffectiveTime().getValue())); - } - } - - // getting allergyObservation - if (cdaAllergyProbAct.getAllergyObservations() != null - && !cdaAllergyProbAct.getAllergyObservations().isEmpty()) { - for (AllergyObservation cdaAllergyObs : cdaAllergyProbAct.getAllergyObservations()) { - if (cdaAllergyObs != null && !cdaAllergyObs.isSetNullFlavor()) { - - // allergyObservation.author -> AllergyIntolerance.recorder - if (cdaAllergyObs.getAuthors() != null && !cdaAllergyObs.getAuthors().isEmpty()) { - for (Author author : cdaAllergyObs.getAuthors()) { - if (author != null && !author.isSetNullFlavor()) { - EntityResult entityResult = tAuthor2Practitioner(author, bundleInfo); - result.updateFrom(entityResult); - if (entityResult.hasPractitioner()) { - Reference reference = getReference(entityResult.getPractitioner()); - fhirAllergyIntolerance.setRecorder(reference); - } - } - } - } - - // allergyObservation.participant.participantRole.playingEntity.code -> code - if (cdaAllergyObs.getParticipants() != null && !cdaAllergyObs.getParticipants().isEmpty()) { - for (Participant2 participant : cdaAllergyObs.getParticipants()) { - if (participant != null && !participant.isSetNullFlavor()) { - if (participant.getParticipantRole() != null - && !participant.getParticipantRole().isSetNullFlavor()) { - if (participant.getParticipantRole().getPlayingEntity() != null - && !participant.getParticipantRole().getPlayingEntity().isSetNullFlavor()) { - - if (participant.getParticipantRole().getPlayingEntity().getCode() != null) { - fhirAllergyIntolerance.setCode(dtt.tCD2CodeableConcept( - participant.getParticipantRole().getPlayingEntity().getCode())); - } - - if (participant.getParticipantRole().getPlayingEntity().getNames() != null) { - List names = participant.getParticipantRole().getPlayingEntity() - .getNames(); - if (!names.isEmpty()) { - if (fhirAllergyIntolerance.getCode() == null) { - fhirAllergyIntolerance.setCode(new CodeableConcept()); - } - PN name = names.get(0); - fhirAllergyIntolerance.getCode().setText(name.getText()); - } - } - - } - } - } - } - } - - // allergyObservation.value[@xsi:type='CD'] -> category - if (cdaAllergyObs.getValues() != null && !cdaAllergyObs.getValues().isEmpty()) { - for (ANY value : cdaAllergyObs.getValues()) { - if (value != null && !value.isSetNullFlavor()) { - if (value instanceof CD) { - if (vst.tAllergyCategoryCode2AllergyIntoleranceCategory( - ((CD) value).getCode()) != null) { - fhirAllergyIntolerance - .addCategory(vst.tAllergyCategoryCode2AllergyIntoleranceCategory( - ((CD) value).getCode())); - } - } - } - } - } - - // allergyObservation.value[@xsi:type='CD'] -> type - if (cdaAllergyObs.getValues() != null && !cdaAllergyObs.getValues().isEmpty()) { - for (ANY value : cdaAllergyObs.getValues()) { - if (value != null && !value.isSetNullFlavor()) { - if (value instanceof CD) { - if (vst.tAllergyCategoryCode2AllergyIntoleranceType( - ((CD) value).getCode()) != null) { - fhirAllergyIntolerance.setType(vst - .tAllergyCategoryCode2AllergyIntoleranceType(((CD) value).getCode())); - } - } - } - } - } - - // effectiveTime -> onset - if (cdaAllergyObs.getEffectiveTime() != null - && !cdaAllergyObs.getEffectiveTime().isSetNullFlavor()) { - - // low(if not exists, value) -> onset - if (cdaAllergyObs.getEffectiveTime().getLow() != null - && !cdaAllergyObs.getEffectiveTime().getLow().isSetNullFlavor()) { - fhirAllergyIntolerance - .setOnset(dtt.tTS2DateTime(cdaAllergyObs.getEffectiveTime().getLow())); - } else if (cdaAllergyObs.getEffectiveTime().getValue() != null - && !cdaAllergyObs.getEffectiveTime().getValue().isEmpty()) { - fhirAllergyIntolerance - .setOnset(dtt.tString2DateTime(cdaAllergyObs.getEffectiveTime().getValue())); - } - } - - // searching for reaction observation - if (cdaAllergyObs.getEntryRelationships() != null - && !cdaAllergyObs.getEntryRelationships().isEmpty()) { - for (EntryRelationship entryRelShip : cdaAllergyObs.getEntryRelationships()) { - if (entryRelShip != null && !entryRelShip.isSetNullFlavor()) { - if (entryRelShip.getObservation() != null && !entryRelShip.isSetNullFlavor()) { - Observation observation = entryRelShip.getObservation(); - - // status observation -> clinical status - if (observation != null && observation instanceof AllergyStatusObservation) { - observation.getValues().stream().filter(value -> value instanceof CE) - .map(value -> (CE) value).map(ce -> ce.getCode()).forEach(code -> { - AllergyIntoleranceClinicalStatus status = vst - .tProblemStatus2AllergyIntoleranceClinicalStatus(code); - fhirAllergyIntolerance.setClinicalStatus(status); - }); - } - - // reaction observation - if (entryRelShip.getObservation() instanceof ReactionObservation) { - - ReactionObservation cdaReactionObs = (ReactionObservation) entryRelShip - .getObservation(); - AllergyIntoleranceReactionComponent fhirReaction = fhirAllergyIntolerance - .addReaction(); - - // reactionObservation/value[@xsi:type='CD'] -> reaction.manifestation - if (cdaReactionObs.getValues() != null - && !cdaReactionObs.getValues().isEmpty()) { - for (ANY value : cdaReactionObs.getValues()) { - if (value instanceof CD) { - fhirReaction.addManifestation(dtt.tCD2CodeableConcept((CD) value, - bundleInfo.getIdedAnnotations())); - } - } - } - // reactionObservation/low -> reaction.onset - if (cdaReactionObs.getEffectiveTime() != null - && !cdaReactionObs.getEffectiveTime().isSetNullFlavor()) { - if (cdaReactionObs.getEffectiveTime().getLow() != null - && !cdaReactionObs.getEffectiveTime().getLow().isSetNullFlavor()) { - fhirReaction.setOnsetElement(dtt.tString2DateTime( - cdaReactionObs.getEffectiveTime().getLow().getValue())); - } - } - - // severityObservation/value[@xsi:type='CD'].code -> severity - if (cdaReactionObs.getSeverityObservation() != null - && !cdaReactionObs.getSeverityObservation().isSetNullFlavor()) { - SeverityObservation cdaSeverityObs = cdaReactionObs - .getSeverityObservation(); - if (cdaSeverityObs.getValues() != null - && !cdaSeverityObs.getValues().isEmpty()) { - for (ANY value : cdaSeverityObs.getValues()) { - if (value != null && !value.isSetNullFlavor()) { - if (value instanceof CD) { - if (vst.tSeverityCode2AllergyIntoleranceSeverity( - ((CD) value).getCode()) != null) { - fhirReaction.setSeverity( - vst.tSeverityCode2AllergyIntoleranceSeverity( - ((CD) value).getCode())); - } - } - } - } - } - } - } - - // criticality observation. found by checking the templateId - // entryRelationship.observation[templateId/@root='2.16.840.1.113883.10.20.22.4.145'].value[CD].code - // -> criticality - if (entryRelShip.getObservation().getTemplateIds() != null - && !entryRelShip.getObservation().getTemplateIds().isEmpty()) { - for (II templateId : entryRelShip.getObservation().getTemplateIds()) { - if (templateId.getRoot() != null && templateId.getRoot() - .equals("2.16.840.1.113883.10.20.22.4.145")) { - org.openhealthtools.mdht.uml.cda.Observation cdaCriticalityObservation = entryRelShip - .getObservation(); - for (ANY value : cdaCriticalityObservation.getValues()) { - if (value != null && !value.isSetNullFlavor()) { - if (value instanceof CD) { - AllergyIntoleranceCriticality allergyIntoleranceCriticalityEnum = vst - .tCriticalityObservationValue2AllergyIntoleranceCriticality( - ((CD) value).getCode()); - if (allergyIntoleranceCriticalityEnum != null) { - fhirAllergyIntolerance.setCriticality( - allergyIntoleranceCriticalityEnum); - } - } - } - } - // since we already found the desired templateId, we may break the - // searching for templateId to avoid containing duplicate observations - break; - } - } - } - } - } - } - } - } - } - } - - // if clinical status is unset, set it to default. - if (!fhirAllergyIntolerance.hasClinicalStatus()) { - fhirAllergyIntolerance.setClinicalStatus(Config.DEFAULT_ALLERGY_CLINICAL_STATUS); - } - - return result; - } - - @Override - public EntityResult tAssignedAuthor2Device(AssignedAuthor cdaAssignedAuthor, IBundleInfo bundleInfo) { - if (cdaAssignedAuthor == null || cdaAssignedAuthor.isSetNullFlavor()) { - return new EntityResult(); - } - - List ids = null; - if (cdaAssignedAuthor.getIds() != null && !cdaAssignedAuthor.getIds().isEmpty()) { - for (II ii : cdaAssignedAuthor.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - if (ids == null) { - ids = new ArrayList(); - } - ids.add(ii); - } - } - } - - if (ids != null) { - IEntityInfo existingInfo = bundleInfo.findEntityResult(ids); - if (existingInfo != null) { - return new EntityResult(existingInfo); - } - } - - EntityInfo info = new EntityInfo(); - Device fhirDevice = new Device(); - - // id -> identifier - if (ids != null) { - for (II id : ids) { - fhirDevice.addIdentifier(dtt.tII2Identifier(id)); - } - } - EntityResult result = new EntityResult(info, ids); - // resource id - IdType resourceDeviceId = new IdType("Device", getUniqueId()); - fhirDevice.setId(resourceDeviceId); - - // All things with the Device. - if (cdaAssignedAuthor.getAssignedAuthoringDevice() != null - && !cdaAssignedAuthor.getAssignedAuthoringDevice().isSetNullFlavor()) { - fhirDevice.setManufacturer( - cdaAssignedAuthor.getAssignedAuthoringDevice().getManufacturerModelName().getText()); - fhirDevice.setVersion(cdaAssignedAuthor.getAssignedAuthoringDevice().getSoftwareName().getText()); - if (cdaAssignedAuthor.getAssignedAuthoringDevice().getCode() != null) { - fhirDevice.setType(dtt.tCD2CodeableConcept(cdaAssignedAuthor.getAssignedAuthoringDevice().getCode())); - } else { - Coding cd1 = new Coding(); - cd1.setCode(cdaAssignedAuthor.getAssignedAuthoringDevice().getManufacturerModelName().getCode()); - if (cdaAssignedAuthor.getAssignedAuthoringDevice().getManufacturerModelName() - .getDisplayName() == null) { - cd1.setDisplay(cdaAssignedAuthor.getAssignedAuthoringDevice().getManufacturerModelName().getText()); - } else { - cd1.setDisplay( - cdaAssignedAuthor.getAssignedAuthoringDevice().getManufacturerModelName().getDisplayName()); - } - cd1.setSystem( - cdaAssignedAuthor.getAssignedAuthoringDevice().getManufacturerModelName().getCodeSystem()); - fhirDevice.setType(new CodeableConcept().addCoding(cd1)); - } - - } - - info.setDevice(fhirDevice); - - // representedOrganization -> EntityInfo.organization - if (cdaAssignedAuthor.getRepresentedOrganization() != null - && !cdaAssignedAuthor.getRepresentedOrganization().isSetNullFlavor()) { - IEntryResult orgResult = tOrganization2Organization(cdaAssignedAuthor.getRepresentedOrganization(), - bundleInfo); - - org.hl7.fhir.dstu3.model.Organization org = (Organization) orgResult - .findResourceResult(org.hl7.fhir.dstu3.model.Organization.class); - - if (orgResult.hasResult()) { - info.setOrgIsNew(true); - } - - result.updateFrom(orgResult); - - if (org != null) { - info.setOrganization(org); - fhirDevice.setOwner(new Reference(org.getId())); - } - - } - - return result; - } - - @Override - public EntityResult tAssignedAuthor2Practitioner(AssignedAuthor cdaAssignedAuthor, IBundleInfo bundleInfo) { - - if (cdaAssignedAuthor == null || cdaAssignedAuthor.isSetNullFlavor()) { - return new EntityResult(); - } - - List ids = null; - if (cdaAssignedAuthor.getIds() != null && !cdaAssignedAuthor.getIds().isEmpty()) { - for (II ii : cdaAssignedAuthor.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - if (ids == null) { - ids = new ArrayList(); - } - ids.add(ii); - } - } - } - - if (ids != null) { - IEntityInfo existingInfo = bundleInfo.findEntityResult(ids); - if (existingInfo != null) { - return new EntityResult(existingInfo); - } - } - - EntityInfo info = new EntityInfo(); - - EntityResult result = new EntityResult(info, ids); - - Practitioner fhirPractitioner = new Practitioner(); - info.setPractitioner(fhirPractitioner); - - // resource id - IdType resourceId = new IdType("Practitioner", getUniqueId()); - fhirPractitioner.setId(resourceId); - - // id -> identifier - if (ids != null) { - for (II id : ids) { - fhirPractitioner.addIdentifier(dtt.tII2Identifier(id)); - } - } - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirPractitioner.getMeta().addProfile(Constants.PROFILE_DAF_PRACTITIONER); - - // assignedPerson.name -> name - if (cdaAssignedAuthor.getAssignedPerson() != null && !cdaAssignedAuthor.getAssignedPerson().isSetNullFlavor()) { - if (cdaAssignedAuthor.getAssignedPerson().getNames() != null - && !cdaAssignedAuthor.getAssignedPerson().getNames().isEmpty()) { - for (PN pn : cdaAssignedAuthor.getAssignedPerson().getNames()) { - if (pn != null && !pn.isSetNullFlavor()) { - fhirPractitioner.addName(dtt.tEN2HumanName(pn)); - } - } - } - } - - // addr -> address - if (cdaAssignedAuthor.getAddrs() != null && !cdaAssignedAuthor.getAddrs().isEmpty()) { - for (AD ad : cdaAssignedAuthor.getAddrs()) { - if (ad != null && !ad.isSetNullFlavor()) { - fhirPractitioner.addAddress(dtt.AD2Address(ad)); - } - } - } - - // telecom -> telecom - if (cdaAssignedAuthor.getTelecoms() != null && !cdaAssignedAuthor.getTelecoms().isEmpty()) { - for (TEL tel : cdaAssignedAuthor.getTelecoms()) { - if (tel != null && !tel.isSetNullFlavor()) { - fhirPractitioner.addTelecom(dtt.tTEL2ContactPoint(tel)); - } - } - } - - // Adding a practitionerRole - // Practitioner.PractitionerRole fhirPractitionerRole = - // fhirPractitioner.addPractitionerRole(); - PractitionerRole fhirPractitionerRole = new PractitionerRole(); - fhirPractitionerRole.setId(new IdType("PractitionerRole", getUniqueId())); - - // code -> practitionerRole.role - if (cdaAssignedAuthor.getCode() != null && !cdaAssignedAuthor.isSetNullFlavor()) { - // fhirPractitionerRole.setRole(dtt.tCD2CodeableConcept(cdaAssignedAuthor.getCode())); - fhirPractitionerRole.addCode(dtt.tCD2CodeableConcept(cdaAssignedAuthor.getCode())); - } - - // representedOrganization -> practitionerRole.managingOrganization - if (cdaAssignedAuthor.getRepresentedOrganization() != null - && !cdaAssignedAuthor.getRepresentedOrganization().isSetNullFlavor()) { - - IEntryResult orgResult = tOrganization2Organization(cdaAssignedAuthor.getRepresentedOrganization(), - bundleInfo); - - org.hl7.fhir.dstu3.model.Organization fhirOrganization = (Organization) orgResult - .findResourceResult(org.hl7.fhir.dstu3.model.Organization.class); - - if (orgResult.hasResult()) { - info.setOrgIsNew(true); - } - result.updateFrom(orgResult); - - if (fhirOrganization != null) { - fhirPractitionerRole.setOrganization(getReference(fhirOrganization)); - // allows us to resolve the identifiers when making the ifNoneExist parameters. - fhirPractitionerRole.setOrganizationTarget(fhirOrganization); - info.setOrganization(fhirOrganization); - fhirPractitionerRole.setPractitioner(getReference(fhirPractitioner)); - info.setPractitionerRole(fhirPractitionerRole); - } - - } - - return result; - } - - @Override - public EntityResult tAssignedEntity2Practitioner(AssignedEntity cdaAssignedEntity, IBundleInfo bundleInfo) { - if (cdaAssignedEntity == null || cdaAssignedEntity.isSetNullFlavor()) { - return new EntityResult(); - } - - List ids = null; - if (cdaAssignedEntity.getIds() != null && !cdaAssignedEntity.getIds().isEmpty()) { - for (II ii : cdaAssignedEntity.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - if (ids == null) { - ids = new ArrayList(); - } - ids.add(ii); - } - } - } - - if (ids != null) { - IEntityInfo existingInfo = bundleInfo.findEntityResult(ids); - if (existingInfo != null) { - return new EntityResult(existingInfo); - } - } - - EntityInfo info = new EntityInfo(); - - EntityResult result = new EntityResult(info, ids); - - Practitioner fhirPractitioner = new Practitioner(); - info.setPractitioner(fhirPractitioner); - - // resource id - IdType resourceId = new IdType("Practitioner", getUniqueId()); - fhirPractitioner.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirPractitioner.getMeta().addProfile(Constants.PROFILE_DAF_PRACTITIONER); - - // id -> identifier - if (ids != null) { - for (II id : ids) { - fhirPractitioner.addIdentifier(dtt.tII2Identifier(id)); - } - } - - // assignedPerson.name -> name - if (cdaAssignedEntity.getAssignedPerson() != null && !cdaAssignedEntity.getAssignedPerson().isSetNullFlavor()) { - for (PN pn : cdaAssignedEntity.getAssignedPerson().getNames()) { - if (pn != null && !pn.isSetNullFlavor()) { - fhirPractitioner.addName(dtt.tEN2HumanName(pn)); - } - } - } - - // addr -> address - if (cdaAssignedEntity.getAddrs() != null && !cdaAssignedEntity.getAddrs().isEmpty()) { - for (AD ad : cdaAssignedEntity.getAddrs()) { - if (ad != null && !ad.isSetNullFlavor()) { - fhirPractitioner.addAddress(dtt.AD2Address(ad)); - } - } - } - - // telecom -> telecom - if (cdaAssignedEntity.getTelecoms() != null && !cdaAssignedEntity.getTelecoms().isEmpty()) { - for (TEL tel : cdaAssignedEntity.getTelecoms()) { - if (tel != null && !tel.isSetNullFlavor()) { - fhirPractitioner.addTelecom(dtt.tTEL2ContactPoint(tel)); - } - } - } - - // Practitioner.PractitionerRole fhirPractitionerRole = - // fhirPractitioner.addPractitionerRole(); - PractitionerRole fhirPractitionerRole = new PractitionerRole(); - fhirPractitionerRole.setId(new IdType("PractitionerRole", getUniqueId())); - - // code -> practitionerRole.role - if (cdaAssignedEntity.getCode() != null && !cdaAssignedEntity.isSetNullFlavor()) { - // fhirPractitionerRole.setRole(dtt.tCD2CodeableConcept(cdaAssignedEntity.getCode())); - fhirPractitionerRole.addCode(dtt.tCD2CodeableConcept(cdaAssignedEntity.getCode())); - } - - // representedOrganization -> practitionerRole.organization - // NOTE: we skipped multiple instances of represented organization; we just omit - // apart from the first - if (!cdaAssignedEntity.getRepresentedOrganizations().isEmpty()) { - if (cdaAssignedEntity.getRepresentedOrganizations().get(0) != null - && !cdaAssignedEntity.getRepresentedOrganizations().get(0).isSetNullFlavor()) { - - IEntryResult orgResult = tOrganization2Organization( - cdaAssignedEntity.getRepresentedOrganizations().get(0), bundleInfo); - - org.hl7.fhir.dstu3.model.Organization fhirOrganization = (Organization) orgResult - .findResourceResult(org.hl7.fhir.dstu3.model.Organization.class); - - if (orgResult.hasResult()) { - info.setOrgIsNew(true); - } - - result.updateFrom(orgResult); - - if (fhirOrganization != null) { - - fhirPractitionerRole.setOrganization(getReference(fhirOrganization)); - fhirPractitionerRole.setPractitioner(getReference(fhirPractitioner)); - info.setPractitionerRole(fhirPractitionerRole); - info.setOrganization(fhirOrganization); - - } - - } - } - - return result; - } - - @Override - public EntityResult tAuthor2Practitioner(org.openhealthtools.mdht.uml.cda.Author cdaAuthor, - IBundleInfo bundleInfo) { - if (cdaAuthor == null || cdaAuthor.isSetNullFlavor()) { - return new EntityResult(); - } - - if (cdaAuthor.getAssignedAuthor() == null || cdaAuthor.getAssignedAuthor().isSetNullFlavor()) { - return new EntityResult(); - } - - return tAssignedAuthor2Practitioner(cdaAuthor.getAssignedAuthor(), bundleInfo); - } - - @Override - public Substance tCD2Substance(CD cdaSubstanceCode) { - if (cdaSubstanceCode == null || cdaSubstanceCode.isSetNullFlavor()) - return null; - - Substance fhirSubstance = new Substance(); - - // resource id - fhirSubstance.setId(new IdType("Substance", getUniqueId())); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirSubstance.getMeta().addProfile(Constants.PROFILE_DAF_SUBSTANCE); - - // code -> code - fhirSubstance.setCode(dtt.tCD2CodeableConcept(cdaSubstanceCode)); - - return fhirSubstance; - } - - @Override - public EntryResult tClinicalDocument2Composition(ClinicalDocument cdaClinicalDocument) { - return tClinicalDocument2Bundle(cdaClinicalDocument, true); - } - - @Override - public EntryResult tClinicalDocument2Bundle(ClinicalDocument cdaClinicalDocument, boolean includeComposition) { - EntryResult result = new EntryResult(); - - if (cdaClinicalDocument == null || cdaClinicalDocument.isSetNullFlavor()) { - return result; - } - - // create and init the global bundle and the composition resources - Composition fhirComp = includeComposition ? new Composition() : null; - - if (fhirComp != null) { - fhirComp.setId(new IdType("Composition", getUniqueId())); - result.addResource(fhirComp); - - CodeableConcept classConcept = new CodeableConcept(); - Coding classCoding = new Coding("http://hl7.org/fhir/ValueSet/doc-classcodes", "LP173421-7", "Note"); - classConcept.addCoding(classCoding); - fhirComp.setClass_(classConcept); - - // id -> identifier - if (cdaClinicalDocument.getId() != null && !cdaClinicalDocument.getId().isSetNullFlavor()) { - fhirComp.setIdentifier(dtt.tII2Identifier(cdaClinicalDocument.getId())); - } - - // status - fhirComp.setStatus(Config.DEFAULT_COMPOSITION_STATUS); - - // effectiveTime -> date - if (cdaClinicalDocument.getEffectiveTime() != null - && !cdaClinicalDocument.getEffectiveTime().isSetNullFlavor()) { - fhirComp.setDateElement(dtt.tTS2DateTime(cdaClinicalDocument.getEffectiveTime())); - } - - // code -> type - if (cdaClinicalDocument.getCode() != null && !cdaClinicalDocument.getCode().isSetNullFlavor()) { - fhirComp.setType(dtt.tCD2CodeableConcept(cdaClinicalDocument.getCode())); - } - - // title.text -> title - if (cdaClinicalDocument.getTitle() != null && !cdaClinicalDocument.getTitle().isSetNullFlavor()) { - if (cdaClinicalDocument.getTitle().getText() != null - && !cdaClinicalDocument.getTitle().getText().isEmpty()) { - fhirComp.setTitle(cdaClinicalDocument.getTitle().getText()); - } - } - - // confidentialityCode -> confidentiality - if (cdaClinicalDocument.getConfidentialityCode() != null - && !cdaClinicalDocument.getConfidentialityCode().isSetNullFlavor()) { - if (cdaClinicalDocument.getConfidentialityCode().getCode() != null - && !cdaClinicalDocument.getConfidentialityCode().getCode().isEmpty()) { - // fhirComp.setConfidentiality(cdaClinicalDocument.getConfidentialityCode().getCode()); - try { - fhirComp.setConfidentiality(DocumentConfidentiality - .fromCode(cdaClinicalDocument.getConfidentialityCode().getCode())); - } catch (FHIRException e) { - throw new IllegalArgumentException(e); - } - } - } - } - - BundleInfo bundleInfo = new BundleInfo(this); - - EList recordTargets = cdaClinicalDocument.getRecordTargets(); - if (recordTargets != null && !recordTargets.isEmpty()) { // Support empty for testing purposes. We might need a - // flag here not to include patient in the bundle as - // well in future - // transform the patient data and assign it to Composition.subject. - // patient might refer to additional resources such as organization; hence the - // method returns a bundle. - IEntryResult patientResult = tPatientRole2Patient( - cdaClinicalDocument.getRecordTargets().get(0).getPatientRole(), bundleInfo); - - result.updateFrom(patientResult); - bundleInfo.updateFrom(patientResult); - - Patient fhirPatient = (Patient) patientResult.findResourceResult(Patient.class); - - if (fhirPatient != null) { - fhirComp.setSubject(getReference(fhirPatient)); - } - - } - - // author.assignedAuthor -> author - if (cdaClinicalDocument.getAuthors() != null && !cdaClinicalDocument.getAuthors().isEmpty()) { - for (Author author : cdaClinicalDocument.getAuthors()) { - // Asserting that at most one author exists - if (author != null && !author.isSetNullFlavor()) { - if (author.getAssignedAuthor() != null && !author.getAssignedAuthor().isSetNullFlavor()) { - if (author.getAssignedAuthor().getAssignedPerson() != null - && !author.getAssignedAuthor().getAssignedPerson().isSetNullFlavor()) { - EntityResult entityResult = tAuthor2Practitioner(author, bundleInfo); - result.updateFrom(entityResult); - bundleInfo.updateFrom(entityResult); - if (fhirComp != null && entityResult.hasPractitioner()) { - fhirComp.addAuthor().setReference(entityResult.getPractitionerId()); - String referenceString = ReferenceInfo.getDisplay(entityResult.getPractitioner()); - if (referenceString != null) { - fhirComp.getAuthor().get(0).setDisplay(referenceString); - } - } - } else if (author.getAssignedAuthor().getAssignedAuthoringDevice() != null - && author.getAssignedAuthor().getRepresentedOrganization() != null - && !author.getAssignedAuthor().getRepresentedOrganization().isSetNullFlavor() - && !author.getAssignedAuthor().getAssignedAuthoringDevice().isSetNullFlavor()) { - EntityResult entityResult = tAssignedAuthor2Device(author.getAssignedAuthor(), bundleInfo); - result.updateFrom(entityResult); - bundleInfo.updateFrom(entityResult); - result.addResource(entityResult.getDevice()); // Device added separately because updateFrom - // ignores it. - if (fhirComp != null && entityResult.hasDevice() && entityResult.hasOrganization()) { - fhirComp.getAuthor().add(new Reference(entityResult.getDeviceId())); - } - } - } - } - } - } - - // legalAuthenticator -> attester[mode = legal] - if (cdaClinicalDocument.getLegalAuthenticator() != null - && !cdaClinicalDocument.getLegalAuthenticator().isSetNullFlavor()) { - CompositionAttesterComponent attester = fhirComp != null ? fhirComp.addAttester() : null; - if (attester != null) { - attester.addMode(CompositionAttestationMode.LEGAL); - attester.setTimeElement(dtt.tTS2DateTime(cdaClinicalDocument.getLegalAuthenticator().getTime())); - } - EntityResult entityResult = tAssignedEntity2Practitioner( - cdaClinicalDocument.getLegalAuthenticator().getAssignedEntity(), bundleInfo); - result.updateFrom(entityResult); - bundleInfo.updateFrom(entityResult); - Reference reference = getReference(entityResult.getPractitioner()); - if (attester != null && reference != null) { - attester.setParty(reference); - } - } - - // authenticator -> attester[mode = professional] - for (org.openhealthtools.mdht.uml.cda.Authenticator authenticator : cdaClinicalDocument.getAuthenticators()) { - if (!authenticator.isSetNullFlavor()) { - CompositionAttesterComponent attester = fhirComp != null ? fhirComp.addAttester() : null; - if (attester != null) { - attester.addMode(CompositionAttestationMode.PROFESSIONAL); - attester.setTimeElement(dtt.tTS2DateTime(authenticator.getTime())); - } - EntityResult entityResult = tAssignedEntity2Practitioner(authenticator.getAssignedEntity(), bundleInfo); - result.updateFrom(entityResult); - bundleInfo.updateFrom(entityResult); - Reference reference = getReference(entityResult.getPractitioner()); - if (attester != null && reference != null) { - attester.setParty(reference); - } - } - } - - for (DocumentationOf docOf : cdaClinicalDocument.getDocumentationOfs()) { - if (docOf.getServiceEvent() != null && fhirComp != null) { - ServiceEvent cdaServiceEvent = docOf.getServiceEvent(); - CompositionEventComponent event = new CompositionEventComponent(); - - fhirComp.addEvent(event); - // documentationOf.serviceEvent.effectiveTime => event.period - if (cdaServiceEvent.getEffectiveTime() != null) { - Period period = dtt.tIVL_TS2Period(cdaServiceEvent.getEffectiveTime()); - event.setPeriod(period); - } - - // documentationOf.serviceEvent.assignedEntity -> composition.event.detail - if (cdaServiceEvent.getPerformers() != null && !cdaServiceEvent.getPerformers().isEmpty()) { - for (Performer1 performer : cdaServiceEvent.getPerformers()) { - if (performer.getAssignedEntity() != null) { - EntityResult entityResult = tPerformer12Practitioner(performer, bundleInfo); - if (entityResult.hasPractitioner()) { - - result.updateFrom(entityResult); - Reference reference = getReference(entityResult.getPractitioner()); - event.addDetail(reference); - } - } - - } - } - } - } - // custodian.assignedCustodian.representedCustodianOrganization -> custodian - if (cdaClinicalDocument.getCustodian() != null && !cdaClinicalDocument.getCustodian().isSetNullFlavor()) { - if (cdaClinicalDocument.getCustodian().getAssignedCustodian() != null - && !cdaClinicalDocument.getCustodian().getAssignedCustodian().isSetNullFlavor()) { - if (cdaClinicalDocument.getCustodian().getAssignedCustodian() - .getRepresentedCustodianOrganization() != null - && !cdaClinicalDocument.getCustodian().getAssignedCustodian() - .getRepresentedCustodianOrganization().isSetNullFlavor()) { - IEntryResult orgResult = tCustodianOrganization2Organization(cdaClinicalDocument.getCustodian() - .getAssignedCustodian().getRepresentedCustodianOrganization(), bundleInfo); - result.updateFrom(orgResult); - bundleInfo.updateFrom(orgResult); - - if (fhirComp != null) { - org.hl7.fhir.dstu3.model.Organization fhirOrganization = (Organization) orgResult - .findResourceResult(org.hl7.fhir.dstu3.model.Organization.class); - - if (fhirOrganization != null) { - fhirComp.setCustodian(getReference(fhirOrganization)); - } - } - - } - } - } - - return result; - } - - @Override - public IEntryResult tCustodianOrganization2Organization( - org.openhealthtools.mdht.uml.cda.CustodianOrganization cdaOrganization, IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaOrganization == null || cdaOrganization.isSetNullFlavor()) - return result; - - org.hl7.fhir.dstu3.model.Organization fhirOrganization = new org.hl7.fhir.dstu3.model.Organization(); - - // resource id - IdType resourceId = new IdType("Organization", getUniqueId()); - fhirOrganization.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirOrganization.getMeta().addProfile(Constants.PROFILE_DAF_ORGANIZATION); - - // id -> identifier - if (cdaOrganization.getIds() != null && !cdaOrganization.getIds().isEmpty()) { - - org.hl7.fhir.dstu3.model.Organization previousOrganization = (Organization) bundleInfo - .findResourceResult(cdaOrganization.getIds(), org.hl7.fhir.dstu3.model.Organization.class); - - if (previousOrganization != null) { - result.addExistingResource(previousOrganization); - return result; - } else { - result.putIIResource(cdaOrganization.getIds(), org.hl7.fhir.dstu3.model.Organization.class, - fhirOrganization); - - } - - for (II ii : cdaOrganization.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - fhirOrganization.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - result.addResource(fhirOrganization); - - // name.text -> name - if (cdaOrganization.getName() != null && !cdaOrganization.getName().isSetNullFlavor()) { - fhirOrganization.setName(cdaOrganization.getName().getText()); - } - - // telecom -> telecom - if (cdaOrganization.getTelecoms() != null && !cdaOrganization.getTelecoms().isEmpty()) { - for (TEL tel : cdaOrganization.getTelecoms()) { - if (tel != null && !tel.isSetNullFlavor()) { - fhirOrganization.addTelecom(dtt.tTEL2ContactPoint(tel)); - } - } - } - - // addr -> address - if (cdaOrganization.getAddrs() != null && !cdaOrganization.getAddrs().isEmpty()) { - for (AD ad : cdaOrganization.getAddrs()) { - if (ad != null && !ad.isSetNullFlavor()) { - fhirOrganization.addAddress(dtt.AD2Address(ad)); - } - } - } - - return result; - } - - @Override - public EntryResult tEncounterActivity2Encounter( - org.openhealthtools.mdht.uml.cda.consol.EncounterActivities cdaEncounterActivity, IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaEncounterActivity == null || cdaEncounterActivity.isSetNullFlavor()) { - return result; - } - - org.hl7.fhir.dstu3.model.Encounter fhirEncounter = new org.hl7.fhir.dstu3.model.Encounter(); - result.addResource(fhirEncounter); - - // NOTE: hospitalization.period not found. However, daf requires it being mapped - - // resource id - IdType resourceId = new IdType("Encounter", getUniqueId()); - fhirEncounter.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirEncounter.getMeta().addProfile(Constants.PROFILE_DAF_ENCOUNTER); - - // subject - fhirEncounter.setSubject(getPatientRef()); - - // id -> identifier - if (cdaEncounterActivity.getIds() != null && !cdaEncounterActivity.getIds().isEmpty()) { - for (II id : cdaEncounterActivity.getIds()) { - if (id != null && !id.isSetNullFlavor()) { - fhirEncounter.addIdentifier(dtt.tII2Identifier(id)); - } - } - } - - // statusCode -> status - if (cdaEncounterActivity.getStatusCode() != null && !cdaEncounterActivity.getStatusCode().isSetNullFlavor()) { - if (vst.tStatusCode2EncounterStatusEnum(cdaEncounterActivity.getStatusCode().getCode()) != null) { - fhirEncounter - .setStatus(vst.tStatusCode2EncounterStatusEnum(cdaEncounterActivity.getStatusCode().getCode())); - } else { - fhirEncounter.setStatus(Config.DEFAULT_ENCOUNTER_STATUS); - } - } else { - fhirEncounter.setStatus(Config.DEFAULT_ENCOUNTER_STATUS); - } - - // code -> type - if (cdaEncounterActivity.getCode() != null) { - fhirEncounter - .addType(dtt.tCD2CodeableConcept(cdaEncounterActivity.getCode(), bundleInfo.getIdedAnnotations())); - } - - // code.translation -> classElement - if (cdaEncounterActivity.getCode() != null && !cdaEncounterActivity.getCode().isSetNullFlavor()) { - if (cdaEncounterActivity.getCode().getTranslations() != null - && !cdaEncounterActivity.getCode().getTranslations().isEmpty()) { - for (CD cd : cdaEncounterActivity.getCode().getTranslations()) { - if (cd != null && !cd.isSetNullFlavor()) { - Coding encounterClass = vst.tEncounterCode2EncounterCode(cd.getCode()); - if (encounterClass != null) { - fhirEncounter.setClass_(encounterClass); - } - } - } - } - } - - // priorityCode -> priority - if (cdaEncounterActivity.getPriorityCode() != null - && !cdaEncounterActivity.getPriorityCode().isSetNullFlavor()) { - fhirEncounter.setPriority(dtt.tCD2CodeableConcept(cdaEncounterActivity.getPriorityCode())); - } - - // performer -> participant.individual - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - if (cdaEncounterActivity.getPerformers() != null && !cdaEncounterActivity.getPerformers().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Performer2 cdaPerformer : cdaEncounterActivity.getPerformers()) { - if (cdaPerformer != null && !cdaPerformer.isSetNullFlavor()) { - EntityResult entityResult = tPerformer22Practitioner(cdaPerformer, localBundleInfo); - result.updateFrom(entityResult); - localBundleInfo.updateFrom(result); - if (entityResult.hasPractitioner()) { - EncounterParticipantComponent fhirParticipant = new EncounterParticipantComponent(); - // default encounter participant type code - fhirParticipant.addType().addCoding(Config.DEFAULT_ENCOUNTER_PARTICIPANT_TYPE_CODE); - fhirParticipant.setIndividual(getReference(entityResult.getPractitioner())); - fhirEncounter.addParticipant(fhirParticipant); - } - } - } - } - - // effectiveTime -> period - if (cdaEncounterActivity.getEffectiveTime() != null - && !cdaEncounterActivity.getEffectiveTime().isSetNullFlavor()) { - fhirEncounter.setPeriod(dtt.tIVL_TS2Period(cdaEncounterActivity.getEffectiveTime())); - } - - // indication -> diagnosis.condition - for (Indication cdaIndication : cdaEncounterActivity.getIndications()) { - if (!cdaIndication.isSetNullFlavor()) { - IEntryResult condResult = tIndication2ConditionEncounter(cdaIndication, bundleInfo); - - result.updateFrom(condResult); - - Condition fhirCondition = (Condition) condResult.findResourceResult(Condition.class); - - if (fhirCondition != null) { - // TODO: check if this is correct mapping - // Reference indicationRef = fhirEncounter.addIndication(); - // indicationRef.setReference(fhirIndication.getId()); - fhirEncounter.addDiagnosis().setCondition(getReference(fhirCondition)); - } - - } - } - - // serviceDeliveryLocation -> location.location - // Although encounter contains serviceDeliveryLocation, - // getServiceDeliveryLocation method returns empty list - // Therefore, get the location information from - // participant[@typeCode='LOC'].participantRole -// if(cdaEncounterActivity.getServiceDeliveryLocations() != null && !cdaEncounterActivity.getServiceDeliveryLocations().isEmpty()) { -// for(ServiceDeliveryLocation SDLOC : cdaEncounterActivity.getServiceDeliveryLocations()) { -// if(SDLOC != null && !SDLOC.isSetNullFlavor()) { -// org.hl7.fhir.dstu3.model.Location fhirLocation = tServiceDeliveryLocation2Location(SDLOC); -// fhirEncounterBundle.addEntry(new BundleEntryComponent().setResource(fhirLocation)); -// fhirEncounter.addLocation().setLocation(new Reference(fhirLocation.getId())); -// } -// } -// } - - // participant[@typeCode='LOC'].participantRole[SDLOC] -> location - if (cdaEncounterActivity.getParticipants() != null && !cdaEncounterActivity.getParticipants().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Participant2 cdaParticipant : cdaEncounterActivity - .getParticipants()) { - if (cdaParticipant != null && !cdaParticipant.isSetNullFlavor()) { - - // checking if the participant is location - if (cdaParticipant.getTypeCode() == ParticipationType.LOC) { - if (cdaParticipant.getParticipantRole() != null - && !cdaParticipant.getParticipantRole().isSetNullFlavor()) { - if (cdaParticipant.getParticipantRole().getClassCode() != null - && cdaParticipant.getParticipantRole().getClassCode() == RoleClassRoot.SDLOC) { - // We first make the mapping to a resource.location - // then, we create a resource.encounter.location - // then, we add the resource.location to resource.encounter.location - - // usage of ParticipantRole2Location - org.hl7.fhir.dstu3.model.Location fhirLocation = tParticipantRole2Location( - cdaParticipant.getParticipantRole()); - result.addResource(fhirLocation); - fhirEncounter.addLocation().setLocation(getReference(fhirLocation)); - } - } - } - } - } - } - - return result; - } - - @Override - public Group tEntity2Group(Entity cdaEntity) { - // never used - if (cdaEntity == null || cdaEntity.isSetNullFlavor()) - return null; - else if (cdaEntity.getDeterminerCode() != org.openhealthtools.mdht.uml.hl7.vocab.EntityDeterminer.KIND) - return null; - - Group fhirGroup = new Group(); - - // id -> identifier - if (cdaEntity.getIds() != null && !cdaEntity.getIds().isEmpty()) { - for (II id : cdaEntity.getIds()) { - if (id != null && !id.isSetNullFlavor()) { - if (id.getDisplayable()) { - // unique - fhirGroup.addIdentifier(dtt.tII2Identifier(id)); - } - } - } - } - - // classCode -> type - if (cdaEntity.getClassCode() != null) { - GroupType groupTypeEnum = vst.tEntityClassRoot2GroupType(cdaEntity.getClassCode()); - if (groupTypeEnum != null) { - fhirGroup.setType(groupTypeEnum); - } - - } - - // deteminerCode -> actual - if (cdaEntity.isSetDeterminerCode() && cdaEntity.getDeterminerCode() != null) { - if (cdaEntity.getDeterminerCode() == EntityDeterminer.KIND) { - fhirGroup.setActual(false); - } else { - fhirGroup.setActual(true); - } - } - - // code -> code - if (cdaEntity.getCode() != null && !cdaEntity.getCode().isSetNullFlavor()) { - fhirGroup.setCode(dtt.tCD2CodeableConcept(cdaEntity.getCode())); - } - - return fhirGroup; - } - - @Override - public FamilyMemberHistory tFamilyHistoryOrganizer2FamilyMemberHistory(FamilyHistoryOrganizer cdaFHO) { - if (cdaFHO == null || cdaFHO.isSetNullFlavor()) - return null; - - FamilyMemberHistory fhirFMH = new FamilyMemberHistory(); - - // resource id - IdType resourceId = new IdType("FamilyMemberHistory", getUniqueId()); - fhirFMH.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirFMH.getMeta().addProfile(Constants.PROFILE_DAF_FAMILY_MEMBER_HISTORY); - - // patient - fhirFMH.setPatient(getPatientRef()); - - // id -> identifier - for (II id : cdaFHO.getIds()) { - if (id != null && !id.isSetNullFlavor()) { - fhirFMH.addIdentifier(dtt.tII2Identifier(id)); - } - } - - // statusCode -> status - if (cdaFHO.getStatusCode() != null && !cdaFHO.getStatusCode().isSetNullFlavor()) { - fhirFMH.setStatus( - vst.tFamilyHistoryOrganizerStatusCode2FamilyHistoryStatus(cdaFHO.getStatusCode().getCode())); - } - - // condition <-> familyHistoryObservation - // also, deceased value is set by looking at - // familyHistoryObservation.familyHistoryDeathObservation - if (cdaFHO.getFamilyHistoryObservations() != null && !cdaFHO.getFamilyHistoryObservations().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.consol.FamilyHistoryObservation familyHistoryObs : cdaFHO - .getFamilyHistoryObservations()) { - if (familyHistoryObs != null && !familyHistoryObs.isSetNullFlavor()) { - - // adding a new condition to fhirFMH - FamilyMemberHistoryConditionComponent condition = fhirFMH.addCondition(); - - // familyHistoryObservation.value[@xsi:type='CD'] -> code - for (ANY value : familyHistoryObs.getValues()) { - if (value != null && !value.isSetNullFlavor()) { - if (value instanceof CD) { - condition.setCode(dtt.tCD2CodeableConcept((CD) value)); - } - } - } - - // NOTE: An alternative is to use the relatedSubject/subject/sdtc:deceasedInd - // and relatedSubject/subject/sdtc:deceasedTime values - // deceased - if (familyHistoryObs.getFamilyHistoryDeathObservation() != null - && !familyHistoryObs.getFamilyHistoryDeathObservation().isSetNullFlavor()) { - // if deathObservation exists, set fmh.deceased true - fhirFMH.setDeceased(new BooleanType(true)); - - // familyHistoryDeathObservation.value[@xsi:type='CD'] -> condition.outcome - for (ANY value : familyHistoryObs.getFamilyHistoryDeathObservation().getValues()) { - if (value != null && !value.isSetNullFlavor()) { - if (value instanceof CD) { - condition.setOutcome(dtt.tCD2CodeableConcept((CD) value)); - } - } - } - } - - // familyHistoryObservation.ageObservation -> condition.onset - if (familyHistoryObs.getAgeObservation() != null - && !familyHistoryObs.getAgeObservation().isSetNullFlavor()) { - Age onset = tAgeObservation2Age(familyHistoryObs.getAgeObservation()); - if (onset != null) { - condition.setOnset(onset); - } - } - } - } - } - - // info from subject.relatedSubject - if (cdaFHO.getSubject() != null && !cdaFHO.isSetNullFlavor() && cdaFHO.getSubject().getRelatedSubject() != null - && !cdaFHO.getSubject().getRelatedSubject().isSetNullFlavor()) { - org.openhealthtools.mdht.uml.cda.RelatedSubject cdaRelatedSubject = cdaFHO.getSubject().getRelatedSubject(); - - // subject.relatedSubject.code -> relationship - if (cdaRelatedSubject.getCode() != null && !cdaRelatedSubject.getCode().isSetNullFlavor()) { - fhirFMH.setRelationship(dtt.tCD2CodeableConcept(cdaRelatedSubject.getCode())); - } - - // info from subject.relatedSubject.subject - if (cdaRelatedSubject.getSubject() != null && !cdaRelatedSubject.getSubject().isSetNullFlavor()) { - org.openhealthtools.mdht.uml.cda.SubjectPerson subjectPerson = cdaRelatedSubject.getSubject(); - - // subject.relatedSubject.subject.name.text -> name - for (EN en : subjectPerson.getNames()) { - if (en != null && !en.isSetNullFlavor()) { - if (en.getText() != null) { - fhirFMH.setName(en.getText()); - } - } - } - - // subject.relatedSubject.subject.administrativeGenderCode -> gender - if (subjectPerson.getAdministrativeGenderCode() != null - && !subjectPerson.getAdministrativeGenderCode().isSetNullFlavor() - && subjectPerson.getAdministrativeGenderCode().getCode() != null) { - fhirFMH.setGender(vst.tAdministrativeGenderCode2AdministrativeGender( - subjectPerson.getAdministrativeGenderCode().getCode())); - } - - // subject.relatedSubject.subject.birthTime -> born - if (subjectPerson.getBirthTime() != null && !subjectPerson.getBirthTime().isSetNullFlavor()) { - fhirFMH.setBorn(dtt.tTS2Date(subjectPerson.getBirthTime())); - } - } - } - - return fhirFMH; - } - - /* - * Functional Status Section contains: 1- Functional Status Observation 2- - * Self-Care Activites Both of them have single Observation which needs mapping. - * Therefore, the parameter for the following - * method(tFunctionalStatus2Observation) chosen to be generic(Observation) .. to - * cover the content of the section. Also, notice that the transformation of - * those Observations are different from the generic Observation transformation - */ - - @Override - public EntryResult tFunctionalStatus2Observation(org.openhealthtools.mdht.uml.cda.Observation cdaObservation, - IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaObservation == null || cdaObservation.isSetNullFlavor()) { - return result; - } - - org.hl7.fhir.dstu3.model.Observation fhirObs = new org.hl7.fhir.dstu3.model.Observation(); - result.addResource(fhirObs); - - // resource id - IdType resourceId = new IdType("Observation", getUniqueId()); - fhirObs.setId(resourceId); - - // subject - fhirObs.setSubject(getPatientRef()); - - // statusCode -> status - if (cdaObservation.getStatusCode() != null && !cdaObservation.getStatusCode().isSetNullFlavor()) { - if (cdaObservation.getStatusCode().getCode() != null - && !cdaObservation.getStatusCode().getCode().isEmpty()) { - fhirObs.setStatus( - vst.tObservationStatusCode2ObservationStatus(cdaObservation.getStatusCode().getCode())); - } - } - - // id -> identifier - if (cdaObservation.getIds() != null && !cdaObservation.getIds().isEmpty()) { - for (II ii : cdaObservation.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - fhirObs.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - - // code -> category - if (cdaObservation.getCode() != null && !cdaObservation.isSetNullFlavor()) { - fhirObs.addCategory(dtt.tCD2CodeableConcept(cdaObservation.getCode())); - } - - // value[@xsi:type='CD'] -> code - if (cdaObservation.getValues() != null && !cdaObservation.getValues().isEmpty()) { - for (ANY value : cdaObservation.getValues()) { - if (value != null && !value.isSetNullFlavor()) { - if (value instanceof CD) { - fhirObs.setCode(dtt.tCD2CodeableConcept((CD) value)); - } - } - } - } - - // author -> performer - if (cdaObservation.getAuthors() != null && !cdaObservation.getAuthors().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Author author : cdaObservation.getAuthors()) { - if (author != null && !author.isSetNullFlavor()) { - EntityResult entityResult = tAuthor2Practitioner(author, bundleInfo); - result.updateFrom(entityResult); - if (entityResult.hasPractitioner()) { - fhirObs.addPerformer().setReference(entityResult.getPractitionerId()); - } - } - } - } - - // effectiveTime -> effective - if (cdaObservation.getEffectiveTime() != null && !cdaObservation.getEffectiveTime().isSetNullFlavor()) { - fhirObs.setEffective(dtt.tIVL_TS2Period(cdaObservation.getEffectiveTime())); - } - - // non-medicinal supply activity -> device - if (cdaObservation.getEntryRelationships() != null && !cdaObservation.getEntryRelationships().isEmpty()) { - for (EntryRelationship entryRelShip : cdaObservation.getEntryRelationships()) { - if (entryRelShip != null && !entryRelShip.isSetNullFlavor()) { - // supply - org.openhealthtools.mdht.uml.cda.Supply cdaSupply = entryRelShip.getSupply(); - if (cdaSupply != null && !cdaSupply.isSetNullFlavor()) { - if (cdaSupply instanceof NonMedicinalSupplyActivity) { - // Non-Medicinal Supply Activity - org.hl7.fhir.dstu3.model.Device fhirDev = tSupply2Device(cdaSupply); - fhirObs.setDevice(getReference(fhirDev)); - result.addResource(fhirDev); - } - } - } - } - } - - return result; - } - - @Override - public ContactComponent tGuardian2Contact(Guardian cdaGuardian) { - if (cdaGuardian == null || cdaGuardian.isSetNullFlavor()) - return null; - - ContactComponent fhirContact = new ContactComponent(); - - // addr -> address - if (cdaGuardian.getAddrs() != null && !cdaGuardian.getAddrs().isEmpty()) { - fhirContact.setAddress(dtt.AD2Address(cdaGuardian.getAddrs().get(0))); - } - - // telecom -> telecom - if (cdaGuardian.getTelecoms() != null && !cdaGuardian.getTelecoms().isEmpty()) { - for (TEL tel : cdaGuardian.getTelecoms()) { - if (tel != null && !tel.isSetNullFlavor()) { - fhirContact.addTelecom(dtt.tTEL2ContactPoint(tel)); - } - } - } - - // guardianPerson/name -> name - if (cdaGuardian.getGuardianPerson() != null && !cdaGuardian.getGuardianPerson().isSetNullFlavor()) { - for (PN pn : cdaGuardian.getGuardianPerson().getNames()) { - if (!pn.isSetNullFlavor()) { - fhirContact.setName(dtt.tEN2HumanName(pn)); - } - } - } - - // code -> relationship - if (cdaGuardian.getCode() != null && !cdaGuardian.getCode().isSetNullFlavor()) { - // try to use IValueSetsTransformer method - // tRoleCode2PatientContactRelationshipCode - Coding relationshipCoding = null; - if (cdaGuardian.getCode().getCode() != null && !cdaGuardian.getCode().getCode().isEmpty()) { - relationshipCoding = vst.tRoleCode2PatientContactRelationshipCode(cdaGuardian.getCode().getCode()); - } - // if tRoleCode2PatientContactRelationshipCode returns non-null value, add as - // coding - // otherwise, add relationship directly by making code - // transformation(tCD2CodeableConcept) - if (relationshipCoding != null) - fhirContact.addRelationship(new CodeableConcept().addCoding(relationshipCoding)); - else - fhirContact.addRelationship(dtt.tCD2CodeableConcept(cdaGuardian.getCode())); - } - return fhirContact; - } - - @Override - public EntryResult tImmunizationActivity2Immunization(ImmunizationActivity cdaImmunizationActivity, - IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - - if (cdaImmunizationActivity == null || cdaImmunizationActivity.isSetNullFlavor()) { - return result; - } - - Immunization fhirImmunization = new Immunization(); - result.addResource(fhirImmunization); - - // resource id - IdType resourceId = new IdType("Immunization", getUniqueId()); - fhirImmunization.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirImmunization.getMeta().addProfile(Constants.PROFILE_DAF_IMMUNIZATION); - - // patient - fhirImmunization.setPatient(getPatientRef()); - - // id -> identifier - if (cdaImmunizationActivity.getIds() != null && !cdaImmunizationActivity.getIds().isEmpty()) { - for (II ii : cdaImmunizationActivity.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - fhirImmunization.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - - // negationInd -> notGiven - if (cdaImmunizationActivity.getNegationInd() != null) { - fhirImmunization.setNotGiven(cdaImmunizationActivity.getNegationInd()); - } - - // effectiveTime -> date - if (cdaImmunizationActivity.getEffectiveTimes() != null - && !cdaImmunizationActivity.getEffectiveTimes().isEmpty()) { - for (SXCM_TS effectiveTime : cdaImmunizationActivity.getEffectiveTimes()) { - if (effectiveTime != null && !effectiveTime.isSetNullFlavor()) { - // Asserting that at most one effective time exists - fhirImmunization.setDateElement(dtt.tTS2DateTime(effectiveTime)); - } - } - } - - // lotNumber, vaccineCode, organization - - if (cdaImmunizationActivity.getConsumable() != null - && !cdaImmunizationActivity.getConsumable().isSetNullFlavor()) { - if (cdaImmunizationActivity.getConsumable().getManufacturedProduct() != null - && !cdaImmunizationActivity.getConsumable().getManufacturedProduct().isSetNullFlavor()) { - ManufacturedProduct manufacturedProduct = cdaImmunizationActivity.getConsumable() - .getManufacturedProduct(); - - if (manufacturedProduct.getManufacturedMaterial() != null - && !manufacturedProduct.getManufacturedMaterial().isSetNullFlavor()) { - Material manufacturedMaterial = manufacturedProduct.getManufacturedMaterial(); - - // consumable.manufacturedProduct.manufacturedMaterial.code -> vaccineCode - if (manufacturedProduct.getManufacturedMaterial().getCode() != null) { - fhirImmunization.setVaccineCode(dtt.tCD2CodeableConcept(manufacturedMaterial.getCode(), - bundleInfo.getIdedAnnotations())); - } - - // consumable.manufacturedProduct.manufacturedMaterial.lotNumberText -> - // lotNumber - if (manufacturedMaterial.getLotNumberText() != null - && !manufacturedMaterial.getLotNumberText().isSetNullFlavor()) { - fhirImmunization.setLotNumberElement(dtt.tST2String(manufacturedMaterial.getLotNumberText())); - } - } - - // consumable.manufacturedProduct.manufacturerOrganization -> manufacturer - if (manufacturedProduct.getManufacturerOrganization() != null - && !manufacturedProduct.getManufacturerOrganization().isSetNullFlavor()) { - - IEntryResult orgResult = tOrganization2Organization( - manufacturedProduct.getManufacturerOrganization(), localBundleInfo); - - result.updateFrom(orgResult); - localBundleInfo.updateFrom(orgResult); - if (orgResult.getFullBundle() != null) { - org.hl7.fhir.dstu3.model.Organization fhirOrganization = FHIRUtil.findFirstResource( - orgResult.getFullBundle(), org.hl7.fhir.dstu3.model.Organization.class); - if (fhirOrganization != null) { - fhirImmunization.setManufacturer(getReference(fhirOrganization)); - } - - } - - } - } - } - - // performer -> practitioner - if (cdaImmunizationActivity.getPerformers() != null && !cdaImmunizationActivity.getPerformers().isEmpty()) { - for (Performer2 performer : cdaImmunizationActivity.getPerformers()) { - if (performer.getAssignedEntity() != null && !performer.getAssignedEntity().isSetNullFlavor()) { - EntityResult entityResult = tPerformer22Practitioner(performer, localBundleInfo); - result.updateFrom(entityResult); - localBundleInfo.updateFrom(entityResult); - if (entityResult.hasPractitioner()) { - // TODO: verify the STU3 mappings - // TODO: find defined valueset/codesystem for immunization role - // fhirImmunization.setPerformer(new Reference(entry.getResource().getId())); - ImmunizationPractitionerComponent perf = fhirImmunization.addPractitioner(); - perf.getRole().addCoding().setSystem("http://hl7.org/fhir/v2/0443").setCode("AP") - .setDisplay("Administering Provider"); - perf.setActor(getReference(entityResult.getPractitioner())); - fhirImmunization.setPrimarySource(true); - } - } - } - } else { - // if no practitioner gets set, default to false. - fhirImmunization.setPrimarySource(false); - } - - // approachSiteCode -> site - for (CD cd : cdaImmunizationActivity.getApproachSiteCodes()) { - fhirImmunization.setSite(dtt.tCD2CodeableConcept(cd)); - } - - // routeCode -> route - if (cdaImmunizationActivity.getRouteCode() != null - && !cdaImmunizationActivity.getRouteCode().isSetNullFlavor()) { - fhirImmunization.setRoute(dtt.tCD2CodeableConcept(cdaImmunizationActivity.getRouteCode())); - } - - // doseQuantity -> doseQuantity - if (cdaImmunizationActivity.getDoseQuantity() != null - && !cdaImmunizationActivity.getDoseQuantity().isSetNullFlavor()) { - SimpleQuantity dose = dtt.tPQ2SimpleQuantity(cdaImmunizationActivity.getDoseQuantity()); - // manually set dose system, source object doesn't support it. - dose.setSystem(vst.tOid2Url("2.16.840.1.113883.1.11.12839")); - - fhirImmunization.setDoseQuantity(dose); - } - - // statusCode -> status - if (cdaImmunizationActivity.getStatusCode() != null - && !cdaImmunizationActivity.getStatusCode().isSetNullFlavor()) { - if (cdaImmunizationActivity.getStatusCode().getCode() != null - && !cdaImmunizationActivity.getStatusCode().getCode().isEmpty()) { - - ImmunizationStatus status = vst - .tStatusCode2ImmunizationStatus(cdaImmunizationActivity.getStatusCode().getCode()); - if (status != null) { - try { - fhirImmunization.setStatus(status); - } catch (FHIRException e) { - throw new IllegalArgumentException(e); - } - } - } - } - - // notGiven == true - if (fhirImmunization.getNotGiven()) { - // immunizationRefusalReason.code -> explanation.reasonNotGiven - if (cdaImmunizationActivity.getImmunizationRefusalReason() != null - && !cdaImmunizationActivity.getImmunizationRefusalReason().isSetNullFlavor()) { - if (cdaImmunizationActivity.getImmunizationRefusalReason().getCode() != null - && !cdaImmunizationActivity.getImmunizationRefusalReason().getCode().isSetNullFlavor()) { - // fhirImmunization.setExplanation(new - // Explanation().addReasonNotGiven(dtt.tCD2CodeableConcept(cdaImmunizationActivity.getImmunizationRefusalReason().getCode()))); - fhirImmunization.getExplanation().addReasonNotGiven( - dtt.tCD2CodeableConcept(cdaImmunizationActivity.getImmunizationRefusalReason().getCode())); - } - } - } - // notGiven == false - else if (!fhirImmunization.getNotGiven()) { - // indication.value -> explanation.reason - if (cdaImmunizationActivity.getIndication() != null - && !cdaImmunizationActivity.getIndication().isSetNullFlavor()) { - if (!cdaImmunizationActivity.getIndication().getValues().isEmpty() - && cdaImmunizationActivity.getIndication().getValues().get(0) != null - && !cdaImmunizationActivity.getIndication().getValues().get(0).isSetNullFlavor()) { - // fhirImmunization.setExplanation(new - // Explanation().addReason(dtt.tCD2CodeableConcept((CD)cdaImmunizationActivity.getIndication().getValues().get(0)))); - fhirImmunization.getExplanation().addReason( - dtt.tCD2CodeableConcept((CD) cdaImmunizationActivity.getIndication().getValues().get(0))); - } - } - } - - // reaction (i.e. - // entryRelationship/observation[templateId/@root="2.16.840.1.113883.10.20.22.4.9"] - // -> reaction - if (cdaImmunizationActivity.getReactionObservation() != null - && !cdaImmunizationActivity.getReactionObservation().isSetNullFlavor()) { - EntryResult er = tReactionObservation2Observation(cdaImmunizationActivity.getReactionObservation(), - bundleInfo); - Bundle reactionBundle = er.getBundle(); - org.hl7.fhir.dstu3.model.Observation fhirReactionObservation = null; - for (BundleEntryComponent entry : reactionBundle.getEntry()) { - result.addResource(entry.getResource()); - if (entry.getResource() instanceof org.hl7.fhir.dstu3.model.Observation) { - fhirReactionObservation = (org.hl7.fhir.dstu3.model.Observation) entry.getResource(); - - ImmunizationReactionComponent fhirReaction = fhirImmunization.addReaction(); - // reaction -> reaction.detail[ref=Observation] - fhirReaction.setDetail(getReference(fhirReactionObservation)); - - // reaction/effectiveTime/low -> reaction.date - if (fhirReactionObservation.getEffective() != null) { - Period reactionDate = (Period) fhirReactionObservation.getEffective(); - if (reactionDate.getStart() != null) - fhirReaction.setDateElement(reactionDate.getStartElement()); - } - - } - - } - } - - // TODO: in STU3 this property at this level was removed. Figure out how - // to map this to STU3 - // fhirImmunization.setReported(Config.DEFAULT_IMMUNIZATION_REPORTED); - return result; - - } - - private boolean conditionHasCategory(Condition condition, Coding otherCategoryCoding) { - if (condition == null || otherCategoryCoding == null) - return false; - - for (CodeableConcept category : condition.getCategory()) { - if (category.hasCoding()) { - - Coding currentCategoryCoding = category.getCodingFirstRep(); - - String code = currentCategoryCoding.getCode(); - - if (code != null) { - if (code.equals(otherCategoryCoding.getCode())) { - return true; - } - } - - } - } - return false; - } - - @Override - public IEntryResult tIndication2ConditionEncounter(Indication cdaIndication, IBundleInfo bundleInfo) { - IEntryResult result = tIndication2Condition(cdaIndication, bundleInfo); - Condition cond = (Condition) result.findResourceResult(Condition.class); - - Coding conditionCategory = new Coding().setSystem(vst.tOid2Url("2.16.840.1.113883.4.642.3.153")); - conditionCategory.setCode("encounter-diagnosis"); - conditionCategory.setDisplay("Encounter Diagnosis"); - if (!conditionHasCategory(cond, conditionCategory)) - cond.addCategory().addCoding(conditionCategory); - return result; - } - - @Override - public IEntryResult tIndication2ConditionProblemListItem(Indication cdaIndication, IBundleInfo bundleInfo) { - IEntryResult result = tIndication2Condition(cdaIndication, bundleInfo); - Condition cond = (Condition) result.findResourceResult(Condition.class); - - Coding conditionCategory = new Coding().setSystem(vst.tOid2Url("2.16.840.1.113883.4.642.3.153")); - conditionCategory.setCode("problem-list-item"); - conditionCategory.setDisplay("Problem List Item"); - if (!conditionHasCategory(cond, conditionCategory)) - cond.addCategory().addCoding(conditionCategory); - return result; - - } - - private IEntryResult tIndication2Condition(Indication cdaIndication, IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaIndication == null || cdaIndication.isSetNullFlavor()) - return result; - - Condition fhirCond = new Condition(); - - // resource id - IdType resourceId = new IdType("Condition", getUniqueId()); - fhirCond.setId(resourceId); - - // patient - fhirCond.setSubject(getPatientRef()); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirCond.getMeta().addProfile(Constants.PROFILE_DAF_CONDITION); - - List ids = cdaIndication.getIds(); - - if (ids != null) { - Condition previous = (Condition) bundleInfo.findResourceResult(ids, Condition.class); - if (previous != null) { - result.addExistingResource(previous); - return result; - } else { - result.putIIResource(ids, Condition.class, fhirCond); - } - } - result.addResource(fhirCond); - - // id -> identifier - if (ids != null && !cdaIndication.getIds().isEmpty()) { - for (II ii : ids) { - fhirCond.addIdentifier(dtt.tII2Identifier(ii)); - } - } - - // effectiveTime -> onset & abatement - if (cdaIndication.getEffectiveTime() != null && !cdaIndication.getEffectiveTime().isSetNullFlavor()) { - - IVXB_TS low = cdaIndication.getEffectiveTime().getLow(); - IVXB_TS high = cdaIndication.getEffectiveTime().getHigh(); - String value = cdaIndication.getEffectiveTime().getValue(); - - // low and high are both empty, and only the @value exists -> onset - if (low == null && high == null && value != null && !value.equals("")) { - fhirCond.setOnset(dtt.tString2DateTime(value)); - } else { - // low -> onset - if (low != null && !low.isSetNullFlavor()) { - fhirCond.setOnset(dtt.tTS2DateTime(low)); - } - // high -> abatement - if (high != null && !high.isSetNullFlavor()) { - fhirCond.setAbatement(dtt.tTS2DateTime(high)); - } - } - } - - // effectiveTime info -> clinicalStatus - if (cdaIndication.getEffectiveTime() != null && !cdaIndication.getEffectiveTime().isSetNullFlavor()) { - // high & low is present -> inactive - if (cdaIndication.getEffectiveTime().getLow() != null - && !cdaIndication.getEffectiveTime().getLow().isSetNullFlavor() - && cdaIndication.getEffectiveTime().getHigh() != null - && !cdaIndication.getEffectiveTime().getHigh().isSetNullFlavor()) { - fhirCond.setClinicalStatus(ConditionClinicalStatus.INACTIVE); - } else if (cdaIndication.getEffectiveTime().getLow() != null - && !cdaIndication.getEffectiveTime().getLow().isSetNullFlavor()) { - // low is present, high is not present -> active - fhirCond.setClinicalStatus(ConditionClinicalStatus.ACTIVE); - } else if (cdaIndication.getEffectiveTime().getValue() != null) { - // value is present, low&high is not present -> active - fhirCond.setClinicalStatus(ConditionClinicalStatus.ACTIVE); - } - } - - // value[CD] -> code - if (cdaIndication.getValues() != null && !cdaIndication.getValues().isEmpty()) { - // There is only 1 value, but anyway... - for (ANY value : cdaIndication.getValues()) { - if (value != null && !value.isSetNullFlavor()) { - if (value instanceof CD) - fhirCond.setCode(dtt.tCD2CodeableConcept((CD) value)); - } - } - } - - return result; - } - - @Override - public PatientCommunicationComponent tLanguageCommunication2Communication( - LanguageCommunication cdaLanguageCommunication) { - if (cdaLanguageCommunication == null || cdaLanguageCommunication.isSetNullFlavor()) - return null; - - PatientCommunicationComponent fhirCommunication = new PatientCommunicationComponent(); - - // languageCode -> language - if (cdaLanguageCommunication.getLanguageCode() != null - && !cdaLanguageCommunication.getLanguageCode().isSetNullFlavor()) { - fhirCommunication.setLanguage(dtt.tCD2CodeableConcept(cdaLanguageCommunication.getLanguageCode())); - // http://hl7.org/fhir/ValueSet/languages -> language.codeSystem - fhirCommunication.getLanguage().getCodingFirstRep().setSystem("http://hl7.org/fhir/ValueSet/languages"); - } - - // preferenceInd -> preferred - if (cdaLanguageCommunication.getPreferenceInd() != null - && !cdaLanguageCommunication.getPreferenceInd().isSetNullFlavor()) { - fhirCommunication.setPreferredElement(dtt.tBL2Boolean(cdaLanguageCommunication.getPreferenceInd())); - } - - return fhirCommunication; - - } - - @Override - public EntryResult tManufacturedProduct2Medication(ManufacturedProduct cdaManufacturedProduct, - IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaManufacturedProduct == null || cdaManufacturedProduct.isSetNullFlavor()) - return result; - - Medication fhirMedication = new Medication(); - IMedicationsInformation medsInfo = null; - CD cd = null; - List orgIds = null; - - if (cdaManufacturedProduct.getManufacturedMaterial() != null - && !cdaManufacturedProduct.getManufacturedMaterial().isSetNullFlavor()) { - - cd = cdaManufacturedProduct.getManufacturedMaterial().getCode(); - - if (cd != null) { - - medsInfo = bundleInfo.findResourceResult(cd); - - // manufacturedMaterial.code -> code - fhirMedication.setCode(dtt.tCD2CodeableConcept( - cdaManufacturedProduct.getManufacturedMaterial().getCode(), bundleInfo.getIdedAnnotations())); - } - } - - // add fhir resource after we check for previous value - - // resource id - IdType resourceId = new IdType("Medication", getUniqueId()); - fhirMedication.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirMedication.getMeta().addProfile(Constants.PROFILE_DAF_MEDICATION); - - // manufacturerOrganization -> manufacturer - if (cdaManufacturedProduct.getManufacturerOrganization() != null - && !cdaManufacturedProduct.getManufacturerOrganization().isSetNullFlavor()) { - - if (cdaManufacturedProduct.getManufacturerOrganization().getIds() != null) { - orgIds = cdaManufacturedProduct.getManufacturerOrganization().getIds(); - } - IEntryResult orgResult = tOrganization2Organization(cdaManufacturedProduct.getManufacturerOrganization(), - bundleInfo); - - org.hl7.fhir.dstu3.model.Organization fhirOrganization = (Organization) orgResult - .findResourceResult(org.hl7.fhir.dstu3.model.Organization.class); - - result.updateFrom(orgResult); - - if (fhirOrganization != null) { - fhirMedication.setManufacturer(getReference(fhirOrganization)); - - } - - } - - if (medsInfo != null && medsInfo.containsMedication(cd, orgIds)) { - Medication previousMedication = medsInfo.getMedication(cd, orgIds); - - if (previousMedication != null) { - result.addExistingResource(previousMedication); - } - } else { - if (medsInfo == null && cd != null) { - medsInfo = new MedicationsInformation(fhirMedication, cd, orgIds); - result.putCDResource(cd, medsInfo); - } else if (!medsInfo.containsMedication(cd, orgIds) && cd != null) { - if (orgIds != null) { - medsInfo.putMedication(fhirMedication, cd, orgIds); - } else { - medsInfo.putMedication(fhirMedication, cd); - } - } - result.addResource(fhirMedication); - } - return result; - } - - @Override - public EntryResult tManufacturedProduct2Medication(Product cdaProduct, IBundleInfo bundleInfo) { - - if (cdaProduct == null || cdaProduct.isSetNullFlavor()) { - return new EntryResult(); - } - - return tManufacturedProduct2Medication(cdaProduct.getManufacturedProduct(), bundleInfo); - } - - @Override - public EntryResult tManufacturedProduct2Medication(Consumable cdaConsumable, IBundleInfo bundleInfo) { - - if (cdaConsumable == null || cdaConsumable.isSetNullFlavor()) { - return new EntryResult(); - } - - return tManufacturedProduct2Medication(cdaConsumable.getManufacturedProduct(), bundleInfo); - - } - - @Override - public EntryResult tMedicationActivity2MedicationStatement(MedicationActivity cdaMedicationActivity, - IBundleInfo bundleInfo) { - - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - EntryResult result = new EntryResult(); - - if (cdaMedicationActivity == null || cdaMedicationActivity.isSetNullFlavor()) { - return result; - } - - MedicationStatement fhirMedSt = new MedicationStatement(); - org.hl7.fhir.dstu3.model.Dosage fhirDosage = fhirMedSt.addDosage(); - result.addResource(fhirMedSt); - - // resource id - IdType resourceId = new IdType("MedicationStatement", getUniqueId()); - fhirMedSt.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirMedSt.getMeta().addProfile(Constants.PROFILE_DAF_MEDICATION_STATEMENT); - - // patient - fhirMedSt.setSubject(getPatientRef()); - - // id -> identifier - if (cdaMedicationActivity.getIds() != null && !cdaMedicationActivity.getIds().isEmpty()) { - for (II ii : cdaMedicationActivity.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - fhirMedSt.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - - // statusCode -> status - if (cdaMedicationActivity.getStatusCode() != null && !cdaMedicationActivity.getStatusCode().isSetNullFlavor()) { - if (cdaMedicationActivity.getStatusCode().getCode() != null - && !cdaMedicationActivity.getStatusCode().getCode().isEmpty()) { - MedicationStatementStatus statusCode = vst - .tStatusCode2MedicationStatementStatus(cdaMedicationActivity.getStatusCode().getCode()); - if (statusCode != null) { - fhirMedSt.setStatus(statusCode); - } - } - } - if (!fhirMedSt.hasStatus()) { - fhirMedSt.setStatus(Config.DEFAULT_MEDICATION_STATEMENT_STATUS); - } - - // author[0] -> informationSource - if (!cdaMedicationActivity.getAuthors().isEmpty()) { - if (!cdaMedicationActivity.getAuthors().get(0).isSetNullFlavor()) { - EntityResult entityResult = tAuthor2Practitioner(cdaMedicationActivity.getAuthors().get(0), bundleInfo); - result.updateFrom(entityResult); - localBundleInfo.updateFrom(entityResult); - if (entityResult.hasPractitioner()) { - fhirMedSt.setInformationSource(getReference(entityResult.getPractitioner())); - } - } - } - - // consumable.manufacturedProduct -> medication - if (cdaMedicationActivity.getConsumable() != null && !cdaMedicationActivity.getConsumable().isSetNullFlavor()) { - EntryResult fhirMedicationResult = tManufacturedProduct2Medication(cdaMedicationActivity.getConsumable(), - localBundleInfo); - result.updateFrom(fhirMedicationResult); - localBundleInfo.updateFrom(fhirMedicationResult); - - Medication medication = (Medication) fhirMedicationResult.findResourceResult(Medication.class); - - if (medication != null) { - fhirMedSt.setMedication(getReference(medication)); - } - - } - - // getting info from effectiveTimes - if (cdaMedicationActivity.getEffectiveTimes() != null && !cdaMedicationActivity.getEffectiveTimes().isEmpty()) { - for (org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS ts : cdaMedicationActivity.getEffectiveTimes()) { - if (ts != null && !ts.isSetNullFlavor()) { - // effectiveTime[@xsi:type='IVL_TS'] -> effective - if (ts instanceof IVL_TS) { - fhirMedSt.setEffective(dtt.tIVL_TS2Period((IVL_TS) ts)); - } - // effectiveTime[@xsi:type='PIVL_TS'] -> dosage.timing - if (ts instanceof PIVL_TS) { - fhirDosage.setTiming(dtt.tPIVL_TS2Timing((PIVL_TS) ts)); - } - } - } - } - - // doseQuantity -> dosage.quantity - if (cdaMedicationActivity.getDoseQuantity() != null - && !cdaMedicationActivity.getDoseQuantity().isSetNullFlavor()) { - SimpleQuantity dose = dtt.tPQ2SimpleQuantity(cdaMedicationActivity.getDoseQuantity()); - // manually set dose system, source object doesn't support it. - dose.setSystem(vst.tOid2Url("2.16.840.1.113883.1.11.12839")); - fhirDosage.setDose(dose); - } - - // routeCode -> dosage.route - if (cdaMedicationActivity.getRouteCode() != null && !cdaMedicationActivity.getRouteCode().isSetNullFlavor()) { - fhirDosage.setRoute(dtt.tCD2CodeableConcept(cdaMedicationActivity.getRouteCode())); - } - - // rateQuantity -> dosage.rate - if (cdaMedicationActivity.getRateQuantity() != null - && !cdaMedicationActivity.getRateQuantity().isSetNullFlavor()) { - fhirDosage.setRate(dtt.tIVL_PQ2Range(cdaMedicationActivity.getRateQuantity())); - } - - // maxDoseQuantity -> dosage.maxDosePerPeriod - if (cdaMedicationActivity.getMaxDoseQuantity() != null - && !cdaMedicationActivity.getMaxDoseQuantity().isSetNullFlavor()) { - // cdaDataType.RTO does nothing but extends cdaDataType.RTO_PQ_PQ - fhirDosage.setMaxDosePerPeriod(dtt.tRTO2Ratio((RTO) cdaMedicationActivity.getMaxDoseQuantity())); - } - - if (cdaMedicationActivity.getEntryRelationships() != null - && !cdaMedicationActivity.getEntryRelationships().isEmpty()) { - - for (EntryRelationship er : cdaMedicationActivity.getEntryRelationships()) { - - if (er.getTypeCode() != null && er.getInversionInd() != null) { - // If entry relationship contains frequency observation instruction - if (er.getTypeCode().equals(x_ActRelationshipEntryRelationship.SUBJ) && er.getInversionInd()) { - if (er.getObservation() != null && !er.getObservation().isSetNullFlavor()) { - Observation obs = er.getObservation(); - if (obs.getClassCode() != null && obs.getMoodCode() != null) { - if (obs.getClassCode().equals(ActClassObservation.OBS) - && obs.getMoodCode().equals(x_ActMoodDocumentObservation.EVN)) { - if (obs.getCode() != null && obs.getCode().getCode().contentEquals("FREQUENCY")) { - if (!obs.getValues().isEmpty()) { - ANY valueElement = obs.getValues().get(0); - // Instruction.Frequency -> Dosage.timing - if (((ED) valueElement).getText() != null) { - CodeableConcept timingCoding = new CodeableConcept(); - Timing timing = new Timing(); - fhirDosage.setTiming(timing); - timingCoding.setText(((ED) valueElement).getText()); - timing.setCode(timingCoding); - } - } - } - } - } - } - } - } else if (er.getTypeCode() != null) { - // if entry relationship contains Medication Free Text Signature - if (er.getTypeCode().equals(x_ActRelationshipEntryRelationship.COMP)) { - if (er.getSubstanceAdministration() != null - && !er.getSubstanceAdministration().isSetNullFlavor()) { - SubstanceAdministration sa = er.getSubstanceAdministration(); - if (sa.getClassCode() != null && sa.getMoodCode() != null) { - // substance administration is a Medication Free Text Sig - if (sa.getClassCode().equals(ActClass.SBADM) - && (sa.getMoodCode().equals(x_DocumentSubstanceMood.EVN) - || sa.getMoodCode().equals(x_DocumentSubstanceMood.INT))) { - - String freeTextInstruction = dtt.tED2Annotation(sa.getText(), - bundleInfo.getIdedAnnotations()); - - if (freeTextInstruction != null) { - // Medication Free Text Sig -> Dosage.text/Dosage.PatientInstructions - fhirDosage.setText(freeTextInstruction); - fhirDosage.setPatientInstruction(freeTextInstruction); - } - } - } - } - } - } - } - } - - // taken -> UNK - fhirMedSt.setTaken(MedicationStatementTaken.UNK); - - // indication -> reason - for (Indication indication : cdaMedicationActivity.getIndications()) { - IEntryResult condResult = tIndication2ConditionProblemListItem(indication, localBundleInfo); - - result.updateFrom(condResult); - - Condition fhirCondition = (Condition) condResult.findResourceResult(Condition.class); - - if (fhirCondition != null) { - fhirMedSt.addReasonReference(getReference(fhirCondition)); - } - } - - if (cdaMedicationActivity.getMedicationSupplyOrder() != null) { - IEntryResult medRequestResult = medicationSupplyOrder2MedicationRequest( - cdaMedicationActivity.getMedicationSupplyOrder(), localBundleInfo); - localBundleInfo.updateFrom(medRequestResult); - result.updateFrom(medRequestResult); - } - - EList dispenses = cdaMedicationActivity.getMedicationDispenses(); - if (dispenses != null && !dispenses.isEmpty()) { - MedicationDispense dispense = dispenses.get(0); // Cardinality is 1 in spec - IEntryResult medDispenseResult = tMedicationDispense2MedicationDispense(dispense, localBundleInfo); - localBundleInfo.updateFrom(medDispenseResult); - result.updateFrom(medDispenseResult); - } - - return result; - } - - @Override - public EntryResult tMedicationDispense2MedicationDispense( - org.openhealthtools.mdht.uml.cda.consol.MedicationDispense cdaMedicationDispense, IBundleInfo bundleInfo) { - - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - EntryResult result = new EntryResult(); - - if (cdaMedicationDispense == null || cdaMedicationDispense.isSetNullFlavor()) { - return result; - } - - // NOTE: Following mapping doesn't really suit the mapping proposed by daf - - org.hl7.fhir.dstu3.model.MedicationDispense fhirMediDisp = new org.hl7.fhir.dstu3.model.MedicationDispense(); - result.addResource(fhirMediDisp); - - // patient - fhirMediDisp.setSubject(getPatientRef()); - - // resource id - IdType resourceId = new IdType("MedicationDispense", getUniqueId()); - fhirMediDisp.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirMediDisp.getMeta().addProfile(Constants.PROFILE_DAF_MEDICATION_DISPENSE); - - // id -> identifier - if (cdaMedicationDispense.getIds() != null & !cdaMedicationDispense.getIds().isEmpty()) { - for (II ii : cdaMedicationDispense.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - // Asserting at most one identifier exists - fhirMediDisp.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - - // statusCode -> status - if (cdaMedicationDispense.getStatusCode() != null && !cdaMedicationDispense.getStatusCode().isSetNullFlavor()) { - if (cdaMedicationDispense.getStatusCode().getCode() != null - && !cdaMedicationDispense.getStatusCode().getCode().isEmpty()) { - MedicationDispenseStatus mediDispStatEnum = vst - .tStatusCode2MedicationDispenseStatus(cdaMedicationDispense.getStatusCode().getCode()); - if (mediDispStatEnum != null) { - fhirMediDisp.setStatus(mediDispStatEnum); - } - } - } - - // product -> medication (reference) - if (cdaMedicationDispense.getProduct() != null && !cdaMedicationDispense.getProduct().isSetNullFlavor()) { - EntryResult fhirMedicationResult = tManufacturedProduct2Medication(cdaMedicationDispense.getProduct(), - localBundleInfo); - result.updateFrom(fhirMedicationResult); - localBundleInfo.updateFrom(fhirMedicationResult); - - Medication medication = (Medication) fhirMedicationResult.findResourceResult(Medication.class); - - if (medication != null) { - fhirMediDisp.setMedication(getReference(medication)); - } - - } - - // performer -> performer - if (cdaMedicationDispense.getPerformers() != null && !cdaMedicationDispense.getPerformers().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Performer2 cdaPerformer : cdaMedicationDispense.getPerformers()) { - if (cdaPerformer != null && !cdaPerformer.isSetNullFlavor()) { - EntityResult entityResult = tPerformer22Practitioner(cdaPerformer, localBundleInfo); - localBundleInfo.updateFrom(entityResult); - result.updateFrom(entityResult); - if (entityResult.hasPractitioner()) { - fhirMediDisp.addPerformer().setActor(getReference(entityResult.getPractitioner())); - } - } - } - } - - // quantity -> quantity - if (cdaMedicationDispense.getQuantity() != null && !cdaMedicationDispense.getQuantity().isSetNullFlavor()) { - fhirMediDisp.setQuantity(dtt.tPQ2SimpleQuantity(cdaMedicationDispense.getQuantity())); - } - - // whenPrepared and whenHandedOver - // effectiveTime[0] -> whenPrepared, effectiveTime[1] -> whenHandedOver - int effectiveTimeCount = 0; - if (cdaMedicationDispense.getEffectiveTimes() != null && !cdaMedicationDispense.getEffectiveTimes().isEmpty()) { - for (SXCM_TS ts : cdaMedicationDispense.getEffectiveTimes()) { - if (effectiveTimeCount == 0) { - // effectiveTime[0] -> whenPrepared - if (ts != null && !ts.isSetNullFlavor()) { - fhirMediDisp.setWhenPreparedElement(dtt.tTS2DateTime(ts)); - } - effectiveTimeCount++; - } else if (effectiveTimeCount == 1) { - // effectiveTime[1] -> whenHandedOver - if (ts != null && !ts.isSetNullFlavor()) { - fhirMediDisp.setWhenHandedOverElement(dtt.tTS2DateTime(ts)); - } - effectiveTimeCount++; - } - } - } - - // Adding dosageInstruction - org.hl7.fhir.dstu3.model.Dosage fhirDosageInstruction = fhirMediDisp.addDosageInstruction(); - - // TODO: The information used for dosageInstruction is used for different - // fields, too. - // Determine which field the information should fit - - // effectiveTimes -> dosageInstruction.timing.event - if (cdaMedicationDispense.getEffectiveTimes() != null && !cdaMedicationDispense.getEffectiveTimes().isEmpty()) { - Timing fhirTiming = new Timing(); - - // adding effectiveTimes to fhirTiming - for (org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS ts : cdaMedicationDispense.getEffectiveTimes()) { - if (ts != null && !ts.isSetNullFlavor()) { - fhirTiming.getEvent().add(dtt.tTS2DateTime(ts)); - } else if (ts.getValue() != null && !ts.getValue().isEmpty()) { - fhirTiming.getEvent().add(dtt.tString2DateTime(ts.getValue())); - } - } - - // setting fhirTiming for dosageInstruction if it is not empty - if (!fhirTiming.isEmpty()) { - fhirDosageInstruction.setTiming(fhirTiming); - } - } - - // quantity -> dosageInstruction.dose - if (cdaMedicationDispense.getQuantity() != null && !cdaMedicationDispense.getQuantity().isSetNullFlavor()) { - fhirDosageInstruction.setDose(dtt.tPQ2SimpleQuantity(cdaMedicationDispense.getQuantity())); - } - - return result; - } - - @Override - public EntryResult medicationSupplyOrder2MedicationRequest(MedicationSupplyOrder cdaSupplyOrder, - IBundleInfo bundleInfo) { - - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - EntryResult result = new EntryResult(); - - if (cdaSupplyOrder == null || cdaSupplyOrder.isSetNullFlavor()) - return result; - - MedicationRequest medRequest = new MedicationRequest(); - result.addResource(medRequest); - - // patient - medRequest.setSubject(getPatientRef()); - - // resource id - IdType resourceId = new IdType("MedicationRequest", getUniqueId()); - medRequest.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - medRequest.getMeta().addProfile(Constants.PROFILE_DAF_MEDICATION_REQUEST); - - // id -> identifier - if (cdaSupplyOrder.getIds() != null && !cdaSupplyOrder.getIds().isEmpty()) { - for (II ii : cdaSupplyOrder.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - medRequest.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - - // statusCode -> status - if (cdaSupplyOrder.getStatusCode() != null && !cdaSupplyOrder.getStatusCode().isSetNullFlavor()) { - medRequest.setStatus(vst.tActStatus2MedicationRequestStatus(cdaSupplyOrder.getStatusCode().getCode())); - } - - // hardcoded to "instance-order" - medRequest.setIntent(MedicationRequestIntent.INSTANCEORDER); - - // product.manufacturedProduct(MedicationInformation || - // ImmunizationMedicationInformation) -> medication - if (cdaSupplyOrder.getProduct() != null && !cdaSupplyOrder.getProduct().isSetNullFlavor()) { - EntryResult fhirMedicationResult = tManufacturedProduct2Medication(cdaSupplyOrder.getProduct(), - localBundleInfo); - result.updateFrom(fhirMedicationResult); - localBundleInfo.updateFrom(fhirMedicationResult); - - Medication medication = (Medication) fhirMedicationResult.findResourceResult(Medication.class); - - if (medication != null) { - medRequest.setMedication(getReference(medication)); - - } - } - - if (cdaSupplyOrder.getQuantity() != null || cdaSupplyOrder.getRepeatNumber() != null - || cdaSupplyOrder.getEffectiveTimes() != null) { - MedicationRequestDispenseRequestComponent dispenseRequest = new MedicationRequestDispenseRequestComponent(); - medRequest.setDispenseRequest(dispenseRequest); - // quantity -> dosageRequest.quantity - if (cdaSupplyOrder.getQuantity() != null && cdaSupplyOrder.getQuantity().getValue() != null - && !cdaSupplyOrder.getQuantity().isSetNullFlavor()) { - SimpleQuantity sq = new SimpleQuantity(); - sq.setValue(cdaSupplyOrder.getQuantity().getValue()); - sq.setUnit(cdaSupplyOrder.getQuantity().getUnit()); - dispenseRequest.setQuantity(sq); - } - // repeatNumber -> dosageRequest.numberOfRepeatsAllowed - if (cdaSupplyOrder.getRepeatNumber() != null && !cdaSupplyOrder.isSetNullFlavor()) { - dispenseRequest.setNumberOfRepeatsAllowed(cdaSupplyOrder.getRepeatNumber().getValue().intValue()); - } - - // effectiveTime -> dispenseRequest.validityPeriod - if (cdaSupplyOrder.getEffectiveTimes() != null && !cdaSupplyOrder.getEffectiveTimes().isEmpty()) { - for (SXCM_TS ts : cdaSupplyOrder.getEffectiveTimes()) { - if (ts instanceof IVL_TS) { - Period period = dtt.tIVL_TS2Period((IVL_TS) ts); - dispenseRequest.setValidityPeriod(period); - } - } - } - } - - // instructions -> notes - if (cdaSupplyOrder.getInstructions() != null && !cdaSupplyOrder.getInstructions().isSetNullFlavor()) { - Instructions instructions = cdaSupplyOrder.getInstructions(); - List annotations = new ArrayList(); - for (Act act : instructions.getActs()) { - Annotation annotation = new Annotation(); - if (act.getText() != null) { - annotation.setText(act.getText().getText()); - annotations.add(annotation); - } - } - medRequest.setNote(annotations); - } - - // author -> requester - if (!cdaSupplyOrder.getAuthors().isEmpty()) { - Author author = cdaSupplyOrder.getAuthors().get(0); - EntityResult entityResult = tAuthor2Practitioner(author, localBundleInfo); - localBundleInfo.updateFrom(entityResult); - result.updateFrom(entityResult); - if (entityResult.hasPractitioner()) { - MedicationRequestRequesterComponent requester = new MedicationRequestRequesterComponent(); - requester.setAgent(getReference(entityResult.getPractitioner())); - medRequest.setRequester(requester); - } - } - - return result; - } - - @Override - public EntryResult tMedicationInformation2Medication(MedicationInformation cdaMedicationInformation, - IBundleInfo bundleInfo) { - /* - * Since MedicationInformation is a ManufacturedProduct instance with a specific - * templateId, tManufacturedProduct2Medication should satisfy the required - * mapping for MedicationInformation - */ - return tManufacturedProduct2Medication(cdaMedicationInformation, bundleInfo); - } - - @Override - public EntryResult tObservation2Observation(org.openhealthtools.mdht.uml.cda.Observation cdaObservation, - IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaObservation == null || cdaObservation.isSetNullFlavor()) { - return result; - } - - org.hl7.fhir.dstu3.model.Observation fhirObs = new org.hl7.fhir.dstu3.model.Observation(); - result.addResource(fhirObs); - - // resource id - IdType resourceId = new IdType("Observation", getUniqueId()); - fhirObs.setId(resourceId); - - // subject - fhirObs.setSubject(getPatientRef()); - - // id -> identifier - if (cdaObservation.getIds() != null && !cdaObservation.getIds().isEmpty()) { - for (II ii : cdaObservation.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - fhirObs.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - - // code -> code - if (cdaObservation.getCode() != null) { - fhirObs.setCode(dtt.tCD2CodeableConcept(cdaObservation.getCode(), bundleInfo.getIdedAnnotations())); - } - - // statusCode -> status - if (cdaObservation.getStatusCode() != null && !cdaObservation.getStatusCode().isSetNullFlavor()) { - if (cdaObservation.getStatusCode().getCode() != null) { - fhirObs.setStatus( - vst.tObservationStatusCode2ObservationStatus(cdaObservation.getStatusCode().getCode())); - } - } - - // effectiveTime -> effective - if (cdaObservation.getEffectiveTime() != null && !cdaObservation.getEffectiveTime().isSetNullFlavor()) { - fhirObs.setEffective(dtt.tIVL_TS2Period(cdaObservation.getEffectiveTime())); - } - - // targetSiteCode -> bodySite - for (CD cd : cdaObservation.getTargetSiteCodes()) { - if (cd != null && !cd.isSetNullFlavor()) { - fhirObs.setBodySite(dtt.tCD2CodeableConcept(cd)); - } - } - - // value or dataAbsentReason - if (cdaObservation.getValues() != null && !cdaObservation.getValues().isEmpty()) { - // We traverse the values in cdaObs - for (ANY value : cdaObservation.getValues()) { - if (value == null) - continue; // If the value is null, continue - else if (value.isSetNullFlavor()) { - // If a null flavor exists, then we set dataAbsentReason by looking at the - // null-flavor value - Coding DataAbsentReasonCode = vst.tNullFlavor2DataAbsentReasonCode(value.getNullFlavor()); - if (DataAbsentReasonCode != null) { - if (fhirObs.getDataAbsentReason() == null || fhirObs.getDataAbsentReason().isEmpty()) { - // If DataAbsentReason was not set, create a new CodeableConcept and add our - // code into it - fhirObs.getDataAbsentReason().addCoding(DataAbsentReasonCode); - } else { - // If DataAbsentReason was set, just get the CodeableConcept and add our code - // into it - fhirObs.getDataAbsentReason().addCoding(DataAbsentReasonCode); - } - } - } else { - // If a non-null value which has no null-flavor exists, then we can get the - // value - // Checking the type of value - if (value instanceof CD) { - fhirObs.setValue(dtt.tCD2CodeableConcept((CD) value)); - } else if (value instanceof IVL_PQ) { - fhirObs.setValue(dtt.tIVL_PQ2Range((IVL_PQ) value)); - } else if (value instanceof PQ) { - fhirObs.setValue(dtt.tPQ2Quantity((PQ) value)); - } else if (value instanceof ST) { - fhirObs.setValue(dtt.tST2String((ST) value)); - } else if (value instanceof RTO) { - fhirObs.setValue(dtt.tRTO2Ratio((RTO) value)); - } else if (value instanceof ED) { - fhirObs.setValue(dtt.tED2Attachment((ED) value)); - } else if (value instanceof TS) { - fhirObs.setValue(dtt.tTS2DateTime((TS) value)); - } else if (value instanceof BL) { - fhirObs.setValue(dtt.tBL2Boolean((BL) value)); - } else if (value instanceof REAL) { - - fhirObs.setValue(dtt.tREAL2Quantity((REAL) value)); - - // Epic specific: attempt to get units from custom observation. - String SNOMED_OID = "2.16.840.1.113883.6.96"; - String SNOMED_VAL = "246514001"; - - for (EntryRelationship er : cdaObservation.getEntryRelationships()) { - Observation obs = er.getObservation(); - if (obs != null) { - if (obs.getCode() != null) { - if (obs.getCode().getCodeSystem() != null && obs.getCode().getCode() != null) { - // Look for SNOMED unit encoding. - if (obs.getCode().getCodeSystem().equals(SNOMED_OID) - && obs.getCode().getCode().equals(SNOMED_VAL)) { - for (ANY val : obs.getValues()) { - if (val instanceof ST) { - ST stVal = (ST) val; - String units = stVal.getText(); - Quantity fhirVal = (Quantity) fhirObs.getValue(); - fhirVal.setUnit(units); - break; - } - } - } - } - } - } - } - } - } - } - } - - // author -> performer - for (org.openhealthtools.mdht.uml.cda.Author author : cdaObservation.getAuthors()) { - if (author != null && !author.isSetNullFlavor()) { - EntityResult entityResult = tAuthor2Practitioner(author, bundleInfo); - result.updateFrom(entityResult); - if (entityResult.hasPractitioner()) { - fhirObs.addPerformer().setReference(entityResult.getPractitionerId()); - } - } - } - - // methodCode -> method - for (CE method : cdaObservation.getMethodCodes()) { - if (method != null && !method.isSetNullFlavor()) { - // Asserting that only one method exists - fhirObs.setMethod(dtt.tCD2CodeableConcept(method)); - } - } - - // author.time -> issued - if (cdaObservation.getAuthors() != null && !cdaObservation.getAuthors().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Author author : cdaObservation.getAuthors()) { - if (author != null && !author.isSetNullFlavor()) { - // get time from author - if (author.getTime() != null && !author.getTime().isSetNullFlavor()) { - fhirObs.setIssuedElement(dtt.tTS2Instant(author.getTime())); - } - } - } - } - - // interpretationCode -> interpretation - if (cdaObservation.getInterpretationCodes() != null && !cdaObservation.getInterpretationCodes().isEmpty()) { - for (org.openhealthtools.mdht.uml.hl7.datatypes.CE cdaInterprCode : cdaObservation - .getInterpretationCodes()) { - if (cdaInterprCode != null && !cdaInterprCode.isSetNullFlavor()) { - // Asserting that only one interpretation code exists - fhirObs.setInterpretation( - vst.tObservationInterpretationCode2ObservationInterpretationCode(cdaInterprCode)); - } - } - } - - // referenceRange -> referenceRange - if (cdaObservation.getReferenceRanges() != null && !cdaObservation.getReferenceRanges().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.ReferenceRange cdaReferenceRange : cdaObservation - .getReferenceRanges()) { - if (cdaReferenceRange != null && !cdaReferenceRange.isSetNullFlavor()) { - fhirObs.addReferenceRange(tReferenceRange2ReferenceRange(cdaReferenceRange)); - } - } - } - - return result; - } - - @Override - public IEntryResult tOrganization2Organization(org.openhealthtools.mdht.uml.cda.Organization cdaOrganization, - IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaOrganization == null || cdaOrganization.isSetNullFlavor()) { - return result; - } - - org.hl7.fhir.dstu3.model.Organization fhirOrganization = new org.hl7.fhir.dstu3.model.Organization(); - - // resource id - IdType resourceId = new IdType("Organization", getUniqueId()); - fhirOrganization.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirOrganization.getMeta().addProfile(Constants.PROFILE_DAF_ORGANIZATION); - - // id -> identifier - if (cdaOrganization.getIds() != null && !cdaOrganization.getIds().isEmpty()) { - org.hl7.fhir.dstu3.model.Organization previousOrganization = (Organization) bundleInfo - .findResourceResult(cdaOrganization.getIds(), org.hl7.fhir.dstu3.model.Organization.class); - - if (previousOrganization != null) { - result.addExistingResource(previousOrganization); - return result; - } else { - result.putIIResource(cdaOrganization.getIds(), org.hl7.fhir.dstu3.model.Organization.class, - fhirOrganization); - } - - for (II ii : cdaOrganization.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - fhirOrganization.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - - // name -> name - if (cdaOrganization.getNames() != null && !cdaOrganization.isSetNullFlavor()) { - - int namesLength = cdaOrganization.getNames().size(); - - for (int iter = 0; iter < namesLength; ++iter) { - ON name = cdaOrganization.getNames().get(iter); - if (name != null && !name.isSetNullFlavor() && name.getText() != null && !name.getText().isEmpty()) { - if (iter == 0) { - fhirOrganization.setName(name.getText()); - } else { - fhirOrganization.addAlias(name.getText()); - } - } - } - - } - - // telecom -> telecom - if (cdaOrganization.getTelecoms() != null && !cdaOrganization.getTelecoms().isEmpty()) { - for (TEL tel : cdaOrganization.getTelecoms()) { - if (tel != null && !tel.isSetNullFlavor()) { - fhirOrganization.addTelecom(dtt.tTEL2ContactPoint(tel)); - } - } - } - - // addr -> address - if (cdaOrganization.getAddrs() != null && !cdaOrganization.getAddrs().isEmpty()) { - for (AD ad : cdaOrganization.getAddrs()) { - if (ad != null && !ad.isSetNullFlavor()) { - fhirOrganization.addAddress(dtt.AD2Address(ad)); - } - } - } - - // organizations must have either a name or an identifier. - if (!fhirOrganization.hasName() && !fhirOrganization.hasIdentifier()) { - return result; - } - - result.addResource(fhirOrganization); - return result; - - } - - @Override - public org.hl7.fhir.dstu3.model.Location tParticipantRole2Location(ParticipantRole cdaParticipantRole) { - if (cdaParticipantRole == null || cdaParticipantRole.isSetNullFlavor()) - return null; - - org.hl7.fhir.dstu3.model.Location fhirLocation = new org.hl7.fhir.dstu3.model.Location(); - - // id -> identifier - if (cdaParticipantRole.getIds() != null && !cdaParticipantRole.getIds().isEmpty()) { - for (II ii : cdaParticipantRole.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - fhirLocation.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - - // resource id - IdType resourceId = new IdType("Location", getUniqueId()); - fhirLocation.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirLocation.getMeta().addProfile(Constants.PROFILE_DAF_LOCATION); - - // code -> type - // TODO: Requires huge mapping work from HL7 HealthcareServiceLocation value set - // to http://hl7.org/fhir/ValueSet/v3-ServiceDeliveryLocationRoleType - if (cdaParticipantRole.getCode() != null && !cdaParticipantRole.getCode().isSetNullFlavor()) { - logger.info( - "Found location.code in the CDA document, which can be mapped to Location.type on the FHIR side. But this is skipped for the moment, as it requires huge mapping work from HL7 HealthcareServiceLocation value set to http://hl7.org/fhir/ValueSet/v3-ServiceDeliveryLocationRoleType"); - // fhirLocation.setType(); - } - - // playingEntity.name.text -> name - if (cdaParticipantRole.getPlayingEntity() != null && !cdaParticipantRole.getPlayingEntity().isSetNullFlavor()) { - if (cdaParticipantRole.getPlayingEntity().getNames() != null - && !cdaParticipantRole.getPlayingEntity().getNames().isEmpty()) { - for (PN pn : cdaParticipantRole.getPlayingEntity().getNames()) { - // Asserting that at most one name exists - if (pn != null && !pn.isSetNullFlavor()) { - fhirLocation.setName(pn.getText()); - } - } - } - } - - // telecom -> telecom - if (cdaParticipantRole.getTelecoms() != null && !cdaParticipantRole.getTelecoms().isEmpty()) { - for (TEL tel : cdaParticipantRole.getTelecoms()) { - if (tel != null && !tel.isSetNullFlavor()) { - fhirLocation.addTelecom(dtt.tTEL2ContactPoint(tel)); - } - } - } - - // addr -> address - if (cdaParticipantRole.getAddrs() != null && !cdaParticipantRole.getAddrs().isEmpty()) { - for (AD ad : cdaParticipantRole.getAddrs()) { - // Asserting that at most one address exists - if (ad != null && !ad.isSetNullFlavor()) { - fhirLocation.setAddress(dtt.AD2Address(ad)); - } - } - } - - return fhirLocation; - } - - @Override - public IEntryResult tPatientRole2Patient(PatientRole cdaPatientRole, IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaPatientRole == null || cdaPatientRole.isSetNullFlavor()) - return result; - - Patient fhirPatient = new Patient(); - - result.addResource(fhirPatient); - // resource id - IdType resourceId = new IdType("Patient", getUniqueId()); - fhirPatient.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirPatient.getMeta().addProfile(Constants.PROFILE_DAF_PATIENT); - - // id -> identifier - if (cdaPatientRole.getIds() != null && !cdaPatientRole.getIds().isEmpty()) { - - for (II id : cdaPatientRole.getIds()) { - if (id != null && !id.isSetNullFlavor()) { - fhirPatient.addIdentifier(dtt.tII2Identifier(id)); - } - } - } - - // addr -> address - for (AD ad : cdaPatientRole.getAddrs()) { - if (ad != null && !ad.isSetNullFlavor()) { - fhirPatient.addAddress(dtt.AD2Address(ad)); - } - } - - // telecom -> telecom - for (TEL tel : cdaPatientRole.getTelecoms()) { - if (tel != null && !tel.isSetNullFlavor()) { - fhirPatient.addTelecom(dtt.tTEL2ContactPoint(tel)); - } - } - - // providerOrganization -> managingOrganization - if (cdaPatientRole.getProviderOrganization() != null - && !cdaPatientRole.getProviderOrganization().isSetNullFlavor()) { - - IEntryResult orgResult = tOrganization2Organization(cdaPatientRole.getProviderOrganization(), bundleInfo); - - org.hl7.fhir.dstu3.model.Organization fhirOrganization = (Organization) orgResult - .findResourceResult(org.hl7.fhir.dstu3.model.Organization.class); - result.updateFrom(orgResult); - - if (fhirOrganization != null) { - fhirPatient.setManagingOrganization(getReference(fhirOrganization)); - } - - } - - org.openhealthtools.mdht.uml.cda.Patient cdaPatient = cdaPatientRole.getPatient(); - - if (cdaPatient != null && !cdaPatient.isSetNullFlavor()) { - // patient.name -> name - for (PN pn : cdaPatient.getNames()) { - if (pn != null && !pn.isSetNullFlavor()) { - fhirPatient.addName(dtt.tEN2HumanName(pn)); - } - } - - // patient.administrativeGenderCode -> gender - if (cdaPatient.getAdministrativeGenderCode() != null - && !cdaPatient.getAdministrativeGenderCode().isSetNullFlavor() - && cdaPatient.getAdministrativeGenderCode().getCode() != null - && !cdaPatient.getAdministrativeGenderCode().getCode().isEmpty()) { - AdministrativeGender administrativeGender = vst.tAdministrativeGenderCode2AdministrativeGender( - cdaPatient.getAdministrativeGenderCode().getCode()); - fhirPatient.setGender(administrativeGender); - } - - // patient.birthTime -> birthDate - if (cdaPatient.getBirthTime() != null && !cdaPatient.getBirthTime().isSetNullFlavor()) { - fhirPatient.setBirthDateElement(dtt.tTS2Date(cdaPatient.getBirthTime())); - } - - // patient.maritalStatusCode -> maritalStatus - if (cdaPatient.getMaritalStatusCode() != null && !cdaPatient.getMaritalStatusCode().isSetNullFlavor()) { - if (cdaPatient.getMaritalStatusCode().getCode() != null - && !cdaPatient.getMaritalStatusCode().getCode().isEmpty()) { - fhirPatient.getMaritalStatus().addCoding( - vst.tMaritalStatusCode2MaritalStatusCode(cdaPatient.getMaritalStatusCode().getCode())); - } - } - - // patient.languageCommunication -> communication - for (LanguageCommunication LC : cdaPatient.getLanguageCommunications()) { - if (LC != null && !LC.isSetNullFlavor()) { - fhirPatient.addCommunication(tLanguageCommunication2Communication(LC)); - } - } - - // patient.guardian -> contact - for (org.openhealthtools.mdht.uml.cda.Guardian guardian : cdaPatient.getGuardians()) { - if (guardian != null && !guardian.isSetNullFlavor()) { - fhirPatient.addContact(tGuardian2Contact(guardian)); - } - } - - } - - return result; - } - - @Override - public EntityResult tPerformer22Practitioner(Performer2 cdaPerformer2, IBundleInfo bundleInfo) { - if (cdaPerformer2 == null || cdaPerformer2.isSetNullFlavor()) { - return new EntityResult(); - } - - return tAssignedEntity2Practitioner(cdaPerformer2.getAssignedEntity(), bundleInfo); - } - - public EntityResult tPerformer12Practitioner(Performer1 cdaPerformer1, IBundleInfo bundleInfo) { - if (cdaPerformer1 == null || cdaPerformer1.isSetNullFlavor()) { - return new EntityResult(); - } - - return tAssignedEntity2Practitioner(cdaPerformer1.getAssignedEntity(), bundleInfo); - } - - @Override - public EntryResult tProblemConcernAct2Condition(ProblemConcernAct cdaProblemConcernAct, IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaProblemConcernAct == null || cdaProblemConcernAct.isSetNullFlavor()) { - return result; - } - - // each problem observation instance -> FHIR Condition instance - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - - for (ProblemObservation cdaProbObs : cdaProblemConcernAct.getProblemObservations()) { - EntryResult er = tProblemObservation2Condition(cdaProbObs, localBundleInfo); - localBundleInfo.updateFrom(er); - result.updateEntitiesFrom(er); - result.updateFrom(er); - - Bundle fhirProbObsBundle = er.getBundle(); - if (fhirProbObsBundle == null) - continue; - - Condition cond = (Condition) er.findResourceResult(Condition.class); - - if (cond != null) { - CS statusCode = cdaProblemConcernAct.getStatusCode(); - String statusCodeValue = statusCode == null || statusCode.isSetNullFlavor() ? null - : statusCode.getCode(); - - // statusCode -> verificationStatus - cond.setVerificationStatus(vst.tStatusCode2ConditionVerificationStatus(statusCodeValue)); - } - - } - - return result; - } - - @Override - public EntryResult tProblemObservation2Condition(ProblemObservation cdaProbObs, IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaProbObs == null || cdaProbObs.isSetNullFlavor()) { - return result; - } - - // NOTE: Although DAF requires the mapping for severity, this data is not - // available on the C-CDA side. - // NOTE: Problem status template is deprecated in C-CDA Release 2.1; hence - // status data is not retrieved from this template. - - Condition fhirCondition = new Condition(); - - // resource id - IdType resourceId = new IdType("Condition", getUniqueId()); - fhirCondition.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirCondition.getMeta().addProfile(Constants.PROFILE_DAF_CONDITION); - - // patient - fhirCondition.setSubject(getPatientRef()); - - List ids = cdaProbObs.getIds(); - - if (ids != null) { - Condition previousFhirCond = (Condition) bundleInfo.findResourceResult(ids, Condition.class); - if (previousFhirCond != null) { - result.addExistingResource(previousFhirCond); - return result; - } else { - result.putIIResource(ids, Condition.class, fhirCondition); - } - } - result.addResource(fhirCondition); - // id -> identifier - for (II id : ids) { - if (!id.isSetNullFlavor()) { - fhirCondition.addIdentifier(dtt.tII2Identifier(id)); - } - } - - // category -> problem-list-item - Coding conditionCategory = new Coding().setSystem("http://hl7.org/fhir/condition-category"); - conditionCategory.setCode("problem-list-item"); - conditionCategory.setDisplay("Problem List Item"); - if (!conditionHasCategory(fhirCondition, conditionCategory)) - fhirCondition.addCategory().addCoding(conditionCategory); - - // value -> code - if (cdaProbObs.getValues() != null && !cdaProbObs.getValues().isEmpty()) { - for (ANY value : cdaProbObs.getValues()) { - if (value != null) { - if (value instanceof CD) { - fhirCondition.setCode(dtt.tCD2CodeableConcept((CD) value, bundleInfo.getIdedAnnotations())); - } - } - } - } - - // onset and abatement - if (cdaProbObs.getEffectiveTime() != null && !cdaProbObs.getEffectiveTime().isSetNullFlavor()) { - - IVXB_TS low = cdaProbObs.getEffectiveTime().getLow(); - IVXB_TS high = cdaProbObs.getEffectiveTime().getHigh(); - - // low -> onset (if doesn't exist, checking value) - if (low != null && !low.isSetNullFlavor()) { - fhirCondition.setOnset(dtt.tTS2DateTime(low)); - } else if (cdaProbObs.getEffectiveTime().getValue() != null - && !cdaProbObs.getEffectiveTime().getValue().isEmpty()) { - fhirCondition.setOnset(dtt.tString2DateTime(cdaProbObs.getEffectiveTime().getValue())); - } - - // high -> abatement - if (high != null && !high.isSetNullFlavor()) { - fhirCondition.setAbatement(dtt.tTS2DateTime(high)); - } - } - - // onset and abatement -> clinicalStatus - if (fhirCondition.getAbatement() != null) { - fhirCondition.setClinicalStatus(ConditionClinicalStatus.INACTIVE); - } else { - fhirCondition.setClinicalStatus(ConditionClinicalStatus.ACTIVE); - } - - // per spec will always have effectiveTime, so no need for verification status - // adjustment (as in indication section). - - // author[0] -> asserter - if (!cdaProbObs.getAuthors().isEmpty()) { - if (cdaProbObs.getAuthors().get(0) != null && !cdaProbObs.getAuthors().get(0).isSetNullFlavor()) { - Author author = cdaProbObs.getAuthors().get(0); - EntityResult entityResult = tAuthor2Practitioner(author, bundleInfo); - result.updateFrom(entityResult); - if (entityResult.hasPractitioner()) { - fhirCondition.setAsserter(getReference(entityResult.getPractitioner())); - } - // author.time -> assertedDate - if (author.getTime() != null && !author.getTime().isSetNullFlavor()) { - fhirCondition.setAssertedDateElement(dtt.tTS2DateTime(author.getTime())); - } - } - } - - return result; - } - - @Override - public EntryResult tProcedure2Procedure(org.openhealthtools.mdht.uml.cda.Procedure cdaProcedure, - IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaProcedure == null || cdaProcedure.isSetNullFlavor()) { - return result; - } - - org.hl7.fhir.dstu3.model.Procedure fhirProc = new org.hl7.fhir.dstu3.model.Procedure(); - result.addResource(fhirProc); - - // resource id - IdType resourceId = new IdType("Procedure", getUniqueId()); - fhirProc.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirProc.getMeta().addProfile(Constants.PROFILE_DAF_PROCEDURE); - - // subject - fhirProc.setSubject(getPatientRef()); - - // id -> identifier - if (cdaProcedure.getIds() != null && !cdaProcedure.getIds().isEmpty()) { - for (II id : cdaProcedure.getIds()) { - if (id != null && !id.isSetNullFlavor()) { - fhirProc.addIdentifier(dtt.tII2Identifier(id)); - } - } - } - - // effectiveTime -> performed - if (cdaProcedure.getEffectiveTime() != null && !cdaProcedure.getEffectiveTime().isSetNullFlavor()) { - fhirProc.setPerformed(dtt.tIVL_TS2Period(cdaProcedure.getEffectiveTime())); - } - - // targetSiteCode -> bodySite - if (cdaProcedure.getTargetSiteCodes() != null && !cdaProcedure.getTargetSiteCodes().isEmpty()) { - for (CD cd : cdaProcedure.getTargetSiteCodes()) { - if (cd != null && !cd.isSetNullFlavor()) { - fhirProc.addBodySite(dtt.tCD2CodeableConcept(cd)); - } - } - } - - // performer -> performer - for (Performer2 performer : cdaProcedure.getPerformers()) { - if (performer.getAssignedEntity() != null && !performer.getAssignedEntity().isSetNullFlavor()) { - EntityResult entityResult = tPerformer22Practitioner(performer, bundleInfo); - result.updateFrom(entityResult); - if (!entityResult.isEmpty()) { - ProcedurePerformerComponent fhirPerformer = new ProcedurePerformerComponent(); - fhirProc.addPerformer(fhirPerformer); - if (entityResult.hasPractitioner()) { - fhirPerformer.setActor(getReference(entityResult.getPractitioner())); - } - if (entityResult.hasOrganization()) { - fhirPerformer.setOnBehalfOf(entityResult.getOrganizationReference()); - } - if (entityResult.hasPractitionerRoleCode()) { - fhirPerformer.setRole(entityResult.getPractitionerRoleCode()); - } - } - } - } - - // statusCode -> status - if (cdaProcedure.getStatusCode() != null && !cdaProcedure.getStatusCode().isSetNullFlavor() - && cdaProcedure.getStatusCode().getCode() != null) { - ProcedureStatus status = vst.tStatusCode2ProcedureStatus(cdaProcedure.getStatusCode().getCode()); - if (status != null) { - fhirProc.setStatus(status); - } - } - - // code -> code - CD code = cdaProcedure.getCode(); - if (code != null) { - CodeableConcept cc = dtt.tCD2CodeableConcept(code, bundleInfo.getIdedAnnotations()); - if (cc != null) { - fhirProc.setCode(cc); - } - } - - // encounter[0] -> context (per spec leave it to encounter section to create the - // encounter resource) - EList encounters = cdaProcedure.getEncounters(); - if (!encounters.isEmpty()) { - if (encounters.size() > 1) { - logger.warn("Procudures cannot have multiple encounter. Only using first."); - } - org.openhealthtools.mdht.uml.cda.Encounter cdaEncounter = encounters.get(0); - List identifiers = tIIs2Identifiers(cdaEncounter.getIds()); - if (!identifiers.isEmpty()) { - if (identifiers.size() > 1) { - logger.warn("Procudures encounter cannot have multiple ids. Only using first."); - } - IDeferredReference deferredReference = new DeferredProcedureEncounterReference(fhirProc, - identifiers.get(0)); - result.addDeferredReference(deferredReference); - } - } - - List relationships = cdaProcedure.getEntryRelationships(); - if (relationships != null) { - for (EntryRelationship relationship : relationships) { - Observation observation = relationship.getObservation(); - if (observation != null && observation instanceof Indication) { - CodeableConcept cc = dtt.tCD2CodeableConcept(observation.getCode()); - if (cc != null) { - fhirProc.addReasonCode(cc); - } - continue; - } - - Act act = relationship.getAct(); - if (act != null && act instanceof CommentActivity) { - String annotation = dtt.tED2Annotation(act.getText(), bundleInfo.getIdedAnnotations()); - if (annotation != null) { - Annotation fhirAnnotation = new Annotation(); - fhirAnnotation.setText(annotation); - fhirProc.addNote(fhirAnnotation); - } - } - } - } - - return result; - } - - @Override - public EntryResult tReactionObservation2Observation(ReactionObservation cdaReactionObservation, - IBundleInfo bundleInfo) { - return tObservation2Observation(cdaReactionObservation, bundleInfo); - } - - @Override - public ObservationReferenceRangeComponent tReferenceRange2ReferenceRange( - org.openhealthtools.mdht.uml.cda.ReferenceRange cdaReferenceRange) { - if (cdaReferenceRange == null || cdaReferenceRange.isSetNullFlavor()) - return null; - - ObservationReferenceRangeComponent fhirRefRange = new ObservationReferenceRangeComponent(); - - // Notice that we get all the desired information from - // cdaRefRange.ObservationRange - // We may think of transforming ObservationRange instead of ReferenceRange - if (cdaReferenceRange.getObservationRange() != null && !cdaReferenceRange.isSetNullFlavor()) { - - // low - high - if (cdaReferenceRange.getObservationRange().getValue() != null - && !cdaReferenceRange.getObservationRange().getValue().isSetNullFlavor()) { - if (cdaReferenceRange.getObservationRange().getValue() instanceof IVL_PQ) { - IVL_PQ cdaRefRangeValue = ((IVL_PQ) cdaReferenceRange.getObservationRange().getValue()); - // low - if (cdaRefRangeValue.getLow() != null && !cdaRefRangeValue.getLow().isSetNullFlavor()) { - fhirRefRange.setLow(dtt.tPQ2SimpleQuantity(cdaRefRangeValue.getLow())); - } - // high - if (cdaRefRangeValue.getHigh() != null && !cdaRefRangeValue.getHigh().isSetNullFlavor()) { - fhirRefRange.setHigh(dtt.tPQ2SimpleQuantity(cdaRefRangeValue.getHigh())); - } - } - } - - // observationRange.interpretationCode -> type - if (cdaReferenceRange.getObservationRange().getInterpretationCode() != null - && !cdaReferenceRange.getObservationRange().getInterpretationCode().isSetNullFlavor()) { - fhirRefRange.setType( - dtt.tCD2CodeableConcept(cdaReferenceRange.getObservationRange().getInterpretationCode())); - } - - // text.text -> text - if (cdaReferenceRange.getObservationRange().getText() != null - && !cdaReferenceRange.getObservationRange().getText().isSetNullFlavor()) { - if (cdaReferenceRange.getObservationRange().getText().getText() != null - && !cdaReferenceRange.getObservationRange().getText().getText().isEmpty()) { - fhirRefRange.setText(cdaReferenceRange.getObservationRange().getText().getText()); - } - } - } - - return fhirRefRange; - } - - @Override - public EntryResult tResultObservation2Observation(ResultObservation cdaResultObservation, IBundleInfo bundleInfo) { - EntryResult result = tObservation2Observation(cdaResultObservation, bundleInfo); - Bundle fhirObservationBundle = result.getBundle(); - if (fhirObservationBundle == null) { - return result; - } - - // finding the observation resource and setting its meta.profile to result - // observation's profile url - if (Config.isGenerateDafProfileMetadata()) { - for (BundleEntryComponent entry : fhirObservationBundle.getEntry()) { - if (entry.getResource() instanceof Observation) { - (entry.getResource()).getMeta().addProfile(Constants.PROFILE_DAF_RESULT_OBS); - } - } - } - - return result; - } - - @Override - public EntryResult tResultOrganizer2DiagnosticReport(ResultOrganizer cdaResultOrganizer, IBundleInfo bundleInfo) { - EntryResult result = new EntryResult(); - - if (cdaResultOrganizer == null || cdaResultOrganizer.isSetNullFlavor()) { - return result; - } - - DiagnosticReport fhirDiagReport = new DiagnosticReport(); - result.addResource(fhirDiagReport); - - // resource id - IdType resourceId = new IdType("DiagnosticReport", getUniqueId()); - fhirDiagReport.setId(resourceId); - - // meta.profile - if (Config.isGenerateDafProfileMetadata()) - fhirDiagReport.getMeta().addProfile(Constants.PROFILE_DAF_DIAGNOSTIC_REPORT); - - // subject - fhirDiagReport.setSubject(getPatientRef()); - - // Although DiagnosticReport.request(DiagnosticOrder) is needed by daf, no - // information exists in CDA side to fill that field. - - // id -> identifier - if (cdaResultOrganizer.getIds() != null && !cdaResultOrganizer.getIds().isEmpty()) { - for (II ii : cdaResultOrganizer.getIds()) { - if (ii != null && !ii.isSetNullFlavor()) { - fhirDiagReport.addIdentifier(dtt.tII2Identifier(ii)); - } - } - } - - // code -> code - if (cdaResultOrganizer.getCode() != null) { - fhirDiagReport - .setCode(dtt.tCD2CodeableConcept(cdaResultOrganizer.getCode(), bundleInfo.getIdedAnnotations())); - } - - // statusCode -> status - if (cdaResultOrganizer.getStatusCode() != null && !cdaResultOrganizer.isSetNullFlavor()) { - fhirDiagReport.setStatus(vst - .tResultOrganizerStatusCode2DiagnosticReportStatus(cdaResultOrganizer.getStatusCode().getCode())); - } - - // effectiveTime -> effective - if (cdaResultOrganizer.getEffectiveTime() != null && !cdaResultOrganizer.getEffectiveTime().isSetNullFlavor()) { - fhirDiagReport.setEffective(dtt.tIVL_TS2Period(cdaResultOrganizer.getEffectiveTime())); - } - - // author -> performer - if (cdaResultOrganizer.getAuthors() != null && !cdaResultOrganizer.getAuthors().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Author author : cdaResultOrganizer.getAuthors()) { - // Asserting that at most one author exists - if (author != null && !author.isSetNullFlavor()) { - EntityResult entityResult = tAuthor2Practitioner(author, bundleInfo); - result.updateFrom(entityResult); - // TODO: what about role? - if (entityResult.hasPractitioner()) { - fhirDiagReport.addPerformer().setActor(getReference(entityResult.getPractitioner())); - } - } - } - - } - - // ResultObservation -> result - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - for (ResultObservation cdaResultObs : cdaResultOrganizer.getResultObservations()) { - if (!cdaResultObs.isSetNullFlavor()) { - EntryResult er = tResultObservation2Observation(cdaResultObs, localBundleInfo); - localBundleInfo.updateFrom(er); - result.updateEntitiesFrom(er); - Bundle fhirObsBundle = er.getBundle(); - if (fhirObsBundle != null) { - for (BundleEntryComponent entry : fhirObsBundle.getEntry()) { - result.addResource(entry.getResource()); - if (entry.getResource() instanceof org.hl7.fhir.dstu3.model.Observation) { - - Reference resultRef = new Reference(); - resultRef.setReference(entry.getResource().getId()); - String referenceString = ReferenceInfo.getDisplay(entry.getResource()); - if (referenceString != null) { - resultRef.setDisplay(referenceString); - } - fhirDiagReport.addResult(resultRef); - - } - } - } - } - } - - return result; - } - - @Override - public SectionComponent tSection2Section(Section cdaSection) { - if (cdaSection == null || cdaSection.isSetNullFlavor()) { - return null; - } - - SectionComponent fhirSec = new SectionComponent(); - - // title -> title.text - if (cdaSection.getTitle() != null && !cdaSection.getTitle().isSetNullFlavor()) { - if (cdaSection.getTitle().getText() != null && !cdaSection.getTitle().getText().isEmpty()) { - fhirSec.setTitle(cdaSection.getTitle().getText()); - } - } - - // code -> code - if (cdaSection.getCode() != null && !cdaSection.getCode().isSetNullFlavor()) { - fhirSec.setCode(dtt.tCD2CodeableConcept(cdaSection.getCode())); - } - - // text -> text - if (cdaSection.getText() != null) { - Narrative fhirText = dtt.tStrucDocText2Narrative(cdaSection.getText()); - if (fhirText != null && Config.getGenerateNarrative()) - fhirSec.setText(fhirText); - } - - fhirSec.setMode(SectionMode.SNAPSHOT); - - return fhirSec; - } - - @Override - public org.hl7.fhir.dstu3.model.Location tServiceDeliveryLocation2Location(ServiceDeliveryLocation cdaSDLOC) { - /* - * ServiceDeliveryLocation is a ParticipantRole instance with a specific - * templateId Therefore, tParticipantRole2Location should satisfy the necessary - * mapping - */ - return tParticipantRole2Location(cdaSDLOC); - } - - @Override - public org.hl7.fhir.dstu3.model.Device tSupply2Device(org.openhealthtools.mdht.uml.cda.Supply cdaSupply) { - if (cdaSupply == null || cdaSupply.isSetNullFlavor()) - return null; - - ProductInstance productInstance = null; - // getting productInstance from cdaSupply.participant.participantRole - if (cdaSupply.getParticipants() != null && !cdaSupply.getParticipants().isEmpty()) { - for (Participant2 participant : cdaSupply.getParticipants()) { - if (participant != null && !participant.isSetNullFlavor()) { - if (participant.getParticipantRole() != null - && !participant.getParticipantRole().isSetNullFlavor()) { - if (participant.getParticipantRole() instanceof ProductInstance) { - productInstance = (ProductInstance) participant.getParticipantRole(); - } - } - } - } - } - - if (productInstance == null) - return null; - - org.hl7.fhir.dstu3.model.Device fhirDev = new org.hl7.fhir.dstu3.model.Device(); - - // resource id - IdType resourceId = new IdType("Device", getUniqueId()); - fhirDev.setId(resourceId); - - // patient - fhirDev.setPatient(getPatientRef()); - - // productInstance.id -> identifier - for (II id : productInstance.getIds()) { - if (!id.isSetNullFlavor()) - fhirDev.addIdentifier(dtt.tII2Identifier(id)); - } - - // productInstance.playingDevice.code -> type - if (productInstance.getPlayingDevice() != null && !productInstance.getPlayingDevice().isSetNullFlavor()) { - if (productInstance.getPlayingDevice().getCode() != null - && !productInstance.getPlayingDevice().getCode().isSetNullFlavor()) { - fhirDev.setType(dtt.tCD2CodeableConcept(productInstance.getPlayingDevice().getCode())); - } - } - - return fhirDev; - } - - @Override - public EntryResult tVitalSignObservation2Observation(VitalSignObservation cdaVitalSignObservation, - IBundleInfo bundleInfo) { - EntryResult result = tObservation2Observation(cdaVitalSignObservation, bundleInfo); - Bundle fhirObservationBundle = result.getBundle(); - if (fhirObservationBundle == null) { - return result; - } - - // finding the observation resource and setting its meta.profile to result - // observation's profile url - if (Config.isGenerateDafProfileMetadata()) { - for (BundleEntryComponent entry : fhirObservationBundle.getEntry()) { - if (entry.getResource() instanceof Observation) { - (entry.getResource()).getMeta().addProfile(Constants.PROFILE_DAF_VITAL_SIGNS); - } - } - } - - return result; - } - - public DocumentReference tDocumentReference(String documentBody) { - - DocumentReference docReference = new DocumentReference(); - - // set id - docReference.setId(new IdType("DocumentReference", getUniqueId())); - - // status -> current - docReference.setStatus(DocumentReferenceStatus.CURRENT); - - // now -> indexed - Date now = new Date(); - docReference.setIndexed(now); - - // type -> 34133-9 (hard-coded from specification) - CodeableConcept docType = new CodeableConcept(); - Coding docTypeCoding = new Coding(); - docTypeCoding.setCode("34133-9"); - docTypeCoding.setSystem("2.16.840.1.113883.6.1"); - docTypeCoding.setDisplay("Summarization of Episode Note"); - docType.addCoding(docTypeCoding); - docReference.setType(docType); - - // attachment - Attachment docAttachment = new Attachment(); - docAttachment.setContentType("text/plain"); - - // attachment doc - Base64BinaryType doc64 = new Base64BinaryType(Base64.encode(documentBody.getBytes())); - docAttachment.setDataElement(doc64); - - // attachment hash - MessageDigest digest; - try { - digest = MessageDigest.getInstance("SHA-1"); - byte[] encodedhash = digest.digest(documentBody.getBytes()); - docAttachment.setHashElement(new Base64BinaryType(Base64.encode(encodedhash))); - } catch (NoSuchAlgorithmException e) { - logger.error(e.toString()); - } - - // set attachment - DocumentReferenceContentComponent docContent = new DocumentReferenceContentComponent(); - docContent.setAttachment(docAttachment); - docReference.addContent(docContent); - - return docReference; - - } - - public Device tDevice(Identifier assemblerDevice) { - Device device = new Device(); - device.setStatus(FHIRDeviceStatus.ACTIVE); - device.addIdentifier(assemblerDevice); - - Narrative deviceNarrative = new Narrative().setStatus(NarrativeStatus.GENERATED); - deviceNarrative.setDivAsString(assemblerDevice.getValue()); - device.setText(deviceNarrative); - - device.setId(new IdType("Device", getUniqueId())); - return device; - } - - @Override - public Bundle tProvenance(Bundle bundle, String documentBody, Identifier assemblerDevice) { - - Provenance provenance = new Provenance(); - ProvenanceAgentComponent pac = new ProvenanceAgentComponent(); - provenance.setId(new IdType("Provenance", getUniqueId())); - - // recorded - Date now = new Date(); - provenance.setRecorded(now); - - // document reference - DocumentReference documentReference = tDocumentReference(documentBody); - bundle.addEntry(new BundleEntryComponent().setResource(documentReference)); - - ProvenanceEntityComponent pec = new ProvenanceEntityComponent(); - pec.setRole(ProvenanceEntityRole.SOURCE); - pec.setWhat(getReference(documentReference)); - provenance.addEntity(pec); - - // device - Device device = tDevice(assemblerDevice); - bundle.addEntry(new BundleEntryComponent().setResource(device)); - - // agent type - Coding agentTypeCoding = new Coding(ProvenanceAgentType.DEVICE.getSystem(), ProvenanceAgentType.DEVICE.toCode(), - ProvenanceAgentType.DEVICE.getDisplay()); - agentTypeCoding.setId(device.getId()); - pac.setRelatedAgentType(new CodeableConcept().addCoding(agentTypeCoding)); - - // agent role - Coding agentRoleCoding = new Coding(ProvenanceAgentRole.ASSEMBLER.getSystem(), - ProvenanceAgentRole.ASSEMBLER.toCode(), ProvenanceAgentRole.ASSEMBLER.getDisplay()); - agentRoleCoding.setId(device.getId()); - pac.addRole(new CodeableConcept().addCoding(agentRoleCoding)); - - pac.setWho(getReference(device)); - provenance.addAgent(pac); - - for (BundleEntryComponent bec : bundle.getEntry()) { - provenance.addTarget(getReference(bec.getResource())); - } - - bundle.addEntry(new BundleEntryComponent().setResource(provenance)); - return bundle; - } - -} \ No newline at end of file diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/ValueSetsTransformerImpl.java b/src/main/java/tr/com/srdc/cda2fhir/transform/ValueSetsTransformerImpl.java deleted file mode 100644 index 7f3c1d3d1..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/ValueSetsTransformerImpl.java +++ /dev/null @@ -1,1209 +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 org.hl7.fhir.dstu3.model.Address.AddressType; -import org.hl7.fhir.dstu3.model.Address.AddressUse; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus; -import org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus; -import org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem; -import org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse; -import org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus; -import org.hl7.fhir.dstu3.model.Encounter.EncounterStatus; -import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender; -import org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus; -import org.hl7.fhir.dstu3.model.Group.GroupType; -import org.hl7.fhir.dstu3.model.HumanName.NameUse; -import org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus; -import org.hl7.fhir.dstu3.model.MedicationDispense.MedicationDispenseStatus; -import org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus; -import org.hl7.fhir.dstu3.model.MedicationStatement.MedicationStatementStatus; -import org.hl7.fhir.dstu3.model.Observation.ObservationStatus; -import org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus; -import org.hl7.fhir.dstu3.model.Timing.UnitsOfTime; -import org.hl7.fhir.dstu3.model.codesystems.V3ActCode; -import org.hl7.fhir.dstu3.model.codesystems.V3MaritalStatus; -import org.hl7.fhir.dstu3.model.codesystems.V3NullFlavor; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.vocab.EntityClassRoot; -import org.openhealthtools.mdht.uml.hl7.vocab.EntityNameUse; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; -import org.openhealthtools.mdht.uml.hl7.vocab.PostalAddressUse; -import org.openhealthtools.mdht.uml.hl7.vocab.TelecommunicationAddressUse; - -public class ValueSetsTransformerImpl implements IValueSetsTransformer, Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - private static final String UMLS_ROOT = "http://www.nlm.nih.gov/research/umls/"; - private static final org.slf4j.Logger LOGGER = org.slf4j.LoggerFactory.getLogger(ValueSetsTransformerImpl.class); - - @Override - public MedicationRequestStatus tActStatus2MedicationRequestStatus(String medicationRequestStatusCode) { - switch (medicationRequestStatusCode) { - case "cancelled": - return MedicationRequestStatus.CANCELLED; - case "aborted": - return MedicationRequestStatus.CANCELLED; - case "nullified": - return MedicationRequestStatus.CANCELLED; - case "active": - return MedicationRequestStatus.ACTIVE; - case "held": - return MedicationRequestStatus.ONHOLD; - case "suspended": - return MedicationRequestStatus.ONHOLD; - case "completed": - return MedicationRequestStatus.COMPLETED; - default: - return MedicationRequestStatus.UNKNOWN; - } - } - - @Override - public AdministrativeGender tAdministrativeGenderCode2AdministrativeGender(String cdaAdministrativeGenderCode) { - switch (cdaAdministrativeGenderCode.toLowerCase()) { - case "f": - return AdministrativeGender.FEMALE; - case "m": - return AdministrativeGender.MALE; - case "un": - return AdministrativeGender.UNKNOWN; - default: - return AdministrativeGender.UNKNOWN; - } - } - - @Override - public String tAgeObservationUnit2AgeUnit(String cdaAgeObservationUnit) { - if (cdaAgeObservationUnit == null || cdaAgeObservationUnit.isEmpty()) - return null; - - switch (cdaAgeObservationUnit.toLowerCase()) { - case "a": - return "Year"; - case "mo": - return "Month"; - case "wk": - return "Week"; - case "d": - return "Day"; - case "h": - return "Hour"; - case "min": - return "Minute"; - default: - return null; - } - } - - @Override - public AllergyIntoleranceCategory tAllergyCategoryCode2AllergyIntoleranceCategory(String cdaAllergyCategoryCode) { - if (cdaAllergyCategoryCode == null) - return null; - switch (cdaAllergyCategoryCode) { - case "416098002": - case "59037007": - case "419511003": - return AllergyIntoleranceCategory.MEDICATION; - case "414285001": - case "235719002": - case "418471000": - return AllergyIntoleranceCategory.FOOD; - case "232347008": - case "420134006": - case "418038007": - case "419199007": - return AllergyIntoleranceCategory.ENVIRONMENT; - default: - LOGGER.error("Unmapped allergy category code: {}", cdaAllergyCategoryCode); - return null; - } - } - - @Override - public AllergyIntoleranceType tAllergyCategoryCode2AllergyIntoleranceType(String cdaAllergyCategoryCode) { - if (cdaAllergyCategoryCode == null) - return null; - switch (cdaAllergyCategoryCode) { - case "419199007": - case "416098002": - case "414285001": - case "232347008": - return AllergyIntoleranceType.ALLERGY; - case "59037007": - case "235719002": - case "420134006": - case "419511003": - case "418471000": - case "418038007": - return AllergyIntoleranceType.INTOLERANCE; - default: - LOGGER.error("Unmapped allergy type code: {}", cdaAllergyCategoryCode); - return null; - } - } - - @Override - public AllergyIntoleranceCriticality tCriticalityObservationValue2AllergyIntoleranceCriticality( - String cdaCriticalityObservationValue) { - if (cdaCriticalityObservationValue == null || cdaCriticalityObservationValue.isEmpty()) - return null; - switch (cdaCriticalityObservationValue.toLowerCase()) { - case "critl": - return AllergyIntoleranceCriticality.LOW; - case "crith": - return AllergyIntoleranceCriticality.HIGH; - case "critu": - return AllergyIntoleranceCriticality.UNABLETOASSESS; - default: - return null; - } - } - - @Override - public Coding tEncounterCode2EncounterCode(String cdaEncounterCode) { - if (cdaEncounterCode == null) - return null; - switch (cdaEncounterCode.toLowerCase()) { - case "amb": - case "ambulatory": - // return EncounterClassEnum.AMBULATORY; - return toCoding(V3ActCode.AMB); - case "out": - case "outpatient": - // TODO: verify if this is correct - // return EncounterClassEnum.OUTPATIENT; - return toCoding(V3ActCode.AMB); - case "in": - case "inp": - case "inpatient": - // return EncounterClassEnum.INPATIENT; - return toCoding(V3ActCode.IMP); - case "day": - case "daytime": - // TODO: check if mapping is correct - // return EncounterClassEnum.DAYTIME; - return toCoding(V3ActCode.AMB); - case "em": - case "eme": - case "emergency": - // return EncounterClassEnum.EMERGENCY; - return toCoding(V3ActCode.EMER); - case "hom": - case "home": - // return EncounterClassEnum.HOME; - return toCoding(V3ActCode.HH); - case "vir": - case "virtual": - // return EncounterClassEnum.VIRTUAL; - return toCoding(V3ActCode.VR); - case "fie": - case "field": - // return EncounterClassEnum.FIELD; - return toCoding(V3ActCode.FLD); - case "other": - case "oth": - // TODO: find correct mapping - // return EncounterClassEnum.OTHER; - throw new IllegalArgumentException("Unmapped " + cdaEncounterCode.toLowerCase()); - default: - return null; - - } - } - - private Coding toCoding(V3ActCode a) { - return new Coding().setSystem(a.getSystem()).setCode(a.toCode()).setDisplay(a.getDisplay()); - } - - @Override - public GroupType tEntityClassRoot2GroupType(EntityClassRoot cdaEntityClassRoot) { - switch (cdaEntityClassRoot) { - case PSN: - return GroupType.PERSON; - case ANM: - return GroupType.ANIMAL; - case DEV: - return GroupType.DEVICE; - case MMAT: - return GroupType.MEDICATION; - default: - return null; - } - } - - @Override - public NameUse tEntityNameUse2NameUse(EntityNameUse cdaEntityNameUse) { - switch (cdaEntityNameUse) { - case C: - return NameUse.USUAL; - case P: - return NameUse.NICKNAME; - default: - return NameUse.USUAL; - } - } - - @Override - public FamilyHistoryStatus tFamilyHistoryOrganizerStatusCode2FamilyHistoryStatus( - String cdaFamilyHistoryOrganizerStatusCode) { - switch (cdaFamilyHistoryOrganizerStatusCode.toLowerCase()) { - case "completed": - return FamilyHistoryStatus.COMPLETED; - case "error": - return FamilyHistoryStatus.ENTEREDINERROR; - case "un": - return FamilyHistoryStatus.HEALTHUNKNOWN; - case "part": - return FamilyHistoryStatus.PARTIAL; - default: - return null; - } - } - - @Override - public Coding tMaritalStatusCode2MaritalStatusCode(String cdaMaritalStatusCode) { - - switch (cdaMaritalStatusCode.toUpperCase()) { - case "A": - return toCoding(V3MaritalStatus.A); - case "D": - return toCoding(V3MaritalStatus.D); - case "I": - return toCoding(V3MaritalStatus.I); - case "L": - return toCoding(V3MaritalStatus.L); - case "M": - return toCoding(V3MaritalStatus.M); - case "P": - return toCoding(V3MaritalStatus.P); - case "S": - return toCoding(V3MaritalStatus.S); - case "T": - return toCoding(V3MaritalStatus.T); - case "W": - return toCoding(V3MaritalStatus.W); - case "UN": - default: - return toCoding(V3NullFlavor.UNK); - } - } - - private Coding toCoding(V3NullFlavor a) { - return new Coding().setSystem(a.getSystem()).setCode(a.toCode()).setDisplay(a.getDisplay()); - } - - private Coding toCoding(V3MaritalStatus a) { - return new Coding().setSystem(a.getSystem()).setCode(a.toCode()).setDisplay(a.getDisplay()); - } - - @Override - public Coding tNullFlavor2DataAbsentReasonCode(NullFlavor cdaNullFlavor) { - Coding DataAbsentReasonCode = new Coding(); - String code = null; - String display = null; - - switch (cdaNullFlavor) { - case UNK: - code = "unknown"; - display = "Unkown"; - break; - case ASKU: - code = "asked"; - display = "Asked"; - break; - case MSK: - code = "masked"; - display = "Masked"; - break; - case NA: - code = "unsupported"; - display = "Unsupported"; - break; - case NASK: - code = "not-asked"; - display = "Not Asked"; - break; - case NAV: - code = "temp"; - display = "Temp"; - break; - case NI: - code = "error"; - display = "Error"; - break; - case NINF: - code = "NaN"; - display = "Not a Number"; - break; - case NP: - code = "unknown"; - display = "Unkown"; - break; - case OTH: - code = "error"; - display = "Error"; - break; - case PINF: - code = "NaN"; - display = "Not a Number"; - break; - case TRC: - code = "NaN"; - display = "Not a Number"; - break; - default: - break; - } - - DataAbsentReasonCode.setSystem("http://hl7.org/fhir/data-absent-reason"); - DataAbsentReasonCode.setCode(code); - DataAbsentReasonCode.setDisplay(display); - - return DataAbsentReasonCode; - } - - @Override - public CodeableConcept tObservationInterpretationCode2ObservationInterpretationCode( - CD cdaObservationInterpretationCode) { - if (cdaObservationInterpretationCode == null) - return null; - Coding obsIntCode = new Coding(); - obsIntCode.setSystem("http://hl7.org/fhir/v2/0078"); - - String code = null, display = null; - - // init code and display with the CDA incomings - if (cdaObservationInterpretationCode.getCode() != null) - code = cdaObservationInterpretationCode.getCode(); - if (cdaObservationInterpretationCode.getDisplayName() != null) - display = cdaObservationInterpretationCode.getDisplayName(); - - // if a different code is found, change it - if (cdaObservationInterpretationCode.getCode() != null) { - switch (cdaObservationInterpretationCode.getCode().toUpperCase()) { - case "AC": - code = "IE"; - display = "Insufficient evidence"; - break; - case "EX": - code = "IND"; - display = "Indeterminate"; - break; - case "HX": - code = "H"; - display = "High"; - break; - case "LX": - code = "L"; - display = "Low"; - break; - case "QCF": - code = "IND"; - display = "Indeterminate"; - break; - case "TOX": - code = "IND"; - display = "Indeterminate"; - break; - case "CAR": - code = "DET"; - display = "Detected"; - break; - case "H>": - code = "HU"; - display = "Very high"; - break; - case "L<": - code = "LU"; - display = "Very low"; - break; - default: - break; - } - } - obsIntCode.setCode(code); - obsIntCode.setDisplay(display); - return new CodeableConcept().addCoding(obsIntCode); - } - - @Override - public ObservationStatus tObservationStatusCode2ObservationStatus(String cdaObservationStatusCode) { - switch (cdaObservationStatusCode.toLowerCase()) { - // TODO: https://www.hl7.org/fhir/valueset-observation-status.html and pdf page - // 476 - // Check the following mapping - case "new": - case "held": - return ObservationStatus.REGISTERED; - case "normal": - case "active": - return ObservationStatus.PRELIMINARY; - case "completed": - return ObservationStatus.FINAL; - case "error": - return ObservationStatus.ENTEREDINERROR; - case "cancelled": - case "aborted": - case "nullified": - case "suspended": - return ObservationStatus.CANCELLED; - case "obsolete": - default: - return ObservationStatus.UNKNOWN; - } - } - - @Override - public String tOid2Url(String codeSystem) { - String system = null; - switch (codeSystem) { - case "2.16.840.1.113883.4.642.3.153": - system = "http://hl7.org/fhir/condition-category"; - break; - case "2.16.840.1.113883.6.96": - system = "http://snomed.info/sct"; - break; - case "2.16.840.1.113883.6.88": - system = UMLS_ROOT + "rxnorm"; - break; - case "2.16.840.1.113883.6.1": - system = "http://loinc.org"; - break; - case "2.16.840.1.113883.6.8": - system = "http://unitsofmeasure.org"; - break; - case "2.16.840.1.113883.3.26.1.2": - system = "http://ncimeta.nci.nih.gov"; - break; - case "2.16.840.1.113883.6.12": - system = "http://www.ama-assn.org/go/cpt"; - break; - case "2.16.840.1.113883.6.209": - system = "http://hl7.org/fhir/ndfrt"; - break; - case "2.16.840.1.113883.4.9": - system = "http://fdasis.nlm.nih.gov"; - break; - case "2.16.840.1.113883.12.292": - system = "http://www2a.cdc.gov/vaccines/iis/iisstandards/vaccines.asp?rpt=cvx"; - break; - case "1.0.3166.1.2.2": - system = "urn:iso:std:iso:3166"; - break; - case "2.16.840.1.113883.6.301.5": - system = "http://www.nubc.org/patient-discharge"; - break; - case "2.16.840.1.113883.6.256": - system = "http://www.radlex.org"; - break; - case "2.16.840.1.113883.6.3": - system = "http://hl7.org/fhir/sid/icd-10"; - break; - case "2.16.840.1.113883.6.4": - system = "http://www.icd10data.com/icd10pcs"; - break; - case "2.16.840.1.113883.6.42": - system = "http://hl7.org/fhir/sid/icd-9"; - break; - case "2.16.840.1.113883.6.73": - system = "http://www.whocc.no/atc"; - break; - case "2.16.840.1.113883.6.24": - system = "urn:std:iso:11073:10101"; - break; - case "1.2.840.10008.2.16.4": - system = "http://nema.org/dicom/dicm"; - break; - case "2.16.840.1.113883.6.281": - system = "http://www.genenames.org"; - break; - case "2.16.840.1.113883.6.280": - system = "http://www.ncbi.nlm.nih.gov/nuccore"; - break; - case "2.16.840.1.113883.6.282": - system = "http://www.hgvs.org/mutnomen"; - break; - case "2.16.840.1.113883.6.284": - system = "http://www.ncbi.nlm.nih.gov/projects/SNP"; - break; - case "2.16.840.1.113883.3.912": - system = "http://cancer.sanger.ac.uk/cancergenome/projects/cosmic"; - break; - case "2.16.840.1.113883.6.283": - system = "http://www.hgvs.org/mutnomen"; - break; - case "2.16.840.1.113883.6.174": - system = "http://www.omim.org"; - break; - case "2.16.840.1.113883.13.191": - system = "http://www.ncbi.nlm.nih.gov/pubmed"; - break; - case "2.16.840.1.113883.3.913": - system = "http://www.pharmgkb.org"; - break; - case "2.16.840.1.113883.3.1077": - system = "http://clinicaltrials.gov"; - break; - case "2.16.840.1.113883.6.314": - system = UMLS_ROOT + "mmsl"; - break; - case "2.16.840.1.113883.3.26.1.1": - system = UMLS_ROOT + "nci"; - break; - case "2.16.840.1.113883.1.11.12839": - system = "http://unitsofmeasure.org/ucum.html"; - break; - default: - system = "urn:oid:" + codeSystem; - LOGGER.info("Encountered unmapped OID: " + codeSystem); - break; - } - return system; - } - - @Override - public Coding tParticipationType2ParticipationTypeCode( - org.openhealthtools.mdht.uml.hl7.vocab.ParticipationType cdaParticipationType) { - Coding fhirParticipationType = new Coding(); - fhirParticipationType.setSystem("http://hl7.org/fhir/v3/ParticipationType"); - String code = null; - String display = null; - - switch (cdaParticipationType) { - case PRF: - code = "PRF"; - display = "performer"; - break; - case SBJ: - code = "SBJ"; - display = "subject"; - break; - case ADM: - code = "ADM"; - display = "admitter"; - break; - case ATND: - code = "ATND"; - display = "attender"; - break; - case AUT: - code = "AUT"; - display = "author"; - break; - case AUTHEN: - code = "AUTHEN"; - display = "authenticator"; - break; - case BBY: - code = "BBY"; - display = "baby"; - break; - case BEN: - code = "BEN"; - display = "beneficiary"; - break; - case CALLBCK: - code = "CALLBCK"; - display = "callback contact"; - break; - case CON: - code = "CON"; - display = "consultant"; - break; - case COV: - code = "COV"; - display = "coverage target"; - break; - case CSM: - code = "CSM"; - display = "consumable"; - break; - case CST: - code = "CST"; - display = "custodian"; - break; - case DEV: - code = "DEV"; - display = "device"; - break; - case DIR: - code = "DIR"; - display = "direct target"; - break; - case DIS: - code = "DIS"; - display = "discharger"; - break; - case DIST: - code = "DIST"; - display = "distributor"; - break; - case DON: - code = "DON"; - display = "donor"; - break; - case DST: - code = "DST"; - display = "destination"; - break; - case ELOC: - code = "ELOC"; - display = "entry location"; - break; - case ENT: - code = "ENT"; - display = " data entry person"; - break; - case ESC: - code = "ESC"; - display = "escort"; - break; - case HLD: - code = "HLD"; - display = "holder"; - break; - case IND: - code = "IND"; - display = "indirect target"; - break; - case INF: - code = "INF"; - display = "informant"; - break; - case IRCP: - code = "IRCP"; - display = "information recipient"; - break; - case LA: - code = "LA"; - display = "legal authenticator"; - break; - case LOC: - code = "LOC"; - display = "location"; - break; - case NOT: - code = "NOT"; - display = "ugent notification contact"; - break; - case NRD: - code = "NRD"; - display = "non-reuseable device"; - break; - case ORG: - code = "ORG"; - display = "origin"; - break; - case PPRF: - code = "PPRF"; - display = "primary performer"; - break; - case PRCP: - code = "PRCP"; - display = "primary information recipient"; - break; - case PRD: - code = "PRD"; - display = "product"; - break; - case RCT: - code = "RCT"; - display = "record target"; - break; - case RCV: - code = "RCV"; - display = "receiver"; - break; - case RDV: - code = "RDV"; - display = "reusable device"; - break; - case REF: - code = "REF"; - display = "referrer"; - break; - case REFB: - code = "REFB"; - display = "Referred By"; - break; - case REFT: - code = "REFT"; - display = "Referred to"; - break; - case RESP: - code = "RESP"; - display = "responsible party"; - break; - case RML: - code = "RML"; - display = "remote"; - break; - case SPC: - code = "SPC"; - display = "specimen"; - break; - case SPRF: - code = "SPRF"; - display = "secondary performer"; - break; - case TRC: - code = "TRC"; - display = "tracker"; - break; - case VIA: - code = "VIA"; - display = "via"; - break; - case VRF: - code = "VRF"; - display = "verifier"; - break; - case WIT: - code = "WIT"; - display = "witness"; - break; - default: - break; - } - if (code != null && display != null) { - fhirParticipationType.setCode(code); - fhirParticipationType.setDisplay(display); - } - return fhirParticipationType; - } - - @Override - public UnitsOfTime tPeriodUnit2UnitsOfTime(String cdaPeriodUnit) { - switch (cdaPeriodUnit.toLowerCase()) { - case "a": - return UnitsOfTime.A; - case "d": - return UnitsOfTime.D; - case "h": - return UnitsOfTime.H; - case "min": - return UnitsOfTime.MIN; - case "mo": - return UnitsOfTime.MO; - case "s": - return UnitsOfTime.S; - case "wk": - return UnitsOfTime.WK; - default: - return null; - } - } - - @Override - public AddressType tPostalAddressUse2AddressType(PostalAddressUse cdaPostalAddressUse) { - switch (cdaPostalAddressUse) { - case PHYS: - return AddressType.PHYSICAL; - case PST: - return AddressType.POSTAL; - default: - return null; - } - } - - @Override - public AddressUse tPostalAdressUse2AddressUse(PostalAddressUse cdaPostalAddressUse) { - switch (cdaPostalAddressUse) { - case HP: - case H: - return AddressUse.HOME; - case WP: - return AddressUse.WORK; - case TMP: - return AddressUse.TEMP; - case BAD: - return AddressUse.OLD; - default: - return AddressUse.TEMP; - } - } - - @Override - public Coding tProblemType2ConditionCategoryCodes(String cdaProblemType) { - // TODO: find a defined enum/valueset/codesystem for this. - // STU3 doesn't seem to have this so use DSTU2 definitions instead. - // https://www.hl7.org/fhir/DSTU2/valueset-condition-category.html - Coding c = new Coding().setSystem("http://hl7.org/fhir/condition-category"); - if (cdaProblemType == null) - return null; - switch (cdaProblemType) { - case "248536006": - case "373930000": - case "404684003": - case "75321-0": - case "75312-9": - // return ConditionCategoryCodesEnum.FINDING; - return c.setCode("finding").setDisplay("Finding"); - case "409586006": - case "75322-8": - case "75313-7": - // return ConditionCategoryCodesEnum.COMPLAINT; - return c.setCode("complaint").setDisplay("Complaint"); - case "282291009": - case "29308-4": - case "75314-5": - case "55607006": // problem - case "75318-6": - case "75323-6": // condition - case "75315-2": - case "64572001": - // return ConditionCategoryCodesEnum.DIAGNOSIS; - return c.setCode("diagnosis").setDisplay("Diagnosis"); - case "418799008": - case "75325-1": - case "75317-8": - // return ConditionCategoryCodesEnum.SYMPTOM; - return c.setCode("symptom").setDisplay("Symptom"); - - default: - return null; - } - } - - @Override - public DiagnosticReportStatus tResultOrganizerStatusCode2DiagnosticReportStatus( - String cdaResultOrganizerStatusCode) { - if (cdaResultOrganizerStatusCode == null) - return null; - - switch (cdaResultOrganizerStatusCode.toLowerCase()) { - case "aborted": - return DiagnosticReportStatus.CANCELLED; - case "active": - return DiagnosticReportStatus.PARTIAL; - case "cancelled": - return DiagnosticReportStatus.CANCELLED; - case "completed": - return DiagnosticReportStatus.FINAL; - case "held": - return DiagnosticReportStatus.REGISTERED; - case "suspended": - return DiagnosticReportStatus.ENTEREDINERROR; - default: - return null; - } - } - - @Override - public Coding tRoleCode2PatientContactRelationshipCode(String cdaRoleCode) { - if (cdaRoleCode == null) - return null; - - Coding fhirPatientContactRelationshipCode = new Coding(); - fhirPatientContactRelationshipCode.setSystem("http://hl7.org/fhir/v2/0131"); - String code = null; - String display = null; - - switch (cdaRoleCode.toLowerCase()) { - case "econ": // emergency contact - case "ext": // extended family member - case "guard": // guardian - case "frnd": // friend - case "sps": // spouse - case "dompart": // domestic partner - case "husb": // husband - case "wife": // wife - case "prn": // parent - case "fth": // father - case "mth": // mother - case "nprn": // natural parent - case "nfth": // natural father - case "nmth": // natural mother - case "prinlaw": // parent in-law - case "fthinlaw": // father in-law - case "mthinlaw": // mother in-law - case "stpprn": // step parent - case "stpfth": // stepfather - case "stpmth": // stepmother - code = "C"; - display = "Emergency Contact"; - break; // emergency contact - case "work": - code = "E"; - display = "Employer"; - break; // employer - case "fammemb": - code = "N"; - display = "Next-of-Kin"; - break; // family - default: - code = "O"; - display = "Other"; - break; // other - } - - fhirPatientContactRelationshipCode.setCode(code); - fhirPatientContactRelationshipCode.setDisplay(display); - return fhirPatientContactRelationshipCode; - } - - @Override - public AllergyIntoleranceSeverity tSeverityCode2AllergyIntoleranceSeverity(String cdaSeverityCode) { - if (cdaSeverityCode == null) - return null; - switch (cdaSeverityCode) { - case "255604002": - return AllergyIntoleranceSeverity.MILD; - case "371923003": - return AllergyIntoleranceSeverity.MILD; - case "6736007": - return AllergyIntoleranceSeverity.MODERATE; - case "371924009": - return AllergyIntoleranceSeverity.MODERATE; - case "24484000": - return AllergyIntoleranceSeverity.SEVERE; - case "399166001": - return AllergyIntoleranceSeverity.SEVERE; - default: - return null; - } - } - - @Override - public AllergyIntoleranceVerificationStatus tStatusCode2AllergyIntoleranceVerificationStatus(String cdaStatusCode) { - switch (cdaStatusCode.toLowerCase()) { - case "completed": - return AllergyIntoleranceVerificationStatus.CONFIRMED; - case "active": - return AllergyIntoleranceVerificationStatus.CONFIRMED; - case "suspended": - return AllergyIntoleranceVerificationStatus.UNCONFIRMED; - case "aborted": - return AllergyIntoleranceVerificationStatus.UNCONFIRMED; - default: - return null; - } - } - - @Override - public ConditionVerificationStatus tStatusCode2ConditionVerificationStatus(String cdaStatusCode) { - if (cdaStatusCode == null) { - return ConditionVerificationStatus.UNKNOWN; - } - switch (cdaStatusCode.toLowerCase()) { - case "completed": - return ConditionVerificationStatus.REFUTED; - case "active": - return ConditionVerificationStatus.CONFIRMED; - case "suspended": - return ConditionVerificationStatus.PROVISIONAL; - case "aborted": - return ConditionVerificationStatus.ENTEREDINERROR; - default: - return ConditionVerificationStatus.UNKNOWN; - } - } - - @Override - public EncounterStatus tStatusCode2EncounterStatusEnum(String cdaStatusCode) { - switch (cdaStatusCode.toLowerCase()) { - case "in-progress": - case "active": - return EncounterStatus.INPROGRESS; - case "onleave": - return EncounterStatus.ONLEAVE; - case "finished": - case "completed": - return EncounterStatus.FINISHED; - case "cancelled": - return EncounterStatus.CANCELLED; - case "planned": - return EncounterStatus.PLANNED; - case "arrived": - return EncounterStatus.ARRIVED; - default: - return null; - } - } - - @Override - public MedicationDispenseStatus tStatusCode2MedicationDispenseStatus(String cdaStatusCode) { - switch (cdaStatusCode.toLowerCase()) { - case "completed": - return MedicationDispenseStatus.COMPLETED; - case "aborted": - return MedicationDispenseStatus.STOPPED; - default: - return null; - } - } - - @Override - public MedicationStatementStatus tStatusCode2MedicationStatementStatus(String cdaStatusCode) { - switch (cdaStatusCode.toLowerCase()) { - case "active": - return MedicationStatementStatus.ACTIVE; - case "intended": - return MedicationStatementStatus.INTENDED; - case "completed": - return MedicationStatementStatus.COMPLETED; - case "nullified": - return MedicationStatementStatus.ENTEREDINERROR; - default: - return null; - } - } - - @Override - public ImmunizationStatus tStatusCode2ImmunizationStatus(String cdaStatusCode) { - if (cdaStatusCode == null) { - return null; - } - - switch (cdaStatusCode.toLowerCase()) { - case "active": - return ImmunizationStatus.COMPLETED; - case "completed": - return ImmunizationStatus.COMPLETED; - case "nullified": - return ImmunizationStatus.ENTEREDINERROR; - case "normal": - return ImmunizationStatus.COMPLETED; - case "new": - return ImmunizationStatus.COMPLETED; - case "aborted": - return ImmunizationStatus.ENTEREDINERROR; - case "suspended": - return ImmunizationStatus.ENTEREDINERROR; - case "cancelled": - return ImmunizationStatus.ENTEREDINERROR; - case "held": - return ImmunizationStatus.ENTEREDINERROR; - case "obselete": - return ImmunizationStatus.ENTEREDINERROR; - - default: - return null; - } - } - - @Override - public ProcedureStatus tStatusCode2ProcedureStatus(String cdaStatusCode) { - switch (cdaStatusCode.toLowerCase()) { - case "active": - return ProcedureStatus.INPROGRESS; - case "completed": - return ProcedureStatus.COMPLETED; - case "aborted": - return ProcedureStatus.ABORTED; - case "cancelled": - return ProcedureStatus.SUSPENDED; - default: - return ProcedureStatus.UNKNOWN; - } - } - - @Override - public ContactPointUse tTelecommunicationAddressUse2ContactPointUse( - TelecommunicationAddressUse cdaTelecommunicationAddressUse) { - switch (cdaTelecommunicationAddressUse) { - case H: - case HP: - return ContactPointUse.HOME; - case WP: - return ContactPointUse.WORK; - case TMP: - return ContactPointUse.TEMP; - case BAD: - return ContactPointUse.OLD; - case MC: - return ContactPointUse.MOBILE; - default: - return ContactPointUse.TEMP; - } - - } - - @Override - public ContactPointSystem tTelValue2ContactPointSystem(String cdaTelValue) { - if (cdaTelValue == null) - return null; - - switch (cdaTelValue.toLowerCase()) { - case "phone": - case "tel": - return ContactPointSystem.PHONE; - case "email": - case "mailto": - return ContactPointSystem.EMAIL; - case "fax": - return ContactPointSystem.FAX; - case "http": - case "https": - return ContactPointSystem.URL; - default: - return null; - } - } - - @Override - public AllergyIntoleranceClinicalStatus tProblemStatus2AllergyIntoleranceClinicalStatus(String code) { - if (code == null) { - return AllergyIntoleranceClinicalStatus.NULL; - } - switch (code) { - case "55561003": - return AllergyIntoleranceClinicalStatus.ACTIVE; - case "73425007": - return AllergyIntoleranceClinicalStatus.INACTIVE; - case "413322009": - return AllergyIntoleranceClinicalStatus.RESOLVED; - default: - return AllergyIntoleranceClinicalStatus.NULL; - } - } - - @Override - public ConditionClinicalStatus tProblemStatus2ConditionClinicalStatus(String code) { - if (code == null) { - return ConditionClinicalStatus.NULL; - } - switch (code) { - case "55561003": - return ConditionClinicalStatus.ACTIVE; - case "73425007": - return ConditionClinicalStatus.INACTIVE; - case "413322009": - return ConditionClinicalStatus.RESOLVED; - default: - return ConditionClinicalStatus.NULL; - } - } -} \ No newline at end of file diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/CDAIIResourceMaps.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/CDAIIResourceMaps.java deleted file mode 100644 index 26fb6abc7..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/CDAIIResourceMaps.java +++ /dev/null @@ -1,134 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.util.ICDAIIResourceMaps; -import tr.com.srdc.cda2fhir.transform.util.ICDAIIResourceMapsSource; -import tr.com.srdc.cda2fhir.transform.util.impl.CDAIIMap; - -public class CDAIIResourceMaps implements ICDAIIResourceMaps, ICDAIIResourceMapsSource { - Map, CDAIIMap> iiMaps = new HashMap, CDAIIMap>(); - - @Override - public boolean hasMap(Class clazz) { - return iiMaps.containsKey(clazz); - } - - @Override - public CDAIIMap getMap(Class clazz) { - return iiMaps.get(clazz); - } - - @Override - public void putMap(Class clazz, CDAIIMap map) { - iiMaps.put(clazz, map); - } - - @Override - public boolean hasMapValues() { - return iiMaps.values().parallelStream().filter(e -> e.hasIIMapValues()).findAny().isPresent(); - } - - @Override - public T get(II ii, Class clazz) { - if (hasMap(clazz)) { - CDAIIMap iiMap = this.getMap(clazz); - - if (iiMap.hasIIMapValues() && iiMap.get(ii) != null) { - return iiMap.get(ii); - } - } - return null; - } - - @Override - public T get(List iis, Class clazz) { - if (hasMap(clazz)) { - CDAIIMap iiMap = getMap(clazz); - if (iiMap.hasIIMapValues() && iiMap.get(iis) != null) { - return iiMap.get(iis); - } - } - return null; - } - - @Override - public void putRootValuesTo(Class clazz, Map target) { - if (iiMaps.containsKey(clazz)) { - CDAIIMap iiMap = iiMaps.get(clazz); - iiMap.putRootValuesTo(target); - } - - } - - @Override - public void putExtensionValuesTo(Class clazz, Map> target) { - if (iiMaps.containsKey(clazz)) { - CDAIIMap iiMap = iiMaps.get(clazz); - iiMap.putExtensionValuesTo(target); - } - - } - - @Override - public Collection> keySet() { - return iiMaps.keySet(); - } - - @Override - public Collection> values() { - return iiMaps.values(); - } - - @Override - public void put(ICDAIIResourceMapsSource sourceMaps) { - - for (Class clazz : sourceMaps.keySet()) { - - CDAIIMap iiMap = this.getMap(clazz); - CDAIIMap iiMapSource = sourceMaps.getMap(clazz); - - if (iiMapSource != null) { - if (iiMap != null) { - - iiMap.put(iiMapSource); - - } else { - iiMap = new CDAIIMap(); - iiMaps.put(clazz, iiMap); - iiMap.put(iiMapSource); - } - } - } - } - - @Override - public void put(List iis, Class clazz, T t) { - CDAIIMap iiMap = iiMaps.get(clazz); - if (iiMap != null) { - iiMap.put(iis, t); - } else { - iiMap = new CDAIIMap(); - iiMap.put(iis, t); - iiMaps.put(clazz, iiMap); - } - } - - @Override - public void put(II ii, Class clazz, T t) { - CDAIIMap iiMap = iiMaps.get(clazz); - if (iiMap != null) { - iiMap.put(ii, t); - } else { - iiMap = new CDAIIMap(); - iiMap.put(ii, t); - iiMaps.put(clazz, iiMap); - } - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IEntityInfo.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IEntityInfo.java deleted file mode 100644 index 94acd93fa..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IEntityInfo.java +++ /dev/null @@ -1,20 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry; - -import org.hl7.fhir.dstu3.model.Device; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; - -public interface IEntityInfo { - Practitioner getPractitioner(); - - PractitionerRole getPractitionerRole(); - - Organization getOrganization(); - - boolean isOrgNew(); - - void setOrgIsNew(boolean orgIsNew); - - Device getDevice(); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IEntityResult.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IEntityResult.java deleted file mode 100644 index 59e12c7c2..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IEntityResult.java +++ /dev/null @@ -1,51 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -public interface IEntityResult extends IEntityInfo { - boolean isFromExisting(); - - List getNewIds(); - - IEntityInfo getInfo(); - - void copyTo(Bundle bundle); - - boolean isEmpty(); - - Bundle getBundle(); - - boolean hasPractitioner(); - - boolean hasOrganization(); - - boolean hasPractitionerRole(); - - boolean hasPractitionerRoleCode(); - - boolean hasDevice(); - - Reference getPractitionerReference(); - - Reference getOrganizationReference(); - - Reference getPractitionerRoleReference(); - - CodeableConcept getPractitionerRoleCode(); - - String getPractitionerId(); - - boolean hasIIResourceMaps(); - - CDAIIResourceMaps getResourceMaps(); - - void put(List iis, Class clazz, IBaseResource resource); - - String getDeviceId(); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IEntryResult.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IEntryResult.java deleted file mode 100644 index a91a4b881..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IEntryResult.java +++ /dev/null @@ -1,20 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Resource; -import org.hl7.fhir.instance.model.api.IBaseResource; - -import tr.com.srdc.cda2fhir.transform.util.IResult; - -public interface IEntryResult extends IResult { - Bundle getBundle(); - - Bundle getFullBundle(); - - void copyTo(Bundle bundle); - - boolean hasResult(); - - IBaseResource findResourceResult(Class clazz); - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IMedicationsInformation.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IMedicationsInformation.java deleted file mode 100644 index 58ee61aaa..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/IMedicationsInformation.java +++ /dev/null @@ -1,19 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Medication; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -public interface IMedicationsInformation { - - boolean containsMedication(CD cd, List iis); - - void putMedication(Medication med, CD code, List iis); - - Medication getMedication(CD cd, List iis); - - void putMedication(Medication med, CD code); - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/DeferredProcedureEncounterReference.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/DeferredProcedureEncounterReference.java deleted file mode 100644 index 9f7fdbce6..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/DeferredProcedureEncounterReference.java +++ /dev/null @@ -1,38 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry.impl; - -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Procedure; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.dstu3.model.Resource; - -import tr.com.srdc.cda2fhir.transform.util.IDeferredReference; - -public class DeferredProcedureEncounterReference implements IDeferredReference { - private Procedure procedure; - private Identifier identifier; - - public DeferredProcedureEncounterReference(Procedure procedure, Identifier identifier) { - this.procedure = procedure; - this.identifier = identifier; - } - - @Override - public String getFhirType() { - return "Encounter"; - } - - @Override - public Identifier getIdentifier() { - return identifier; - } - - @Override - public Resource getResource() { - return procedure; - } - - @Override - public void resolve(Reference reference) { - procedure.setContext(reference); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/EntityInfo.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/EntityInfo.java deleted file mode 100644 index 5b2538880..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/EntityInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry.impl; - -import org.hl7.fhir.dstu3.model.Device; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; - -import tr.com.srdc.cda2fhir.transform.entry.IEntityInfo; - -public class EntityInfo implements IEntityInfo { - private Practitioner practitioner; - private PractitionerRole role; - private Organization organization; - - private boolean orgIsNew = false; - private Device device; - - public void setPractitioner(Practitioner practitioner) { - this.practitioner = practitioner; - } - - public void setPractitionerRole(PractitionerRole practitionerRole) { - this.role = practitionerRole; - } - - public void setOrganization(Organization organization) { - this.organization = organization; - } - - public void setDevice(Device device) { - this.device = device; - } - - @Override - public Practitioner getPractitioner() { - return practitioner; - } - - @Override - public PractitionerRole getPractitionerRole() { - return role; - } - - @Override - public Organization getOrganization() { - return organization; - } - - @Override - public boolean isOrgNew() { - return orgIsNew; - } - - @Override - public void setOrgIsNew(boolean orgIsNew) { - this.orgIsNew = orgIsNew; - } - - @Override - public Device getDevice() { - return device; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/EntityResult.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/EntityResult.java deleted file mode 100644 index 6d4ff3e8e..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/EntityResult.java +++ /dev/null @@ -1,224 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry.impl; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Device; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.entry.CDAIIResourceMaps; -import tr.com.srdc.cda2fhir.transform.entry.IEntityInfo; -import tr.com.srdc.cda2fhir.transform.entry.IEntityResult; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; - -public class EntityResult implements IEntityResult { - private IEntityInfo info; - private List ids; - private CDAIIResourceMaps resourceMaps; - private boolean fromExisting; - - public EntityResult() { - info = new EntityInfo(); - fromExisting = true; - } - - public EntityResult(IEntityInfo info) { - this.info = info; - fromExisting = true; - } - - public EntityResult(IEntityInfo info, List ids) { - this.info = info; - this.ids = ids; - fromExisting = false; - } - - @Override - public boolean isFromExisting() { - return fromExisting; - } - - @Override - public List getNewIds() { - return ids; - } - - @Override - public IEntityInfo getInfo() { - return info; - } - - @Override - public void copyTo(Bundle bundle) { - Practitioner practitioner = info.getPractitioner(); - if (practitioner != null) { - bundle.addEntry().setResource(practitioner); - } - PractitionerRole role = info.getPractitionerRole(); - if (role != null) { - bundle.addEntry().setResource(role); - } - - Organization organization = info.getOrganization(); - if (organization != null && info.isOrgNew()) { - bundle.addEntry().setResource(organization); - } - } - - @Override - public Bundle getBundle() { - if (!isEmpty()) { - Bundle result = new Bundle(); - copyTo(result); - return result; - } - return null; - } - - @Override - public boolean isEmpty() { - return info.getPractitioner() == null && info.getPractitionerRole() == null && info.getOrganization() == null; - } - - @Override - public boolean hasPractitioner() { - return info.getPractitioner() != null; - } - - @Override - public boolean hasOrganization() { - return info.getOrganization() != null; - } - - @Override - public boolean hasPractitionerRole() { - return info.getPractitionerRole() != null; - } - - @Override - public boolean hasPractitionerRoleCode() { - PractitionerRole role = info.getPractitionerRole(); - return role != null && role.hasCode(); - } - - @Override - public boolean hasDevice() { - return info.getDevice() != null; - } - - @Override - public Practitioner getPractitioner() { - return info.getPractitioner(); - } - - @Override - public PractitionerRole getPractitionerRole() { - return info.getPractitionerRole(); - } - - @Override - public Organization getOrganization() { - return info.getOrganization(); - } - - @Override - public Device getDevice() { - return info.getDevice(); - } - - @Override - public Reference getPractitionerReference() { - Practitioner practitioner = info.getPractitioner(); - if (practitioner != null) { - return new Reference(practitioner.getId()); - } - return null; - } - - @Override - public Reference getOrganizationReference() { - Organization organization = info.getOrganization(); - if (organization != null) { - return new Reference(organization.getId()); - } - return null; - } - - @Override - public Reference getPractitionerRoleReference() { - PractitionerRole role = info.getPractitionerRole(); - if (role != null) { - return new Reference(role.getId()); - } - return null; - } - - @Override - public CodeableConcept getPractitionerRoleCode() { - PractitionerRole role = info.getPractitionerRole(); - if (role != null && role.hasCode()) { - return role.getCode().get(0); - } - return null; - } - - @Override - public String getPractitionerId() { - Practitioner practitioner = info.getPractitioner(); - if (practitioner != null) { - return practitioner.getId(); - } - return null; - } - - @Override - public boolean hasIIResourceMaps() { - return resourceMaps != null; - } - - @Override - public CDAIIResourceMaps getResourceMaps() { - return resourceMaps; - } - - @Override - public void put(List iis, Class clazz, IBaseResource resource) { - if (iis != null && clazz != null && resource != null) { - this.resourceMaps.put(iis, clazz, resource); - } - } - - public void updateFrom(IEntryResult result) { - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - if (result.hasIIResourceMaps()) { - resourceMaps.put(result.getResourceMaps()); - } - } - - @Override - public boolean isOrgNew() { - return info.isOrgNew(); - } - - @Override - public void setOrgIsNew(boolean orgIsNew) { - info.setOrgIsNew(orgIsNew); - } - - @Override - public String getDeviceId() { - Device device = info.getDevice(); - if (device != null) { - return device.getId(); - } - return null; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/EntryResult.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/EntryResult.java deleted file mode 100644 index 87bdd8b5e..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/EntryResult.java +++ /dev/null @@ -1,337 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.dstu3.model.Resource; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.entry.CDAIIResourceMaps; -import tr.com.srdc.cda2fhir.transform.entry.IEntityInfo; -import tr.com.srdc.cda2fhir.transform.entry.IEntityResult; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.entry.IMedicationsInformation; -import tr.com.srdc.cda2fhir.transform.util.IDeferredReference; -import tr.com.srdc.cda2fhir.transform.util.impl.CDACDMap; -import tr.com.srdc.cda2fhir.transform.util.impl.CDAIIMap; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class EntryResult implements IEntryResult { - - private Bundle newResourceBundle; - private Bundle fullBundle; - private List deferredReferences; - private CDAIIMap entities; - private CDAIIResourceMaps resourceMaps; - private CDACDMap cdMap; - - @Override - public Bundle getBundle() { - return newResourceBundle; - } - - @Override - public Bundle getFullBundle() { - return fullBundle; - } - - @Override - public void copyTo(Bundle bundle) { - if (bundle != null) { - FHIRUtil.mergeBundle(this.newResourceBundle, bundle); - } - } - - @Override - public IBaseResource findResourceResult(Class clazz) { - if (this.hasResult() && !FHIRUtil.findResources(this.newResourceBundle, clazz).isEmpty()) { - return findNewResource(clazz); - } else { - return findExistingResource(clazz); - } - } - - private IBaseResource findNewResource(Class clazz) { - if (newResourceBundle == null || newResourceBundle.isEmpty()) { - return null; - } else { - return FHIRUtil.findFirstResource(this.newResourceBundle, clazz); - } - } - - private IBaseResource findExistingResource(Class clazz) { - if (fullBundle == null || fullBundle.isEmpty()) { - return null; - } else { - return FHIRUtil.findFirstResource(fullBundle, clazz); - } - } - - public void addResource(Resource resource) { - if (newResourceBundle == null) { - newResourceBundle = new Bundle(); - } - if (fullBundle == null) { - fullBundle = new Bundle(); - } - newResourceBundle.addEntry(new BundleEntryComponent().setResource(resource)); - fullBundle.addEntry(new BundleEntryComponent().setResource(resource)); - - } - - public void addExistingResource(Resource resource) { - if (fullBundle == null) { - fullBundle = new Bundle(); - } - fullBundle.addEntry(new BundleEntryComponent().setResource(resource)); - } - - public void updateBundleFrom(IEntryResult entryResult) { - // copy external bundle's new resources to both our new resource bundle - // as well as our full bundle. The resources not in the new resource bundle - // are presumably already recorded and can be ignored. - if (newResourceBundle == null) { - newResourceBundle = new Bundle(); - } - entryResult.copyTo(newResourceBundle); - if (fullBundle == null) { - fullBundle = new Bundle(); - } - entryResult.copyTo(fullBundle); - if (entryResult.hasDeferredReferences()) { - addDeferredReferences(entryResult.getDeferredReferences()); - } - } - - public void updateMapsFrom(IEntryResult entryResult) { - updateEntitiesFrom(entryResult); - updateIIResourcesFrom(entryResult); - updateCDResourcesFrom(entryResult); - } - - @Override - public void updateFrom(IEntryResult entryResult) { - if (entryResult.hasDeferredReferences()) { - addDeferredReferences(entryResult.getDeferredReferences()); - } - if (entryResult.hasResult()) { - updateBundleFrom(entryResult); - } - if (entryResult.hasMapValues()) { - updateMapsFrom(entryResult); - } - - } - - public void addDeferredReferences(List references) { - if (deferredReferences == null) { - deferredReferences = new ArrayList(); - } - deferredReferences.addAll(references); - } - - public void updateFrom(IEntityResult entityResult) { - List iis = entityResult.getNewIds(); - if (iis != null) { - if (newResourceBundle == null) { - newResourceBundle = new Bundle(); - } - if (fullBundle == null) { - fullBundle = new Bundle(); - } - entityResult.copyTo(newResourceBundle); - entityResult.copyTo(fullBundle); - if (entities == null) { - entities = new CDAIIMap(); - } - entities.put(iis, entityResult.getInfo()); - } else if (!entityResult.isFromExisting()) { - if (newResourceBundle == null) { - newResourceBundle = new Bundle(); - } - if (fullBundle == null) { - fullBundle = new Bundle(); - } - entityResult.copyTo(newResourceBundle); - entityResult.copyTo(fullBundle); - } - if (entityResult.hasIIResourceMaps()) { - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - resourceMaps.put(entityResult.getResourceMaps()); - } - - } - - public void updateEntitiesFrom(IEntryResult entryResult) { - if (entryResult.hasEntities()) { - if (entities == null) { - entities = new CDAIIMap(); - } - entities.put(entryResult); - - } - } - - public void updateIIResourcesFrom(IEntryResult entryResult) { - if (entryResult.hasIIResourceMaps()) { - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - resourceMaps.put(entryResult); - } - } - - public void updateCDResourcesFrom(IEntryResult entryResult) { - if (entryResult.hasCDMap()) { - if (cdMap == null) { - cdMap = new CDACDMap(); - } - cdMap.put(entryResult); - } - } - - public void addDeferredReference(IDeferredReference deferredReference) { - if (deferredReferences == null) { - deferredReferences = new ArrayList(); - } - deferredReferences.add(deferredReference); - } - - @Override - public boolean hasDeferredReferences() { - return deferredReferences != null && !deferredReferences.isEmpty(); - } - - @Override - public List getDeferredReferences() { - return deferredReferences; - } - - @Override - public void putRootValuesTo(Map target) { - if (entities != null) { - entities.putRootValuesTo(target); - } - } - - @Override - public void putExtensionValuesTo(Map> target) { - if (entities != null) { - entities.putExtensionValuesTo(target); - } - } - - @Override - public boolean hasEntities() { - return entities != null; - } - - @Override - public boolean hasIIResourceMaps() { - return resourceMaps != null; - } - - @Override - public boolean hasCDMap() { - return cdMap != null; - } - - @Override - public boolean hasIIMapValues() { - return entities != null || resourceMaps != null; - } - - @Override - public boolean hasMapValues() { - return entities != null || resourceMaps != null || cdMap != null; - } - - @Override - public boolean hasResult() { - return this.newResourceBundle != null && !this.newResourceBundle.isEmpty(); - } - - @Override - public void putRootValuesTo(Class clazz, Map target) { - if (resourceMaps != null) { - resourceMaps.putRootValuesTo(clazz, target); - } - - } - - @Override - public void putExtensionValuesTo(Class clazz, - Map> target) { - if (resourceMaps != null) { - resourceMaps.putExtensionValuesTo(clazz, target); - } - } - - @Override - public CDAIIMap getMap(Class clazz) { - return resourceMaps.getMap(clazz); - } - - @Override - public void putMap(Class clazz, CDAIIMap map) { - resourceMaps.putMap(clazz, map); - } - - @Override - public void putCDValuesTo(Map target) { - if (cdMap != null) { - cdMap.putCDValuesTo(target); - } - } - - @Override - public boolean hasCDMapValues() { - return cdMap != null && cdMap.hasCDMapValues(); - } - - @Override - public void putCDResource(CD cd, IMedicationsInformation resource) { - if (cdMap == null) { - cdMap = new CDACDMap(); - } - cdMap.put(cd, resource); - } - - @Override - public void putIIResource(II ii, Class clazz, IBaseResource resource) { - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - resourceMaps.put(ii, clazz, resource); - } - - @Override - public void putIIResource(List iis, Class clazz, IBaseResource resource) { - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - resourceMaps.put(iis, clazz, resource); - } - - @Override - public CDAIIResourceMaps getResourceMaps() { - return resourceMaps; - } - - @Override - public Collection> keySet() { - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - return resourceMaps.keySet(); - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/MedicationsInformation.java b/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/MedicationsInformation.java deleted file mode 100644 index 422f4413f..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/entry/impl/MedicationsInformation.java +++ /dev/null @@ -1,126 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.entry.impl; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Medication; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.entry.IMedicationsInformation; -import tr.com.srdc.cda2fhir.transform.util.impl.CDACDMap; -import tr.com.srdc.cda2fhir.transform.util.impl.CDAIIMap; - -public class MedicationsInformation implements IMedicationsInformation { - - private CDACDMap medContainers = new CDACDMap(); - - private class MedicationContainer { - private CD code; - - // Mapping of organization IDs to medication. - // Used to ensure medications with different organizations - // are not treated as duplicates. - CDAIIMap orgIIMap = null; - - // Medication instance set only when no organization is present. - // Used to determine whether a medication without an organization is a - // duplicate. - private Medication medication = null; - - public MedicationContainer(Medication medication, CD code, List iis) { - this.code = code; - if (iis != null) { - orgIIMap = new CDAIIMap(); - orgIIMap.put(iis, medication); - } - } - - public MedicationContainer(Medication medication, CD code) { - this.code = code; - this.medication = medication; - } - - private boolean checkIds(List iis) { - if (iis == null && this.medication != null) { - return true; - } else if (orgIIMap == null || iis == null) { - return false; - } - - return orgIIMap.get(iis) != null; - - } - - public boolean isMedication(CD cd, List iis) { - if (cd == null || code == null) { - return false; - } - - // No need to check cds at this point because this is contained - // in a cd map - return checkIds(iis); - - } - - public Medication getMedication(List iis) { - if (iis != null && orgIIMap.get(iis) != null) { - return orgIIMap.get(iis); - } else if (iis == null && this.medication != null) { - return this.medication; - } - return null; - } - - } - - public MedicationsInformation(Medication fhirMedication, CD cd, List orgIds) { - - MedicationContainer medContainer; - if (orgIds == null) { - medContainer = new MedicationContainer(fhirMedication, cd); - } else { - medContainer = new MedicationContainer(fhirMedication, cd, orgIds); - } - medContainers.put(cd, medContainer); - } - - @Override - public boolean containsMedication(CD cd, List iis) { - MedicationContainer medContainer = medContainers.get(cd); - - if (medContainer != null) { - return medContainer.isMedication(cd, iis); - } - return false; - } - - @Override - public Medication getMedication(CD cd, List iis) { - MedicationContainer medContainer = medContainers.get(cd); - - if (medContainer != null) { - if (medContainer.isMedication(cd, iis)) { - return medContainer.getMedication(iis); - } - } - return null; - - } - - @Override - public void putMedication(Medication med, CD code, List iis) { - if (!containsMedication(code, iis)) { - MedicationContainer medContainer = new MedicationContainer(med, code, iis); - medContainers.put(code, medContainer); - } - } - - @Override - public void putMedication(Medication med, CD code) { - if (!containsMedication(code, null)) { - MedicationContainer medContainer = new MedicationContainer(med, code); - medContainers.put(code, medContainer); - } - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/CDASectionTypeEnum.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/CDASectionTypeEnum.java deleted file mode 100644 index 15c2ae034..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/CDASectionTypeEnum.java +++ /dev/null @@ -1,336 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section; - -import org.openhealthtools.mdht.uml.cda.Section; -import org.openhealthtools.mdht.uml.cda.consol.MedicationsSection; -import org.openhealthtools.mdht.uml.cda.consol.PayersSection; -import org.openhealthtools.mdht.uml.cda.consol.PlanOfCareSection; -import org.openhealthtools.mdht.uml.cda.consol.ProblemSection; -import org.openhealthtools.mdht.uml.cda.consol.ProceduresSection; -import org.openhealthtools.mdht.uml.cda.consol.ResultsSection; -import org.openhealthtools.mdht.uml.cda.consol.SocialHistorySection; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSection; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSectionEntriesOptional; -import org.openhealthtools.mdht.uml.cda.consol.AdvanceDirectivesSection; -import org.openhealthtools.mdht.uml.cda.consol.AllergiesSection; -import org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument; -import org.openhealthtools.mdht.uml.cda.consol.EncountersSection; -import org.openhealthtools.mdht.uml.cda.consol.EncountersSectionEntriesOptional; -import org.openhealthtools.mdht.uml.cda.consol.FamilyHistorySection; -import org.openhealthtools.mdht.uml.cda.consol.FunctionalStatusSection; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationsSection; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationsSectionEntriesOptional; -import org.openhealthtools.mdht.uml.cda.consol.MedicalEquipmentSection; - -import tr.com.srdc.cda2fhir.transform.section.impl.CDAAllergiesSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAEncountersSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAEncountersSectionEntriesOptional; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAFamilyHistorySection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAFunctionalStatusSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAImmunizationsSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAImmunizationsSectionEntriesOptional; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAMedicalEquipmentSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAMedicationsSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAProblemsSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAProceduresSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAResultsSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDASocialHistorySection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAUnplementedSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAVitalSignsSection; -import tr.com.srdc.cda2fhir.transform.section.impl.CDAVitalSignsSectionEntriesOptional; - -public enum CDASectionTypeEnum { - ALLERGIES_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof AllergiesSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAAllergiesSection((AllergiesSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAAllergiesSection(ccd.getAllergiesSection()); - } - }, - IMMUNIZATIONS_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof ImmunizationsSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAImmunizationsSection((ImmunizationsSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return null; - } - }, - IMMUNIZATIONS_SECTION_ENTRIES_OPTIONAL { - @Override - public boolean supports(Section section) { - return section instanceof ImmunizationsSectionEntriesOptional; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAImmunizationsSectionEntriesOptional((ImmunizationsSectionEntriesOptional) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAImmunizationsSectionEntriesOptional(ccd.getImmunizationsSectionEntriesOptional()); - } - }, - MEDICATIONS_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof MedicationsSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAMedicationsSection((MedicationsSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAMedicationsSection(ccd.getMedicationsSection()); - } - }, - PROBLEM_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof ProblemSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAProblemsSection((ProblemSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAProblemsSection(ccd.getProblemSection()); - } - }, - PROCEDURES_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof ProceduresSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAProceduresSection((ProceduresSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAProceduresSection(ccd.getProceduresSection()); - } - }, - ENCOUNTERS_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof EncountersSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAEncountersSection((EncountersSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAEncountersSection(ccd.getEncountersSection()); - } - }, - ENCOUNTERS_SECTION_ENTRIES_OPTIONAL { - @Override - public boolean supports(Section section) { - return section instanceof EncountersSectionEntriesOptional; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAEncountersSectionEntriesOptional((EncountersSectionEntriesOptional) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return null; - } - }, - VITAL_SIGNS_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof VitalSignsSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAVitalSignsSection((VitalSignsSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return null; - } - }, - VITAL_SIGNS_SECTION_ENTRIES_OPTIONAL { - @Override - public boolean supports(Section section) { - return section instanceof VitalSignsSectionEntriesOptional; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAVitalSignsSectionEntriesOptional((VitalSignsSectionEntriesOptional) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAVitalSignsSectionEntriesOptional(ccd.getVitalSignsSectionEntriesOptional()); - } - }, - SOCIAL_HISTORY_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof SocialHistorySection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDASocialHistorySection((SocialHistorySection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDASocialHistorySection(ccd.getSocialHistorySection()); - } - }, - RESULTS_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof ResultsSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAResultsSection((ResultsSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAResultsSection(ccd.getResultsSection()); - } - }, - FUNCTIONAL_STATUS_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof FunctionalStatusSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAFunctionalStatusSection((FunctionalStatusSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAFunctionalStatusSection(ccd.getFunctionalStatusSection()); - } - }, - FAMILY_HISTORY_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof FamilyHistorySection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAFamilyHistorySection((FamilyHistorySection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAFamilyHistorySection(ccd.getFamilyHistorySection()); - } - }, - MEDICAL_EQUIPMENT_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof MedicalEquipmentSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAMedicalEquipmentSection((MedicalEquipmentSection) section); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAMedicalEquipmentSection(ccd.getMedicalEquipmentSection()); - } - }, - ADVANCED_DIRECTIVES_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof AdvanceDirectivesSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAUnplementedSection(); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAUnplementedSection(); - } - }, - PAYERS_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof PayersSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAUnplementedSection(); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAUnplementedSection(); - } - }, - PLAN_OF_CARE_SECTION { - @Override - public boolean supports(Section section) { - return section instanceof PlanOfCareSection; - } - - @Override - public ICDASection toCDASection(Section section) { - return new CDAUnplementedSection(); - } - - @Override - public ICDASection toCDASection(ContinuityOfCareDocument ccd) { - return new CDAUnplementedSection(); - } - }; - - public abstract boolean supports(Section section); - - public abstract ICDASection toCDASection(Section section); - - public abstract ICDASection toCDASection(ContinuityOfCareDocument ccd); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/ICDASection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/ICDASection.java deleted file mode 100644 index 3808e4a88..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/ICDASection.java +++ /dev/null @@ -1,7 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section; - -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public interface ICDASection { - ISectionResult transform(IBundleInfo bundleInfo); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/ISectionResult.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/ISectionResult.java deleted file mode 100644 index a6e73c15f..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/ISectionResult.java +++ /dev/null @@ -1,16 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Resource; - -import tr.com.srdc.cda2fhir.transform.util.IResult; - -public interface ISectionResult extends IResult { - Bundle getBundle(); - - List getSectionResources(); - - boolean hasResourceMaps(); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAAllergiesSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAAllergiesSection.java deleted file mode 100644 index b057c0e5e..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAAllergiesSection.java +++ /dev/null @@ -1,36 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -import org.openhealthtools.mdht.uml.cda.consol.AllergiesSection; -import org.openhealthtools.mdht.uml.cda.consol.AllergyProblemAct; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.LocalBundleInfo; - -public class CDAAllergiesSection implements ICDASection { - private AllergiesSection section; - - @SuppressWarnings("unused") - private CDAAllergiesSection() { - }; - - public CDAAllergiesSection(AllergiesSection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular.getInstance(AllergyIntolerance.class); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - for (AllergyProblemAct act : section.getAllergyProblemActs()) { - IEntryResult er = rt.tAllergyProblemAct2AllergyIntolerance(act, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - return result; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAEncountersSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAEncountersSection.java deleted file mode 100644 index 82ad55e6f..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAEncountersSection.java +++ /dev/null @@ -1,24 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Encounter; -import org.openhealthtools.mdht.uml.cda.consol.EncountersSection; - -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public class CDAEncountersSection implements ICDASection { - private EncountersSection section; - - @SuppressWarnings("unused") - private CDAEncountersSection() { - }; - - public CDAEncountersSection(EncountersSection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - return CDASectionCommon.transformEncounterActivitiesList(section.getEncounterActivitiess(), bundleInfo); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAEncountersSectionEntriesOptional.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAEncountersSectionEntriesOptional.java deleted file mode 100644 index 45ae9ef35..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAEncountersSectionEntriesOptional.java +++ /dev/null @@ -1,24 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Encounter; -import org.openhealthtools.mdht.uml.cda.consol.EncountersSectionEntriesOptional; - -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public class CDAEncountersSectionEntriesOptional implements ICDASection { - private EncountersSectionEntriesOptional section; - - @SuppressWarnings("unused") - private CDAEncountersSectionEntriesOptional() { - }; - - public CDAEncountersSectionEntriesOptional(EncountersSectionEntriesOptional section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - return CDASectionCommon.transformEncounterActivitiesList(section.getEncounterActivitiess(), bundleInfo); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAFamilyHistorySection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAFamilyHistorySection.java deleted file mode 100644 index 35cbce1bf..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAFamilyHistorySection.java +++ /dev/null @@ -1,33 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.FamilyMemberHistory; -import org.openhealthtools.mdht.uml.cda.consol.FamilyHistoryOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.FamilyHistorySection; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public class CDAFamilyHistorySection implements ICDASection { - private FamilyHistorySection section; - - @SuppressWarnings("unused") - private CDAFamilyHistorySection() { - }; - - public CDAFamilyHistorySection(FamilyHistorySection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - Bundle result = new Bundle(); - for (FamilyHistoryOrganizer org : section.getFamilyHistories()) { - FamilyMemberHistory fmh = rt.tFamilyHistoryOrganizer2FamilyMemberHistory(org); - result.addEntry().setResource(fmh); - } - return SectionResultSingular.getInstance(result, FamilyMemberHistory.class); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAFunctionalStatusSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAFunctionalStatusSection.java deleted file mode 100644 index 9375627bf..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAFunctionalStatusSection.java +++ /dev/null @@ -1,38 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Observation; -import org.openhealthtools.mdht.uml.cda.consol.FunctionalStatusResultOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.FunctionalStatusSection; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.LocalBundleInfo; - -public class CDAFunctionalStatusSection implements ICDASection { - private FunctionalStatusSection section; - - @SuppressWarnings("unused") - private CDAFunctionalStatusSection() { - }; - - public CDAFunctionalStatusSection(FunctionalStatusSection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular.getInstance(Observation.class); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - for (FunctionalStatusResultOrganizer org : section.getFunctionalStatusResultOrganizers()) { - for (org.openhealthtools.mdht.uml.cda.Observation obs : org.getObservations()) { - IEntryResult er = rt.tFunctionalStatus2Observation(obs, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - } - return result; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAImmunizationsSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAImmunizationsSection.java deleted file mode 100644 index 3ef117dee..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAImmunizationsSection.java +++ /dev/null @@ -1,24 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Immunization; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationsSection; - -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public class CDAImmunizationsSection implements ICDASection { - private ImmunizationsSection section; - - @SuppressWarnings("unused") - private CDAImmunizationsSection() { - }; - - public CDAImmunizationsSection(ImmunizationsSection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - return CDASectionCommon.transformImmunizationActivityList(section.getImmunizationActivities(), bundleInfo); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAImmunizationsSectionEntriesOptional.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAImmunizationsSectionEntriesOptional.java deleted file mode 100644 index 6e6b6a041..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAImmunizationsSectionEntriesOptional.java +++ /dev/null @@ -1,24 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Immunization; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationsSectionEntriesOptional; - -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public class CDAImmunizationsSectionEntriesOptional implements ICDASection { - private ImmunizationsSectionEntriesOptional section; - - @SuppressWarnings("unused") - private CDAImmunizationsSectionEntriesOptional() { - }; - - public CDAImmunizationsSectionEntriesOptional(ImmunizationsSectionEntriesOptional section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - return CDASectionCommon.transformImmunizationActivityList(section.getImmunizationActivities(), bundleInfo); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAMedicalEquipmentSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAMedicalEquipmentSection.java deleted file mode 100644 index 7616d568f..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAMedicalEquipmentSection.java +++ /dev/null @@ -1,55 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Device; -import org.openhealthtools.mdht.uml.cda.Organizer; -import org.openhealthtools.mdht.uml.cda.Procedure; -import org.openhealthtools.mdht.uml.cda.Supply; -import org.openhealthtools.mdht.uml.cda.consol.MedicalEquipmentSection; -import org.openhealthtools.mdht.uml.cda.consol.NonMedicinalSupplyActivity; -import org.openhealthtools.mdht.uml.cda.consol.ProcedureActivityProcedure; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public class CDAMedicalEquipmentSection implements ICDASection { - private MedicalEquipmentSection section; - - @SuppressWarnings("unused") - private CDAMedicalEquipmentSection() { - }; - - public CDAMedicalEquipmentSection(MedicalEquipmentSection section) { - this.section = section; - } - - @Override - public SectionResultDynamic transform(IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultDynamic result = new SectionResultDynamic(); - // Case 1: Entry is a Non-Medicinal Supply Activity (V2) - for (NonMedicinalSupplyActivity act : section.getNonMedicinalSupplyActivities()) { - Device device = rt.tSupply2Device(act); - result.add(device); - } - // Case 2: Entry is a Medical Equipment Organizer, which is indeed a collection - // of Non-Medicinal Supply Activity (V2) - for (Organizer org : section.getOrganizers()) { - for (Supply supply : org.getSupplies()) { - if (supply instanceof NonMedicinalSupplyActivity) { - Device device = rt.tSupply2Device(supply); - result.add(device); - } - } - } - // Case 3: Entry is a Procedure Activity Procedure (V2) - for (Procedure procedure : section.getProcedures()) { - if (procedure instanceof ProcedureActivityProcedure) { - IEntryResult entryResult = rt.tProcedure2Procedure(procedure, bundleInfo); - result.updateFrom(entryResult, org.hl7.fhir.dstu3.model.Procedure.class); - } - } - return result; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAMedicationsSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAMedicationsSection.java deleted file mode 100644 index 7e91b8554..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAMedicationsSection.java +++ /dev/null @@ -1,40 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.openhealthtools.mdht.uml.cda.consol.MedicationActivity; -import org.openhealthtools.mdht.uml.cda.consol.MedicationsSection; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.LocalBundleInfo; - -public class CDAMedicationsSection implements ICDASection { - private MedicationsSection section; - - @SuppressWarnings("unused") - private CDAMedicationsSection() { - }; - - public CDAMedicationsSection(MedicationsSection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular - .getInstance(MedicationStatement.class); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - - for (MedicationActivity act : section.getMedicationActivities()) { - IEntryResult er = rt.tMedicationActivity2MedicationStatement(act, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - return result; - - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAProblemsSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAProblemsSection.java deleted file mode 100644 index ba1c1bc57..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAProblemsSection.java +++ /dev/null @@ -1,36 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Condition; -import org.openhealthtools.mdht.uml.cda.consol.ProblemConcernAct; -import org.openhealthtools.mdht.uml.cda.consol.ProblemSection; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.LocalBundleInfo; - -public class CDAProblemsSection implements ICDASection { - private ProblemSection section; - - @SuppressWarnings("unused") - private CDAProblemsSection() { - }; - - public CDAProblemsSection(ProblemSection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular.getInstance(Condition.class); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - for (ProblemConcernAct act : section.getConsolProblemConcerns()) { - IEntryResult er = rt.tProblemConcernAct2Condition(act, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - return result; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAProceduresSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAProceduresSection.java deleted file mode 100644 index 397d26569..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAProceduresSection.java +++ /dev/null @@ -1,36 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Procedure; -import org.openhealthtools.mdht.uml.cda.consol.ProcedureActivityProcedure; -import org.openhealthtools.mdht.uml.cda.consol.ProceduresSection; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.LocalBundleInfo; - -public class CDAProceduresSection implements ICDASection { - private ProceduresSection section; - - @SuppressWarnings("unused") - private CDAProceduresSection() { - }; - - public CDAProceduresSection(ProceduresSection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular.getInstance(Procedure.class); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - for (ProcedureActivityProcedure act : section.getConsolProcedureActivityProcedures()) { - IEntryResult er = rt.tProcedure2Procedure(act, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - return result; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAResultsSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAResultsSection.java deleted file mode 100644 index 4e675d5df..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAResultsSection.java +++ /dev/null @@ -1,36 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.ResultsSection; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.LocalBundleInfo; - -public class CDAResultsSection implements ICDASection { - private ResultsSection section; - - @SuppressWarnings("unused") - private CDAResultsSection() { - }; - - public CDAResultsSection(ResultsSection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular.getInstance(DiagnosticReport.class); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - for (ResultOrganizer org : section.getResultOrganizers()) { - IEntryResult er = rt.tResultOrganizer2DiagnosticReport(org, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - return result; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDASectionCommon.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDASectionCommon.java deleted file mode 100644 index d0d24eab8..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDASectionCommon.java +++ /dev/null @@ -1,58 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.eclipse.emf.common.util.EList; -import org.hl7.fhir.dstu3.model.Encounter; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.Observation; -import org.openhealthtools.mdht.uml.cda.consol.EncounterActivities; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationActivity; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignObservation; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsOrganizer; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.LocalBundleInfo; - -public class CDASectionCommon { - public static SectionResultSingular transformImmunizationActivityList( - EList actList, IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular.getInstance(Immunization.class); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - for (ImmunizationActivity act : actList) { - IEntryResult er = rt.tImmunizationActivity2Immunization(act, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - return result; - } - - public static SectionResultSingular transformVitalSignsOrganizerList( - EList orgList, IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular.getInstance(Observation.class); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - for (VitalSignsOrganizer org : orgList) { - for (VitalSignObservation obs : org.getVitalSignObservations()) { - IEntryResult er = rt.tVitalSignObservation2Observation(obs, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - } - return result; - } - - public static SectionResultSingular transformEncounterActivitiesList( - EList encounterList, IBundleInfo bundleInfo) { - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular.getInstance(Encounter.class); - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - for (EncounterActivities act : encounterList) { - IEntryResult er = rt.tEncounterActivity2Encounter(act, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - return result; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDASocialHistorySection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDASocialHistorySection.java deleted file mode 100644 index 18d2018bf..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDASocialHistorySection.java +++ /dev/null @@ -1,41 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Observation; -import org.openhealthtools.mdht.uml.cda.consol.SocialHistorySection; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.impl.LocalBundleInfo; - -public class CDASocialHistorySection implements ICDASection { - private SocialHistorySection section; - - @SuppressWarnings("unused") - private CDASocialHistorySection() { - }; - - public CDASocialHistorySection(SocialHistorySection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - /** - * The generic observation transformer should be able to transform all the - * possible entries: Caregiver Characteristics Characteristics of Home - * Environment Cultural and Religious Observation Pregnancy Observation Smoking - * Status - Meaningful Use (V2) Social History Observation (V3) Tobacco Use (V2) - */ - LocalBundleInfo localBundleInfo = new LocalBundleInfo(bundleInfo); - IResourceTransformer rt = bundleInfo.getResourceTransformer(); - SectionResultSingular result = SectionResultSingular.getInstance(Observation.class); - for (org.openhealthtools.mdht.uml.cda.Observation obs : section.getObservations()) { - IEntryResult er = rt.tObservation2Observation(obs, localBundleInfo); - result.updateFrom(er); - localBundleInfo.updateFrom(er); - } - return result; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAUnplementedSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAUnplementedSection.java deleted file mode 100644 index a48013db2..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAUnplementedSection.java +++ /dev/null @@ -1,12 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.section.ISectionResult; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public class CDAUnplementedSection implements ICDASection { - @Override - public ISectionResult transform(IBundleInfo bundleInfo) { - return null; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAVitalSignsSection.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAVitalSignsSection.java deleted file mode 100644 index efbdc6947..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAVitalSignsSection.java +++ /dev/null @@ -1,24 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Observation; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSection; - -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public class CDAVitalSignsSection implements ICDASection { - private VitalSignsSection section; - - @SuppressWarnings("unused") - private CDAVitalSignsSection() { - }; - - public CDAVitalSignsSection(VitalSignsSection section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - return CDASectionCommon.transformVitalSignsOrganizerList(section.getVitalSignsOrganizers(), bundleInfo); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAVitalSignsSectionEntriesOptional.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAVitalSignsSectionEntriesOptional.java deleted file mode 100644 index 325ec6403..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/CDAVitalSignsSectionEntriesOptional.java +++ /dev/null @@ -1,24 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import org.hl7.fhir.dstu3.model.Observation; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSectionEntriesOptional; - -import tr.com.srdc.cda2fhir.transform.section.ICDASection; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; - -public class CDAVitalSignsSectionEntriesOptional implements ICDASection { - private VitalSignsSectionEntriesOptional section; - - @SuppressWarnings("unused") - private CDAVitalSignsSectionEntriesOptional() { - }; - - public CDAVitalSignsSectionEntriesOptional(VitalSignsSectionEntriesOptional section) { - this.section = section; - } - - @Override - public SectionResultSingular transform(IBundleInfo bundleInfo) { - return CDASectionCommon.transformVitalSignsOrganizerList(section.getVitalSignsOrganizers(), bundleInfo); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/SectionResult.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/SectionResult.java deleted file mode 100644 index 0207b05d2..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/SectionResult.java +++ /dev/null @@ -1,193 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.entry.CDAIIResourceMaps; -import tr.com.srdc.cda2fhir.transform.entry.IEntityInfo; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.entry.IMedicationsInformation; -import tr.com.srdc.cda2fhir.transform.section.ISectionResult; -import tr.com.srdc.cda2fhir.transform.util.IDeferredReference; -import tr.com.srdc.cda2fhir.transform.util.impl.CDACDMap; -import tr.com.srdc.cda2fhir.transform.util.impl.CDAIIMap; - -public abstract class SectionResult implements ISectionResult { - - private Bundle bundle; - private List deferredReferences; - private CDAIIMap entities; - private CDAIIResourceMaps resourceMaps; - private CDACDMap cdMap; - - SectionResult() { - bundle = new Bundle(); - } - - SectionResult(Bundle bundle) { - this.bundle = bundle; - } - - @Override - public boolean hasDeferredReferences() { - return deferredReferences != null && !deferredReferences.isEmpty(); - } - - public void addDeferredReferences(List references) { - if (deferredReferences == null) { - deferredReferences = new ArrayList(); - } - deferredReferences.addAll(references); - } - - @Override - public List getDeferredReferences() { - return deferredReferences; - } - - @Override - public Bundle getBundle() { - return bundle; - } - - @Override - public void updateFrom(IEntryResult entryResult) { - entryResult.copyTo(bundle); - if (entryResult.hasDeferredReferences()) { - addDeferredReferences(entryResult.getDeferredReferences()); - } - if (entryResult.hasIIMapValues()) { - if (entities == null) { - entities = new CDAIIMap(); - } - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - - if (cdMap == null) { - cdMap = new CDACDMap(); - } - entities.put(entryResult); - resourceMaps.put(entryResult); - cdMap.put(entryResult); - } - } - - @Override - public void putCDValuesTo(Map target) { - if (cdMap != null) { - cdMap.putCDValuesTo(target); - } - - } - - @Override - public void putRootValuesTo(Map target) { - if (entities != null) { - entities.putRootValuesTo(target); - } - } - - @Override - public void putExtensionValuesTo(Map> target) { - if (entities != null) { - entities.putExtensionValuesTo(target); - } - } - - @Override - public boolean hasEntities() { - return entities != null; - } - - @Override - public boolean hasIIResourceMaps() { - return resourceMaps != null; - } - - @Override - public boolean hasCDMap() { - return cdMap != null; - } - - @Override - public boolean hasIIMapValues() { - return entities != null || resourceMaps != null; - } - - @Override - public boolean hasResourceMaps() { - return resourceMaps != null; - } - - @Override - public void putRootValuesTo(Class clazz, Map target) { - if (resourceMaps != null) { - resourceMaps.putRootValuesTo(clazz, target); - } - } - - @Override - public void putExtensionValuesTo(Class clazz, - Map> target) { - if (resourceMaps != null) { - resourceMaps.putExtensionValuesTo(clazz, target); - } - } - - @Override - public CDAIIMap getMap(Class clazz) { - return resourceMaps.getMap(clazz); - } - - @Override - public void putMap(Class clazz, CDAIIMap map) { - resourceMaps.putMap(clazz, map); - } - - @Override - public boolean hasCDMapValues() { - return cdMap != null && cdMap.hasCDMapValues(); - } - - @Override - public boolean hasMapValues() { - return entities != null || resourceMaps != null || cdMap != null; - } - - @Override - public void putCDResource(CD cd, IMedicationsInformation resource) { - cdMap.put(cd, resource); - } - - @Override - public void putIIResource(II ii, Class clazz, IBaseResource resource) { - resourceMaps.put(ii, clazz, resource); - } - - @Override - public void putIIResource(List iis, Class clazz, IBaseResource resource) { - resourceMaps.put(iis, clazz, resource); - } - - @Override - public CDAIIResourceMaps getResourceMaps() { - return resourceMaps; - } - - @Override - public Collection> keySet() { - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - return resourceMaps.keySet(); - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/SectionResultDynamic.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/SectionResultDynamic.java deleted file mode 100644 index 41ce9e654..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/SectionResultDynamic.java +++ /dev/null @@ -1,34 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Resource; - -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class SectionResultDynamic extends SectionResult { - private List resources = new ArrayList(); - - public void add(Resource resource) { - getBundle().addEntry().setResource(resource); - resources.add(resource); - } - - public void updateFrom(IEntryResult entryResult, Class clazz) { - updateFrom(entryResult); - Bundle bundle = entryResult.getBundle(); - if (bundle != null) { - List sectionResources = FHIRUtil.findResources(bundle, clazz); - resources.addAll(sectionResources); - } - } - - @Override - public List getSectionResources() { - return resources; - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/SectionResultSingular.java b/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/SectionResultSingular.java deleted file mode 100644 index b6137dcbc..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/section/impl/SectionResultSingular.java +++ /dev/null @@ -1,37 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.section.impl; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Resource; - -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class SectionResultSingular extends SectionResult { - private Class clazz; - - public SectionResultSingular(Bundle bundle, Class clazz) { - super(bundle); - this.clazz = clazz; - } - - public SectionResultSingular(Class clazz) { - super(); - this.clazz = clazz; - } - - public static SectionResultSingular getInstance(Bundle bundle, Class clazz) { - return new SectionResultSingular(bundle, clazz); - } - - public static SectionResultSingular getInstance(Class clazz) { - return new SectionResultSingular(clazz); - } - - @Override - public List getSectionResources() { - Bundle bundle = getBundle(); - return FHIRUtil.findResources(bundle, clazz); - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IBundleInfo.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/IBundleInfo.java deleted file mode 100644 index 64f9f45f3..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IBundleInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.CDAIIResourceMaps; -import tr.com.srdc.cda2fhir.transform.entry.IEntityInfo; -import tr.com.srdc.cda2fhir.transform.entry.IEntityResult; -import tr.com.srdc.cda2fhir.transform.entry.IMedicationsInformation; -import tr.com.srdc.cda2fhir.transform.util.impl.CDACDMap; -import tr.com.srdc.cda2fhir.transform.util.impl.CDAIIMap; - -public interface IBundleInfo { - IResourceTransformer getResourceTransformer(); - - Map getIdedAnnotations(); - - Reference getReferenceByIdentifier(String fhirType, Identifier identifier); - - IEntityInfo findEntityResult(II ii); - - IEntityInfo findEntityResult(List iis); - - IBaseResource findResourceResult(II ii, Class clazz); - - IBaseResource findResourceResult(List iis, Class clazz); - - public IMedicationsInformation findResourceResult(CD cd); - - public void updateFrom(IResult source); - - public void updateFrom(IEntityResult entityResult); - - public CDAIIMap getEntities(); - - public CDAIIResourceMaps getResourceMaps(); - - public CDACDMap getCDMap(); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDACDMap.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDACDMap.java deleted file mode 100644 index d6241c619..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDACDMap.java +++ /dev/null @@ -1,11 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; - -public interface ICDACDMap { - - void put(CD cd, T value); - - T get(CD cd); - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDACDMapSource.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDACDMapSource.java deleted file mode 100644 index ebb88db5c..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDACDMapSource.java +++ /dev/null @@ -1,10 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import java.util.Map; - -public interface ICDACDMapSource { - void putCDValuesTo(Map hashCdMap); - - boolean hasCDMapValues(); - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIMap.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIMap.java deleted file mode 100644 index f2bbd271f..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIMap.java +++ /dev/null @@ -1,14 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import java.util.List; - -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -public interface ICDAIIMap { - - void put(II id, T value); - - T get(II ii); - - T get(List iis); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIMapSource.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIMapSource.java deleted file mode 100644 index ddc409d06..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIMapSource.java +++ /dev/null @@ -1,13 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import java.util.Map; - -public interface ICDAIIMapSource { - - void putRootValuesTo(Map target); - - void putExtensionValuesTo(Map> target); - - boolean hasIIMapValues(); - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIResourceMaps.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIResourceMaps.java deleted file mode 100644 index 33f36400c..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIResourceMaps.java +++ /dev/null @@ -1,30 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import java.util.Collection; -import java.util.List; - -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.util.impl.CDAIIMap; - -public interface ICDAIIResourceMaps { - - Collection> keySet(); - - Collection> values(); - - CDAIIMap getMap(Class clazz); - - void put(ICDAIIResourceMapsSource sourceMaps); - - T get(List iis, Class clazz); - - T get(II ii, Class clazz); - - boolean hasMap(Class clazz); - - void put(II ii, Class clazz, T t); - - void put(List iis, Class clazz, T t); - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIResourceMapsSource.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIResourceMapsSource.java deleted file mode 100644 index 7ac36dbcf..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/ICDAIIResourceMapsSource.java +++ /dev/null @@ -1,21 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import java.util.Collection; -import java.util.Map; - -import tr.com.srdc.cda2fhir.transform.util.impl.CDAIIMap; - -public interface ICDAIIResourceMapsSource { - void putRootValuesTo(Class clazz, Map target); - - void putExtensionValuesTo(Class clazz, Map> target); - - boolean hasMapValues(); - - public CDAIIMap getMap(Class clazz); - - void putMap(Class clazz, CDAIIMap map); - - Collection> keySet(); - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IDeferredReference.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/IDeferredReference.java deleted file mode 100644 index 1ea755830..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IDeferredReference.java +++ /dev/null @@ -1,15 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.dstu3.model.Resource; - -public interface IDeferredReference { - public String getFhirType(); - - public Identifier getIdentifier(); - - public Resource getResource(); - - public void resolve(Reference reference); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IIdentifierMap.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/IIdentifierMap.java deleted file mode 100644 index 236dbcef6..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IIdentifierMap.java +++ /dev/null @@ -1,24 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Identifier; - -public interface IIdentifierMap { - void put(String fhirType, Identifier identifier, T identifiedValue); - - void put(String fhirType, String system, String value, T identifiedValue); - - void put(String fhirType, List identifiers, T identifiedValue); - - T get(String fhirType, Identifier identifier); - - T get(String fhirType, String value); - - T get(String fhirType, String system, String value); - - T getFromJSONArray(String fhirType, List identifiers); - - T getFromJSONArray(String fhirType, Map identifier); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IResult.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/IResult.java deleted file mode 100644 index 3bab02e6a..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IResult.java +++ /dev/null @@ -1,36 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import java.util.List; - -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.entry.CDAIIResourceMaps; -import tr.com.srdc.cda2fhir.transform.entry.IEntityInfo; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.entry.IMedicationsInformation; - -public interface IResult extends ICDAIIMapSource, ICDAIIResourceMapsSource, - ICDACDMapSource { - - List getDeferredReferences(); - - void updateFrom(IEntryResult entryResult); - - boolean hasDeferredReferences(); - - boolean hasEntities(); - - boolean hasIIResourceMaps(); - - boolean hasCDMap(); - - public void putCDResource(CD cd, IMedicationsInformation resource); - - CDAIIResourceMaps getResourceMaps(); - - void putIIResource(II ii, Class clazz, IBaseResource resource); - - void putIIResource(List iis, Class clazz, IBaseResource resource); -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IdentifierMapFactory.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/IdentifierMapFactory.java deleted file mode 100644 index 06a6136cb..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/IdentifierMapFactory.java +++ /dev/null @@ -1,99 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Base; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Property; -import org.hl7.fhir.dstu3.model.Resource; -import org.hl7.fhir.exceptions.FHIRException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import tr.com.srdc.cda2fhir.transform.util.impl.IdentifierMap; - -public class IdentifierMapFactory { - interface ResourceInfo { - T get(Resource resource); - } - - private final static Logger logger = LoggerFactory.getLogger(IdentifierMapFactory.class); - - public static IIdentifierMap bundleToResourceInfo(Bundle bundle, ResourceInfo resourceInfo) { - IdentifierMap identifierMap = new IdentifierMap(); - for (BundleEntryComponent entry : bundle.getEntry()) { - Resource resource = entry.getResource(); - Property property = resource.getNamedProperty("identifier"); - if (property != null) { - List bases = property.getValues(); - if (!bases.isEmpty()) { - for (Base base : bases) { - try { - if (base != null) { - Identifier identifier = resource.castToIdentifier(base); - String fhirType = resource.fhirType(); - T info = resourceInfo.get(resource); - if (info != null) { - identifierMap.put(fhirType, identifier, info); - } - } - } catch (FHIRException e) { - } - } - } - } - } - return identifierMap; - } - - public static IIdentifierMap resourcesToResourceInfo(List resources, - ResourceInfo resourceInfo) { - IdentifierMap identifierMap = new IdentifierMap(); - for (Resource resource : resources) { - Property property = resource.getNamedProperty("identifier"); - if (property != null) { - List bases = property.getValues(); - if (!bases.isEmpty()) { - for (Base base : bases) { - try { - Identifier identifier = resource.castToIdentifier(base); - String fhirType = resource.fhirType(); - T info = resourceInfo.get(resource); - if (info != null) { - identifierMap.put(fhirType, identifier, info); - } - } catch (FHIRException e) { - } - } - } - } - } - return identifierMap; - } - - public static IdentifierMap resourcesToOrder(List resources) { - IdentifierMap result = new IdentifierMap(); - for (int index = 0; index < resources.size(); ++index) { - Resource resource = resources.get(index); - Property property = resource.getNamedProperty("identifier"); - if (property == null) { - logger.warn("No identifier. Cannot be ordered"); - } - for (Base base : property.getValues()) { - Identifier identifier = resource.castToIdentifier(base); - result.put(resource.fhirType(), identifier, index); - } - } - return result; - } - - public static IIdentifierMap bundleToIds(Bundle bundle) { - return bundleToResourceInfo(bundle, r -> r.getId()); - } - - public static IIdentifierMap bundleToResource(Bundle bundle) { - return bundleToResourceInfo(bundle, r -> r); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/BundleInfo.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/BundleInfo.java deleted file mode 100644 index 4c2b2f6ce..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/BundleInfo.java +++ /dev/null @@ -1,126 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.CDAIIResourceMaps; -import tr.com.srdc.cda2fhir.transform.entry.IEntityInfo; -import tr.com.srdc.cda2fhir.transform.entry.IEntityResult; -import tr.com.srdc.cda2fhir.transform.entry.IMedicationsInformation; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.IIdentifierMap; -import tr.com.srdc.cda2fhir.transform.util.IResult; - -public class BundleInfo implements IBundleInfo { - private IResourceTransformer resourceTransformer; - private Map idedAnnotations = new HashMap(); - private IIdentifierMap identifiedReferences = new IdentifierMap(); - - private CDAIIMap entities = new CDAIIMap(); - private CDAIIResourceMaps resourceMaps = new CDAIIResourceMaps(); - private CDACDMap cdMap = new CDACDMap(); - - public BundleInfo(IResourceTransformer resourceTransformer) { - this.resourceTransformer = resourceTransformer; - } - - @Override - public IResourceTransformer getResourceTransformer() { - return resourceTransformer; - } - - @Override - public Map getIdedAnnotations() { - return idedAnnotations; - } - - public void mergeIdedAnnotations(Map newAnnotations) { - idedAnnotations.putAll(newAnnotations); - } - - @Override - public Reference getReferenceByIdentifier(String fhirType, Identifier identifier) { - return identifiedReferences.get(fhirType, identifier); - } - - public void putReference(String fhirType, Identifier identifier, Reference reference) { - identifiedReferences.put(fhirType, identifier, reference); - } - - @Override - public void updateFrom(IEntityResult entityResult) { - List iis = entityResult.getNewIds(); - if (iis != null) { - entities.put(iis, entityResult.getInfo()); - } - - if (entityResult.hasIIResourceMaps()) { - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - resourceMaps.put(entityResult.getResourceMaps()); - } - } - - @Override - public void updateFrom(IResult source) { - if (source.hasEntities()) { - entities.put(source); - } - if (source.hasIIResourceMaps()) { - resourceMaps.put(source); - } - if (source.hasCDMap()) { - cdMap.put(source); - } - } - - @Override - public IEntityInfo findEntityResult(II ii) { - return entities.get(ii); - } - - @Override - public IEntityInfo findEntityResult(List iis) { - return entities.get(iis); - } - - @Override - public IBaseResource findResourceResult(II ii, Class clazz) { - return resourceMaps.get(ii, clazz); - } - - @Override - public IBaseResource findResourceResult(List iis, Class clazz) { - return resourceMaps.get(iis, clazz); - } - - @Override - public IMedicationsInformation findResourceResult(CD cd) { - return cdMap.get(cd); - } - - @Override - public CDAIIMap getEntities() { - return entities; - } - - @Override - public CDAIIResourceMaps getResourceMaps() { - return resourceMaps; - } - - @Override - public CDACDMap getCDMap() { - return cdMap; - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/BundleRequest.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/BundleRequest.java deleted file mode 100644 index f927275dc..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/BundleRequest.java +++ /dev/null @@ -1,181 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util.impl; - -import java.util.List; -import java.util.ResourceBundle; - -import org.hl7.fhir.dstu3.model.Base; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryRequestComponent; -import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.hl7.fhir.dstu3.model.Property; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import tr.com.srdc.cda2fhir.conf.Config; - -public class BundleRequest { - - private final static Logger logger = LoggerFactory.getLogger(BundleRequest.class); - - /** - * Reads the configuration file, and parses out any overriding OIDs. - * - * @param resourceType - the resource name of the OID - * @return Array of OID strings for use. - */ - private static String[] getDefinedOIDs(String resourceType) { - - String[] splitOIDs = null; - try { - final ResourceBundle rb = ResourceBundle.getBundle("config"); - String newOIDs = rb.getString(resourceType); - splitOIDs = newOIDs.split(","); - } catch (Exception e) { - // do not log exception. - } - return splitOIDs; - } - - /** - * Takes a bundle entry and generates the ifNotExists String. - * - * @param bundleEntry - * @return String for application on request. - */ - public static String generateIfNoneExist(BundleEntryComponent bundleEntry) { - - String ifNotExistString = ""; - - // all ifNoneExist strings attempt to start with an identifier. - Property identifierObject = bundleEntry.getResource().getNamedProperty("identifier"); - - // find any overriding OIDs. - String[] subsetOIDArray = getDefinedOIDs(bundleEntry.getResource().getResourceType().name()); - - if (bundleEntry.getResource().getResourceType().name() != "Medication" - && bundleEntry.getResource().getResourceType().name() != "PractitionerRole") { - if (identifierObject != null) { - List identifiers = identifierObject.getValues(); - if (identifiers != null) { - for (Base identifier : identifiers) { - - Identifier currentId = (Identifier) identifier; - - if (currentId.getValue() != null) { - if (subsetOIDArray != null) { - // override OID selection(s). - for (String OID : subsetOIDArray) { - if (currentId.getSystem().equals(OID)) { - if (ifNotExistString != "") { - ifNotExistString = ifNotExistString + ","; - } else { - ifNotExistString = "identifier="; - } - ifNotExistString = ifNotExistString + currentId.getSystem() + "|" - + currentId.getValue(); - } - } - } else { - if (ifNotExistString != "") { - ifNotExistString = ifNotExistString + ","; - } else { - ifNotExistString = "identifier="; - } - if (currentId.getSystem() != null) { - ifNotExistString = ifNotExistString + currentId.getSystem() + "|" - + currentId.getValue(); - } else { - ifNotExistString = ifNotExistString + currentId.getValue(); - } - } - } - } - } - } - } - - // if we can't pull an identifier, try other logic. - if (ifNotExistString == "") { - // if it's a medication, check by aggregate encodings. - if (bundleEntry.getResource().getResourceType().name() == "Medication") { - Property medicationCode = bundleEntry.getResource().getChildByName("code"); - if (medicationCode != null) { - List conceptList = medicationCode.getValues(); - for (Base concept : conceptList) { - CodeableConcept currentConcept = (CodeableConcept) concept; - List currentCoding = currentConcept.getCoding(); - for (Coding coding : currentCoding) { - - if (Config.MEDICATION_CODE_SYSTEM != null) { - if (coding.getCode() != null) { - if (coding.getSystem() == Config.MEDICATION_CODE_SYSTEM) { - // add or for multiple parameters - if (ifNotExistString != "") { - ifNotExistString = ifNotExistString + "&"; - } else { - ifNotExistString = "code="; - } - ifNotExistString = ifNotExistString + coding.getSystem() + "|" - + coding.getCode(); - } - } - } else { - if (coding.getCode() != null) { - // add or for multiple parameters - if (ifNotExistString != "") { - ifNotExistString = ifNotExistString + "&"; - } else { - ifNotExistString = "code="; - } - ifNotExistString = ifNotExistString + coding.getSystem() + "|" + coding.getCode(); - } - } - } - } - } - } - - // if it's a practitioner role, de-duplicate by reference ids. - if (bundleEntry.getResource().getResourceType().name() == "PractitionerRole") { - PractitionerRole practitionerRole = (PractitionerRole) bundleEntry.getResource(); - Identifier practitionerIdentifier = practitionerRole.getPractitionerTarget().getIdentifierFirstRep(); - Identifier organizationIdentifier = practitionerRole.getOrganizationTarget().getIdentifierFirstRep(); - if (organizationIdentifier != null & practitionerIdentifier != null) { - ifNotExistString = "practitioner.identifier=" + practitionerIdentifier.getSystem() + "|" - + practitionerIdentifier.getValue(); - ifNotExistString = ifNotExistString + "&" + "organization.identifier=" - + organizationIdentifier.getSystem() + "|" + organizationIdentifier.getValue(); - } - } - - } - - return ifNotExistString; - - } - - /** - * Adds request field to the entry, method is POST, url is resource type. - * - * @param entry Entry which request field to be added. - */ - public static void addRequestToEntry(BundleEntryComponent entry) { - - BundleEntryRequestComponent request = new BundleEntryRequestComponent(); - - String ifNoneExistString = generateIfNoneExist(entry).replace(" ", "+"); - if (ifNoneExistString != null) { - request.setIfNoneExist(ifNoneExistString); - } - - request.setMethod(HTTPVerb.POST); - // request.setUrl(entry.getResource().getResourceName()); - request.setUrl(entry.getResource().getResourceType().name()); - entry.setRequest(request); - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/CDACDMap.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/CDACDMap.java deleted file mode 100644 index 1afd90cea..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/CDACDMap.java +++ /dev/null @@ -1,119 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util.impl; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; - -import tr.com.srdc.cda2fhir.conf.Config; -import tr.com.srdc.cda2fhir.transform.util.ICDACDMap; -import tr.com.srdc.cda2fhir.transform.util.ICDACDMapSource; - -public class CDACDMap implements ICDACDMap, ICDACDMapSource { - - Map cdMap; - - @Override - public void put(CD cd, T value) { - if (cdMap == null) { - cdMap = new HashMap(); - } - - String codeSetKey = getKeyString(cd); - - if (!codeSetKey.contentEquals("")) { - put(codeSetKey, value); - } - } - - private String getKeyString(CD cd) { - ArrayList codeSetKeyArr = new ArrayList(); - - String codeSystem = cd.getCodeSystem(); - String code = cd.getCode(); - - if (codeSystem != null && code != null) { - checkSystemFlagAndAdd(codeSetKeyArr, codeSystem, code); - } - - if (cd.getTranslations() != null && !cd.getTranslations().isEmpty()) { - for (CD currCD : cd.getTranslations()) { - if (currCD.getCodeSystem() != null && currCD.getCode() != null) { - checkSystemFlagAndAdd(codeSetKeyArr, currCD.getCodeSystem(), currCD.getCode()); - } - } - } - - codeSetKeyArr.sort(Comparator.comparing(String::toString)); - - String codeSetKey = codeSetKeyArr.parallelStream().collect(Collectors.joining()); - - return codeSetKey; - } - - private void checkSystemFlagAndAdd(ArrayList arr, String system, String value) { - if (Config.MEDICATION_CODE_SYSTEM != null && Config.MEDICATION_CODE_SYSTEM.contentEquals(system.trim())) { - arr.add(system.trim()); - arr.add(value.trim()); - } else if (Config.MEDICATION_CODE_SYSTEM == null) { - arr.add(system.trim()); - arr.add(value.trim()); - } - } - - private void put(String key, T value) { - if (key == null || value == null) { - return; - } - - if (cdMap == null) { - cdMap = new HashMap(); - } - - cdMap.put(key, value); - } - - public void put(ICDACDMapSource source) { - if (source == null) - return; - - if (cdMap == null) { - cdMap = new HashMap(); - } - - source.putCDValuesTo(cdMap); - } - - @Override - public void putCDValuesTo(Map target) { - if (cdMap != null) { - target.putAll(cdMap); - } - } - - @Override - public boolean hasCDMapValues() { - return cdMap != null; - } - - @Override - public T get(CD cd) { - if (cdMap != null) { - String keyStr = getKeyString(cd); - - if (!keyStr.contentEquals("")) { - return cdMap.get(keyStr); - } - - } - return null; - } - - public Map getCDMap() { - return cdMap; - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/CDAIIMap.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/CDAIIMap.java deleted file mode 100644 index b2c63d258..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/CDAIIMap.java +++ /dev/null @@ -1,175 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.util.ICDAIIMap; -import tr.com.srdc.cda2fhir.transform.util.ICDAIIMapSource; - -public class CDAIIMap implements ICDAIIMap, ICDAIIMapSource { - private Map rootMap; - private Map> extensionMaps; - - public void put(String root, String extension, T value) { - if (root != null) { - if (extension != null) { - if (extensionMaps == null) { - extensionMaps = new HashMap>(); - } - Map extensionMap = extensionMaps.get(root); - if (extensionMap == null) { - extensionMap = new HashMap(); - extensionMaps.put(root, extensionMap); - } - extensionMap.put(extension, value); - } else { - if (rootMap == null) { - rootMap = new HashMap(); - } - rootMap.put(root, value); - } - } - } - - @Override - public void put(II id, T value) { - put(id.getRoot(), id.getExtension(), value); - } - - public void put(List ids, T value) { - for (II id : ids) { - put(id, value); - } - } - - public void put(ICDAIIMapSource source) { - if (source == null) - return; - if (rootMap == null) { - rootMap = new HashMap(); - } - source.putRootValuesTo(rootMap); - if (extensionMaps == null) { - extensionMaps = new HashMap>(); - } - source.putExtensionValuesTo(extensionMaps); - } - - public void jput(Map identifier, T value) { - String root = (String) identifier.get("root"); - Object extensionObject = identifier.get("extension"); - String extension = extensionObject == null ? null : extensionObject.toString(); - put(root, extension, value); - } - - @SuppressWarnings("unchecked") - public void jput(Object identifier, T value) { - jput((Map) identifier, value); - } - - public void jput(List identifiers, T value) { - identifiers.forEach(identifier -> jput(identifier, value)); - } - - private T get(String root, String extension) { - if (root != null) { - if (extension != null) { - if (extensionMaps == null) { - return null; - } - Map extensionMap = extensionMaps.get(root); - if (extensionMap == null) { - return null; - } - return extensionMap.get(extension); - } - if (rootMap != null) { - return rootMap.get(root); - } - } - return null; - } - - @Override - public T get(II ii) { - if (ii == null) { - return null; - } - return get(ii.getRoot(), ii.getExtension()); - } - - @Override - public T get(List iis) { - if (iis != null) { - for (II ii : iis) { - T result = get(ii); - if (result != null) { - return result; - } - } - } - return null; - } - - public T jget(Map identifier) { - String root = (String) identifier.get("root"); - Object extensionObject = identifier.get("extension"); - String extension = extensionObject == null ? null : extensionObject.toString(); - return get(root, extension); - } - - @SuppressWarnings("unchecked") - public T jget(Object identifier) { - return jget((Map) identifier); - } - - public T jget(List identifiers) { - for (Object identifier : identifiers) { - T value = jget(identifier); - if (value != null) { - return value; - } - } - return null; - } - - @Override - public void putRootValuesTo(Map target) { - if (rootMap != null) { - target.putAll(rootMap); - } - } - - @Override - public void putExtensionValuesTo(Map> target) { - if (extensionMaps != null) { - for (Map.Entry> entry : extensionMaps.entrySet()) { - String root = entry.getKey(); - Map extensionMap = entry.getValue(); - Map targetExtensionMap = target.get(root); - if (targetExtensionMap == null) { - target.put(root, extensionMap); - } else { - targetExtensionMap.putAll(extensionMap); - } - } - } - } - - @Override - public boolean hasIIMapValues() { - return rootMap != null || extensionMaps != null; - } - - public Map getRootMap() { - return rootMap; - } - - public Map> getExtensionMap() { - return extensionMaps; - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/IdentifierMap.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/IdentifierMap.java deleted file mode 100644 index 063e1fc86..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/IdentifierMap.java +++ /dev/null @@ -1,100 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Identifier; - -import tr.com.srdc.cda2fhir.transform.util.IIdentifierMap; - -public class IdentifierMap implements IIdentifierMap { - private Map> map = new HashMap>(); - - @Override - public void put(String fhirType, Identifier identifier, T identifiedValue) { - InnerIdentifierMap innerMap = map.get(fhirType); - if (innerMap == null) { - innerMap = new InnerIdentifierMap(); - map.put(fhirType, innerMap); - } - innerMap.put(identifier, identifiedValue); - } - - @Override - public void put(String fhirType, List identifiers, T identifiedValue) { - identifiers.forEach(identifier -> put(fhirType, identifier, identifiedValue)); - } - - @Override - public void put(String fhirType, String system, String value, T identifiedValue) { - InnerIdentifierMap innerMap = map.get(fhirType); - if (innerMap == null) { - innerMap = new InnerIdentifierMap(); - map.put(fhirType, innerMap); - } - innerMap.put(system, value, identifiedValue); - } - - @Override - public T get(String fhirType, Identifier identifier) { - InnerIdentifierMap innerMap = map.get(fhirType); - if (innerMap != null) { - return innerMap.get(identifier); - } - return null; - } - - @Override - public T get(String fhirType, String value) { - InnerIdentifierMap innerMap = map.get(fhirType); - if (innerMap != null) { - return innerMap.get(value); - } - return null; - } - - @Override - public T get(String fhirType, String system, String value) { - InnerIdentifierMap innerMap = map.get(fhirType); - if (innerMap != null) { - return innerMap.get(system, value); - } - return null; - } - - @SuppressWarnings("unchecked") - public void putFromJSONArray(String fhirType, List identifiers, T identifiedValue) { - for (Object identifier : identifiers) { - Map idAsMap = (Map) identifier; - String system = (String) idAsMap.get("system"); - String value = (String) idAsMap.get("value"); - - put(fhirType, system, value, identifiedValue); - } - } - - @Override - public T getFromJSONArray(String fhirType, Map identifier) { - String system = (String) identifier.get("system"); - String value = (String) identifier.get("value"); - - return get(fhirType, system, value); - } - - @Override - @SuppressWarnings("unchecked") - public T getFromJSONArray(String fhirType, List identifiers) { - for (Object identifier : identifiers) { - Map idAsMap = (Map) identifier; - String system = (String) idAsMap.get("system"); - String value = (String) idAsMap.get("value"); - - T result = get(fhirType, system, value); - if (result != null) { - return result; - } - } - return null; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/InnerIdentifierMap.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/InnerIdentifierMap.java deleted file mode 100644 index 8d4401f50..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/InnerIdentifierMap.java +++ /dev/null @@ -1,65 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Identifier; - -public class InnerIdentifierMap { - private Map genericMap; - private Map> systemMaps; - - public void put(String system, String value, T identifiedValue) { - if (value != null) { - if (system != null) { - if (systemMaps == null) { - systemMaps = new HashMap>(); - } - Map systemMap = systemMaps.get(system); - if (systemMap == null) { - systemMap = new HashMap(); - systemMaps.put(system, systemMap); - } - systemMap.put(value, identifiedValue); - } else { - if (genericMap == null) { - genericMap = new HashMap(); - } - genericMap.put(value, identifiedValue); - } - } - } - - public void put(Identifier identifier, T identifiedValue) { - String value = identifier.getValue(); - String system = identifier.getSystem(); - put(system, value, identifiedValue); - } - - public T get(String system, String value) { - if (value != null) { - if (system != null) { - if (systemMaps == null) { - return null; - } - Map systemMap = systemMaps.get(system); - if (systemMap == null) { - return null; - } - return systemMap.get(value); - } - if (genericMap != null) { - return genericMap.get(value); - } - } - return null; - } - - public T get(Identifier identifier) { - return get(identifier.getSystem(), identifier.getValue()); - } - - public T get(String value) { - return get(null, value); - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/LocalBundleInfo.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/LocalBundleInfo.java deleted file mode 100644 index 0116890b6..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/LocalBundleInfo.java +++ /dev/null @@ -1,135 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util.impl; - -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.IResourceTransformer; -import tr.com.srdc.cda2fhir.transform.entry.CDAIIResourceMaps; -import tr.com.srdc.cda2fhir.transform.entry.IEntityInfo; -import tr.com.srdc.cda2fhir.transform.entry.IEntityResult; -import tr.com.srdc.cda2fhir.transform.entry.IMedicationsInformation; -import tr.com.srdc.cda2fhir.transform.util.IBundleInfo; -import tr.com.srdc.cda2fhir.transform.util.IResult; - -public class LocalBundleInfo implements IBundleInfo { - private IBundleInfo bundleInfo; - private CDAIIMap entities = new CDAIIMap(); - private CDAIIResourceMaps resourceMaps = new CDAIIResourceMaps(); - private CDACDMap cdMap = new CDACDMap(); - - public LocalBundleInfo(IBundleInfo bundleInfo) { - this.bundleInfo = bundleInfo; - entities.put(bundleInfo.getEntities()); - resourceMaps.put(bundleInfo.getResourceMaps()); - cdMap.put(bundleInfo.getCDMap()); - - } - - @Override - public IResourceTransformer getResourceTransformer() { - return bundleInfo.getResourceTransformer(); - } - - @Override - public Map getIdedAnnotations() { - return bundleInfo.getIdedAnnotations(); - } - - @Override - public Reference getReferenceByIdentifier(String fhirType, Identifier identifier) { - return bundleInfo.getReferenceByIdentifier(fhirType, identifier); - } - - @Override - public void updateFrom(IResult source) { - if (source.hasEntities()) { - entities.put(source); - } - if (source.hasIIResourceMaps()) { - resourceMaps.put(source); - } - if (source.hasCDMap()) { - cdMap.put(source); - } - } - - @Override - public void updateFrom(IEntityResult entityResult) { - List iis = entityResult.getNewIds(); - if (iis != null) { - entities.put(iis, entityResult.getInfo()); - } - - if (entityResult.hasIIResourceMaps()) { - if (resourceMaps == null) { - resourceMaps = new CDAIIResourceMaps(); - } - resourceMaps.put(entityResult.getResourceMaps()); - } - - } - - @Override - public IEntityInfo findEntityResult(II ii) { - IEntityInfo result = bundleInfo.findEntityResult(ii); - if (result == null) { - return entities.get(ii); - } - - return result; - } - - @Override - public IEntityInfo findEntityResult(List iis) { - IEntityInfo result = bundleInfo.findEntityResult(iis); - if (result == null) { - return entities.get(iis); - } - return result; - } - - @Override - public IBaseResource findResourceResult(II ii, Class clazz) { - IBaseResource result = bundleInfo.findResourceResult(ii, clazz); - if (result == null) { - return resourceMaps.get(ii, clazz); - } - return result; - } - - @Override - public IBaseResource findResourceResult(List iis, Class clazz) { - IBaseResource result = bundleInfo.findResourceResult(iis, clazz); - if (result == null) { - return resourceMaps.get(iis, clazz); - } - return result; - } - - @Override - public IMedicationsInformation findResourceResult(CD cd) { - return cdMap.get(cd); - } - - @Override - public CDAIIMap getEntities() { - return entities; - } - - @Override - public CDAIIResourceMaps getResourceMaps() { - return resourceMaps; - } - - @Override - public CDACDMap getCDMap() { - return cdMap; - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/LocalCDAIIMap.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/LocalCDAIIMap.java deleted file mode 100644 index a4de79b3d..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/LocalCDAIIMap.java +++ /dev/null @@ -1,62 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util.impl; - -import java.util.List; -import java.util.Map; - -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.transform.util.ICDAIIMap; -import tr.com.srdc.cda2fhir.transform.util.ICDAIIMapSource; - -public class LocalCDAIIMap implements ICDAIIMap, ICDAIIMapSource { - private CDAIIMap newIIMap; - private ICDAIIMap existingIIMap; - - public LocalCDAIIMap(ICDAIIMap iiMap) { - existingIIMap = iiMap; - } - - public void put(II id, T value) { - if (newIIMap == null) { - newIIMap = new CDAIIMap(); - } - newIIMap.put(id, value); - } - - @Override - public T get(II ii) { - T result = existingIIMap.get(ii); - if (result == null && newIIMap != null) { - return newIIMap.get(ii); - } - return result; - } - - @Override - public T get(List iis) { - T result = existingIIMap.get(iis); - if (result == null && newIIMap != null) { - return newIIMap.get(iis); - } - return result; - } - - @Override - public void putRootValuesTo(Map target) { - if (newIIMap != null) { - newIIMap.putRootValuesTo(target); - } - } - - @Override - public void putExtensionValuesTo(Map> target) { - if (newIIMap != null) { - newIIMap.putExtensionValuesTo(target); - } - } - - @Override - public boolean hasIIMapValues() { - return newIIMap != null; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/ReferenceInfo.java b/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/ReferenceInfo.java deleted file mode 100644 index b1a9c622b..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/transform/util/impl/ReferenceInfo.java +++ /dev/null @@ -1,141 +0,0 @@ -package tr.com.srdc.cda2fhir.transform.util.impl; - -import java.util.Iterator; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Base; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Enumeration; -import org.hl7.fhir.dstu3.model.HumanName; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.dstu3.model.Resource; -import org.hl7.fhir.dstu3.model.StringType; - -public class ReferenceInfo { - - /** - * Walks a codeable concept and returns a string representation. - * - * @param entry codeable concept to analyze. - * @return string of the codeable concept. - */ - private static String getStringFromConcept(CodeableConcept entry) { - if (entry != null) { - if (entry.hasText()) { - return entry.getText(); - } else { - // if no text loop the displays and take the first one. - if (entry.getCoding() != null) { - if (entry.getCoding().size() > 0) { - for (Coding codeEntry : entry.getCoding()) { - if (codeEntry.getDisplay() != null) { - return codeEntry.getDisplay(); - } - } - } - } - } - } - return null; - } - - /** - * Returns a string representation used for display assignment for references. - * - * @param resource to be referenced which will be searched for a display value. - * @return a string representation of the resource. - */ - public static String getDisplay(Resource resource) { - - // take coded object to get display value if possible. - if (resource.getNamedProperty("code") != null) { - if (!resource.getNamedProperty("code").getValues().isEmpty()) { - CodeableConcept code = (CodeableConcept) resource.getNamedProperty("code").getValues().get(0); - String outputString = getStringFromConcept(code); - if (outputString != null) { - return outputString; - } - } - } - - // for vaccines, take vaccine code. - if (resource.getNamedProperty("vaccineCode") != null) { - if (!resource.getNamedProperty("vaccineCode").getValues().isEmpty()) { - CodeableConcept vaccineCode = (CodeableConcept) resource.getNamedProperty("vaccineCode").getValues() - .get(0); - String outputString = getStringFromConcept(vaccineCode); - if (outputString != null) { - return outputString; - } - - } - } - - // for med statement/requests, get ref med. - if (resource.getNamedProperty("medicationReference") != null) { - if (!resource.getNamedProperty("medicationReference").getValues().isEmpty()) { - Reference medRef = (Reference) resource.getNamedProperty("medicationReference").getValues().get(0); - if (medRef != null) { - Medication med = (Medication) medRef.getResource(); - String outputString = getStringFromConcept(med.getCode()); - if (outputString != null) { - return outputString; - } - } - } - } - - // for encounter/device use type if present. - if (resource.getNamedProperty("type") != null) { - if (!resource.getNamedProperty("type").getValues().isEmpty()) { - Base val = resource.getNamedProperty("type").getValues().get(0); - if (!(val instanceof Enumeration)) { - CodeableConcept typeCode = (CodeableConcept) resource.getNamedProperty("type").getValues().get(0); - String outputString = getStringFromConcept(typeCode); - if (outputString != null) { - return outputString; - } - } - } - } - - // for all others attempt to take name. - if (resource.getNamedProperty("name") != null) { - if (!resource.getNamedProperty("name").getValues().isEmpty()) { - - Object nameObj = resource.getNamedProperty("name").getValues().get(0); - if (nameObj instanceof StringType) { - - StringType str = (StringType) resource.getNamedProperty("name").getValues().get(0); - if (str != null) { - return str.asStringValue(); - } - - } else if (nameObj instanceof HumanName) { - - List nameList = resource.getNamedProperty("name").getValues(); - if (!nameList.isEmpty()) { - String allNames = ""; - Iterator iter = nameList.listIterator(); - while (iter.hasNext()) { - Base humanNameBase = iter.next(); - HumanName humanName = (HumanName) humanNameBase; - if (!humanName.getNameAsSingleString().trim().contentEquals("")) { - allNames += humanName.getNameAsSingleString(); - if (iter.hasNext()) - allNames += ", "; - } - } - return allNames; - } - } - - } - - } - return null; - } - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/util/Constants.java b/src/main/java/tr/com/srdc/cda2fhir/util/Constants.java deleted file mode 100644 index 8c813fa74..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/util/Constants.java +++ /dev/null @@ -1,66 +0,0 @@ -package tr.com.srdc.cda2fhir.util; - -/* - * #%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% - */ - -public class Constants { - - // DAF Profile URLs (based on FHIR DSTU2) - public static final String PROFILE_DAF_ALLERGY_INTOLERANCE = "http://hl7.org/fhir/StructureDefinition/daf-allergyintolerance"; - public static final String PROFILE_DAF_ALLERGY_LIST = "http://hl7.org/fhir/StructureDefinition/daf-allergylist"; - public static final String PROFILE_DAF_CONDITION = "http://hl7.org/fhir/StructureDefinition/daf-condition"; - public static final String PROFILE_DAF_DIAGNOSTIC_ORDER = "http://hl7.org/fhir/StructureDefinition/daf-diagnosticorder"; - public static final String PROFILE_DAF_DIAGNOSTIC_REPORT = "http://hl7.org/fhir/StructureDefinition/daf-diagnosticreport"; - public static final String PROFILE_DAF_ENCOUNTER = "http://hl7.org/fhir/StructureDefinition/daf-encounter"; - public static final String PROFILE_DAF_ENCOUNTER_LIST = "http://hl7.org/fhir/StructureDefinition/daf-encounterlist"; - public static final String PROFILE_DAF_FAMILY_MEMBER_HISTORY = "http://hl7.org/fhir/StructureDefinition/daf-familymemberhistory"; - public static final String PROFILE_DAF_IMMUNIZATION = "http://hl7.org/fhir/StructureDefinition/daf-immunization"; - public static final String PROFILE_DAF_IMMUNIZATION_LIST = "http://hl7.org/fhir/StructureDefinition/daf-immunizationlist"; - public static final String PROFILE_DAF_LOCATION = "http://hl7.org/fhir/StructureDefinition/daf-location"; - public static final String PROFILE_DAF_MEDICATION = "http://hl7.org/fhir/StructureDefinition/daf-medication"; - public static final String PROFILE_DAF_MEDICATION_ADMINISTRATION = "http://hl7.org/fhir/StructureDefinition/daf-medicationadministration"; - public static final String PROFILE_DAF_MEDICATION_DISPENSE = "http://hl7.org/fhir/StructureDefinition/daf-medicationdispense"; - public static final String PROFILE_DAF_MEDICATION_LIST = "http://hl7.org/fhir/StructureDefinition/daf-medicationlist"; - public static final String PROFILE_DAF_MEDICATION_ORDER = "http://hl7.org/fhir/StructureDefinition/daf-medicationorder"; - public static final String PROFILE_DAF_MEDICATION_STATEMENT = "http://hl7.org/fhir/StructureDefinition/daf-medicationstatement"; - public static final String PROFILE_DAF_MEDICATION_REQUEST = "http://hl7.org/fhir/StructureDefinition/daf-medicationRequest"; - - public static final String PROFILE_DAF_ORGANIZATION = "http://hl7.org/fhir/StructureDefinition/daf-organization"; - public static final String PROFILE_DAF_PATIENT = "http://hl7.org/fhir/StructureDefinition/daf-patient"; - public static final String PROFILE_DAF_PRACTITIONER = "http://hl7.org/fhir/StructureDefinition/daf-pract"; - public static final String PROFILE_DAF_PROBLEM_LIST = "http://hl7.org/fhir/StructureDefinition/daf-problemlist"; - public static final String PROFILE_DAF_PROCEDURE = "http://hl7.org/fhir/StructureDefinition/daf-procedure"; - public static final String PROFILE_DAF_PROCEDURE_LIST = "http://hl7.org/fhir/StructureDefinition/daf-procedurelist"; - public static final String PROFILE_DAF_RELATED_PERSON = "http://hl7.org/fhir/StructureDefinition/daf-relatedperson"; - public static final String PROFILE_DAF_RESULT_LIST = "http://hl7.org/fhir/StructureDefinition/daf-resultlist"; - public static final String PROFILE_DAF_RESULT_OBS = "http://hl7.org/fhir/StructureDefinition/daf-resultobs"; - public static final String PROFILE_DAF_SMOKING_STATUS = "http://hl7.org/fhir/StructureDefinition/daf-smokingstatus"; - public static final String PROFILE_DAF_SPECIMEN = "http://hl7.org/fhir/StructureDefinition/daf-spec"; - public static final String PROFILE_DAF_SUBSTANCE = "http://hl7.org/fhir/StructureDefinition/daf-substance"; - public static final String PROFILE_DAF_VITAL_SIGNS = "http://hl7.org/fhir/StructureDefinition/daf-vitalsigns"; - - // Extension URLs - public static final String URL_EXTENSION_BIRTHPLACE = "http://hl7.org/fhir/StructureDefinition/birthPlace"; - public static final String URL_EXTENSION_DATA_ABSENT_REASON = "http://hl7.org/fhir/StructureDefinition/data-absent-reason"; - public static final String URL_EXTENSION_ETHNICITY = "http://hl7.org/fhir/StructureDefinition/us-core-ethnicity"; - public static final String URL_EXTENSION_RACE = "http://hl7.org/fhir/StructureDefinition/us-core-race"; - public static final String URL_EXTENSION_RELIGION = "http://hl7.org/fhir/StructureDefinition/us-core-religion"; - -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/util/EMFUtil.java b/src/main/java/tr/com/srdc/cda2fhir/util/EMFUtil.java deleted file mode 100644 index d337c01c8..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/util/EMFUtil.java +++ /dev/null @@ -1,71 +0,0 @@ -package tr.com.srdc.cda2fhir.util; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.util.FeatureMap; -import org.eclipse.emf.ecore.util.FeatureMap.Entry; -import org.eclipse.emf.ecore.xml.type.AnyType; -import org.openhealthtools.mdht.uml.cda.StrucDocText; - -public class EMFUtil { - - private static String[] supportedTypes = { "content", "td", "paragraph" }; - - static private String findAttribute(FeatureMap attributes, String name) { - if (attributes != null) { - for (Entry attribute : attributes) { - String attrName = attribute.getEStructuralFeature().getName(); - if (name.equalsIgnoreCase(attrName)) { - return attribute.getValue().toString(); - } - } - } - return null; - } - - static private void putReferences(FeatureMap featureMap, Map result) { - if (featureMap == null) { - return; - } - for (Entry entry : featureMap) { - EStructuralFeature feature = entry.getEStructuralFeature(); - if (feature instanceof EReference) { - AnyType anyType = (AnyType) entry.getValue(); - - if (Arrays.stream(supportedTypes).anyMatch(feature.getName().toLowerCase()::equals)) { - String id = findAttribute(anyType.getAnyAttribute(), "id"); - if (id != null) { - FeatureMap idValueMap = anyType.getMixed(); - if (idValueMap != null && !idValueMap.isEmpty()) { - Object value = idValueMap.get(0).getValue(); - if (value != null) { - result.put(id, value.toString().trim()); - } - } - } - } - putReferences(anyType.getMixed(), result); - } - } - } - - /*** - * Pulls text references out of source HTML for later use. - * - * @param text the structured text portion of the CCD document. - * @return map of ids and values from that section. - */ - static public Map findReferences(StrucDocText text) { - if(text != null) { - Map result = new HashMap(); - FeatureMap featureMap = text.getMixed(); - putReferences(featureMap, result); - return result; - } - return null; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/util/FHIRUtil.java b/src/main/java/tr/com/srdc/cda2fhir/util/FHIRUtil.java deleted file mode 100644 index a719a43b7..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/util/FHIRUtil.java +++ /dev/null @@ -1,259 +0,0 @@ -package tr.com.srdc.cda2fhir.util; - -/* - * #%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.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.Writer; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.dstu3.model.Resource; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import ca.uhn.fhir.parser.DataFormatException; -import ca.uhn.fhir.parser.IParser; -import tr.com.srdc.cda2fhir.conf.Config; - -public class FHIRUtil { - - private static IParser jsonParser; - private static IParser xmlParser; - - private final static Logger logger = LoggerFactory.getLogger(FHIRUtil.class); - - static { - jsonParser = Config.getFhirContext().newJsonParser(); - xmlParser = Config.getFhirContext().newXmlParser(); - jsonParser.setPrettyPrint(true); - xmlParser.setPrettyPrint(true); - } - - public static String encodeToJSON(IBaseResource res) { - return jsonParser.encodeResourceToString(res); - } - - public static String encodeToJSON(Collection resources) { - String[] objects = resources.stream().map(r -> encodeToJSON(r)).toArray(String[]::new); - return "[" + String.join(", ", objects) + "]"; - } - - public static String encodeToXML(IBaseResource res) { - return xmlParser.encodeResourceToString(res); - } - - public static void printJSON(IBaseResource res) { - System.out.println(jsonParser.encodeResourceToString(res)); - } - - public static void printJSON(Collection resources) { - System.out.println(encodeToJSON(resources)); - } - - public static void printXML(IBaseResource res) { - System.out.println(xmlParser.encodeResourceToString(res)); - } - - public static void printJSON(IBaseResource res, String filePath) throws IOException { - File f = new File(filePath); - f.getParentFile().mkdirs(); - FileWriter fw = null; - try { - fw = new FileWriter(f); - jsonParser.encodeResourceToWriter(res, fw); - } catch (IOException ie) { - logger.error("Could not print FHIR JSON to file", ie); - throw new IOException(ie); - } catch (DataFormatException de) { - logger.error("Could not print FHIR JSON to file", de); - throw new DataFormatException(de); - } finally { - if (fw != null) { - try { - fw.close(); - } catch (IOException ie) { - logger.error("Could not close writer for function \"printJSON.\" with IBaseResource."); - } - } - } - } - - public static void printJSON(Collection resources, String filePath) - throws IOException { - File f = new File(filePath); - f.getParentFile().mkdirs(); - FileWriter fw = null; - try { - fw = new FileWriter(f); - String json = encodeToJSON(resources); - fw.write(json); - } catch (IOException e) { - logger.error("Could not print FHIR JSON to file", e); - } finally { - if (fw != null) { - try { - fw.close(); - } catch (IOException ie) { - logger.error("Could not close writer for function \"printJSON.\" with Collection."); - } - } - } - } - - public static void printXML(IBaseResource res, String filePath) throws IOException { - File f = new File(filePath); - f.getParentFile().mkdirs(); - FileWriter fw = null; - try { - fw = new FileWriter(f); - xmlParser.encodeResourceToWriter(res, fw); - } catch (IOException e) { - logger.error("Could not print FHIR XML to file", e); - } finally { - if (fw != null) { - try { - fw.close(); - } catch (IOException ie) { - logger.error("Could not close writer for function \"printJSON.\" with Collection."); - } - } - } - } - - public static void printJSON(IBaseResource res, Writer writer) { - try { - jsonParser.encodeResourceToWriter(res, writer); - } catch (IOException e) { - logger.error("Could not print FHIR JSON to writer", e); - } - } - - public static void printXML(IBaseResource res, Writer writer) { - try { - xmlParser.encodeResourceToWriter(res, writer); - } catch (IOException e) { - logger.error("Could not print FHIR XML to writer", e); - } - } - - public static List findResources(Bundle bundle, Class type) { - return bundle.getEntry().stream().map(b -> b.getResource()).filter(r -> type.isInstance(r)) - .map(r -> type.cast(r)).collect(Collectors.toList()); - } - - public static T findFirstResource(Bundle bundle, Class type) { - Optional result = bundle.getEntry().stream().map(b -> b.getResource()).filter(r -> type.isInstance(r)) - .map(r -> type.cast(r)).findFirst(); - return result.orElse(null); - - } - - public static void mergeBundle(Bundle source, Bundle target) { - if (source == null || target == null) { - return; - } - - for (BundleEntryComponent entry : source.getEntry()) { - if (entry != null) { - target.addEntry(entry); - } - } - } - - public static Map getIdResourceMap(Bundle bundle) { - Map result = new HashMap(); - bundle.getEntry().stream().map(e -> e.getResource()).forEach(r -> result.put(r.getId(), r)); - return result; - } - - interface ResourcePredicate { - boolean get(Resource resource); - } - - public static Bundle bundleJSON(File file) throws IOException { - InputStream targetStream = new FileInputStream(file); - Bundle resultBundle = (Bundle) jsonParser.parseResource(targetStream); - targetStream.close(); - return resultBundle; - } - - public static String toCDADatetime(String fhirDatetime) { - String noColon = fhirDatetime.replace(":", ""); - String[] pieces = noColon.split("T"); - String result = pieces[0].replace("-", ""); - if (pieces.length > 1) { - String timezone = null; - if (pieces[1].indexOf('-') >= 0) { - String[] pieces2 = pieces[1].split("-"); - result += pieces2[0].replace(":", ""); - timezone = "-" + pieces2[1]; - } else if (pieces[1].indexOf('+') >= 0) { - String[] pieces2 = pieces[1].split("+"); - result += pieces2[0].replace(":", ""); - timezone = "+" + pieces2[1]; - } - if (timezone != null) { - result += timezone; - } - } - return result; - } - - public static String toFHIRDatetime(String cdaDateTime) { - if (cdaDateTime.length() < 4) { - return null; - } - String[] pieces = cdaDateTime.split("-"); - String datetime = pieces[0]; - int length = datetime.length(); - String result = datetime.substring(0, 4); - if (length > 5) { - result += "-" + datetime.substring(4, 6); - if (length > 7) { - result += "-" + datetime.substring(6, 8); - if (length > 11) { - result += "T" + datetime.substring(8, 10) + ":" + datetime.substring(10, 12); - if (length > 13) { - result += ":" + datetime.substring(12, 14); - } else { - result += ":00"; - } - } - } - } - String zone = pieces.length > 1 ? pieces[1] : null; - if (zone != null && zone.length() > 0) { - result += "-" + zone.substring(0, 2) + ":" + zone.substring(2, 4); - } - return result; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/util/IdGeneratorEnum.java b/src/main/java/tr/com/srdc/cda2fhir/util/IdGeneratorEnum.java deleted file mode 100644 index 50c17c0a1..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/util/IdGeneratorEnum.java +++ /dev/null @@ -1,25 +0,0 @@ -package tr.com.srdc.cda2fhir.util; - -/* - * #%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% - */ - -public enum IdGeneratorEnum { - COUNTER, UUID -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/util/StringUtil.java b/src/main/java/tr/com/srdc/cda2fhir/util/StringUtil.java deleted file mode 100644 index 6f17f87e5..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/util/StringUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -package tr.com.srdc.cda2fhir.util; - -/* - * #%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.util.regex.Pattern; - -public class StringUtil { - - // oid one is very simple, not a complete validator - private static final Pattern OID_PATTERN = Pattern.compile("([0-9]+\\.)*[0-9]+"); - private static final Pattern UUID_PATTERN = Pattern - .compile("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"); - - public static boolean isOID(String oidString) { - return isMatched(oidString, OID_PATTERN); - } - - public static boolean isUUID(String uuidString) { - return isMatched(uuidString, UUID_PATTERN); - } - - private static boolean isMatched(String sourceText, Pattern pattern) { - if (pattern.matcher(sourceText).matches()) - return true; - else - return false; - } -} diff --git a/src/main/java/tr/com/srdc/cda2fhir/validation/IValidator.java b/src/main/java/tr/com/srdc/cda2fhir/validation/IValidator.java deleted file mode 100644 index 5b8d76c83..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/validation/IValidator.java +++ /dev/null @@ -1,82 +0,0 @@ -package tr.com.srdc.cda2fhir.validation; - -import java.io.FileNotFoundException; -import java.io.IOException; - -/* - * #%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.OutputStream; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.instance.model.api.IBaseResource; - -import ca.uhn.fhir.validation.ValidationResult; - -public interface IValidator { - - /** - * Validates the FHIR resource(s) contained in the FHIR Bundle by using the - * validation engine supplied by hl7.org - * - * @param bundle A FHIR Bundle instance containing the FHIR resource(s) to be - * validated. If the (DAF) profile is supplied in meta.profile - * attribute of contained resources, then (DAF) profile validation - * is enable automatically. - * @return An output stream containing the validation result(s). The validation - * results are contained in separate div elements. - */ - OutputStream validateBundle(Bundle bundle); - - /** - * Validates a FHIR IBaseResource instance by using the validation engine - * supplied by hl7.org - * - * @param resource A FHIR IBaseResource instance. If the (DAF) profile is - * supplied in meta.profile attribute, then (DAF) profile - * validation is enable automatically. - * @return An output stream containing the validation result. The validation - * result is contained in div element. - */ - OutputStream validateResource(IBaseResource resource); - - /** - * Validates a FHIR File - * - * @param filepath The path of the file. - * @return An output object that contains validation results. - */ - ValidationResult validateFile(String filepath) throws IOException, FileNotFoundException; - - /** - * Validates the FHIR resource(s) contained in the FHIR Bundle by using the - * validation engine supplied by hl7.org - * - * - * @param bundle A FHIR Bundle instance containing the FHIR resource(s) to be - * validated. If the (DAF) profile is supplied in meta.profile - * attribute of contained resources, then (DAF) profile validation - * is enable automatically. - * @return A ValidationResult object. - */ - - ValidationResult validateResourceResultOnly(IBaseResource resource); - -} \ No newline at end of file diff --git a/src/main/java/tr/com/srdc/cda2fhir/validation/ValidatorImpl.java b/src/main/java/tr/com/srdc/cda2fhir/validation/ValidatorImpl.java deleted file mode 100644 index ac5bc1632..000000000 --- a/src/main/java/tr/com/srdc/cda2fhir/validation/ValidatorImpl.java +++ /dev/null @@ -1,235 +0,0 @@ -package tr.com.srdc.cda2fhir.validation; - -/* - * #%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.ByteArrayOutputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -import org.apache.commons.io.IOUtils; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.validation.FhirValidator; -import ca.uhn.fhir.validation.IValidatorModule; -import ca.uhn.fhir.validation.SchemaBaseValidator; -import ca.uhn.fhir.validation.SingleValidationMessage; -import ca.uhn.fhir.validation.ValidationResult; -import ca.uhn.fhir.validation.schematron.SchematronBaseValidator; - -public class ValidatorImpl implements IValidator { - - private final Logger logger = LoggerFactory.getLogger(ValidatorImpl.class); - - private FhirContext ctx = FhirContext.forDstu3(); - - public ValidatorImpl(FhirContext ctx) { - this.setCtx(ctx); - } - - /** - * Constructs a validator using the default configuration. - */ - public ValidatorImpl() { - this.setCtx(FhirContext.forDstu3()); - } - - @Override - public OutputStream validateBundle(Bundle bundle) { - if (bundle == null) { - logger.warn("The bundle to be validated is null. Returning null."); - return null; - } - if (bundle.getEntry().isEmpty()) { - logger.warn("The bundle to be validated is empty. Returning null"); - return null; - } - - logger.info("Validating the bundle containing " + bundle.getEntry().size() + " entries"); - - // create an output stream to return - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - // init the html output - try { - outputStream.write("\n\t".getBytes("UTF-8")); - } catch (IOException e) { - logger.error("Could not write to the output stream.", e); - } - - // traverse the entries of the bundle - for (BundleEntryComponent entry : bundle.getEntry()) { - if (entry != null && entry.getResource() != null) { - try { - // validate the resource contained in the entry - ByteArrayOutputStream byteArrayOutputStream = (ByteArrayOutputStream) validateResource( - entry.getResource()); - - if (byteArrayOutputStream != null) { - byte[] byteArray = byteArrayOutputStream.toByteArray(); - if (byteArray != null) - outputStream.write(byteArray); - } - } catch (IOException e) { - logger.error( - "Exception occurred while trying to write the validation outcome to the output stream. Ignoring", - e); - } - } else { - logger.warn("Null bundle entry found. Ignoring the entry."); - } - } - - // last touch to the html output - try { - outputStream.write("\n\t\n".getBytes("UTF-8")); - } catch (IOException e) { - logger.error("Could not write to the output stream.", e); - } - - return outputStream; - } - - public void logValidationResult(ValidationResult result) { - if (logger.isDebugEnabled()) { - if (result.isSuccessful()) { - logger.info("Validation of resource passed."); - } else { - logger.info("Validation of resource failed."); - } - List messages = result.getMessages(); - for (SingleValidationMessage message : messages) { - logger.debug("Validation Message:"); - logger.debug(" * Location: " + message.getLocationString()); - logger.debug(" * Severity: " + message.getSeverity()); - logger.debug(" * Message : " + message.getMessage()); - } - } - } - - private String getOutcomeMessagesString(ValidationResult result) { - String messagesStr = ""; - if (result.isSuccessful()) { - messagesStr += "Validation successful\n"; - } - if (result.getMessages().size() > 0) { - for (SingleValidationMessage message : result.getMessages()) { - messagesStr += message.getLocationString() + "\n"; - messagesStr += message.getSeverity() + "\n"; - messagesStr += message.getMessage(); - } - } - return messagesStr; - - } - - @Override - public OutputStream validateResource(IBaseResource resource) { - if (resource == null) { - logger.warn("The resource to be validated is null. Returning null"); - return null; - } - - if (resource instanceof Bundle) { - logger.error( - "Bundle is not a proper parameter for the method Validator.validateResource. Use Validator.validateBundle instead."); - return null; - } - - logger.info("Validating resource " + resource.getIdElement()); - - FhirValidator validator = ctx.newValidator(); - - IValidatorModule schemaModule = new SchemaBaseValidator(ctx); - IValidatorModule schematronModule = new SchematronBaseValidator(ctx); - validator.registerValidatorModule(schemaModule); - validator.registerValidatorModule(schematronModule); - - ValidationResult result = validator.validateWithResult(resource); - logValidationResult(result); - - // direct outcome string to an output stream - ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream(); - - // notice that html tag is not included in the outcome string - try { - String outcomeText = getOutcomeMessagesString(result); - outcomeText = "

" + resource.getIdElement() + "

" + outcomeText + "
"; - outputStream.write(outcomeText.getBytes("UTF-8")); - } catch (IOException e) { - logger.error( - "Exception occurred while trying to write the validation outcome to the output stream. Returning null", - e); - return null; - } - - return outputStream; - } - - @Override - public ValidationResult validateResourceResultOnly(IBaseResource resource) { - if (resource == null) { - logger.warn("The resource to be validated is null. Returning null"); - return null; - } - - logger.info("Validating resource " + resource.getIdElement()); - - FhirContext ctx = FhirContext.forDstu3(); - FhirValidator validator = ctx.newValidator(); - - IValidatorModule schemaModule = new SchemaBaseValidator(ctx); - IValidatorModule schematronModule = new SchematronBaseValidator(ctx); - validator.registerValidatorModule(schemaModule); - validator.registerValidatorModule(schematronModule); - - return validator.validateWithResult(resource); - - } - - @Override - public ValidationResult validateFile(String filepath) throws IOException, FileNotFoundException { - - FhirValidator validator = ctx.newValidator(); - validator.setValidateAgainstStandardSchema(true); - validator.setValidateAgainstStandardSchematron(true); - - String content = IOUtils.toString(new FileReader(filepath)); - IBaseResource resource = ctx.newXmlParser().parseResource(content); - ValidationResult result = validator.validateWithResult(resource); - logValidationResult(result); - return result; - } - - public FhirContext getCtx() { - return ctx; - } - - public void setCtx(FhirContext ctx) { - this.ctx = ctx; - } -} diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties deleted file mode 100644 index 11909dda5..000000000 --- a/src/main/resources/config.properties +++ /dev/null @@ -1,2 +0,0 @@ -# Optional OID subset for use in ifNotExist generation. -# Patient=urn:oid:2.16.840.1.113883.3.552.1.3.11.13.1.8.2 \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml deleted file mode 100644 index b9441170f..000000000 --- a/src/main/resources/logback.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n - - - - - - logs/cda2fhir.log - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - - %msg%n - - - - logs/cda2fhir.%i.log.zip - 1 - 10 - - - - 10MB - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/narrative/AllergyIntolerance.html b/src/main/resources/narrative/AllergyIntolerance.html deleted file mode 100644 index 19dbc8cf4..000000000 --- a/src/main/resources/narrative/AllergyIntolerance.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - -
Substance
Onset
Reaction -
-
-
- - - - - \ No newline at end of file diff --git a/src/main/resources/narrative/CodeableConceptDt.html b/src/main/resources/narrative/CodeableConceptDt.html deleted file mode 100644 index 18867ccb9..000000000 --- a/src/main/resources/narrative/CodeableConceptDt.html +++ /dev/null @@ -1,4 +0,0 @@ -
- -
diff --git a/src/main/resources/narrative/Condition.html b/src/main/resources/narrative/Condition.html deleted file mode 100644 index 6f2253214..000000000 --- a/src/main/resources/narrative/Condition.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
Code
Asserted Date
Category
Clinical Status
Onset
-
- - - - - diff --git a/src/main/resources/narrative/DateDt.html b/src/main/resources/narrative/DateDt.html deleted file mode 100644 index 1b34d54fe..000000000 --- a/src/main/resources/narrative/DateDt.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - -
- -
- - - - - \ No newline at end of file diff --git a/src/main/resources/narrative/DateTimeDt.html b/src/main/resources/narrative/DateTimeDt.html deleted file mode 100644 index 1b34d54fe..000000000 --- a/src/main/resources/narrative/DateTimeDt.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - -
- -
- - - - - \ No newline at end of file diff --git a/src/main/resources/narrative/Device.html b/src/main/resources/narrative/Device.html deleted file mode 100644 index ea76ad44d..000000000 --- a/src/main/resources/narrative/Device.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - -
Identifier
Type
-
- - - - - diff --git a/src/main/resources/narrative/DiagnosticReport.html b/src/main/resources/narrative/DiagnosticReport.html deleted file mode 100644 index e9d2a0cc1..000000000 --- a/src/main/resources/narrative/DiagnosticReport.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - - - - - - - Complete Blood Count - -
- - - - - - - - - - - - - - - - -
StatusFinal
Issued22 March 2012
ConclusionThis is the - conclusion text
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameValueInterpretationReference RangeStatus
- - - - - - - - - - - Hb 2.2 g/L - N - 2.2 g/L - - - 2.9 g/L - final
This is a comment
This is a comment
Lkc198 g/LH78 g/L - 99 g/Lfinal
Yet another comment
- -
- - - - - - - diff --git a/src/main/resources/narrative/Encounter.html b/src/main/resources/narrative/Encounter.html deleted file mode 100644 index 208bbcf34..000000000 --- a/src/main/resources/narrative/Encounter.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
Type
Reason
Start
End
-
- - - - - diff --git a/src/main/resources/narrative/FamilyMemberHistory.html b/src/main/resources/narrative/FamilyMemberHistory.html deleted file mode 100644 index 5c46766af..000000000 --- a/src/main/resources/narrative/FamilyMemberHistory.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - -
Name
Relationship
Born
Deceased
- - - - - - - - - - - - - - - - - - -
Code
Onset
Outcome
-
- - - - - diff --git a/src/main/resources/narrative/Immunization.html b/src/main/resources/narrative/Immunization.html deleted file mode 100644 index 812e42243..000000000 --- a/src/main/resources/narrative/Immunization.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
Vaccine Code
Date (Vaccine Administered)
Not GivenTrue
Route
Dose
-
- - - - - diff --git a/src/main/resources/narrative/Location.html b/src/main/resources/narrative/Location.html deleted file mode 100644 index 06e51fc33..000000000 --- a/src/main/resources/narrative/Location.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - -
Identifier
Name
-
- - - - - diff --git a/src/main/resources/narrative/Medication.html b/src/main/resources/narrative/Medication.html deleted file mode 100644 index c0194a285..000000000 --- a/src/main/resources/narrative/Medication.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - -
- -
-
-
- - - - - - diff --git a/src/main/resources/narrative/MedicationDispense.html b/src/main/resources/narrative/MedicationDispense.html deleted file mode 100644 index e8a3cc1e2..000000000 --- a/src/main/resources/narrative/MedicationDispense.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - -
Dosage Instruction
Timing
Dose
-
- - - - - \ No newline at end of file diff --git a/src/main/resources/narrative/MedicationStatement.html b/src/main/resources/narrative/MedicationStatement.html deleted file mode 100644 index 39fedeca1..000000000 --- a/src/main/resources/narrative/MedicationStatement.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - -
Reason Not Taken
Period
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Timing
Body Site
Route
Quantity
Rate
Max Dose per Period
-
-
- - - - - diff --git a/src/main/resources/narrative/Observation.html b/src/main/resources/narrative/Observation.html deleted file mode 100644 index ba7037483..000000000 --- a/src/main/resources/narrative/Observation.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Category
Code
Date/Period
Body Site
Result
Interpretation
-
- - - - - diff --git a/src/main/resources/narrative/Organization.html b/src/main/resources/narrative/Organization.html deleted file mode 100644 index 06e51fc33..000000000 --- a/src/main/resources/narrative/Organization.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - -
Identifier
Name
-
- - - - - diff --git a/src/main/resources/narrative/Patient.html b/src/main/resources/narrative/Patient.html deleted file mode 100644 index b379e0834..000000000 --- a/src/main/resources/narrative/Patient.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - - - - - - -
Identifier
Address
Date of birth
-
- - - - - diff --git a/src/main/resources/narrative/Practitioner.html b/src/main/resources/narrative/Practitioner.html deleted file mode 100644 index 4ce3dc590..000000000 --- a/src/main/resources/narrative/Practitioner.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - -
Identifier
Name
-
- - - - - diff --git a/src/main/resources/narrative/Procedure.html b/src/main/resources/narrative/Procedure.html deleted file mode 100644 index 555144b3a..000000000 --- a/src/main/resources/narrative/Procedure.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - -
- - - - - - - - - - - -
Type
Date/Period
-
- - - - - diff --git a/src/main/resources/narrative/QuantityDt.html b/src/main/resources/narrative/QuantityDt.html deleted file mode 100644 index a32e8943e..000000000 --- a/src/main/resources/narrative/QuantityDt.html +++ /dev/null @@ -1,4 +0,0 @@ -
- -
diff --git a/src/main/resources/narrative/Substance.html b/src/main/resources/narrative/Substance.html deleted file mode 100644 index d22846fc1..000000000 --- a/src/main/resources/narrative/Substance.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - -
- - - - - - - -
Substance
-
- - - - - diff --git a/src/main/resources/narrative/TimingDt.html b/src/main/resources/narrative/TimingDt.html deleted file mode 100644 index bc596228b..000000000 --- a/src/main/resources/narrative/TimingDt.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - -
- -
- - - - - \ No newline at end of file diff --git a/src/main/resources/narrative/customnarrative.properties b/src/main/resources/narrative/customnarrative.properties deleted file mode 100644 index fc7b8f569..000000000 --- a/src/main/resources/narrative/customnarrative.properties +++ /dev/null @@ -1,101 +0,0 @@ -################################################ -# Composite Datatype -################################################ - -# CodeableConceptDt -codeableconcept.class=org.hl7.fhir.dstu3.model.CodeableConcept -codeableconcept.narrative=file:src/main/resources/narrative/CodeableConceptDt.html - -# DateDt -date.class=org.hl7.fhir.dstu3.model.DateType -date.narrative=file:src/main/resources/narrative/DateDt.html - -# DateTimeDt -datetime.class=org.hl7.fhir.dstu3.model.DateTimeType -datetime.narrative=file:src/main/resources/narrative/DateTimeDt.html - -# TimingDt -timing.class=org.hl7.fhir.dstu3.model.Timing -timing.narrative=file:src/main/resources/narrative/TimingDt.html - -# QuantityDt -quantity.class=org.hl7.fhir.dstu3.model.Quantity -quantity.narrative=file:src/main/resources/narrative/QuantityDt.html - -################################################ -# Resources -################################################ - -# Condition -condition.class=org.hl7.fhir.dstu3.model.Condition -condition.narrative=file:src/main/resources/narrative/Condition.html - -# Device -device.class=org.hl7.fhir.dstu3.model.Device -device.narrative=file:src/main/resources/narrative/Device.html - -# DiagnosticReport -diagnosticreport.class=org.hl7.fhir.dstu3.model.DiagnosticReport -diagnosticreport.narrative=file:src/main/resources/narrative/DiagnosticReport.html - -# Encounter -encounter.class=org.hl7.fhir.dstu3.model.Encounter -encounter.narrative=file:src/main/resources/narrative/Encounter.html - -# FamilyMemberHistory -familymemberhistory.class=org.hl7.fhir.dstu3.model.FamilyMemberHistory -familymemberhistory.narrative=file:src/main/resources/narrative/FamilyMemberHistory.html - -# Patient -patient.class=org.hl7.fhir.dstu3.model.Patient -patient.narrative=file:src/main/resources/narrative/Patient.html - -# Medication -medication.class=org.hl7.fhir.dstu3.model.Medication -medication.narrative=file:src/main/resources/narrative/Medication.html - -# Practitioner -practitioner.class=org.hl7.fhir.dstu3.model.Practitioner -practitioner.narrative=file:src/main/resources/narrative/Practitioner.html - - -# Immunization -immunization.class=org.hl7.fhir.dstu3.model.Immunization -immunization.narrative=file:src/main/resources/narrative/Immunization.html - - -# Observation -observation.class=org.hl7.fhir.dstu3.model.Observation -observation.narrative=file:src/main/resources/narrative/Observation.html - - -# AllergyIntolerance -allergyintolerance.class=org.hl7.fhir.dstu3.model.AllergyIntolerance -allergyintolerance.narrative=file:src/main/resources/narrative/AllergyIntolerance.html - -# MedicationStatement -medicationstatement.class=org.hl7.fhir.dstu3.model.MedicationStatement -medicationstatement.narrative=file:src/main/resources/narrative/MedicationStatement.html - -# MedicationDispense -medicationdispense.class=org.hl7.fhir.dstu3.model.MedicationDispense -medicationdispense.narrative=file:src/main/resources/narrative/MedicationDispense.html - - -# Procedure -procedure.class=org.hl7.fhir.dstu3.model.Procedure -procedure.narrative=file:src/main/resources/narrative/Procedure.html - -# Organization -organization.class=org.hl7.fhir.dstu3.model.Organization -organization.narrative=file:src/main/resources/narrative/Organization.html - -# Location -location.class=org.hl7.fhir.dstu3.model.Location -location.narrative=file:src/main/resources/narrative/Location.html - -# Substance -substance.class=org.hl7.fhir.dstu3.model.Substance -substance.narrative=file:src/main/resources/narrative/Substance.html - - diff --git a/src/test/java/tr/com/srdc/cda2fhir/AllergyConcernActTest.java b/src/test/java/tr/com/srdc/cda2fhir/AllergyConcernActTest.java deleted file mode 100644 index 19b70d030..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/AllergyConcernActTest.java +++ /dev/null @@ -1,475 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.DiagnosticChain; -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent; -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Enumeration; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.Participant2; -import org.openhealthtools.mdht.uml.cda.ParticipantRole; -import org.openhealthtools.mdht.uml.cda.PlayingEntity; -import org.openhealthtools.mdht.uml.cda.consol.AllergyProblemAct; -import org.openhealthtools.mdht.uml.cda.consol.impl.AllergyObservationImpl; -import org.openhealthtools.mdht.uml.cda.consol.impl.AllergyProblemActImpl; -import org.openhealthtools.mdht.uml.cda.consol.impl.AllergyStatusObservationImpl; -import org.openhealthtools.mdht.uml.cda.consol.impl.ConsolFactoryImpl; -import org.openhealthtools.mdht.uml.cda.consol.impl.ReactionObservationImpl; -import org.openhealthtools.mdht.uml.cda.impl.CDAFactoryImpl; -import org.openhealthtools.mdht.uml.cda.impl.EntryRelationshipImpl; -import org.openhealthtools.mdht.uml.cda.impl.Participant2Impl; -import org.openhealthtools.mdht.uml.cda.impl.PlayingEntityImpl; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVXB_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.PN; -import org.openhealthtools.mdht.uml.hl7.datatypes.impl.DatatypesFactoryImpl; -import org.openhealthtools.mdht.uml.hl7.vocab.EntityClassRoot; -import org.openhealthtools.mdht.uml.hl7.vocab.ParticipationType; -import org.openhealthtools.mdht.uml.hl7.vocab.RoleClassRoot; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.AuthorGenerator; -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntryResult; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class AllergyConcernActTest { - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - private static final AuthorGenerator authorGenerator = new AuthorGenerator(); - private static ConsolFactoryImpl cdaObjFactory; - private static DatatypesFactory cdaTypeFactory; - private static CDAFactoryImpl cdaFactory; - - private static Map cdaProblemStatusCodeToName = new HashMap(); - private static Map cdaAllergyIntoleranceTypeCodeToName = new HashMap(); - - private static Map verificationStatusMap = JsonUtils - .filepathToMap("src/test/resources//value-maps/AllergyIntoleranceVerificationStatus.json"); - private static Map categoryMap = JsonUtils - .filepathToMap("src/test/resources//value-maps/AllergyIntoleranceCategory.json"); - private static Map typeMap = JsonUtils - .filepathToMap("src/test/resources//value-maps/AllergyIntoleranceType.json"); - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - - cdaObjFactory = (ConsolFactoryImpl) ConsolFactoryImpl.init(); - cdaTypeFactory = DatatypesFactoryImpl.init(); - cdaFactory = (CDAFactoryImpl) CDAFactoryImpl.init(); - - cdaProblemStatusCodeToName.put("55561003", "Active"); - cdaProblemStatusCodeToName.put("73425007", "Inactive"); - cdaProblemStatusCodeToName.put("413322009", "Resolved"); - - cdaAllergyIntoleranceTypeCodeToName.put("419199007", "Allergy to substance (disorder)"); - cdaAllergyIntoleranceTypeCodeToName.put("416098002", "Drug allergy (disorder)"); - cdaAllergyIntoleranceTypeCodeToName.put("59037007", "Drug intolerance (disorder)"); - cdaAllergyIntoleranceTypeCodeToName.put("414285001", "Food allergy (disorder)"); - cdaAllergyIntoleranceTypeCodeToName.put("235719002", "Food intolerance (disorder)"); - cdaAllergyIntoleranceTypeCodeToName.put("420134006", "Propensity to adverse reactions (disorder)"); - cdaAllergyIntoleranceTypeCodeToName.put("419511003", "Propensity to adverse reactions to drug (disorder)"); - cdaAllergyIntoleranceTypeCodeToName.put("418471000", "Propensity to adverse reactions to food (disorder)"); - cdaAllergyIntoleranceTypeCodeToName.put("418038007", "Propensity to adverse reactions to substance (disorder)"); - cdaAllergyIntoleranceTypeCodeToName.put("232347008", "Dander (animal) allergy"); - } - - static private AllergyIntolerance findOneResource(Bundle bundle) throws Exception { - List allergyResources = bundle.getEntry().stream().map(r -> r.getResource()) - .filter(r -> (r instanceof AllergyIntolerance)).map(r -> (AllergyIntolerance) r) - .collect(Collectors.toList()); - Assert.assertEquals("Multiple AllergyIntolerance resources in the bundle", 1, allergyResources.size()); - return allergyResources.get(0); - } - - static private void verifyAllergyIntoleranceCategory(AllergyProblemAct act, String expected) throws Exception { - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo).getBundle(); - AllergyIntolerance allergyIntolerance = findOneResource(bundle); - - Enumeration category = allergyIntolerance.getCategory().get(0); - String actual = category == null ? null : category.asStringValue(); - Assert.assertEquals("Unexpected AllergyIntolerance category", expected, actual); - } - - static private void verifyAllergyIntoleranceType(AllergyProblemAct act, String expected) throws Exception { - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo).getBundle(); - AllergyIntolerance allergyIntolerance = findOneResource(bundle); - - AllergyIntolerance.AllergyIntoleranceType type = allergyIntolerance.getType(); - String actual = type == null ? null : type.toString().toLowerCase(); - Assert.assertEquals("Unexpected AllergyIntolerance type", expected, actual); - } - - static private AllergyStatusObservationImpl createAllergyStatusObservation(String cdaProblemStatusCode) { - AllergyStatusObservationImpl allergyStatus = (AllergyStatusObservationImpl) cdaObjFactory - .createAllergyStatusObservation(); - - II templateId = cdaTypeFactory.createII("2.16.840.1.113883.10.20.22.4.28"); - allergyStatus.getTemplateIds().add(templateId); - - CD code = cdaTypeFactory.createCD("33999-4", "2.16.840.1.113883.6.1", null, null); - allergyStatus.setCode(code); - - CS cs = cdaTypeFactory.createCS("completed"); - allergyStatus.setStatusCode(cs); - - return allergyStatus; - } - - static private AllergyObservationImpl createAllergyObservation() { - AllergyObservationImpl observation = (AllergyObservationImpl) cdaObjFactory.createAllergyObservation(); - - II templateId = cdaTypeFactory.createII("2.16.840.1.113883.10.20.22.4.7", "2014-06-09"); - observation.getTemplateIds().add(templateId); - - EntryRelationshipImpl entryRelationship = (EntryRelationshipImpl) cdaFactory.createEntryRelationship(); - observation.getEntryRelationships().add(entryRelationship); - AllergyStatusObservationImpl allergyStatus = createAllergyStatusObservation(null); - entryRelationship.setObservation(allergyStatus); - - observation.getEntryRelationships().clear(); - observation.getEntryRelationships().add(entryRelationship); - - return observation; - } - - static private AllergyProblemActImpl createAllergyConcernAct() { - AllergyProblemActImpl act = (AllergyProblemActImpl) cdaObjFactory.createAllergyProblemAct(); - - AllergyObservationImpl observation = createAllergyObservation(); - - act.addObservation(observation); - act.getEntryRelationships().stream().filter(r -> (r.getObservation() == observation)) - .forEach(r -> r.setTypeCode(x_ActRelationshipEntryRelationship.SUBJ)); - - return act; - } - - static private Participant2 createParticipant(String substance) { - Participant2 participant = cdaFactory.createParticipant2(); - ParticipantRole role = cdaFactory.createParticipantRole(); - PlayingEntity entity = cdaFactory.createPlayingEntity(); - PN name = cdaTypeFactory.createPN(); - name.addText(substance); - entity.getNames().add(name); - role.setPlayingEntity(entity); - participant.setParticipantRole(role); - return participant; - } - - @Test - public void testAllergyIntoleranceSubstance() throws Exception { - - String substance = "ASPIRIN"; - AllergyProblemActImpl act = createAllergyConcernAct(); - AllergyObservationImpl observation = (AllergyObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - Participant2 participant = createParticipant(substance); - observation.getParticipants().add(participant); - act.addObservation(observation); - BundleInfo bundleInfo = new BundleInfo(rt); - - EntryResult result = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo); - - AllergyIntolerance fhirAllergy = BundleUtil.findOneResource(result.getBundle(), AllergyIntolerance.class); - - Assert.assertEquals("Allergy.code.display equals substance name", substance, fhirAllergy.getCode().getText()); - } - - @Test - public void testAllergyIntoleranceAuthorToRecorder() throws Exception { - - String substance = "ASPIRIN"; - AllergyProblemActImpl act = createAllergyConcernAct(); - AllergyObservationImpl observation = (AllergyObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - - BundleInfo bundleInfo = new BundleInfo(rt); - - PN name = cdaTypeFactory.createPN(); - name.addText(substance); - Author author = authorGenerator.generateDefaultAuthor(); - observation.getAuthors().add(author); - act.addObservation(observation); - - EntryResult result = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo); - - AllergyIntolerance fhirAllergy = BundleUtil.findOneResource(result.getBundle(), AllergyIntolerance.class); - Practitioner practitioner = BundleUtil.findOneResource(result.getBundle(), Practitioner.class); - - Assert.assertEquals("Allergy.recorder is cda author", practitioner.getId(), - fhirAllergy.getRecorder().getReference()); - } - - @Test - public void testAllergyIntoleranceObservationEffectiveTime() throws Exception { - AllergyProblemActImpl act = createAllergyConcernAct(); - AllergyObservationImpl observation = (AllergyObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - BundleInfo bundleInfo = new BundleInfo(rt); - - String expected1 = "20171002"; - - IVL_TS ivlTs1 = cdaTypeFactory.createIVL_TS(); - IVXB_TS ivxb1 = cdaTypeFactory.createIVXB_TS(); - ivxb1.setValue(expected1); - ivlTs1.setLow(ivxb1); - observation.setEffectiveTime(ivlTs1); - - DiagnosticChain dxChain = new BasicDiagnostic(); - Boolean validation = act.validateAllergyProblemActAllergyObservation(dxChain, null); - Assert.assertTrue("Invalid Allergy Problem Act in Test", validation); - - Bundle bundle1 = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo).getBundle(); - AllergyIntolerance allergyIntolerance1 = findOneResource(bundle1); - String actual1 = allergyIntolerance1.getOnsetDateTimeType().getValueAsString(); - Assert.assertEquals("Unexpected AllergyIntolerance OnSet", expected1, actual1.replaceAll("-", "")); - - String expected2 = "20161103"; - IVL_TS ivlTs2 = cdaTypeFactory.createIVL_TS(); - ivlTs2.setValue(expected2); - observation.setEffectiveTime(ivlTs2); - - Bundle bundle2 = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo).getBundle(); - AllergyIntolerance allergyIntolerance2 = findOneResource(bundle2); - String actual2 = allergyIntolerance2.getOnsetDateTimeType().getValueAsString(); - Assert.assertEquals("Unexpected AllergyIntolerance OnSet", expected2, actual2.replaceAll("-", "")); - } - - @Test - public void testSubstanceReactantForIntolerance() throws Exception { - AllergyProblemActImpl act = createAllergyConcernAct(); - AllergyObservationImpl observation = (AllergyObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - - Participant2Impl participant = (Participant2Impl) cdaFactory.createParticipant2(); - participant.setTypeCode(ParticipationType.CSM); - observation.getParticipants().add(participant); - - ParticipantRole role = cdaFactory.createParticipantRole(); - role.setClassCode(RoleClassRoot.MANU); - participant.setParticipantRole(role); - - PlayingEntityImpl entity = (PlayingEntityImpl) cdaFactory.createPlayingEntity(); - entity.setClassCode(EntityClassRoot.MMAT); - CE ce = cdaTypeFactory.createCE("2670", "2.16.840.1.113883.6.88", "RxNorm", "Codeine"); - entity.setCode(ce); - role.setPlayingEntity(entity); - - DiagnosticChain dxChain = new BasicDiagnostic(); - Boolean validation = act.validateAllergyProblemActAllergyObservation(dxChain, null); - Assert.assertTrue("Invalid Allergy Problem Act in Test", validation); - - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo).getBundle(); - AllergyIntolerance allergyIntolerance = findOneResource(bundle); - CodeableConcept cc = allergyIntolerance.getCode(); - Coding coding = cc.getCoding().get(0); - - Assert.assertEquals("Unexpected AllergyIntolerance code value", "2670", coding.getCode()); - Assert.assertEquals("Unexpected AllergyIntolerance code display value", "Codeine", coding.getDisplay()); - } - - @Test - public void testAllergyAndIntoleranceCategory() throws Exception { - AllergyProblemActImpl act = createAllergyConcernAct(); - AllergyObservationImpl observationTop = (AllergyObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - verifyAllergyIntoleranceVerificationStatus(act, "unconfirmed"); - - for (Map.Entry entry : categoryMap.entrySet()) { - String cdaType = entry.getKey(); - String fhirCategory = (String) entry.getValue(); - String cdaTypeName = cdaAllergyIntoleranceTypeCodeToName.get(cdaType); - - CE ce = cdaTypeFactory.createCE(cdaType, "2.16.840.1.11388 3.6.96", "SNOMED CT", cdaTypeName); - - observationTop.getValues().clear(); - observationTop.getValues().add(ce); - - DiagnosticChain dxChain = new BasicDiagnostic(); - Boolean validation = act.validateAllergyProblemActAllergyObservation(dxChain, null); - Assert.assertTrue("Invalid Allergy Problem Act in Test", validation); - - verifyAllergyIntoleranceCategory(act, fhirCategory); - } - } - - @Test - public void testAllergyAndIntoleranceType() throws Exception { - AllergyProblemActImpl act = createAllergyConcernAct(); - AllergyObservationImpl observationTop = (AllergyObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - verifyAllergyIntoleranceVerificationStatus(act, "unconfirmed"); - - for (Map.Entry entry : typeMap.entrySet()) { - String cdaType = entry.getKey(); - String fhirCategory = (String) entry.getValue(); - String cdaTypeName = cdaAllergyIntoleranceTypeCodeToName.get(cdaType); - - CE ce = cdaTypeFactory.createCE(cdaType, "2.16.840.1.11388 3.6.96", "SNOMED CT", cdaTypeName); - - observationTop.getValues().clear(); - observationTop.getValues().add(ce); - - DiagnosticChain dxChain = new BasicDiagnostic(); - Boolean validation = act.validateAllergyProblemActAllergyObservation(dxChain, null); - Assert.assertTrue("Invalid Allergy Problem Act in Test", validation); - - verifyAllergyIntoleranceType(act, fhirCategory); - } - } - - static private IVL_TS createEffectiveTimeLow(String value) { - IVL_TS ivlTs = cdaTypeFactory.createIVL_TS(); - IVXB_TS ivxb = cdaTypeFactory.createIVXB_TS(); - ivxb.setValue(value); - ivlTs.setLow(ivxb); - return ivlTs; - } - - static private IVL_TS createEffectiveTimeValue(String value) { - IVL_TS ivlTs = cdaTypeFactory.createIVL_TS(); - ivlTs.setValue(value); - return ivlTs; - } - - @Test - public void testReactionObservationEffectiveTime() throws Exception { - AllergyProblemActImpl act = createAllergyConcernAct(); - AllergyObservationImpl observation = (AllergyObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - - String expected1 = "20171102"; - ReactionObservationImpl reactionObservation1 = (ReactionObservationImpl) cdaObjFactory - .createReactionObservation(); - IVL_TS ivlTs1 = createEffectiveTimeLow(expected1); - reactionObservation1.setEffectiveTime(ivlTs1); - - EntryRelationshipImpl entryRelationship1 = (EntryRelationshipImpl) cdaFactory.createEntryRelationship(); - entryRelationship1.setObservation(reactionObservation1); - observation.getEntryRelationships().add(entryRelationship1); - - String expected2 = "20171202"; - ReactionObservationImpl reactionObservation2 = (ReactionObservationImpl) cdaObjFactory - .createReactionObservation(); - IVL_TS ivlTs2 = createEffectiveTimeLow(expected2); - reactionObservation2.setEffectiveTime(ivlTs2); - - EntryRelationshipImpl entryRelationship2 = (EntryRelationshipImpl) cdaFactory.createEntryRelationship(); - entryRelationship2.setObservation(reactionObservation2); - observation.getEntryRelationships().add(entryRelationship2); - - DiagnosticChain dxChain = new BasicDiagnostic(); - Boolean validation = act.validateAllergyProblemActAllergyObservation(dxChain, null); - Assert.assertTrue("Invalid Allergy Problem Act in Test", validation); - - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo).getBundle(); - AllergyIntolerance allergyIntolerance = findOneResource(bundle); - List reactions = allergyIntolerance.getReaction(); - - AllergyIntoleranceReactionComponent reaction1 = reactions.get(0); - AllergyIntoleranceReactionComponent reaction2 = reactions.get(1); - - String actual1 = reaction1.getOnsetElement().getValueAsString(); - String actual2 = reaction2.getOnsetElement().getValueAsString(); - - Assert.assertEquals("Unexpected AllergyIntolerance Reaction Onset value (1):", expected1, - actual1.replaceAll("-", "")); - Assert.assertEquals("Unexpected AllergyIntolerance Reaction Onset value (2):", expected2, - actual2.replaceAll("-", "")); - - } - - @Test - public void testEffectiveTime() throws Exception { - AllergyProblemActImpl act = createAllergyConcernAct(); - DiagnosticChain dxChain = new BasicDiagnostic(); - BundleInfo bundleInfo = new BundleInfo(rt); - - String expected1 = "20171002"; - IVL_TS ivlTs1 = createEffectiveTimeLow(expected1); - act.setEffectiveTime(ivlTs1); - - Boolean validation1 = act.validateAllergyProblemActEffectiveTime(dxChain, null); - Assert.assertTrue("Invalid Allergy Problem Act in Test", validation1); - - Bundle bundle1 = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo).getBundle(); - AllergyIntolerance allergyIntolerance1 = findOneResource(bundle1); - String actual1 = allergyIntolerance1.getAssertedDateElement().getValueAsString(); - Assert.assertEquals("Unexpected AllergyIntolerance Asserted Date (1)", expected1, actual1.replaceAll("-", "")); - - String expected2 = "20161103"; - IVL_TS ivlTs2 = createEffectiveTimeValue(expected2); - act.setEffectiveTime(ivlTs2); - - Boolean validation2 = act.validateAllergyProblemActEffectiveTime(dxChain, null); - Assert.assertTrue("Invalid Allergy Problem Act in Test", validation2); - - Bundle bundle2 = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo).getBundle(); - AllergyIntolerance allergyIntolerance2 = findOneResource(bundle2); - String actual2 = allergyIntolerance2.getAssertedDateElement().getValueAsString(); - Assert.assertEquals("Unexpected AllergyIntolerance Asserted Date (2)", expected2, actual2.replaceAll("-", "")); - } - - static private void verifyAllergyIntoleranceVerificationStatus(AllergyProblemAct act, String expected) - throws Exception { - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tAllergyProblemAct2AllergyIntolerance(act, bundleInfo).getBundle(); - AllergyIntolerance allergyIntolerance = findOneResource(bundle); - - AllergyIntoleranceVerificationStatus verificationStatus = allergyIntolerance.getVerificationStatus(); - String actual = verificationStatus == null ? null : verificationStatus.toCode(); - Assert.assertEquals(expected, actual); - } - - @Test - public void testAllergyIntoleranceStatusCode() throws Exception { - AllergyProblemActImpl act = (AllergyProblemActImpl) cdaObjFactory.createAllergyProblemAct(); - verifyAllergyIntoleranceVerificationStatus(act, "unconfirmed"); - - act.setStatusCode(null); - verifyAllergyIntoleranceVerificationStatus(act, "unconfirmed"); - - act.setStatusCode(cdaTypeFactory.createCS("invalid")); - Assert.assertFalse("Unexpected Valid Allergy Problem Act in Test", - act.validateAllergyProblemActStatusCode(null, null)); - - for (Map.Entry entry : verificationStatusMap.entrySet()) { - String cdaStatusCode = entry.getKey(); - String fhirStatus = (String) entry.getValue(); - - CS cs = cdaTypeFactory.createCS(cdaStatusCode); - act.setStatusCode(cs); - Assert.assertTrue("Invalid Allergy Problem Act in Test", - act.validateAllergyProblemActStatusCode(null, null)); - - verifyAllergyIntoleranceVerificationStatus(act, fhirStatus); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/BundleRequestTest.java b/src/test/java/tr/com/srdc/cda2fhir/BundleRequestTest.java deleted file mode 100644 index 00d6f5e20..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/BundleRequestTest.java +++ /dev/null @@ -1,486 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -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.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Composition; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Device; -import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.hl7.fhir.dstu3.model.Encounter; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.Location; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.MedicationRequest; -import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.hl7.fhir.dstu3.model.Observation; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Patient; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.hl7.fhir.dstu3.model.Procedure; -import org.hl7.fhir.dstu3.model.Reference; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.generator.CDGenerator; -import tr.com.srdc.cda2fhir.transform.CCDTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleRequest; -import tr.com.srdc.cda2fhir.util.FHIRUtil; -import tr.com.srdc.cda2fhir.util.IdGeneratorEnum; - -public class BundleRequestTest { - - private static CDAFactories factories; - private CDGenerator codeGenerator; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - factories = CDAFactories.init(); - - } - - @Test - public void testPatient() throws Exception { - - String sys = "urn:oid:2.16.840.1.113883.3.552.1.3.11.13.1.8.2"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Patient becEntry = new Patient(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertEquals("ifNoneExists has been populated", bec.getRequest().getIfNoneExist(), - "identifier=" + sys + "|" + val); - - } - - @Test - public void testPatientMultipleIds() throws Exception { - String sys1 = "urn:oid:1.2.840.114350.1.13.88.3.7.3.698084.8"; - String val1 = "12345"; - String sys2 = "urn:oid:1.2.840.114350.0.0.0.0.0.0.0.0"; - String val2 = "67890"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Practitioner becEntry = new Practitioner(); - Identifier becId1 = new Identifier(); - Identifier becId2 = new Identifier(); - becId1.setSystem(sys1); - becId1.setValue(val1); - becId2.setSystem(sys2); - becId2.setValue(val2); - becEntry.addIdentifier(becId1); - becEntry.addIdentifier(becId2); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys1 + "|" + val1 + "," + sys2 + "|" + val2)); - } - - @Test - public void testCondition() throws Exception { - - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.2.768076"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Condition becEntry = new Condition(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - - } - - @Test - public void testReports() throws Exception { - - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.2.798268"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - DiagnosticReport becEntry = new DiagnosticReport(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - - } - - @Test - public void testAllergies() throws Exception { - - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.2.768076"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - AllergyIntolerance becEntry = new AllergyIntolerance(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - - } - - @Test - public void testImmunizations() throws Exception { - - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.2.768076"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Immunization becEntry = new Immunization(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - - } - - @Test - public void testMedStatement() throws Exception { - - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.2.798268"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - MedicationStatement becEntry = new MedicationStatement(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - - } - - @Test - public void testMedRequest() throws Exception { - - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.2.798268"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - MedicationRequest becEntry = new MedicationRequest(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - - } - - @Test - public void testProcedure() throws Exception { - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.1.1988.1"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Procedure becEntry = new Procedure(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - } - - @Test - public void testVitalSigns() throws Exception { - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.1.2109.1"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Observation becEntry = new Observation(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - } - - @Test - public void testResults() throws Exception { - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.6.798268.2000"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Observation becEntry = new Observation(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - } - - @Test - public void testEncounter() throws Exception { - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.3.698084.8"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Encounter becEntry = new Encounter(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - } - - @Test - public void testPractitioner() throws Exception { - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.3.698084.8"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Practitioner becEntry = new Practitioner(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - } - - @Test - public void testComposition() throws Exception { - String sys = "urn:oid:2.16.840.1.113883.3.552.1.3.100.1.13.1.999362"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Composition becEntry = new Composition(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.setIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - } - - @Test - public void testLocation() throws Exception { - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.2.686980"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Location becEntry = new Location(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - } - - @Test - public void testOrganization() throws Exception { - String sys = "urn:oid:1.2.840.114350.1.13.88.3.7.2.688879"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Organization becEntry = new Organization(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - } - - @Test - public void testDevice() throws Exception { - String sys = "urn:oid:1.2.840.114350.1.1"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Device becEntry = new Device(); - Identifier becId = new Identifier(); - becId.setSystem(sys); - becId.setValue(val); - becEntry.addIdentifier(becId); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("identifier=" + sys + "|" + val)); - } - - @Test - public void testPractitionerRole() throws Exception { - String pracSys = "urn:oid:1.2.840.114350.1.13.88.3.7.3.698084.8"; - String pracVal = "12345"; - - String orgSys = "urn:oid:1.2.840.114350.1.13.88.3.7.2.696570"; - String orgVal = "67890"; - - // create practitioner - BundleEntryComponent pracBec = new BundleEntryComponent(); - Practitioner pracEntry = new Practitioner(); - Identifier pracId = new Identifier(); - pracId.setSystem(pracSys); - pracId.setValue(pracVal); - pracEntry.addIdentifier(pracId); - pracBec.setResource(pracEntry); - - // create organization - BundleEntryComponent orgBec = new BundleEntryComponent(); - Organization orgEntry = new Organization(); - Identifier orgId = new Identifier(); - orgId.setSystem(orgSys); - orgId.setValue(orgVal); - orgEntry.addIdentifier(orgId); - orgBec.setResource(orgEntry); - - // create linked role. - BundleEntryComponent roleBec = new BundleEntryComponent(); - PractitionerRole roleEntry = new PractitionerRole(); - roleEntry.setOrganization(new Reference(orgBec.getId())); - roleEntry.setPractitioner(new Reference(pracBec.getId())); - roleEntry.setOrganizationTarget(orgEntry); - roleEntry.setPractitionerTarget(pracEntry); - roleBec.setResource(roleEntry); - - BundleRequest.addRequestToEntry(roleBec); - - Assert.assertEquals("ifNoneExists has been populated", roleBec.getRequest().getIfNoneExist(), - "practitioner.identifier=" + pracSys + "|" + pracVal + "&" + "organization.identifier=" + orgSys + "|" - + orgVal); - } - - @Test - public void testUnidentifiedMedication() throws Exception { - String sys = "http://www.nlm.nih.gov/research/umls/rxnorm"; - String val = "12345"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Medication becEntry = new Medication(); - CodeableConcept medicationCode = new CodeableConcept(); - Coding code = new Coding(); - code.setCode(val); - code.setSystem(sys); - code.setDisplay("drug"); - - becEntry.getCode().addCoding(code); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated", - bec.getRequest().getIfNoneExist().equals("code=" + sys + "|" + val)); - } - - @Test - public void testUnidentifiedMedicationMultiCode() throws Exception { - String sys = "http://www.nlm.nih.gov/research/umls/rxnorm"; - String val1 = "12345"; - String val2 = "67890"; - - BundleEntryComponent bec = new BundleEntryComponent(); - Medication becEntry = new Medication(); - CodeableConcept medicationCode = new CodeableConcept(); - Coding code1 = new Coding(); - Coding code2 = new Coding(); - code1.setCode(val1); - code1.setSystem(sys); - code1.setDisplay("drug"); - code2.setCode(val2); - code2.setSystem(sys); - code2.setDisplay("drug"); - - becEntry.getCode().addCoding(code1); - becEntry.getCode().addCoding(code2); - bec.setResource(becEntry); - - BundleRequest.addRequestToEntry(bec); - - Assert.assertTrue("ifNoneExists has been populated correctly.", - bec.getRequest().getIfNoneExist().equals("code=" + sys + "|" + val1 + "&" + sys + "|" + val2)); - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/CCDTransformerTest.java b/src/test/java/tr/com/srdc/cda2fhir/CCDTransformerTest.java deleted file mode 100644 index c4e676f16..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/CCDTransformerTest.java +++ /dev/null @@ -1,362 +0,0 @@ -package tr.com.srdc.cda2fhir; - -/* - * #%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.FileInputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Composition; -import org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode; -import org.hl7.fhir.dstu3.model.Composition.SectionComponent; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.hl7.fhir.dstu3.model.Encounter; -import org.hl7.fhir.dstu3.model.FamilyMemberHistory; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.hl7.fhir.dstu3.model.Observation; -import org.hl7.fhir.dstu3.model.Patient; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.Procedure; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.dstu3.model.Resource; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -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.conf.Config; -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.transform.CCDTransformerImpl; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.section.CDASectionTypeEnum; -import tr.com.srdc.cda2fhir.transform.util.IIdentifierMap; -import tr.com.srdc.cda2fhir.transform.util.IdentifierMapFactory; -import tr.com.srdc.cda2fhir.util.FHIRUtil; -import tr.com.srdc.cda2fhir.util.IdGeneratorEnum; - -public class CCDTransformerTest { - private static final Logger logger = LoggerFactory.getLogger(ResourceTransformerImpl.class); - private final static List addlSections = new ArrayList(); - - static { - addlSections.add(CDASectionTypeEnum.VITAL_SIGNS_SECTION); - addlSections.add(CDASectionTypeEnum.SOCIAL_HISTORY_SECTION); - addlSections.add(CDASectionTypeEnum.RESULTS_SECTION); - addlSections.add(CDASectionTypeEnum.FUNCTIONAL_STATUS_SECTION); - addlSections.add(CDASectionTypeEnum.FAMILY_HISTORY_SECTION); - addlSections.add(CDASectionTypeEnum.MEDICAL_EQUIPMENT_SECTION); - }; - - @BeforeClass - public static void init() { - // 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(); - } - - private static List getSectionEntriesByCode(Composition composition, String code) { - for (SectionComponent section : composition.getSection()) { - String sectionCode = section.getCode().getCoding().get(0).getCode(); - if (code.equals(sectionCode)) { - return section.getEntry(); - } - } - return null; - } - - private static void verifySectionCounts(Bundle bundle, String sectionCode, Class clazz) { - Composition composition = (Composition) bundle.getEntry().get(0).getResource(); - List compositionEntries = getSectionEntriesByCode(composition, sectionCode); - List resources = FHIRUtil.findResources(bundle, clazz); - String msg = String.format("Expect only section resources for type %s", clazz.getSimpleName()); - Assert.assertEquals(msg, compositionEntries == null ? 0 : compositionEntries.size(), resources.size()); - } - - private static void verifyNoDuplicatePractitioner(Bundle bundle) { - IIdentifierMap identifierMap = IdentifierMapFactory.bundleToIds(bundle); - List practitioners = FHIRUtil.findResources(bundle, Practitioner.class); - for (Practitioner practitioner : practitioners) { - if (!practitioner.hasIdentifier()) { - logger.info("No practioner identifier"); - continue; - } - String id = practitioner.getId(); - for (Identifier identifier : practitioner.getIdentifier()) { - String idInMap = identifierMap.get(practitioner.fhirType(), identifier); - Assert.assertNotNull("Practitioner id from map", idInMap); - Assert.assertEquals("Practitioner id from map", id, idInMap); - } - } - } - - private static Bundle readVerifyFile(String sourceName, List addlSections) throws Exception { - logger.info(String.format("Verifying file %s", sourceName)); - FileInputStream fis = new FileInputStream("src/test/resources/" + sourceName); - - ContinuityOfCareDocument cda = (ContinuityOfCareDocument) CDAUtil.loadAs(fis, - ConsolPackage.eINSTANCE.getContinuityOfCareDocument()); - CCDTransformerImpl ccdTransformer = new CCDTransformerImpl(IdGeneratorEnum.COUNTER); - if (addlSections != null) { - addlSections.stream().forEach(r -> ccdTransformer.addSection(r)); - } - Config.setGenerateDafProfileMetadata(false); - Config.setGenerateNarrative(true); - Bundle bundle = ccdTransformer.transformDocument(cda, null, null); - Assert.assertNotNull("Expect a bundle after transformation", bundle); - Assert.assertTrue("Expect some entries", bundle.hasEntry()); - - String baseName = sourceName.substring(0, sourceName.length() - 4); - FHIRUtil.printJSON(bundle, "src/test/resources/output/" + baseName + ".json"); - - BundleUtil.verifyIdsUnique(bundle); - - Composition composition = BundleUtil.findOneResource(bundle, Composition.class); - Assert.assertTrue("Expect composition to be the first resource", - bundle.getEntry().get(0).getResource() == composition); - - // Nothing should create encounters but Encounters Section - verifySectionCounts(bundle, "46240-8", Encounter.class); - - verifyNoDuplicatePractitioner(bundle); - - return bundle; - } - - private static List getSectionEntries(Composition composition, String title) { - for (SectionComponent section : composition.getSection()) { - if (title.equals(section.getTitle())) { - return section.getEntry(); - } - } - return null; - } - - private static void verifySection(Bundle bundle, String title, Class clazz, int count, - int referenceCount) throws Exception { - List resources = BundleUtil.findResources(bundle, clazz, count); - Set ids = resources.stream().map(r -> r.getId()).collect(Collectors.toSet()); - Composition composition = (Composition) bundle.getEntry().get(0).getResource(); - List references = getSectionEntries(composition, title); - Assert.assertNotNull("Expect references in section " + title, references); - Assert.assertEquals("Expect " + referenceCount + " references in composition", referenceCount, - references.size()); - for (int idx = 0; idx < referenceCount; ++idx) { - String id = references.get(idx).getReference().toString(); - Assert.assertTrue("Expect composition reference to be a resource id", ids.contains(id)); - } - } - - private static void verifySection(Bundle bundle, String title, Class clazz, int count) - throws Exception { - verifySection(bundle, title, clazz, count, count); - } - - // Gold Sample r2.1 - @Test - public void testSample1() throws Exception { - readVerifyFile("170.315_b1_toc_gold_sample2_v1.xml", addlSections); - Bundle bundle = readVerifyFile("170.315_b1_toc_gold_sample2_v1.xml", null); - - verifySection(bundle, "ALLERGIES AND ADVERSE REACTIONS", AllergyIntolerance.class, 1); - verifySection(bundle, "PROBLEMS", Condition.class, 1); - verifySection(bundle, "MEDICATIONS", MedicationStatement.class, 1); - verifySection(bundle, "IMMUNIZATIONS", Immunization.class, 1); - verifySection(bundle, "PROCEDURES", Procedure.class, 1); - verifySection(bundle, "VITAL SIGNS", Observation.class, 3); - - // Spot checks - Patient patient = BundleUtil.findOneResource(bundle, Patient.class); - Assert.assertTrue("Expect an identifier for patient", patient.hasIdentifier()); - Assert.assertEquals("Expect the patient id in the CCDA file", "414122222", - patient.getIdentifier().get(0).getValue()); - } - - @Test - public void testSample2() throws Exception { - Bundle bundle = readVerifyFile("C-CDA_R2-1_CCD.xml", addlSections); - - verifySection(bundle, "ALLERGIES AND ADVERSE REACTIONS", AllergyIntolerance.class, 2); - verifySection(bundle, "PROBLEMS", Condition.class, 6, 4); - verifySection(bundle, "MEDICATIONS", MedicationStatement.class, 2); - verifySection(bundle, "IMMUNIZATIONS", Immunization.class, 5); - verifySection(bundle, "PROCEDURES", Procedure.class, 2, 1); - verifySection(bundle, "ENCOUNTERS", Encounter.class, 1); - verifySection(bundle, "VITAL SIGNS", Observation.class, 20, 8); - verifySection(bundle, "SOCIAL HISTORY", Observation.class, 20, 3); - verifySection(bundle, "RESULTS", DiagnosticReport.class, 2, 2); - verifySection(bundle, "FUNCTIONAL STATUS", Observation.class, 20, 2); - verifySection(bundle, "FAMILY HISTORY", FamilyMemberHistory.class, 1, 1); - verifySection(bundle, "MEDICAL EQUIPMENT", Resource.class, 81, 4); - - // Spot checks - BundleUtil util = new BundleUtil(bundle); - util.spotCheckImmunizationPractitioner("e6f1ba43-c0ed-4b9b-9f12-f435d8ad8f92", "Hippocrates", null, - "Good Health Clinic"); - util.spotCheckEncounterPractitioner("2a620155-9d11-439e-92b3-5d9815ff4de8", null, "59058001", null); - util.spotCheckProcedurePractitioner("d68b7e32-7810-4f5b-9cc2-acd54b0fd85d", null, null, - "Community Health and Hospitals"); - util.spotCheckPractitioner("urn:oid:2.16.840.1.113883.19.5.9999.456", "2981823", null, "1001 Village Avenue"); - util.spotCheckAttesterPractitioner(CompositionAttestationMode.PROFESSIONAL, "Primary", "207QA0505X", null); - util.spotCheckAttesterPractitioner(CompositionAttestationMode.LEGAL, "Primary", "207QA0505X", null); - util.spotCheckPractitioner("urn:oid:2.16.840.1.113883.4.6", "5555555555", "Primary", "1004 Healthcare Drive"); - util.spotCheckAuthorPractitioner("Primary", "207QA0505X", null); - util.spotCheckObservationPractitioner("b63a8636-cfff-4461-b018-40ba58ba8b32", null, null, null); - util.spotCheckMedStatementPractitioner("6c844c75-aa34-411c-b7bd-5e4a9f206e29", "Primary", null, null); - util.spotCheckObservationPractitioner("ed9589fd-fda0-41f7-a3d0-dc537554f5c2", null, null, null); - util.spotCheckConditionPractitioner("ab1791b0-5c71-11db-b0de-0800200c9a66", null, null, null); - util.spotCheckAllergyPractitioner("36e3e930-7b14-11db-9fe1-0800200c9a66", null, null, null); - } - - @Test - public void testSample3() throws Exception { - readVerifyFile("170.315_b1_toc_gold_sample2_v1.xml", addlSections); - Bundle bundle = readVerifyFile("Vitera_CCDA_SMART_Sample.xml", null); - - verifySection(bundle, "Allergies", AllergyIntolerance.class, 5); - verifySection(bundle, "Problems", Condition.class, 1); - verifySection(bundle, "Medications", MedicationStatement.class, 16); - verifySection(bundle, "Immunizations", Immunization.class, 1); - verifySection(bundle, "Procedures and Surgical/Medical History", Procedure.class, 4); - verifySection(bundle, "Encounters", Encounter.class, 13); - } - - @Ignore - @Test - public void testEpicSample1() throws Exception { - readVerifyFile("Epic/DOC0001.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample2() throws Exception { - readVerifyFile("Epic/DOC0001 2.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample3() throws Exception { - readVerifyFile("Epic/DOC0001 3.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample4() throws Exception { - readVerifyFile("Epic/DOC0001 4.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample5() throws Exception { - readVerifyFile("Epic/DOC0001 5.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample6() throws Exception { - readVerifyFile("Epic/DOC0001 6.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample7() throws Exception { - readVerifyFile("Epic/DOC0001 7.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample8() throws Exception { - readVerifyFile("Epic/DOC0001 8.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample9() throws Exception { - readVerifyFile("Epic/DOC0001 9.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample10() throws Exception { - readVerifyFile("Epic/DOC0001 10.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample11() throws Exception { - readVerifyFile("Epic/DOC0001 11.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample12() throws Exception { - readVerifyFile("Epic/DOC0001 12.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample13() throws Exception { - readVerifyFile("Epic/DOC0001 13.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample14() throws Exception { - readVerifyFile("Epic/DOC0001 14.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample15() throws Exception { - readVerifyFile("Epic/DOC0001 15.XML", addlSections); - } - - @Ignore - @Test - public void testEpicSample16() throws Exception { - readVerifyFile("Epic/HannahBanana_EpicCCD.xml", addlSections); - } - - @Ignore - @Test - public void testCernerSample1() throws Exception { - readVerifyFile("Cerner/Person-RAKIA_TEST_DOC00001 (1).XML", addlSections); - } - - @Ignore - @Test - public void testCernerSample2() throws Exception { - readVerifyFile("Cerner/Encounter-RAKIA_TEST_DOC00001.XML", addlSections); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/CDAIIMapTest.java b/src/test/java/tr/com/srdc/cda2fhir/CDAIIMapTest.java deleted file mode 100644 index 5963587e0..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/CDAIIMapTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.transform.util.impl.CDAIIMap; - -public class CDAIIMapTest { - private static CDAFactories factories; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - factories = CDAFactories.init(); - } - - private static List generateIIList(String root, String extension) { - II ii = factories.datatype.createII(root, extension); - List list = new ArrayList(); - list.add(ii); - return list; - } - - @Test - public void testBasic() { - CDAIIMap testObject = new CDAIIMap(); - - List lid1 = generateIIList("2.1.4.5", "3344"); - List lid2 = generateIIList("2.2.4.5", "3344"); - List lid3 = generateIIList("2.2.6.5", "3355"); - - testObject.put(lid1, "value1"); - Assert.assertEquals("The first value", "value1", testObject.get(lid1)); - testObject.put(lid2, "value2"); - Assert.assertEquals("The second value", "value2", testObject.get(lid2)); - Assert.assertEquals("The first value", "value1", testObject.get(lid1)); - testObject.put(lid3, "value3"); - Assert.assertEquals("The second value", "value2", testObject.get(lid2)); - Assert.assertEquals("The first value", "value1", testObject.get(lid1)); - Assert.assertEquals("The third value", "value3", testObject.get(lid3)); - - CDAIIMap testObject2 = new CDAIIMap(); - List lid21 = generateIIList("2.1.4.5", "4444"); - List lid22 = generateIIList("2.2.4.5", "4544"); - List lid23 = generateIIList("2.2.7.5", "5555"); - testObject2.put(lid21, "value21"); - testObject2.put(lid22, "value22"); - testObject2.put(lid23, "value23"); - - testObject.put(testObject2); - Assert.assertEquals("The first value", "value1", testObject.get(lid1)); - Assert.assertEquals("The second value", "value2", testObject.get(lid2)); - Assert.assertEquals("The third value", "value3", testObject.get(lid3)); - Assert.assertEquals("The fourth value", "value21", testObject.get(lid21)); - Assert.assertEquals("The fifth value", "value22", testObject.get(lid22)); - Assert.assertEquals("The sixth value", "value23", testObject.get(lid23)); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/CompositionTest.java b/src/test/java/tr/com/srdc/cda2fhir/CompositionTest.java deleted file mode 100644 index a2e369187..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/CompositionTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Composition; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.ClinicalDocument; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; - -import tr.com.srdc.cda2fhir.conf.Config; -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.generator.ClinicalDocumentMetadataGenerator; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntryResult; - -public class CompositionTest { - static ResourceTransformerImpl rt; - static CDAFactories factories; - static ClinicalDocumentMetadataGenerator metadataGenerator; - static String defaultExpectedUse = Config.DEFAULT_IDENTIFIER_USE.getDisplay(); - static String defaultExpectedStatus = Config.DEFAULT_COMPOSITION_STATUS.getDisplay(); - static String defaultExpectedAssigner = ClinicalDocumentMetadataGenerator.DEFAULT_ASSN_AUTH; - static String defaultExpectedIdValue = ClinicalDocumentMetadataGenerator.DEFAULT_ID_ROOT; - static String defaultExpectedTypeCode = ClinicalDocumentMetadataGenerator.DEFAULT_CODE_CODE; - static String defaultExpectedTypeSystem = "http://loinc.org"; - static String defaultExpectedTypeDisplay = ClinicalDocumentMetadataGenerator.DEFAULT_CODE_DISPLAY; - static String defaultExpectedTitle = ClinicalDocumentMetadataGenerator.DEFAULT_TITLE; - static String defaultExpectedConfidentiality = "N"; - static String defaultExpectedPeriodStart = "1970-09-19"; - static String defaultExpectedPeriodEnd = "2019-02-14"; - static String defaultExpectedEventCodeText = "Primary Care Physician"; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - rt = new ResourceTransformerImpl(); - factories = CDAFactories.init(); - metadataGenerator = new ClinicalDocumentMetadataGenerator(); - } - - @Test - public void testComposition() throws Exception { - - ClinicalDocument clinicalDoc = metadataGenerator.generateClinicalDoc(factories); - EntryResult entryResult = rt.tClinicalDocument2Composition(clinicalDoc); - Bundle bundle = entryResult.getBundle(); - Composition comp = BundleUtil.findOneResource(bundle, Composition.class); - Practitioner primary = BundleUtil.findOneResource(bundle, Practitioner.class); - - Assert.assertEquals("Expect assigner to equal assigningAuthorityName", defaultExpectedAssigner, - comp.getIdentifier().getAssigner().getDisplay()); - Assert.assertEquals("Expect use to equal default", defaultExpectedUse, - comp.getIdentifier().getUse().getDisplay()); - Assert.assertEquals("Expect status to equal default", defaultExpectedStatus, comp.getStatus().getDisplay()); - Assert.assertEquals("Expect Identifier Value to equal Clinical Document id root", defaultExpectedIdValue, - comp.getIdentifier().getValue()); - Assert.assertEquals("Expect type.code to equal code.code", defaultExpectedTypeCode, - comp.getType().getCodingFirstRep().getCode()); - Assert.assertEquals("Expect type.system code.codeSystemName", defaultExpectedTypeSystem, - comp.getType().getCodingFirstRep().getSystem()); - Assert.assertEquals("Expect type.display code.displayName", defaultExpectedTypeDisplay, - comp.getType().getCodingFirstRep().getDisplay()); - Assert.assertEquals("Expect title to equal title", defaultExpectedTitle, comp.getTitle()); - Assert.assertEquals("Expect confidentiality to equal confidentiality", defaultExpectedConfidentiality, - comp.getConfidentiality().toString()); - Assert.assertEquals("Expect composition to code system to equal http://hl7.org/fhir/ValueSet/doc-classcodes", - "http://hl7.org/fhir/ValueSet/doc-classcodes", comp.getClass_().getCodingFirstRep().getSystem()); - Assert.assertEquals("Expect composition to code to equal LP173418-7", "LP173421-7", - comp.getClass_().getCodingFirstRep().getCode()); - Assert.assertEquals("Expect composition to code display to equal Note", "Note", - comp.getClass_().getCodingFirstRep().getDisplay()); - Assert.assertEquals("Expect composition event.detail to contain reference to prmary care physician", - comp.getEvent().get(0).getDetailFirstRep().getReference(), primary.getId()); - Assert.assertEquals("Expect composition event.period.start to equal service Event effective time low", - defaultExpectedPeriodStart, comp.getEvent().get(0).getPeriod().getStartElement().getValueAsString()); - Assert.assertEquals("Expect composition event.period.end to equal service Event effective time high", - defaultExpectedPeriodEnd, comp.getEvent().get(0).getPeriod().getEndElement().getValueAsString()); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/ConditionTest.java b/src/test/java/tr/com/srdc/cda2fhir/ConditionTest.java deleted file mode 100644 index 9459b2382..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ConditionTest.java +++ /dev/null @@ -1,104 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Condition; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.consol.Indication; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.generator.IndicationGenerator; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class ConditionTest { - - private static CDAFactories factories; - private static IndicationGenerator indicationGenerator; - private static ResourceTransformerImpl rt = new ResourceTransformerImpl(); - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - factories = CDAFactories.init(); - indicationGenerator = IndicationGenerator.getDefaultInstance(); - } - - @Test - public void tIndication2ConditionCategoryTest() { - Indication indication = indicationGenerator.generate(factories); - - IEntryResult encounterCondResult = rt.tIndication2ConditionEncounter(indication, new BundleInfo(rt)); - Condition encounterCondition = null; - if (encounterCondResult.hasResult()) { - Bundle bundle = encounterCondResult.getBundle(); - encounterCondition = FHIRUtil.findFirstResource(bundle, Condition.class); - } else { - Bundle bundle = encounterCondResult.getFullBundle(); - encounterCondition = FHIRUtil.findFirstResource(bundle, Condition.class); - } - - IEntryResult problemListItemResult = rt.tIndication2ConditionProblemListItem(indication, new BundleInfo(rt)); - Condition problemListItemCondition = null; - if (problemListItemResult.hasResult()) { - Bundle bundle = problemListItemResult.getBundle(); - problemListItemCondition = FHIRUtil.findFirstResource(bundle, Condition.class); - } else { - Bundle bundle = problemListItemResult.getFullBundle(); - problemListItemCondition = FHIRUtil.findFirstResource(bundle, Condition.class); - } - - String categoryDisplay = encounterCondition.getCategoryFirstRep().getCodingFirstRep().getDisplay(); - String categoryCode = encounterCondition.getCategoryFirstRep().getCodingFirstRep().getCode(); - String categorySystem = encounterCondition.getCategoryFirstRep().getCodingFirstRep().getSystem(); - - Assert.assertEquals("category system is http://hl7.org/fhir/condition-category", categorySystem, - "http://hl7.org/fhir/condition-category"); - Assert.assertEquals("category code is encounter-diagnosis", categoryCode, "encounter-diagnosis"); - Assert.assertEquals("category displauy is Encounter Diagnosis", categoryDisplay, "Encounter Diagnosis"); - - categoryDisplay = problemListItemCondition.getCategoryFirstRep().getCodingFirstRep().getDisplay(); - categoryCode = problemListItemCondition.getCategoryFirstRep().getCodingFirstRep().getCode(); - categorySystem = problemListItemCondition.getCategoryFirstRep().getCodingFirstRep().getSystem(); - - Assert.assertEquals("category system is http://hl7.org/fhir/condition-category", categorySystem, - "http://hl7.org/fhir/condition-category"); - Assert.assertEquals("category code is problem-list-item", categoryCode, "problem-list-item"); - Assert.assertEquals("category displauy is Problem List Item", categoryDisplay, "Problem List Item"); - - } - - @Test - public void testRepeatConditionCategory() { - BundleInfo bundleInfo = new BundleInfo(rt); - - Indication indication = indicationGenerator.generate(factories); - - IEntryResult encounterCondResult = rt.tIndication2ConditionEncounter(indication, bundleInfo); - - bundleInfo.updateFrom(encounterCondResult); - - IEntryResult problemListItemResult = rt.tIndication2ConditionProblemListItem(indication, bundleInfo); - Condition problemListItemCondition = null; - - if (problemListItemResult.hasResult()) { - Bundle bundle = problemListItemResult.getBundle(); - problemListItemCondition = FHIRUtil.findFirstResource(bundle, Condition.class); - } else { - Bundle bundle = problemListItemResult.getFullBundle(); - problemListItemCondition = FHIRUtil.findFirstResource(bundle, Condition.class); - } - CodeableConcept categoryEncounter = problemListItemCondition.getCategoryFirstRep(); - CodeableConcept categoryProblemListItem = problemListItemCondition.getCategory().get(1); - - Assert.assertEquals(categoryEncounter.getCodingFirstRep().getCode(), "encounter-diagnosis"); - Assert.assertEquals(categoryProblemListItem.getCodingFirstRep().getCode(), "problem-list-item"); - - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/DataTypesTransformerTest.java b/src/test/java/tr/com/srdc/cda2fhir/DataTypesTransformerTest.java deleted file mode 100644 index afc7532a1..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/DataTypesTransformerTest.java +++ /dev/null @@ -1,1010 +0,0 @@ -package tr.com.srdc.cda2fhir; - -/* - * #%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.math.BigDecimal; -import java.util.Map; -import java.util.TimeZone; - -import org.hl7.fhir.dstu3.model.Address; -import org.hl7.fhir.dstu3.model.Attachment; -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.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.InstantType; -import org.hl7.fhir.dstu3.model.IntegerType; -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.StringType; -import org.hl7.fhir.dstu3.model.Timing; -import org.junit.Assert; -import org.junit.Test; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -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.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.IVXB_PQ; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVXB_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.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.vocab.EntityNameUse; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; -import org.openhealthtools.mdht.uml.hl7.vocab.PostalAddressUse; -import org.openhealthtools.mdht.uml.hl7.vocab.TelecommunicationAddressUse; - -import com.helger.commons.collection.attr.StringMap; - -import tr.com.srdc.cda2fhir.conf.Config; -import tr.com.srdc.cda2fhir.transform.DataTypesTransformerImpl; -import tr.com.srdc.cda2fhir.transform.IDataTypesTransformer; - -public class DataTypesTransformerTest { - IDataTypesTransformer dtt = new DataTypesTransformerImpl(); - - @SuppressWarnings("deprecation") - @Test - public void testAD2Address() { - // simple instance test - AD ad = DatatypesFactory.eINSTANCE.createAD(); - // See https://www.hl7.org/fhir/valueset-address-use.html to see valuset of - // address use - ad.getUses().add(PostalAddressUse.H); // PostalAddressUse.H maps to home - ad.getUses().add(PostalAddressUse.PST); // PST maps to postal - ad.addText("theText"); - String[] lineArray = new String[2]; - lineArray[0] = "streetLine"; - lineArray[1] = "deliveryLine"; - ad.addStreetAddressLine(lineArray[0]); - ad.addDeliveryAddressLine(lineArray[1]); - ad.addCity("theCity"); - ad.addCounty("theDistrict"); // Notice that it is county, not country - ad.addState("theState"); - ad.addPostalCode("thePostalCode"); - ad.addCountry("theCountry"); - - SXCM_TS start = DatatypesFactory.eINSTANCE.createSXCM_TS(); - SXCM_TS end = DatatypesFactory.eINSTANCE.createSXCM_TS(); - start.setValue("19630516"); - end.setValue("20130721"); - ad.getUseablePeriods().add(start); - ad.getUseablePeriods().add(end); - - Address address = dtt.AD2Address(ad); - - Assert.assertEquals("AD.use was not transformed", "home", address.getUse().toCode()); - Assert.assertEquals("AD.type was not transformed", "postal", address.getType().toCode()); - Assert.assertEquals("AD.text was not transformed", "theText", address.getText()); - - // line array check - int matchingElements = 0; - for (StringType line : address.getLine()) { - for (String line2 : lineArray) { - if (line.getValue().equals(line2)) { - matchingElements++; - } - } - } - - Assert.assertTrue("AD.line was not transformed", matchingElements == lineArray.length); - Assert.assertEquals("AD.city was not transformed", "theCity", address.getCity()); - Assert.assertEquals("AD.district was not transformed", "theDistrict", address.getDistrict()); - Assert.assertEquals("AD.state was not transformed", "theState", address.getState()); - Assert.assertEquals("AD.postalCode was not transformed", "thePostalCode", address.getPostalCode()); - Assert.assertEquals("AD.country was not transformed", "theCountry", address.getCountry()); - - // Notice that Date.getYear() returns THE_YEAR - 1900. It returns 116 for 2016 - // since 2016-1900 = 116. - Assert.assertEquals("AD.period.start.year was not transformed", 1963 - 1900, - address.getPeriod().getStart().getYear()); - // Notice that Date.getMonth() returns THE_MONTH - 1 (since the months are - // indexed btw the range 0-11) - Assert.assertEquals("AD.period.start.month was not transformed", 5 - 1, - address.getPeriod().getStart().getMonth()); - Assert.assertEquals("AD.period.start.date was not transformed", 16, address.getPeriod().getStart().getDate()); - Assert.assertEquals("AD.period.end.year was not transformed", 2013 - 1900, - address.getPeriod().getEnd().getYear()); - Assert.assertEquals("AD.period.end.month was not transformed", 7 - 1, address.getPeriod().getEnd().getMonth()); - Assert.assertEquals("AD.period.end.date was not transformed", 21, address.getPeriod().getEnd().getDate()); - - // instance test: there exists an instance of ED but no setter is called - AD ad4 = DatatypesFactory.eINSTANCE.createAD(); - Address address4 = dtt.AD2Address(ad4); - Assert.assertNull("AD.use was not transformed", address4.getUse()); - Assert.assertNull("AD.type was not transformed", address4.getType()); - Assert.assertNull("AD.text was not transformed", address4.getText()); - - Assert.assertTrue("AD.line was not transformed", address4.getLine().size() == 0); - Assert.assertNull("AD.city was not transformed", address4.getCity()); - Assert.assertNull("AD.district was not transformed", address4.getDistrict()); - Assert.assertNull("AD.state was not transformed", address4.getState()); - Assert.assertNull("AD.postalCode was not transformed", address4.getPostalCode()); - Assert.assertNull("AD.country was not transformed", address4.getCountry()); - - // Notice that Date.getYear() returns THE_YEAR - 1900. It returns 116 for 2016 - // since 2016-1900 = 116. - Assert.assertNull("AD.period.start was not transformed", address4.getPeriod().getStart()); - Assert.assertNull("AD.period.end was not transformed", address4.getPeriod().getEnd()); - - // null instance test - AD ad2 = null; - Address address2 = dtt.AD2Address(ad2); - Assert.assertNull("AD null instance transform failed", address2); - - // nullFlavor instance test - AD ad3 = DatatypesFactory.eINSTANCE.createAD(); - ad3.setNullFlavor(NullFlavor.NI); - Address address3 = dtt.AD2Address(ad3); - Assert.assertNull("AD.nullFlavor set instance transform failed", address3); - } - - @Test - public void testBL2Boolean() { - // simple instance test - BL bl = DatatypesFactory.eINSTANCE.createBL(); - bl.setValue(true); - BooleanType bool = dtt.tBL2Boolean(bl); - Assert.assertEquals("BL.value was not transformed", true, bool.getValue()); - - // null instance test - BL bl2 = null; - BooleanType bool2 = dtt.tBL2Boolean(bl2); - Assert.assertNull("BL null instance transform failed", bool2); - - } - - @Test - public void testCD2CodeableConcept() { - // simple instance test - CD cd = DatatypesFactory.eINSTANCE.createCD(); - - cd.setCode("code"); - cd.setCodeSystem("codeSystem"); - cd.setCodeSystemVersion("codeSystemVersion"); - cd.setDisplayName("displayName"); - - CodeableConcept codeableConcept = dtt.tCD2CodeableConcept(cd); - - Assert.assertEquals("CD.code transformation failed", "code", codeableConcept.getCoding().get(0).getCode()); - Assert.assertEquals("CD.codeSystem transformation failed", "urn:oid:codeSystem", - codeableConcept.getCoding().get(0).getSystem()); - Assert.assertEquals("CD.codeSystemVersion transformation failed", "codeSystemVersion", - codeableConcept.getCoding().get(0).getVersion()); - Assert.assertEquals("CD.displayName transformation failed", "displayName", - codeableConcept.getCoding().get(0).getDisplay()); - - // null instance test - CD cd2 = null; - CodeableConcept codeableConcept2 = dtt.tCD2CodeableConcept(cd2); - Assert.assertNull("CD null instance transform failed", codeableConcept2); - - // nullFlavor instance test - CD cd3 = DatatypesFactory.eINSTANCE.createCD(); - cd3.setNullFlavor(NullFlavor.NI); - CodeableConcept codeableConcept3 = dtt.tCD2CodeableConcept(cd3); - Assert.assertNull("CodeableConcept.nullFlavor set instance transform failed", codeableConcept3); - - // originalText test with reference. - CD cd4 = DatatypesFactory.eINSTANCE.createCD(); - ED ed4 = DatatypesFactory.eINSTANCE.createED(); - TEL tel4 = DatatypesFactory.eINSTANCE.createTEL(); - tel4.setValue("#fakeid1"); - ed4.setReference(tel4); - - cd4.setCode("code"); - cd4.setCodeSystem("codeSystem"); - cd4.setOriginalText(ed4); - - Map idedAnnotations = new StringMap(); - idedAnnotations.put("fakeid1", "fakevalue2"); - - CodeableConcept codeableConcept4 = dtt.tCD2CodeableConcept(cd4, idedAnnotations); - Assert.assertEquals("CodeableConcept sets text based on pointer and annotations", "fakevalue2", - codeableConcept4.getText()); - - // originalText test without reference. - CD cd5 = DatatypesFactory.eINSTANCE.createCD(); - ED ed5 = DatatypesFactory.eINSTANCE.createED(); - ed5.addText("originalText"); - cd5.setCode("code"); - cd5.setCodeSystem("codeSystem"); - cd5.setOriginalText(ed5); - - CodeableConcept codeableConcept5 = dtt.tCD2CodeableConcept(cd5); - Assert.assertEquals("CodeableConcept sets original text without references", "originalText", - codeableConcept5.getText()); - - // empty padded strings don't create ref. - CD cd6 = DatatypesFactory.eINSTANCE.createCD(); - ED ed6 = DatatypesFactory.eINSTANCE.createED(); - ed6.addText(" "); - cd6.setCode("code"); - cd6.setCodeSystem("codeSystem"); - cd6.setOriginalText(ed6); - - CodeableConcept codeableConcept6 = dtt.tCD2CodeableConcept(cd6); - Assert.assertEquals("CodeableConcept sets original text without references", null, codeableConcept6.getText()); - - } - - @Test - public void testCV2Coding() { - // simple instance test - CV cv = DatatypesFactory.eINSTANCE.createCV(); - cv.setCodeSystem("theCodeSystem"); - cv.setCodeSystemVersion("theCodeSystemVersion"); - cv.setCode("theCode"); - cv.setDisplayName("theDisplayName"); - - Coding coding = dtt.tCV2Coding(cv); - - Assert.assertEquals("CV.codeSystem was not transformed", "theCodeSystem", coding.getSystem()); - Assert.assertEquals("CV.codeSystemVersion was not transformed", "theCodeSystemVersion", coding.getVersion()); - Assert.assertEquals("CV.code was not transformed", "theCode", coding.getCode()); - Assert.assertEquals("CV.displayName was not transformed", "theDisplayName", coding.getDisplay()); - - // instance test: there exists an instance of CV but no setter is called - CV cv4 = DatatypesFactory.eINSTANCE.createCV(); - - Coding coding4 = dtt.tCV2Coding(cv4); - - Assert.assertNull("CV.codeSystem null value was not transformed properly", coding4.getSystem()); - Assert.assertNull("CV.codeSystemVersion null value was not transformed properly", coding4.getVersion()); - Assert.assertNull("CV.code null value was not transformed properly", coding4.getCode()); - Assert.assertNull("CV.displayName null value was not transformed properly", coding4.getDisplay()); - - // null instance test - CV cv2 = null; - Coding coding2 = dtt.tCV2Coding(cv2); - Assert.assertNull("CV null instance transform failed", coding2); - - // nullFlavor instance test - CV cv3 = DatatypesFactory.eINSTANCE.createCV(); - cv3.setNullFlavor(NullFlavor.NI); - Coding coding3 = dtt.tCV2Coding(cv3); - Assert.assertNull("CV.nullFlavor set instance transform failed", coding3); - } - - @Test - public void testED2Attachment() { - // simple instance test - ED ed = DatatypesFactory.eINSTANCE.createED(); - ed.setMediaType("theMediaType"); - ed.setLanguage("theLanguage"); - ed.addText("theData"); - TEL theTel = DatatypesFactory.eINSTANCE.createTEL(); - theTel.setValue("theUrl"); - ed.setReference(theTel); - ed.setIntegrityCheck("theIntegrityCheck".getBytes()); - - Attachment attachment = dtt.tED2Attachment(ed); - Assert.assertEquals("ED.mediaType was not transformed", "theMediaType", attachment.getContentType()); - Assert.assertEquals("ED.language was not transformed", "theLanguage", attachment.getLanguage()); - Assert.assertArrayEquals("ED.data was not transformed", "theData".getBytes(), attachment.getData()); - Assert.assertEquals("ED.reference.literal was not transformed", "theUrl", attachment.getUrl()); - Assert.assertArrayEquals("ED.integrityCheck was not transformed", "theIntegrityCheck".getBytes(), - attachment.getHash()); - - // instance test: there exists an instance of ED but no setter is called - ED ed4 = DatatypesFactory.eINSTANCE.createED(); - Attachment attachment4 = dtt.tED2Attachment(ed4); - Assert.assertNull("ED.mediaType was not transformed", attachment4.getContentType()); - Assert.assertNull("ED.language was not transformed", attachment4.getLanguage()); - Assert.assertNull("ED.data was not transformed", attachment4.getData()); - Assert.assertNull("ED.reference.literal was not transformed", attachment4.getUrl()); - Assert.assertNull("ED.integrityCheck was not transformed", attachment4.getHash()); - - // null instance test - ED ed2 = null; - Attachment attachment2 = dtt.tED2Attachment(ed2); - Assert.assertNull("ED null instance transform failed", attachment2); - - // nullFlavor instance test - ED ed3 = DatatypesFactory.eINSTANCE.createED(); - ed3.setNullFlavor(NullFlavor.NI); - Attachment attachment3 = dtt.tED2Attachment(ed3); - Assert.assertNull("ED.nullFlavor set instance transform failed", attachment3); - } - - @Test - public void testEN2HumanName() { - // simple instance test 1 - EN en = DatatypesFactory.eINSTANCE.createEN(); - // Notice that EntityNameUse.P maps to NameUseEnum.NICKNAME. - en.getUses().add(EntityNameUse.P); - en.addText("theText"); - en.addFamily("theFamily"); - en.addGiven("theGiven"); - en.addPrefix("thePrefix"); - en.addSuffix("theSuffix"); - - // Data for ivl_ts: low: 19950127, high: 20160228 - IVL_TS ivl_ts = DatatypesFactory.eINSTANCE.createIVL_TS("19950115", "20160228"); - en.setValidTime(ivl_ts); - - HumanName humanName = dtt.tEN2HumanName(en); - - Assert.assertEquals("EN.use was not transformed", "nickname", humanName.getUse().toCode()); - Assert.assertEquals("EN.text was not transformed", "theText", humanName.getText()); - Assert.assertEquals("EN.family was not transformed", "theFamily", humanName.getFamily()); - Assert.assertEquals("EN.given was not transformed", "theGiven", humanName.getGiven().get(0).getValue()); - Assert.assertEquals("EN.prefix was not transformed", "thePrefix", humanName.getPrefix().get(0).getValue()); - Assert.assertEquals("EN.suffix was not transformed", "theSuffix", humanName.getSuffix().get(0).getValue()); - - // EN.period tests for the simple instance test 1 - Period en_period = dtt.tIVL_TS2Period(ivl_ts); - Assert.assertEquals("EN.period(low) was not transformed", en_period.getStart(), - humanName.getPeriod().getStart()); - Assert.assertEquals("EN.period(high) was not transformed", en_period.getEnd(), humanName.getPeriod().getEnd()); - - // instance test: there exists an instance of ED but no setter is called - EN en4 = DatatypesFactory.eINSTANCE.createEN(); - HumanName humanName4 = dtt.tEN2HumanName(en4); - Assert.assertNull("EN.use was not transformed", humanName4.getUse()); - Assert.assertNull("EN.text was not transformed", humanName4.getText()); - Assert.assertTrue("EN.family was not transformed", !humanName4.getFamilyElement().hasValue()); - Assert.assertTrue("EN.given was not transformed", humanName4.getGiven().size() == 0); - Assert.assertTrue("EN.prefix was not transformed", humanName4.getPrefix().size() == 0); - Assert.assertTrue("EN.suffix was not transformed", humanName4.getSuffix().size() == 0); - - // null instance test - EN en2 = null; - HumanName humanName2 = dtt.tEN2HumanName(en2); - Assert.assertNull("ED null instance transform failed", humanName2); - - // nullFlavor instance test - EN en3 = DatatypesFactory.eINSTANCE.createEN(); - en3.setNullFlavor(NullFlavor.NI); - HumanName humanName3 = dtt.tEN2HumanName(en3); - Assert.assertNull("EN.nullFlavor set instance transform failed", humanName3); - } - - @Test - public void testII2Identifier() { - // simple instance test - II ii = DatatypesFactory.eINSTANCE.createII(); - ii.setRoot("2.16.840.1.113883.19.5.99999.1"); - ii.setExtension("myIdentifierExtension"); - ii.setAssigningAuthorityName("assigning Authority Name"); - - Identifier identifier = dtt.tII2Identifier(ii); - Assert.assertEquals("II.root was not transformed", "urn:oid:2.16.840.1.113883.19.5.99999.1", - identifier.getSystem()); - Assert.assertEquals("II.extension was not transformed", "myIdentifierExtension", identifier.getValue()); - Assert.assertEquals("II.assigningAuthorityName was not transformed", "assigning Authority Name", - identifier.getAssigner().getDisplay()); - - // test defaults - - Assert.assertEquals("II.use equals default use", Config.DEFAULT_IDENTIFIER_USE, identifier.getUse()); - Assert.assertEquals("II.type.", Config.DEFAULT_IDENTIFIER_USE, identifier.getUse()); - - // null instance test - - II ii2 = null; - Identifier identifier2 = dtt.tII2Identifier(ii2); - Assert.assertNull("II null instance was not transformed", identifier2); - - // nullFlavor instance test - II ii3 = DatatypesFactory.eINSTANCE.createII(); - ii3.setNullFlavor(NullFlavor.MSK); - Identifier identifier3 = dtt.tII2Identifier(ii3); - Assert.assertNull("II nullFlavor set instance transform failed", identifier3); - - } - - @Test - public void testINT2Integer() { - // simple instance test - INT myInt = DatatypesFactory.eINSTANCE.createINT(); - myInt.setValue(65); - IntegerType integer = dtt.tINT2Integer(myInt); - - Assert.assertEquals("INT.value was not transformed", 65.0, integer.getValue().doubleValue(), 0.001); - - // null instance test - INT int2 = null; - IntegerType integer2 = dtt.tINT2Integer(int2); - Assert.assertNull("INT null instance transform failed", integer2); - - } - - @Test - public void testIVL_PQ2Range() { - // simple instance test - IVL_PQ ivlpq = DatatypesFactory.eINSTANCE.createIVL_PQ(); - IVXB_PQ ivxbpqH = DatatypesFactory.eINSTANCE.createIVXB_PQ(); - ivxbpqH.setValue(0.2); - ivxbpqH.setUnit("unit"); - IVXB_PQ ivxbpqL = DatatypesFactory.eINSTANCE.createIVXB_PQ(); - ivxbpqL.setValue(0.1); - ivxbpqL.setUnit("unit"); - - ivlpq.setHigh(ivxbpqH); - ivlpq.setLow(ivxbpqL); - - Range range = dtt.tIVL_PQ2Range(ivlpq); - - Assert.assertEquals("IVL_PQ.high.unit was not transformed", ivlpq.getHigh().getUnit(), - range.getHigh().getUnit()); - Assert.assertEquals("IVL_PQ.high.value was not transformed", ivlpq.getHigh().getValue(), - range.getHigh().getValue()); - Assert.assertEquals("IVL_PQ.low.unit was not transformed", ivlpq.getLow().getUnit(), range.getLow().getUnit()); - Assert.assertEquals("IVL_PQ.low.value was not transformed", ivlpq.getLow().getValue(), - range.getLow().getValue()); - - // null instance test - IVL_PQ ivlpq2 = null; - Range range2 = dtt.tIVL_PQ2Range(ivlpq2); - Assert.assertNull("IVL_PQ null instance transform failed", range2); - - // nullFlavor instance test - IVL_PQ ivlpq3 = DatatypesFactory.eINSTANCE.createIVL_PQ(); - ivlpq3.setNullFlavor(NullFlavor.NI); - Range range3 = dtt.tIVL_PQ2Range(ivlpq3); - Assert.assertNull("IVL_PQ.nullFlavor set instance transform failed", range3); - - IVL_PQ ivlpq5 = DatatypesFactory.eINSTANCE.createIVL_PQ(); - IVXB_PQ ivxbpqH_2 = DatatypesFactory.eINSTANCE.createIVXB_PQ(); - ivxbpqH_2.setNullFlavor(NullFlavor.NI); - ivlpq5.setHigh(ivxbpqH_2); - - Range range5 = dtt.tIVL_PQ2Range(ivlpq5); - Assert.assertNull("IVL_PQ.nullFlavor set instance transform failed", range5.getHigh().getValue()); - - // non-null empty instance test - IVL_PQ ivlpq4 = DatatypesFactory.eINSTANCE.createIVL_PQ(); - Range range4 = dtt.tIVL_PQ2Range(ivlpq4); - Assert.assertNull("IVL_PQ.high.value transform failed", range4.getHigh().getValue()); - Assert.assertNull("IVL_PQ.low.value transform failed", range4.getLow().getValue()); - Assert.assertNull("IVL_PQ.high.unit transform failed", range4.getHigh().getUnit()); - Assert.assertNull("IVL_PQ.low.unit transform failed", range4.getLow().getUnit()); - - } - - @SuppressWarnings("deprecation") - @Test - public void testIVL_TS2Period() { - // simple instance test 1 - IVL_TS ivl_ts = DatatypesFactory.eINSTANCE.createIVL_TS(); - - IVXB_TS ivxb_tsLow = DatatypesFactory.eINSTANCE.createIVXB_TS(); - IVXB_TS ivxb_tsHigh = DatatypesFactory.eINSTANCE.createIVXB_TS(); - - ivxb_tsLow.setValue("19630116"); - ivxb_tsHigh.setValue("20151122"); - - ivl_ts.setLow(ivxb_tsLow); - ivl_ts.setHigh(ivxb_tsHigh); - - Period period = dtt.tIVL_TS2Period(ivl_ts); - - // Notice that Date.getYear() returns THE_YEAR - 1900. It returns 116 for 2016 - // since 2016-1900 = 116. - Assert.assertEquals("IVL_TS.low(year) was not transformed", 1963 - 1900, period.getStart().getYear()); - // Notice that Date.getMonth() returns THE_MONTH - 1 (since the months are - // indexed btw the range 0-11) - Assert.assertEquals("IVL_TS.low(month) was not transformed", 1 - 1, period.getStart().getMonth()); - Assert.assertEquals("IVL_TS.low(date[1-31]) was not transformed", 16, period.getStart().getDate()); - Assert.assertEquals("IVL_TS.high(year) was not transformed", 2015 - 1900, period.getEnd().getYear()); - Assert.assertEquals("IVL_TS.high(month) was not transformed", 11 - 1, period.getEnd().getMonth()); - Assert.assertEquals("IVL_TS.high(date[1-31]) was not transformed", 22, period.getEnd().getDate()); - - // instance test: there exists an instance of ED but no setter is called - IVL_TS ivl_ts4 = DatatypesFactory.eINSTANCE.createIVL_TS(); - Period period4 = dtt.tIVL_TS2Period(ivl_ts4); - Assert.assertNull("IVL_TS.low was not transformed", period4.getStart()); - Assert.assertNull("IVL_TS.high(year) was not transformed", period4.getEnd()); - - // null instance test - IVL_TS ivl_ts2 = null; - Period period2 = dtt.tIVL_TS2Period(ivl_ts2); - Assert.assertNull("IVL_TS null instance transform failed", period2); - - // nullFlavor instance test - IVL_TS ivl_ts3 = DatatypesFactory.eINSTANCE.createIVL_TS(); - ivl_ts3.setNullFlavor(NullFlavor.NI); - Period period3 = dtt.tIVL_TS2Period(ivl_ts3); - Assert.assertNull("IVL_TS.nullFlavor set instance transform failed", period3); - } - - @SuppressWarnings("deprecation") - @Test - public void testPIVL_TS2Timing() { - // null instance test - PIVL_TS pivlNull = null; - Timing timingNull = dtt.tPIVL_TS2Timing(pivlNull); - Assert.assertNull("PIVL_TS null instance transform failed", timingNull); - - // nullFlavor instance test - PIVL_TS pivlNullFlavor = DatatypesFactory.eINSTANCE.createPIVL_TS(); - pivlNullFlavor.setNullFlavor(NullFlavor.NA); - Timing timingNF = dtt.tPIVL_TS2Timing(pivlNullFlavor); - Assert.assertNull("PIVL_TS.nullFlavor set instance transform failed", timingNF); - - // simple instance tests - - // 1 - PIVL_TS pivl1 = DatatypesFactory.eINSTANCE.createPIVL_TS(); - // period of pivl1 - PQ pq1 = DatatypesFactory.eINSTANCE.createPQ(); - pq1.setValue(123.4); - pq1.setUnit("h"); - pivl1.setPeriod(pq1); - - // phase of pivl1 - IVL_TS ivlts1 = DatatypesFactory.eINSTANCE.createIVL_TS(); - // low - IVXB_TS ivxbLow1 = DatatypesFactory.eINSTANCE.createIVXB_TS(); - ivxbLow1.setValue("20140523"); - ivlts1.setLow(ivxbLow1); - // high - IVXB_TS ivxbHigh1 = DatatypesFactory.eINSTANCE.createIVXB_TS(); - ivxbHigh1.setValue("20161201"); - ivlts1.setHigh(ivxbHigh1); - pivl1.setPhase(ivlts1); - - Timing timing1 = dtt.tPIVL_TS2Timing(pivl1); - - BigDecimal bigDecimal = new BigDecimal(123.4); - Assert.assertTrue("PIVL_TS.period.value was not transformed", 123 == bigDecimal.longValue()); - Period period = (Period) timing1.getRepeat().getBounds(); - // Notice that Date.getYear() returns THE_YEAR - 1900. It returns 116 for 2016 - // since 2016-1900 = 116. - Assert.assertEquals("PIVL_TS.phase.low.year was not transformed", 2014 - 1900, period.getStart().getYear()); - // Notice that Date.getMonth() returns THE_MONTH - 1 (since the months are - // indexed btw the range 0-11) - Assert.assertEquals("PIVL_TS.phase.low.month was not transformed", 5 - 1, period.getStart().getMonth()); - Assert.assertEquals("PIVL_TS.phase.low.date was not transformed", 23, period.getStart().getDate()); - - Assert.assertEquals("PIVL_TS.phase.high.year was not transformed", 2016 - 1900, period.getEnd().getYear()); - Assert.assertEquals("PIVL_TS.phase.high.month was not transformed", 12 - 1, period.getEnd().getMonth()); - Assert.assertEquals("PIVL_TS.phase.high.date was not transformed", 1, period.getEnd().getDate()); - } - - @Test - public void testPQ2Quantity() { - // simple instance test - PQ pq = DatatypesFactory.eINSTANCE.createPQ(); - pq.setValue(120.0); - pq.setUnit("mg"); - Quantity quantity = dtt.tPQ2Quantity(pq); - - Assert.assertEquals("PQ.value was not transformed", 120.0, quantity.getValue().doubleValue(), 0.001); - Assert.assertEquals("PQ.unit was not transformed", "mg", quantity.getUnit()); - - // null instance test - PQ pq2 = null; - Quantity quantity2 = dtt.tPQ2Quantity(pq2); - Assert.assertNull("PQ null instance transform failed", quantity2); - - // nullFlavor instance test - PQ pq3 = DatatypesFactory.eINSTANCE.createPQ(); - pq3.setNullFlavor(NullFlavor.NI); - Quantity quantity3 = dtt.tPQ2Quantity(pq3); - Assert.assertNull("PQ.nullFlavor set instance transform failed", quantity3); - - PQ pq4 = DatatypesFactory.eINSTANCE.createPQ(); - pq4.setValue(25.0); - pq4.setUnit(null); - - Quantity quantity4 = dtt.tPQ2Quantity(pq4); - Assert.assertEquals("PQ.value was not transformed", 25.0, quantity4.getValue().doubleValue(), 0.001); - Assert.assertNull("PQ.unit null was not transformed", quantity4.getUnit()); - }// end Quantity test - - @Test - public void testREAL2DecimalType() { - // simple instance test - REAL real = DatatypesFactory.eINSTANCE.createREAL(); - real.setValue(78965.0); - DecimalType decimal = dtt.tREAL2DecimalType(real); - Assert.assertEquals("REAL.value was not transformed", 78965.0, decimal.getValue().doubleValue(), 0.001); - - // null instance test - REAL real2 = null; - DecimalType decimal2 = dtt.tREAL2DecimalType(real2); - Assert.assertNull("REAL null instance transform failed", decimal2); - - } - - @Test - public void testRTO2Ratio() { - // simple instance test - RTO rto = DatatypesFactory.eINSTANCE.createRTO(); - REAL real = DatatypesFactory.eINSTANCE.createREAL(); - real.setValue(65.0); - REAL real2 = DatatypesFactory.eINSTANCE.createREAL(); - real2.setValue(137.6); - rto.setNumerator(real); - rto.setDenominator(real2); - Ratio ratio = dtt.tRTO2Ratio(rto); - Assert.assertEquals("RTO.numerator was not transformed", 65.0, ratio.getNumerator().getValue().doubleValue(), - 0.001); - Assert.assertEquals("RTO.denominator was not transformed", 137.6, - ratio.getDenominator().getValue().doubleValue(), 0.001); - // null instance test - - RTO rto2 = null; - Ratio ratio2 = dtt.tRTO2Ratio(rto2); - Assert.assertNull("RTO null instance set was failed", ratio2); - - // nullFlavor instance test - RTO rto3 = DatatypesFactory.eINSTANCE.createRTO(); - rto3.setNullFlavor(NullFlavor.NINF); - Ratio ratio3 = dtt.tRTO2Ratio(rto3); - Assert.assertNull("RTO nullFlavor instance set was failed", ratio3); - } - - @Test - public void testST2String() { - // simple instance test - ST st = DatatypesFactory.eINSTANCE.createST(); - st.addText("theText"); - StringType string = dtt.tST2String(st); - Assert.assertEquals("ST.text was not transformed", "theText", string.getValue()); - - // null instance test - ST st2 = null; - StringType string2 = dtt.tST2String(st2); - Assert.assertNull("ST null instance transform failed", string2); - } - - @Test - public void testREAL2Quantity() { - // simple instance test - REAL real = DatatypesFactory.eINSTANCE.createREAL(); - real.setValue(11000.5478); - Quantity quantity1 = dtt.tREAL2Quantity(real); - Assert.assertEquals("REAL.value was transformed", "11000.5478", quantity1.getValue().toString()); - - // null instance test - REAL real2 = null; - Quantity quantity2 = dtt.tREAL2Quantity(real2); - Assert.assertNull("REAL null instance transform failed", quantity2); - } - - @Test - public void testString2DateTime() { - // null instance test - String nullStr = null; - DateTimeType dateTimeNull = dtt.tString2DateTime(nullStr); - Assert.assertNull("TS null instance set was failed", dateTimeNull); - - // simple instance tests - - // 1 yyyy - String str1 = "2016"; - DateTimeType dateTime1 = dtt.tString2DateTime(str1); - - Assert.assertEquals("TS.value was not transformed", "2016", dateTime1.getValueAsString()); - - // 2 yyyymm - String str2 = "201605"; - DateTimeType dateTime2 = dtt.tString2DateTime(str2); - - Assert.assertEquals("TS.value was not transformed", "2016-05", dateTime2.getValueAsString()); - - // 3 yyyymmdd - String str3 = "20160527"; - DateTimeType dateTime3 = dtt.tString2DateTime(str3); - Assert.assertEquals("TS.value was not transformed", "2016-05-27", dateTime3.getValueAsString()); - - // 4 yyyymmddhhmm - String str4 = "201605271540"; - DateTimeType dateTime4 = dtt.tString2DateTime(str4); - - Assert.assertEquals("TS.value was not transformed", "2016-05-27T15:40:00" + getLocalTimeZoneString(), - dateTime4.getValueAsString()); - - // 5 +timezone - String str5 = "201605271540+0800"; - DateTimeType dateTime5 = dtt.tString2DateTime(str5); - - Assert.assertEquals("TS.value was not transformed", "2016-05-27T15:40:00+08:00", dateTime5.getValueAsString()); - - // 6 -timezone - String str6 = "201605271540-0800"; - DateTimeType dateTime6 = dtt.tString2DateTime(str6); - - Assert.assertEquals("TS.value was not transformed", "2016-05-27T15:40:00-08:00", dateTime6.getValueAsString()); - } - - @SuppressWarnings("deprecation") - @Test - public void testTEL2ContactPoint() { - - TEL tel = DatatypesFactory.eINSTANCE.createTEL(); - - tel.setValue("tel:+1(555)555-1004"); - - SXCM_TS sxcmts = DatatypesFactory.eINSTANCE.createSXCM_TS(); - sxcmts.setValue("19950424"); - SXCM_TS sxcmts2 = DatatypesFactory.eINSTANCE.createSXCM_TS(); - sxcmts2.setValue("19950427"); - - tel.getUseablePeriods().add(sxcmts); - tel.getUseablePeriods().add(sxcmts2); - - tel.getUses().add(TelecommunicationAddressUse.H); - - ContactPoint contactPoint = dtt.tTEL2ContactPoint(tel); - Assert.assertEquals("Tel.system failed", "phone", contactPoint.getSystem().toCode()); - Assert.assertEquals("Tel.value failed", "+1(555)555-1004", contactPoint.getValue()); - Assert.assertEquals("Tel.periodStart getYear failed", 95, contactPoint.getPeriod().getStart().getYear()); - Assert.assertEquals("Tel.periodStart getMonth failed", 3, contactPoint.getPeriod().getStart().getMonth()); - Assert.assertEquals("Tel.periodStart getMonth failed", 24, contactPoint.getPeriod().getStart().getDate()); - Assert.assertEquals("Tel.periodEnd getYear failed", 95, contactPoint.getPeriod().getEnd().getYear()); - Assert.assertEquals("Tel.periodEnd getMonth failed", 3, contactPoint.getPeriod().getEnd().getMonth()); - Assert.assertEquals("Tel.periodEnd getMonth failed", 27, contactPoint.getPeriod().getEnd().getDate()); - Assert.assertEquals("Tel.use failed", "home", contactPoint.getUse().toCode()); - - // null instance test - TEL tel2 = null; - ContactPoint contactPoint2 = dtt.tTEL2ContactPoint(tel2); - Assert.assertNull("TEL null instance transform failed", contactPoint2); - - // nullFlavor instance test - TEL tel3 = DatatypesFactory.eINSTANCE.createTEL(); - tel3.setNullFlavor(NullFlavor.NI); - ContactPoint contactPoint3 = dtt.tTEL2ContactPoint(tel3); - Assert.assertNull("ContactPoint.nullFlavor set instance transform failed", contactPoint3); - - // instance test: non-null empty instance - TEL tel4 = DatatypesFactory.eINSTANCE.createTEL(); - ContactPoint contactPoint4 = dtt.tTEL2ContactPoint(tel4); - - Assert.assertNull("TEL.value transformation failed", contactPoint4.getValue()); - Assert.assertNull("TEL.period.Start transformation failed", contactPoint4.getPeriod().getStart()); - Assert.assertNull("TEL.period.End transformation failed", contactPoint4.getPeriod().getEnd()); - } - - @Test - public void testTS2Date() { - // simple instance test yyyymmdd - TS ts = DatatypesFactory.eINSTANCE.createTS(); - ts.setValue("20160923"); - DateType date = dtt.tTS2Date(ts); - - Assert.assertEquals("TS.value was not transformed", "2016-09-23", date.getValueAsString()); - - // simple instance test 2 yyyymm - TS ts4 = DatatypesFactory.eINSTANCE.createTS(); - ts4.setValue("201506"); - DateType date4 = dtt.tTS2Date(ts4); - Assert.assertEquals("TS.value was not transformed", "2015-06", date4.getValueAsString()); - - // simple instance test 3 yyyy - TS ts5 = DatatypesFactory.eINSTANCE.createTS(); - ts5.setValue("2010"); - DateType date5 = dtt.tTS2Date(ts5); - Assert.assertEquals("TS.value was not transformed", "2010", date5.getValueAsString()); - - // simple instance test 4 yyyymmddhhmm - TS ts6 = DatatypesFactory.eINSTANCE.createTS(); - ts6.setValue("201305141317"); - DateType date6 = dtt.tTS2Date(ts6); - Assert.assertEquals("TS.value was not transformed", "2013-05-14", date6.getValueAsString()); - - // simple instance test 5 yyyymmddhhmmss.s - TS ts7 = DatatypesFactory.eINSTANCE.createTS(); - ts7.setValue("20130514131719.6"); - DateType date7 = dtt.tTS2Date(ts7); - Assert.assertEquals("TS.value was not transformed", "2013-05-14", date7.getValueAsString()); - - // null instance test - TS ts2 = null; - DateType date2 = dtt.tTS2Date(ts2); - Assert.assertNull("TS null was not transformed", date2); - - // nullFlavor instance test - TS ts3 = DatatypesFactory.eINSTANCE.createTS(); - ts3.setNullFlavor(NullFlavor.UNK); - DateType date3 = dtt.tTS2Date(ts3); - Assert.assertNull("TS.nullFlavor was not transformed", date3); - } - - @Test - public void testTS2DateTime() { - // simple instance test,yyyy - TS ts = DatatypesFactory.eINSTANCE.createTS(); - ts.setValue("2016"); - DateTimeType datetime = dtt.tTS2DateTime(ts); - Assert.assertEquals("TS.value was not transformed", "2016", datetime.getValueAsString()); - - // simple instance test,yyyymm - TS ts2 = DatatypesFactory.eINSTANCE.createTS(); - ts2.setValue("201605"); - DateTimeType datetime2 = dtt.tTS2DateTime(ts2); - Assert.assertEquals("TS.value was not transformed", "2016-05", datetime2.getValueAsString()); - - // simple instance test,yyyymmdd - TS ts3 = DatatypesFactory.eINSTANCE.createTS(); - ts3.setValue("20160527"); - DateTimeType datetime3 = dtt.tTS2DateTime(ts3); - Assert.assertEquals("TS.value was not transformed", "2016-05-27", datetime3.getValueAsString()); - - // simple instance test,yyyymmddhhmm - TS ts4 = DatatypesFactory.eINSTANCE.createTS(); - ts4.setValue("201605271540"); - DateTimeType datetime4 = dtt.tTS2DateTime(ts4); - - Assert.assertEquals("TS.value was not transformed", "2016-05-27T15:40:00" + getLocalTimeZoneString(), - datetime4.getValueAsString()); - - // complex instance test,with +timezone - TS ts5 = DatatypesFactory.eINSTANCE.createTS(); - ts5.setValue("201605271540+0800"); - DateTimeType datetime5 = dtt.tTS2DateTime(ts5); - - Assert.assertEquals("TS.value was not transformed", "2016-05-27T15:40:00+08:00", datetime5.getValueAsString()); - - // complex instance test,with -timezone - TS ts7 = DatatypesFactory.eINSTANCE.createTS(); - ts7.setValue("201605271540-0800"); - DateTimeType datetime7 = dtt.tTS2DateTime(ts7); - - Assert.assertEquals("TS.value was not transformed", "2016-05-27T15:40:00-08:00", datetime7.getValueAsString()); - - // null instance test - TS ts6 = null; - DateTimeType datetime6 = dtt.tTS2DateTime(ts6); - Assert.assertNull("TS null instance set was failed", datetime6); - } - - // tTS2Instant, tTS2Date and tTS2DateTime are based on tTS2BaseDateTimeType - // The most comprehensive test is testTS2Instant - @Test - public void testTS2Instant() { - // null instance test - TS nullTs = null; - InstantType nullInstant1 = dtt.tTS2Instant(nullTs); - Assert.assertNull("TS null was not transformed", nullInstant1); - - // nullFlavor instance test - TS nullFlavorTs = DatatypesFactory.eINSTANCE.createTS(); - nullFlavorTs.setNullFlavor(NullFlavor.NA); - InstantType nullInstant2 = dtt.tTS2Instant(nullFlavorTs); - Assert.assertNull("TS.nullFlavor was not transformed", nullInstant2); - - // simple instance tests - - // 1 yyyy -// TS ts1 = DatatypesFactory.eINSTANCE.createTS(); -// ts1.setValue("2013"); -// InstantType instant1 = dtt.tTS2Instant(ts1); -// -// Assert.assertEquals("TS.value was not transformed","2013",instant1.getValueAsString()); - - // 2 yyyymm -// TS ts2 = DatatypesFactory.eINSTANCE.createTS(); -// ts2.setValue("199711"); -// InstantType instant2 = dtt.tTS2Instant(ts2); -// -// Assert.assertEquals("TS.value was not transformed","1997-11",instant2.getValueAsString()); - - // 3 yyyymmdd - TS ts3 = DatatypesFactory.eINSTANCE.createTS(); - ts3.setValue("20160514"); - InstantType instant3 = dtt.tTS2Instant(ts3); - Assert.assertEquals("TS.value was not transformed", "2016-05-14T00:00:00" + getLocalTimeZoneString(), - instant3.getValueAsString()); - - // 4 yyyymmddhhmm - TS ts4 = DatatypesFactory.eINSTANCE.createTS(); - ts4.setValue("201305141317"); - InstantType instant4 = dtt.tTS2Instant(ts4); - - Assert.assertEquals("TS.value was not transformed", "2013-05-14T13:17:00" + getLocalTimeZoneString(), - instant4.getValueAsString()); - - // 5 yyyymmddhhmmss.s - TS ts5 = DatatypesFactory.eINSTANCE.createTS(); - ts5.setValue("20130514131719.6"); - InstantType instant5 = dtt.tTS2Instant(ts5); - - Assert.assertEquals("TS.value was not transformed", "2013-05-14T13:17:19.600" + getLocalTimeZoneString(), - instant5.getValueAsString()); - - // 6 yyyymmddhhmmss.ss - TS ts6 = DatatypesFactory.eINSTANCE.createTS(); - ts6.setValue("20130514131719.67"); - InstantType instant6 = dtt.tTS2Instant(ts6); - - Assert.assertEquals("TS.value was not transformed", "2013-05-14T13:17:19.670" + getLocalTimeZoneString(), - instant6.getValueAsString()); - - // 7 yyyymmddhhmmss.sss - TS ts7 = DatatypesFactory.eINSTANCE.createTS(); - ts7.setValue("20130514131719.673"); - InstantType instant7 = dtt.tTS2Instant(ts7); - - Assert.assertEquals("TS.value was not transformed", "2013-05-14T13:17:19.673" + getLocalTimeZoneString(), - instant7.getValueAsString()); - - // 8 yyyymmddhhmmss.sss+ZZzz - TS ts8 = DatatypesFactory.eINSTANCE.createTS(); - ts8.setValue("20130514131719.673+0107"); - InstantType instant8 = dtt.tTS2Instant(ts8); - - Assert.assertEquals("TS.value was not transformed", "2013-05-14T13:17:19.673+01:07", - instant8.getValueAsString()); - - // 9 yyyymmddhhmmss.ss-ZZzz - TS ts9 = DatatypesFactory.eINSTANCE.createTS(); - ts9.setValue("20130514131719.12-0253"); - InstantType instant9 = dtt.tTS2Instant(ts9); - - Assert.assertEquals("TS.value was not transformed", "2013-05-14T13:17:19.120-02:53", - instant9.getValueAsString()); - - // 10 yyyymmddhhmmss - TS ts10 = DatatypesFactory.eINSTANCE.createTS(); - ts10.setValue("20130514131719"); - InstantType instant10 = dtt.tTS2Instant(ts10); - - Assert.assertEquals("TS.value was not transformed", "2013-05-14T13:17:19" + getLocalTimeZoneString(), - instant10.getValueAsString()); - } - - // LocalTimeZone is used for the tests of TS2DateTime and TS2Instant - private String getLocalTimeZoneString() { - int timeZoneOffset = TimeZone.getDefault().getRawOffset(); - int hour = 0, min = 0; - String hourString, minString; - String sign = "+"; - - timeZoneOffset /= (1000 * 60); // millisec to minutes - min = timeZoneOffset % 60; - hour = timeZoneOffset / 60; - - if (timeZoneOffset < 0) { - hour *= -1; - min *= -1; - sign = "-"; - } - - hourString = hour > 9 ? "" + hour : "0" + hour; // transform "h" to "0h" - minString = min > 9 ? "" + min : "0" + min; // transform "m" to "0m" - - return sign + hourString + ":" + minString; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/DeduplicationTest.java b/src/test/java/tr/com/srdc/cda2fhir/DeduplicationTest.java deleted file mode 100644 index 2ce3d23d7..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/DeduplicationTest.java +++ /dev/null @@ -1,851 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.Organization; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.AssignedCustodian; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.Component3; -import org.openhealthtools.mdht.uml.cda.Custodian; -import org.openhealthtools.mdht.uml.cda.CustodianOrganization; -import org.openhealthtools.mdht.uml.cda.PatientRole; -import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; -import org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument; -import org.openhealthtools.mdht.uml.cda.consol.MedicationActivity; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.generator.AssignedEntityGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.AuthorGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.CDAEncouncersSectionComponentGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.CDAImmunizationSectionComponentGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.CDAMedicationSectionComponentGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.CDAProblemsListSectionComponentGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.CEGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.ClinicalDocumentMetadataGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.EncounterActivityGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.ImmunizationActivityGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.ImmunizationMedicationInformationGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.IndicationGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.MedicationActivityGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.MedicationDispenseGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.MedicationInformationGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.MedicationSupplyOrderGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.OrganizationGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.PatientRoleGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.PerformerGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.ProblemConcernActGenerator; -import tr.com.srdc.cda2fhir.testutil.generator.ProblemObservationGenerator; -import tr.com.srdc.cda2fhir.transform.CCDTransformerImpl; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class DeduplicationTest { - static CCDTransformerImpl ccdTransformer; - static CDAFactories factories; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - ccdTransformer = new CCDTransformerImpl(); - factories = CDAFactories.init(); - - } - - private MedicationDispenseGenerator getMedDispenseGeneratorMedInfoSameOrg( - MedicationInformationGenerator medInfoGen) { - MedicationDispenseGenerator medDispenseGenerator = MedicationDispenseGenerator.getDefaultInstance(); - - OrganizationGenerator orgGen = medInfoGen.getOrganizationGenerator(); - - medDispenseGenerator.setMedicationInformationGenerator(medInfoGen); - - AssignedEntityGenerator assignedEntityGenerator = AssignedEntityGenerator.getDefaultInstance(); - - PerformerGenerator performerGenerator = PerformerGenerator.getDefaultInstance(); - - assignedEntityGenerator.setOrganizationGenerator(orgGen); - - performerGenerator.setAssignedEntityGenerator(assignedEntityGenerator); - - List performerGenerators = new ArrayList(); - - performerGenerators.add(performerGenerator); - - medDispenseGenerator.setPerformerGenerators(performerGenerators); - - return medDispenseGenerator; - } - - private MedicationActivityGenerator getMedicationActivityGeneratorOneMedInfoGenerator( - MedicationInformationGenerator medInfoGenerator) { - - MedicationDispenseGenerator medDispenseGen = getMedDispenseGeneratorMedInfoSameOrg(medInfoGenerator); - - MedicationActivityGenerator medActGenerator = MedicationActivityGenerator.getDefaultInstance(); - - MedicationSupplyOrderGenerator medicationSupplyOrderGenerator = MedicationSupplyOrderGenerator - .getDefaultInstance(); - - medDispenseGen.setMedicationInformationGenerator(medInfoGenerator); - - AuthorGenerator authorGenerator = AuthorGenerator.getDefaultInstance(); - - authorGenerator.setOrganizationGenerator(medInfoGenerator.getOrganizationGenerator()); - - medicationSupplyOrderGenerator.setAuthorGenerator(authorGenerator); - - medicationSupplyOrderGenerator.setMedicationInfoGenerator(medInfoGenerator); - medActGenerator.setAuthorGenerator(authorGenerator); - medActGenerator.setMedicationInfoGenerator(medInfoGenerator); - medActGenerator.setMedicationSupplyOrderGenerator(medicationSupplyOrderGenerator); - medActGenerator.setMedicationDispenseGenerator(medDispenseGen); - - return medActGenerator; - - } - - private ContinuityOfCareDocument getClincalDocNoOrgs() { - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - docGenerator.setAssignedEntityGenerator(null); - - ContinuityOfCareDocument clinicalDoc = docGenerator.generateClinicalDoc(factories); - - return clinicalDoc; - - } - - private Bundle runMedidicationDeduplicationTest(List medicationActivities, int medicationCount, - boolean print, String path) throws Exception { - CDAMedicationSectionComponentGenerator medSectionComponentGenerator = new CDAMedicationSectionComponentGenerator(); - ccdTransformer = new CCDTransformerImpl(); - - List substanceAdministrations = new ArrayList(); - - for (MedicationActivity medAct : medicationActivities) { - substanceAdministrations.add(medAct); - } - - medSectionComponentGenerator.setSubstanceAdministrations(substanceAdministrations); - - ContinuityOfCareDocument clinicalDoc = getClincalDocNoOrgs(); - - Component3 medicationsSectionComponent = medSectionComponentGenerator.generate(factories); - - List components = new ArrayList(); - - components.add(medicationsSectionComponent); - - ClinicalDocumentMetadataGenerator.setStructuredBody(factories, clinicalDoc, components); - - Bundle resultBundle = ccdTransformer.transformDocument(clinicalDoc); - - if (print) - FHIRUtil.printJSON(resultBundle, path); - - BundleUtil.findResources(resultBundle, Medication.class, medicationCount); - - return resultBundle; - } - - @Test - public void testMedicationDeduplicationOneMedicationTwoInstancesNoOrg() throws Exception { - - List medActs = new ArrayList(); - - MedicationActivityGenerator medActGenerator = getMedicationActivityGeneratorOneMedInfoGenerator( - MedicationInformationGenerator.getDefaultInstance()); - - medActs.add(medActGenerator.generate(factories)); - - runMedidicationDeduplicationTest(medActs, 1, false, null); - - } - - @Test - public void testMedicationDeduplicationTwoMedicationsFourInstances2Orgs() throws Exception { - List medActs = new ArrayList(); - - OrganizationGenerator orgGenerator1 = OrganizationGenerator.getDefaultInstance(); - - OrganizationGenerator orgGenerator2 = OrganizationGenerator.getDefaultInstance(); - - MedicationInformationGenerator medInfoGen1 = MedicationInformationGenerator.getDefaultInstance(); - - MedicationInformationGenerator medInfoGen2 = MedicationInformationGenerator.getDefaultInstance(); - - medInfoGen1.setOrganizationGenerator(orgGenerator1); - - medInfoGen2.setOrganizationGenerator(orgGenerator2); - - MedicationActivityGenerator medActGenerator1 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen1); - - MedicationActivityGenerator medActGenerator2 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen2); - - medActs.add(medActGenerator1.generate(factories)); - - medActs.add(medActGenerator2.generate(factories)); - - Bundle resultBundle = runMedidicationDeduplicationTest(medActs, 2, false, null); - - BundleUtil.findResources(resultBundle, Organization.class, 2); - - } - - @Test - public void testMedicationDeduplicationTwoMedicationsFourInstancesSameOrg() throws Exception { - List medActs = new ArrayList(); - - OrganizationGenerator orgGenerator = OrganizationGenerator.getDefaultInstance(); - - MedicationInformationGenerator medInfoGen1 = MedicationInformationGenerator.getDefaultInstance(); - - MedicationInformationGenerator medInfoGen2 = MedicationInformationGenerator.getDefaultInstance(); - - medInfoGen1.setOrganizationGenerator(orgGenerator); - - medInfoGen2.setOrganizationGenerator(orgGenerator); - - MedicationActivityGenerator medActGenerator1 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen1); - - MedicationActivityGenerator medActGenerator2 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen2); - - medActs.add(medActGenerator1.generate(factories)); - - medActs.add(medActGenerator2.generate(factories)); - - Bundle resultBundle = runMedidicationDeduplicationTest(medActs, 2, false, null); - - BundleUtil.findResources(resultBundle, Organization.class, 1); - - } - - @Test - public void testMedicationDeduplicationTwoMedicationsFourInstancesNoOrg() throws Exception { - List medActs = new ArrayList(); - - MedicationInformationGenerator medInfoGen1 = MedicationInformationGenerator.getDefaultInstance(); - - MedicationInformationGenerator medInfoGen2 = MedicationInformationGenerator.getDefaultInstance(); - - medInfoGen1.setOrganizationGenerator(null); - - medInfoGen2.setOrganizationGenerator(null); - - MedicationActivityGenerator medActGenerator1 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen1); - - MedicationActivityGenerator medActGenerator2 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen2); - - medActs.add(medActGenerator1.generate(factories)); - - medActs.add(medActGenerator2.generate(factories)); - - Bundle resultBundle = runMedidicationDeduplicationTest(medActs, 2, false, null); - - BundleUtil.findResources(resultBundle, Organization.class, 0); - - } - - @Test - public void testMedicationDeduplicationSameMedicationOneWithOrg() throws Exception { - List medActs = new ArrayList(); - - OrganizationGenerator orgGenerator = OrganizationGenerator.getDefaultInstance(); - - MedicationInformationGenerator medInfoGen1 = MedicationInformationGenerator.getDefaultInstance(); - - MedicationInformationGenerator medInfoGen2 = MedicationInformationGenerator.getDefaultInstance(); - - MedicationInformationGenerator medInfoGen3 = new MedicationInformationGenerator(); - - medInfoGen3.setCodeGenerator(medInfoGen2.getCodeGenerator()); - - medInfoGen1.setOrganizationGenerator(null); - - medInfoGen2.setOrganizationGenerator(null); - - medInfoGen3.setOrganizationGenerator(orgGenerator); - - MedicationActivityGenerator medActGenerator1 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen1); - - MedicationActivityGenerator medActGenerator2 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen2); - - MedicationActivityGenerator medActGenerator3 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen3); - - medActs.add(medActGenerator1.generate(factories)); - - medActs.add(medActGenerator2.generate(factories)); - - medActs.add(medActGenerator3.generate(factories)); - - Bundle resultBundle = runMedidicationDeduplicationTest(medActs, 3, true, "src/test/resources/output/wtf.json"); - - BundleUtil.findResources(resultBundle, Organization.class, 1); - - } - - @Test - public void testMedicationDeduplicationThreeMedicationsThreeInstances5Orgs() throws Exception { - - List medActs = new ArrayList(); - - OrganizationGenerator orgGen = OrganizationGenerator.getDefaultInstance(); - - MedicationInformationGenerator medInfoGen = MedicationInformationGenerator.getDefaultInstance(); - - medInfoGen.setOrganizationGenerator(orgGen); - - MedicationDispenseGenerator medDispenseGen = getMedDispenseGeneratorMedInfoSameOrg(medInfoGen); - - MedicationActivityGenerator medActGenerator1 = MedicationActivityGenerator.getDefaultInstance(); - MedicationActivityGenerator medActGenerator2 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen); - - medActGenerator1.setMedicationDispenseGenerator(medDispenseGen); - - medActGenerator2.setMedicationDispenseGenerator(medDispenseGen); - - medActs.add(medActGenerator1.generate(factories)); - - medActs.add(medActGenerator2.generate(factories)); - - Bundle resultBundle = runMedidicationDeduplicationTest(medActs, 3, true, - "src/test/resources/output/hello-world.json"); - - BundleUtil.findResources(resultBundle, Organization.class, 5); - - } - - @Test - public void testMedicationDeduplicationOneMedicationTwoOrganizations() throws Exception { - - CEGenerator codeGenerator = CEGenerator.getNextInstance(); - - List medActs = new ArrayList(); - - OrganizationGenerator orgGen1 = OrganizationGenerator.getFullInstance(); - - OrganizationGenerator orgGen2 = OrganizationGenerator.getFullInstance(); - - MedicationInformationGenerator medInfoGen1 = MedicationInformationGenerator.getDefaultInstance(); - - medInfoGen1.setOrganizationGenerator(orgGen1); - - medInfoGen1.setCodeGenerator(codeGenerator); - - MedicationInformationGenerator medInfoGen2 = MedicationInformationGenerator.getDefaultInstance(); - - // different organization generator used for each - medInfoGen2.setOrganizationGenerator(orgGen2); - - // Same code generator instance used means same code - medInfoGen2.setCodeGenerator(codeGenerator); - - MedicationActivityGenerator medActGenerator1 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen1); - - MedicationActivityGenerator medActGenerator2 = getMedicationActivityGeneratorOneMedInfoGenerator(medInfoGen2); - - medActs.add(medActGenerator1.generate(factories)); - - medActs.add(medActGenerator2.generate(factories)); - - Bundle resultBundle = runMedidicationDeduplicationTest(medActs, 2, false, null); - - BundleUtil.findResources(resultBundle, Organization.class, 2); - - } - - private List getSubstanceAdministrationComponentsOneOrg(OrganizationGenerator orgGenerator) { - - ImmunizationMedicationInformationGenerator immunMedInfoGen = ImmunizationMedicationInformationGenerator - .getDefaultInstance(); - - immunMedInfoGen.setOrganizationGenerator(orgGenerator); - - MedicationInformationGenerator medInfoGenerator = MedicationInformationGenerator.getDefaultInstance(); - - medInfoGenerator.setOrganizationGenerator(orgGenerator); - - MedicationDispenseGenerator medDispenseGen = getMedDispenseGeneratorMedInfoSameOrg(medInfoGenerator); - - MedicationActivityGenerator medActGenerator = getMedicationActivityGeneratorOneMedInfoGenerator( - medInfoGenerator); - - medActGenerator.getMedicationSupplyOrderGenerator().setAuthorGenerator(null); - medActGenerator.setAuthorGenerator(null); - medActGenerator.setMedicationInfoGenerator(medInfoGenerator); - medActGenerator.setMedicationDispenseGenerator(medDispenseGen); - - ImmunizationActivityGenerator immunizationActivityGenerator = ImmunizationActivityGenerator - .getDefaultInstance(); - - immunizationActivityGenerator.setReactionObservationGenerator(null); - - immunizationActivityGenerator.getPerformerGenerators().clear(); - - immunizationActivityGenerator.setMedicationInformationGenerator(immunMedInfoGen); - - List medicationSubstanceAdministrations = new ArrayList(); - - List immunSubstanceAdministrations = new ArrayList(); - - medicationSubstanceAdministrations.add(medActGenerator.generate(factories)); - - immunSubstanceAdministrations.add(immunizationActivityGenerator.generate(factories)); - - CDAImmunizationSectionComponentGenerator immunSectionComponentGenerator = new CDAImmunizationSectionComponentGenerator(); - - CDAMedicationSectionComponentGenerator medSectionComponentGenerator = new CDAMedicationSectionComponentGenerator(); - - immunSectionComponentGenerator.setSubstanceAdministrations(immunSubstanceAdministrations); - - medSectionComponentGenerator.setSubstanceAdministrations(medicationSubstanceAdministrations); - - List components = new ArrayList(); - - components.add(medSectionComponentGenerator.generate(factories)); - - components.add(immunSectionComponentGenerator.generate(factories)); - - return components; - } - - private List getSubstanceAdministrationComponentsSeparateOrgs(OrganizationGenerator orgGenerator1, - OrganizationGenerator orgGenerator2) { - ImmunizationMedicationInformationGenerator immunMedInfoGen = ImmunizationMedicationInformationGenerator - .getDefaultInstance(); - - immunMedInfoGen.setOrganizationGenerator(orgGenerator1); - - MedicationInformationGenerator medInfoGenerator = MedicationInformationGenerator.getDefaultInstance(); - - medInfoGenerator.setOrganizationGenerator(orgGenerator2); - - MedicationActivityGenerator medActGenerator = getMedicationActivityGeneratorOneMedInfoGenerator( - medInfoGenerator); - - medActGenerator.getMedicationSupplyOrderGenerator().setAuthorGenerator(null); - medActGenerator.setAuthorGenerator(null); - medActGenerator.setMedicationInfoGenerator(medInfoGenerator); - - ImmunizationActivityGenerator immunizationActivityGenerator = ImmunizationActivityGenerator - .getDefaultInstance(); - - immunizationActivityGenerator.setReactionObservationGenerator(null); - - immunizationActivityGenerator.getPerformerGenerators().clear(); - - immunizationActivityGenerator.setMedicationInformationGenerator(immunMedInfoGen); - - List medicationSubstanceAdministrations = new ArrayList(); - - List immunSubstanceAdministrations = new ArrayList(); - - medicationSubstanceAdministrations.add(medActGenerator.generate(factories)); - - immunSubstanceAdministrations.add(immunizationActivityGenerator.generate(factories)); - - CDAImmunizationSectionComponentGenerator immunSectionComponentGenerator = new CDAImmunizationSectionComponentGenerator(); - - CDAMedicationSectionComponentGenerator medSectionComponentGenerator = new CDAMedicationSectionComponentGenerator(); - - immunSectionComponentGenerator.setSubstanceAdministrations(immunSubstanceAdministrations); - - medSectionComponentGenerator.setSubstanceAdministrations(medicationSubstanceAdministrations); - - List components = new ArrayList(); - - components.add(medSectionComponentGenerator.generate(factories)); - - components.add(immunSectionComponentGenerator.generate(factories)); - - return components; - } - - private PatientRole getPatientRoleWithOrg(OrganizationGenerator orgGenerator) { - PatientRoleGenerator patientRoleGenerator = PatientRoleGenerator.getDefaultInstance(); - patientRoleGenerator.setProviderOrgGenerator(orgGenerator); - return patientRoleGenerator.generate(factories); - } - - private Author getAuthorWithOrg(OrganizationGenerator orgGenerator) { - AuthorGenerator authorGen = AuthorGenerator.getFullInstance(); - authorGen.setOrganizationGenerator(orgGenerator); - Author author = authorGen.generate(factories); - return author; - - } - - private Custodian getCustodianWithOrg(OrganizationGenerator orgGenerator) { - CustodianOrganization custodianOrg = orgGenerator.generateCustodianOrg(factories); - // Not sure why this is set by default. - custodianOrg.unsetNullFlavor(); - AssignedCustodian assignedCustodian = factories.base.createAssignedCustodian(); - assignedCustodian.setRepresentedCustodianOrganization(custodianOrg); - - Custodian custodian = factories.base.createCustodian(); - custodian.setAssignedCustodian(assignedCustodian); - return custodian; - } - - @Test - public void testClinicalDocGeneratorNoOrgs() throws Exception { - ccdTransformer = new CCDTransformerImpl(); - - ContinuityOfCareDocument clinicalDoc = getClincalDocNoOrgs(); - - Bundle resultBundle = ccdTransformer.transformDocument(clinicalDoc); - - BundleUtil.findResources(resultBundle, Organization.class, 0); - } - - @Test - public void testOrganizationDeduplicationMedActImmunActSameOrg() throws Exception { - OrganizationGenerator orgGenerator1 = OrganizationGenerator.getDefaultInstance(); - - List substanceAdminComponents = getSubstanceAdministrationComponentsOneOrg(orgGenerator1); - - ccdTransformer = new CCDTransformerImpl(); - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - docGenerator.setAssignedEntityGenerator(null); - - ContinuityOfCareDocument clinicalDoc = docGenerator.generateClinicalDoc(factories); - - ClinicalDocumentMetadataGenerator.setStructuredBody(factories, clinicalDoc, substanceAdminComponents); - - Bundle resultBundle = ccdTransformer.transformDocument(clinicalDoc); - - BundleUtil.findResources(resultBundle, Organization.class, 1); - - } - - @Test - public void testOrganizationDeduplicationMedActImmunActDifferentOrgs() throws Exception { - OrganizationGenerator orgGenerator1 = OrganizationGenerator.getDefaultInstance(); - - OrganizationGenerator orgGenerator2 = OrganizationGenerator.getDefaultInstance(); - - List substanceAdminComponents = getSubstanceAdministrationComponentsSeparateOrgs(orgGenerator1, - orgGenerator2); - - ccdTransformer = new CCDTransformerImpl(); - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - docGenerator.setAssignedEntityGenerator(null); - - ContinuityOfCareDocument clinicalDoc = docGenerator.generateClinicalDoc(factories); - - ClinicalDocumentMetadataGenerator.setStructuredBody(factories, clinicalDoc, substanceAdminComponents); - - Bundle resultBundle = ccdTransformer.transformDocument(clinicalDoc); - - BundleUtil.findResources(resultBundle, Organization.class, 2); - - } - - @Test - public void testOrganizationDeduplicationAssignedEntity() throws Exception { - - OrganizationGenerator orgGenerator = OrganizationGenerator.getDefaultInstance(); - - AssignedEntityGenerator assignedEntityGenerator = new AssignedEntityGenerator(); - - assignedEntityGenerator.setOrganizationGenerator(orgGenerator); - - ccdTransformer = new CCDTransformerImpl(); - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - docGenerator.setAssignedEntityGenerator(assignedEntityGenerator); - - ContinuityOfCareDocument document = docGenerator.generateClinicalDoc(factories); - - Bundle resultBundle = ccdTransformer.transformDocument(document); - - BundleUtil.findResources(resultBundle, Organization.class, 1); - - } - - @Test - public void testOrganizationDeduplicationPatientRole() throws Exception { - - OrganizationGenerator orgGenerator = OrganizationGenerator.getDefaultInstance(); - - PatientRole patientRole = getPatientRoleWithOrg(orgGenerator); - - ccdTransformer = new CCDTransformerImpl(); - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - docGenerator.setAssignedEntityGenerator(null); - - ContinuityOfCareDocument document = docGenerator.generateClinicalDoc(factories); - - ClinicalDocumentMetadataGenerator.setRecordTarget(factories, document, patientRole); - - Bundle resultBundle = ccdTransformer.transformDocument(document); - - BundleUtil.findResources(resultBundle, Organization.class, 1); - - } - - @Test - public void testOrganizationDeduplicationAuthor() throws Exception { - - OrganizationGenerator orgGenerator = OrganizationGenerator.getDefaultInstance(); - - Author author = getAuthorWithOrg(orgGenerator); - - ccdTransformer = new CCDTransformerImpl(); - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - docGenerator.setAssignedEntityGenerator(null); - - ContinuityOfCareDocument document = docGenerator.generateClinicalDoc(factories); - - ClinicalDocumentMetadataGenerator.setAuthor(factories, document, author); - - Bundle resultBundle = ccdTransformer.transformDocument(document); - - BundleUtil.findResources(resultBundle, Organization.class, 1); - - } - - @Test - public void testOrganizationDeduplicationCustodian() throws Exception { - - OrganizationGenerator orgGenerator = OrganizationGenerator.getDefaultInstance(); - - Custodian custodian = getCustodianWithOrg(orgGenerator); - - ccdTransformer = new CCDTransformerImpl(); - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - docGenerator.setAssignedEntityGenerator(null); - - ContinuityOfCareDocument document = docGenerator.generateClinicalDoc(factories); - - ClinicalDocumentMetadataGenerator.setCustodian(factories, document, custodian); - - Bundle resultBundle = ccdTransformer.transformDocument(document); - - BundleUtil.findResources(resultBundle, Organization.class, 1); - - } - - @Test - public void testOrganizationDeduplicationOneOrgMultipleInstances() throws Exception { - - OrganizationGenerator orgGenerator = OrganizationGenerator.getDefaultInstance(); - - AssignedEntityGenerator assignedEntityGenerator = new AssignedEntityGenerator(); - - assignedEntityGenerator.setOrganizationGenerator(orgGenerator); - - PatientRole patientRole = getPatientRoleWithOrg(orgGenerator); - - Author author = getAuthorWithOrg(orgGenerator); - - Custodian custodian = getCustodianWithOrg(orgGenerator); - - List substanceAdminComponents1 = getSubstanceAdministrationComponentsOneOrg(orgGenerator); - - List substanceAdminComponents2 = getSubstanceAdministrationComponentsOneOrg(orgGenerator); - - List substanceAdminComponents3 = getSubstanceAdministrationComponentsOneOrg(orgGenerator); - - List components = new ArrayList(); - - components.addAll(substanceAdminComponents1); - components.addAll(substanceAdminComponents2); - components.addAll(substanceAdminComponents3); - - ccdTransformer = new CCDTransformerImpl(); - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - docGenerator.setAssignedEntityGenerator(assignedEntityGenerator); - - ContinuityOfCareDocument document = docGenerator.generateClinicalDoc(factories); - - ClinicalDocumentMetadataGenerator.setStructuredBody(factories, document, components); - - ClinicalDocumentMetadataGenerator.setRecordTarget(factories, document, patientRole); - - ClinicalDocumentMetadataGenerator.setCustodian(factories, document, custodian); - - ClinicalDocumentMetadataGenerator.setAuthor(factories, document, author); - - Bundle resultBundle = ccdTransformer.transformDocument(document); - - BundleUtil.findResources(resultBundle, Organization.class, 1); - - } - - @Test - public void testOrganization5OrgsMultipleInstances() throws Exception { - OrganizationGenerator orgGenerator1 = OrganizationGenerator.getDefaultInstance(); - - OrganizationGenerator orgGenerator2 = OrganizationGenerator.getDefaultInstance(); - - OrganizationGenerator orgGenerator3 = OrganizationGenerator.getDefaultInstance(); - - OrganizationGenerator orgGenerator4 = OrganizationGenerator.getDefaultInstance(); - - OrganizationGenerator orgGenerator5 = OrganizationGenerator.getDefaultInstance(); - - AssignedEntityGenerator assignedEntityGenerator = new AssignedEntityGenerator(); - - assignedEntityGenerator.setOrganizationGenerator(orgGenerator1); - - PatientRole patientRole = getPatientRoleWithOrg(orgGenerator1); - - Author author = getAuthorWithOrg(orgGenerator2); - - Custodian custodian = getCustodianWithOrg(orgGenerator3); - - List substanceAdminComponents1 = getSubstanceAdministrationComponentsOneOrg(orgGenerator4); - - List substanceAdminComponents2 = getSubstanceAdministrationComponentsOneOrg(orgGenerator5); - - List substanceAdminComponents3 = getSubstanceAdministrationComponentsOneOrg(orgGenerator5); - - List components = new ArrayList(); - - components.addAll(substanceAdminComponents1); - components.addAll(substanceAdminComponents2); - components.addAll(substanceAdminComponents3); - - ccdTransformer = new CCDTransformerImpl(); - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - docGenerator.setAssignedEntityGenerator(assignedEntityGenerator); - - ContinuityOfCareDocument document = docGenerator.generateClinicalDoc(factories); - - ClinicalDocumentMetadataGenerator.setStructuredBody(factories, document, components); - - ClinicalDocumentMetadataGenerator.setRecordTarget(factories, document, patientRole); - - ClinicalDocumentMetadataGenerator.setCustodian(factories, document, custodian); - - ClinicalDocumentMetadataGenerator.setAuthor(factories, document, author); - - Bundle resultBundle = ccdTransformer.transformDocument(document); - - BundleUtil.findResources(resultBundle, Organization.class, 5); - - } - - private List create2ProblemConcernActGenerators1Observation() { - List components = new ArrayList(); - - ProblemObservationGenerator probObsGen = ProblemObservationGenerator.getDefaultInstance(); - - List probsObsGenList = new ArrayList(); - - probsObsGenList.add(probObsGen); - - ProblemConcernActGenerator probConcernActGen1 = ProblemConcernActGenerator.getDefaultInstance(); - - ProblemConcernActGenerator probConcernActGen2 = ProblemConcernActGenerator.getDefaultInstance(); - - probConcernActGen1.setProblemObservationGenerators(probsObsGenList); - - probConcernActGen2.setProblemObservationGenerators(probsObsGenList); - - CDAProblemsListSectionComponentGenerator probListSectionGen = new CDAProblemsListSectionComponentGenerator(); - - List problemConcernActGens = new ArrayList(); - - problemConcernActGens.add(probConcernActGen1); - - problemConcernActGens.add(probConcernActGen2); - - probListSectionGen.setProblemConcernActsGenerators(problemConcernActGens); - - components.add(probListSectionGen.generate(factories)); - - return components; - - } - - private List createActComponentsSameIndication(IndicationGenerator indGen) { - List components = new ArrayList(); - - CDAEncouncersSectionComponentGenerator encounterSectionGen = new CDAEncouncersSectionComponentGenerator(); - - CDAMedicationSectionComponentGenerator medSectionCompGen = new CDAMedicationSectionComponentGenerator(); - - List indicationGenerators = new ArrayList(); - - indicationGenerators.add(indGen); - - EncounterActivityGenerator encounterActivityGen = EncounterActivityGenerator.getDefaultInstance(); - - encounterActivityGen.setIndicationGenerator(indicationGenerators); - - MedicationActivityGenerator medActGen = MedicationActivityGenerator.getDefaultInstance(); - - medActGen.setIndicationGenerators(indicationGenerators); - - List encounters = new ArrayList(); - - List medActs = new ArrayList(); - - encounters.add(encounterActivityGen); - - medActs.add(medActGen.generate(factories)); - - encounterSectionGen.setEncounterActivities(encounters); - - medSectionCompGen.setSubstanceAdministrations(medActs); - - components.add(encounterSectionGen.generate(factories)); - - components.add(medSectionCompGen.generate(factories)); - - return components; - - } - - @Test - public void conditionTest() throws Exception { - ccdTransformer = new CCDTransformerImpl(); - - IndicationGenerator indGenerator = IndicationGenerator.getDefaultInstance(); - - ClinicalDocumentMetadataGenerator docGenerator = new ClinicalDocumentMetadataGenerator(); - - ContinuityOfCareDocument document = docGenerator.generateClinicalDoc(factories); - - List actComponents = createActComponentsSameIndication(indGenerator); - - List problemObsComponents = create2ProblemConcernActGenerators1Observation(); - - List components = new ArrayList(); - - components.addAll(actComponents); - - components.addAll(problemObsComponents); - ClinicalDocumentMetadataGenerator.setStructuredBody(factories, document, components); - - Bundle resultBundle = ccdTransformer.transformDocument(document); - - BundleUtil.findResources(resultBundle, Condition.class, 2); - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/EncounterTest.java b/src/test/java/tr/com/srdc/cda2fhir/EncounterTest.java deleted file mode 100644 index e5922b7d6..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/EncounterTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Encounter; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.consol.EncounterActivities; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -import com.helger.commons.collection.attr.StringMap; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class EncounterTest { - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - private static CDAFactories factories; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - - factories = CDAFactories.init(); - } - - @Test - public void testEncounterOriginalText() throws Exception { - - // Make an encounter activity. - EncounterActivities encounterActivities = factories.consol.createEncounterActivities(); - - BundleInfo bundleInfo = new BundleInfo(rt); - String expectedValue = "freetext entry"; - String referenceValue = "fakeid1"; - CD cd = factories.datatype.createCD(); - ED ed = factories.datatype.createED(); - TEL tel = factories.datatype.createTEL(); - tel.setValue("#" + referenceValue); - ed.setReference(tel); - cd.setCode("code"); - cd.setCodeSystem("codeSystem"); - cd.setOriginalText(ed); - Map idedAnnotations = new StringMap(); - idedAnnotations.put(referenceValue, expectedValue); - bundleInfo.mergeIdedAnnotations(idedAnnotations); - - encounterActivities.setCode(cd); - Bundle bundle = rt.tEncounterActivity2Encounter(encounterActivities, bundleInfo).getBundle(); - Encounter fhirEncounter = BundleUtil.findOneResource(bundle, Encounter.class); - CodeableConcept cc = fhirEncounter.getType().get(0); - Assert.assertEquals("Encounter Activity Code text value assigned", expectedValue, cc.getText()); - - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/EntitiesTest.java b/src/test/java/tr/com/srdc/cda2fhir/EntitiesTest.java deleted file mode 100644 index e79a47794..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/EntitiesTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package tr.com.srdc.cda2fhir; - -/* - * #%L - * CDA to FHIR Transformer Library - * %% - * Copyright (C) 2019 Amida Technology Solutions, Inc. - * %% - * 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.util.List; - -import org.hl7.fhir.dstu3.model.Base; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.AssignedEntity; -import org.openhealthtools.mdht.uml.cda.impl.AssignedAuthorImpl; -import org.openhealthtools.mdht.uml.cda.impl.AuthorImpl; -import org.openhealthtools.mdht.uml.cda.impl.CDAFactoryImpl; -import org.openhealthtools.mdht.uml.cda.impl.OrganizationImpl; -import org.openhealthtools.mdht.uml.cda.impl.PersonImpl; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory; -import org.openhealthtools.mdht.uml.hl7.datatypes.ON; -import org.openhealthtools.mdht.uml.hl7.datatypes.PN; -import org.openhealthtools.mdht.uml.hl7.datatypes.impl.DatatypesFactoryImpl; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.generator.AssignedEntityGenerator; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.entry.IEntityResult; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class EntitiesTest { - - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - - private static CDAFactories factories; - - private static DatatypesFactory cdaTypeFactory; - private static CDAFactoryImpl cdaFactory; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - factories = CDAFactories.init(); - cdaTypeFactory = DatatypesFactoryImpl.init(); - cdaFactory = (CDAFactoryImpl) CDAFactoryImpl.init(); - } - - @Test - public void organizationNameAlias() throws Exception { - - String orgStringOne = "Fake Organization One"; - String orgStringTwo = "Fake Organization Two"; - - // Make an organization, add two names. - OrganizationImpl org = (OrganizationImpl) cdaFactory.createOrganization(); - - ON orgNameOne = cdaTypeFactory.createON(); - orgNameOne.addText(orgStringOne); - org.getNames().add(orgNameOne); - - ON orgNameTwo = cdaTypeFactory.createON(); - orgNameTwo.addText(orgStringTwo); - org.getNames().add(orgNameTwo); - - // Transform from CDA to FHIR. - IEntryResult result = rt.tOrganization2Organization(org, new BundleInfo(rt)); - - org.hl7.fhir.dstu3.model.Organization fhirOrganization = BundleUtil.findOneResource(result.getBundle(), - org.hl7.fhir.dstu3.model.Organization.class); - - // Make assertions. - Assert.assertEquals("Organization name was set", orgStringOne, fhirOrganization.getName()); - Assert.assertEquals("Organization alias was set", orgStringTwo, - fhirOrganization.getAlias().get(0).asStringValue()); - Assert.assertEquals("Only one organization alias", 1, fhirOrganization.getAlias().size()); - } - - @Test - public void practitionerNameMultiple() throws Exception { - - String authorStringOne = "Name One"; - String authorStringTwo = "Name Two"; - - // Make an author, add two names. - AuthorImpl auth = (AuthorImpl) cdaFactory.createAuthor(); - AssignedAuthorImpl assAuth = (AssignedAuthorImpl) cdaFactory.createAssignedAuthor(); - PersonImpl pers = (PersonImpl) cdaFactory.createPerson(); - - auth.basicSetAssignedAuthor(assAuth, null); - auth.getAssignedAuthor().setAssignedPerson(pers); - - PN authorNameOne = cdaTypeFactory.createPN(); - authorNameOne.addText(authorStringOne); - auth.getAssignedAuthor().getAssignedPerson().getNames().add(authorNameOne); - - PN authorNameTwo = cdaTypeFactory.createPN(); - authorNameTwo.addText(authorStringTwo); - auth.getAssignedAuthor().getAssignedPerson().getNames().add(authorNameTwo); - - // Transform from CDA to FHIR. - BundleInfo bundleInfo = new BundleInfo(rt); - IEntityResult entityResult = rt.tAuthor2Practitioner(auth, bundleInfo); - org.hl7.fhir.dstu3.model.Resource fhirResource = entityResult.getPractitioner(); - List fhirNames = fhirResource.getNamedProperty("name").getValues(); - - // Make assertions. - Assert.assertEquals("Multiple Name for Practitioner Supported", 2, fhirNames.size()); - Assert.assertEquals("Practitioner Name One Set", authorStringOne, - fhirNames.get(0).getNamedProperty("text").getValues().get(0).toString()); - ; - Assert.assertEquals("Practitioner Name Two Set", authorStringTwo, - fhirNames.get(1).getNamedProperty("text").getValues().get(0).toString()); - ; - } - - @Test - public void testAssignedEntityBasic() throws Exception { - AssignedEntityGenerator aeg = AssignedEntityGenerator.getDefaultInstance(); - - AssignedEntity ae = aeg.generate(factories); - BundleInfo bundleInfo = new BundleInfo(rt); - IEntityResult entityResult = rt.tAssignedEntity2Practitioner(ae, bundleInfo); - - Practitioner practitioner = entityResult.getPractitioner(); - aeg.verify(practitioner); - - PractitionerRole role = entityResult.getPractitionerRole(); - aeg.verify(role); - - Organization org = entityResult.getOrganization(); - aeg.verify(org); - } -} \ No newline at end of file diff --git a/src/test/java/tr/com/srdc/cda2fhir/ImmunizationActivityTest.java b/src/test/java/tr/com/srdc/cda2fhir/ImmunizationActivityTest.java deleted file mode 100644 index f2d4ec478..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ImmunizationActivityTest.java +++ /dev/null @@ -1,219 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.Map; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.DiagnosticChain; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.Consumable; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.Material; -import org.openhealthtools.mdht.uml.cda.Performer2; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationActivity; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationRefusalReason; -import org.openhealthtools.mdht.uml.cda.consol.impl.ImmunizationActivityImpl; -import org.openhealthtools.mdht.uml.cda.consol.impl.ImmunizationRefusalReasonImpl; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import com.bazaarvoice.jolt.JsonUtils; -import com.helger.commons.collection.attr.StringMap; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.generator.PerformerGenerator; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class ImmunizationActivityTest { - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - - private static CDAFactories factories; - - private static Map statusMap = JsonUtils - .filepathToMap("src/test/resources//value-maps/ImmunizationStatus.json"); - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - factories = CDAFactories.init(); - } - - @Test - public void testPerformer() throws Exception { - ImmunizationActivityImpl act = (ImmunizationActivityImpl) factories.consol.createImmunizationActivity(); - BundleInfo bundleInfo = new BundleInfo(rt); - - Bundle bundle = rt.tImmunizationActivity2Immunization(act, bundleInfo).getBundle(); - Immunization immunization = BundleUtil.findOneResource(bundle, Immunization.class); - Assert.assertEquals("Unexpected positive primary source", false, immunization.getPrimarySource()); - - PerformerGenerator performerGenerator = PerformerGenerator.getDefaultInstance(); - Performer2 performer = performerGenerator.generate(factories); - act.getPerformers().add(performer); - - Bundle bundle1 = rt.tImmunizationActivity2Immunization(act, bundleInfo).getBundle(); - Immunization immunization1 = BundleUtil.findOneResource(bundle1, Immunization.class); - Assert.assertEquals("Unexpected negative primary source", true, immunization1.getPrimarySource()); - - String reference = immunization1.getPractitioner().get(0).getActor().getReference(); - Practitioner practitioner = BundleUtil.findOneResource(bundle1, Practitioner.class); - Assert.assertEquals("Unexpected Reference", reference, practitioner.getId()); - performerGenerator.verify(practitioner); - } - - static private void verifyNotGiven(ImmunizationActivity act, ImmunizationRefusalReason refusal, Boolean value) - throws Exception { - if (value != null) { - act.setNegationInd(value); - act.addObservation(refusal); - DiagnosticChain dxChain = new BasicDiagnostic(); - Boolean validation = act.validateImmunizationActivityNegationInd(dxChain, null); - Assert.assertTrue("Invalid Immunization Activity in Test", validation); - } - - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tImmunizationActivity2Immunization(act, bundleInfo).getBundle(); - Immunization immunization = BundleUtil.findOneResource(bundle, Immunization.class); - Assert.assertEquals("Unexpected not given", value == null ? false : value, immunization.getNotGiven()); - Assert.assertEquals("Unexpected Not Given Reason", value == null ? false : value, - immunization.getExplanation().getReasonNotGiven().size() > 0); - } - - @Test - public void testNegationInd() throws Exception { - ImmunizationActivityImpl act = (ImmunizationActivityImpl) factories.consol.createImmunizationActivity(); - ImmunizationRefusalReasonImpl refusal = (ImmunizationRefusalReasonImpl) factories.consol - .createImmunizationRefusalReason(); - CD cd = factories.datatype.createCD(); - cd.setCode("PATOBJ"); - refusal.setCode(cd); - verifyNotGiven(act, refusal, true); - verifyNotGiven(act, refusal, false); - } - - static private void verifyImmunizationStatus(ImmunizationActivityImpl act, String expected) throws Exception { - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tImmunizationActivity2Immunization(act, bundleInfo).getBundle(); - Immunization immunization = BundleUtil.findOneResource(bundle, Immunization.class); - - ImmunizationStatus status = immunization.getStatus(); - String actual = status == null ? null : status.toCode(); - Assert.assertEquals("Expect the correct immunization status", expected, actual); - } - - static private void verifyImmunizationOriginalText(ImmunizationActivityImpl act, Map annotations, - String expected) throws Exception { - BundleInfo bundleInfo = new BundleInfo(rt); - bundleInfo.mergeIdedAnnotations(annotations); - Bundle bundle = rt.tImmunizationActivity2Immunization(act, bundleInfo).getBundle(); - Immunization immunization = BundleUtil.findOneResource(bundle, Immunization.class); - - CodeableConcept code = immunization.getVaccineCode(); - Assert.assertEquals("Expect the correct immunization original text", expected, code.getText()); - } - - @Test - public void testStatusCode() throws Exception { - ImmunizationActivityImpl act = (ImmunizationActivityImpl) factories.consol.createImmunizationActivity(); - DiagnosticChain dxChain = new BasicDiagnostic(); - verifyImmunizationStatus(act, null); - - act.setStatusCode(null); - verifyImmunizationStatus(act, null); - - act.setStatusCode(factories.datatype.createCS("invalid")); - // Boolean invalidation = act.validateImmunizationActivityStatusCode(dxChain, - // null); - // Assert.assertFalse("Expect status code validation failure", invalidation) ; - // Maybe CDA implementation error?? - - CS csNullFlavor = factories.datatype.createCS(); - csNullFlavor.setNullFlavor(NullFlavor.UNK); - act.setStatusCode(csNullFlavor); - Boolean validationNF = act.validateImmunizationActivityStatusCode(dxChain, null); - Assert.assertTrue("Expect null flavor status code validation success", validationNF); - verifyImmunizationStatus(act, null); - - for (Map.Entry entry : statusMap.entrySet()) { - String cdaStatusCode = entry.getKey(); - String fhirStatus = (String) entry.getValue(); - - CS cs = factories.datatype.createCS(cdaStatusCode); - act.setStatusCode(cs); - Boolean validation = act.validateImmunizationActivityStatusCode(dxChain, null); - Assert.assertTrue("Expect status code validation success for valid status code", validation); - - verifyImmunizationStatus(act, fhirStatus); - } - } - - @Test - public void testCodeReference() throws Exception { - ImmunizationActivityImpl act = (ImmunizationActivityImpl) factories.consol.createImmunizationActivity(); - verifyImmunizationStatus(act, null); - - CE code = factories.datatype.createCE(); - ED ed = factories.datatype.createED(); - TEL tel = factories.datatype.createTEL(); - - tel.setValue("#fakeid1"); - ed.setReference(tel); - - code.setCode("code"); - code.setCodeSystem("codeSystem"); - code.setOriginalText(ed); - - Consumable cons = factories.base.createConsumable(); - ManufacturedProduct manProd = factories.base.createManufacturedProduct(); - Material mat = factories.base.createMaterial(); - mat.setCode(code); - manProd.setManufacturedMaterial(mat); - cons.setManufacturedProduct(manProd); - act.setConsumable(cons); - - Map idedAnnotations = new StringMap(); - idedAnnotations.put("fakeid1", "fakevalue2"); - - verifyImmunizationOriginalText(act, idedAnnotations, "fakevalue2"); - - } - - @Test - public void testImmunizationDosage() throws Exception { - - // Make a imm activity. - ImmunizationActivityImpl act = (ImmunizationActivityImpl) factories.consol.createImmunizationActivity(); - - IVL_PQ doseQuantity = factories.datatype.createIVL_PQ(); - - doseQuantity.setUnit("mg"); - doseQuantity.setValue(100.000); - act.setDoseQuantity(doseQuantity); - - // Transform from CDA to FHIR. - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle fhirBundle = rt.tImmunizationActivity2Immunization(act, bundleInfo).getBundle(); - - org.hl7.fhir.dstu3.model.Resource fhirResource = fhirBundle.getEntry().get(0).getResource(); - - String systemString = fhirResource.getNamedProperty("doseQuantity").getValues().get(0) - .getNamedProperty("system").getValues().get(0).toString(); - - Assert.assertEquals("URI attached for ucum", "UriType[http://unitsofmeasure.org/ucum.html]", systemString); - - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/IntegrationTest.java b/src/test/java/tr/com/srdc/cda2fhir/IntegrationTest.java deleted file mode 100644 index d68f26fdb..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/IntegrationTest.java +++ /dev/null @@ -1,310 +0,0 @@ - -package tr.com.srdc.cda2fhir; - -import java.io.IOException; - -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryResponseComponent; -import org.hl7.fhir.dstu3.model.Bundle.BundleType; -import org.hl7.fhir.dstu3.model.Composition; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Device; -import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.hl7.fhir.dstu3.model.DocumentReference; -import org.hl7.fhir.dstu3.model.Encounter; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.Location; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.MedicationRequest; -import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.hl7.fhir.dstu3.model.Observation; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Patient; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.Procedure; -import org.hl7.fhir.dstu3.model.Provenance; -import org.joda.time.Duration; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Ignore; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.palantir.docker.compose.DockerComposeRule; -import com.palantir.docker.compose.connection.waiting.HealthChecks; - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.rest.client.api.IGenericClient; -import tr.com.srdc.cda2fhir.transform.CCDTransformerImpl; -import tr.com.srdc.cda2fhir.util.FHIRUtil; -import tr.com.srdc.cda2fhir.util.IdGeneratorEnum; -import tr.com.srdc.cda2fhir.validation.ValidatorImpl; - -public class IntegrationTest { - static String hapiURL = "http://localhost:1137"; - static String serverBase = hapiURL + "/fhir"; - static FhirContext ctx; - static IGenericClient client; - static CCDTransformerImpl ccdTransformer; - static Logger logger; - - @BeforeClass - public static void init() throws IOException { - CDAUtil.loadPackages(); - ctx = FhirContext.forDstu3(); - ctx.getRestfulClientFactory().setConnectTimeout(20 * 1000); - client = ctx.newRestfulGenericClient(serverBase); - logger = LoggerFactory.getLogger(ValidatorImpl.class); - } - - @ClassRule - public static DockerComposeRule docker = DockerComposeRule - .builder().file("src/test/resources/docker-compose.yaml").waitingForService("hapi", - HealthChecks.toRespondOverHttp(8080, (port) -> port.inFormat(hapiURL)), Duration.standardMinutes(2)) - .build(); - - @Before - public void setup() { - ccdTransformer = new CCDTransformerImpl(IdGeneratorEnum.COUNTER); - } - - @Test - public void CCDIntegration() throws Exception { - - String sourceName = "170.315_b1_toc_inp_ccd_r21_sample1_v5.xml"; - String documentBody = "document"; - Identifier assemblerDevice = new Identifier(); - assemblerDevice.setValue("Data Transformer One"); - assemblerDevice.setSystem("http://www.amida.com"); - - // create transaction bundle from ccda bundle - Bundle transactionBundle = ccdTransformer.transformDocument("src/test/resources/" + sourceName, - BundleType.TRANSACTION, null, documentBody, assemblerDevice); - - // print pre-post bundle. - FHIRUtil.printJSON(transactionBundle, "src/test/resources/output/170.315_b1_toc_inp_ccd_r21_sample1_v5.json"); - - // Send transaction bundle to server. - Bundle resp = client.transaction().withBundle(transactionBundle).execute(); - - for (BundleEntryComponent entry : resp.getEntry()) { - BundleEntryResponseComponent entryResp = entry.getResponse(); - Assert.assertEquals("201 Created", entryResp.getStatus()); - } - - // Re-Send the same transactional bundle to server to test ifNoneExist. - client.transaction().withBundle(transactionBundle).execute(); - - Bundle patientResults = (Bundle) client.search().forResource(Patient.class).prettyPrint().execute(); - Assert.assertEquals(1, patientResults.getTotal()); - - Bundle medicationStatement = (Bundle) client.search().forResource(MedicationStatement.class).prettyPrint() - .execute(); - Assert.assertEquals(12, medicationStatement.getTotal()); - - Bundle medicationResults = (Bundle) client.search().forResource(Medication.class).prettyPrint().execute(); - Assert.assertEquals(12, medicationResults.getTotal()); - - Bundle conditionResults = (Bundle) client.search().forResource(Condition.class).prettyPrint().execute(); - Assert.assertEquals(6, conditionResults.getTotal()); - - Bundle immunizationResults = (Bundle) client.search().forResource(Immunization.class).prettyPrint().execute(); - Assert.assertEquals(3, immunizationResults.getTotal()); - - Bundle allergyResults = (Bundle) client.search().forResource(AllergyIntolerance.class).prettyPrint().execute(); - Assert.assertEquals(2, allergyResults.getTotal()); - - Bundle encounterResults = (Bundle) client.search().forResource(Encounter.class).prettyPrint().execute(); - Assert.assertEquals(1, encounterResults.getTotal()); - - Bundle reportResults = (Bundle) client.search().forResource(DiagnosticReport.class).prettyPrint().execute(); - Assert.assertEquals(2, reportResults.getTotal()); - - Bundle observationResults = (Bundle) client.search().forResource(Observation.class).prettyPrint().execute(); - Assert.assertEquals(19, observationResults.getTotal()); - - Bundle practitionerResults = (Bundle) client.search().forResource(Practitioner.class).prettyPrint().execute(); - Assert.assertEquals(7, practitionerResults.getTotal()); - - Bundle procedureResults = (Bundle) client.search().forResource(Procedure.class).prettyPrint().execute(); - Assert.assertEquals(3, procedureResults.getTotal()); - - Bundle deviceResults = (Bundle) client.search().forResource(Device.class).prettyPrint().execute(); - Assert.assertEquals(1, deviceResults.getTotal()); - - // no identifier on location. - Bundle locationResults = (Bundle) client.search().forResource(Location.class).prettyPrint().execute(); - Assert.assertEquals(2, locationResults.getTotal()); - - // 3 organizations don't have identifiers. - Bundle organizationResults = (Bundle) client.search().forResource(Organization.class).prettyPrint().execute(); - Assert.assertEquals(9, organizationResults.getTotal()); - - // Non de-duplicating resources below. - Bundle documentReferenceResults = (Bundle) client.search().forResource(DocumentReference.class).prettyPrint() - .execute(); - Assert.assertEquals(2, documentReferenceResults.getTotal()); - - Bundle provenanceResults = (Bundle) client.search().forResource(Provenance.class).prettyPrint().execute(); - Assert.assertEquals(2, provenanceResults.getTotal()); - - Bundle compositionResults = (Bundle) client.search().forResource(Composition.class).prettyPrint().execute(); - Assert.assertEquals(1, compositionResults.getTotal()); - - } - - @Ignore - public void hannahIntegration() throws Exception { - - String sourceName = "Epic/HannahBanana_EpicCCD-pretty.xml"; - String documentBody = "Hannah"; - Identifier assemblerDevice = new Identifier(); - assemblerDevice.setValue("Data Transformer Two"); - assemblerDevice.setSystem("http://www.amida.com"); - // create transaction bundle from ccda bundle - - Bundle transactionBundle = ccdTransformer.transformDocument("src/test/resources/" + sourceName, - BundleType.TRANSACTION, null, documentBody, assemblerDevice); - - // print pre-post bundle - FHIRUtil.printJSON(transactionBundle, "src/test/resources/output/HannahBanana_EpicCCD-pretty.json"); - - // Send transaction bundle to server. - Bundle resp = client.transaction().withBundle(transactionBundle).execute(); - - for (BundleEntryComponent entry : resp.getEntry()) { - BundleEntryResponseComponent entryResp = entry.getResponse(); - Assert.assertEquals("201 Created", entryResp.getStatus()); - } - - // Re-Send the same transactional bundle to server to test ifNoneExist. - client.transaction().withBundle(transactionBundle).execute(); - - // 1 Patient - Bundle patientResults = (Bundle) client.search().forResource(Patient.class).prettyPrint().execute(); - Assert.assertEquals(1, patientResults.getTotal()); - - // 1 Med request for esomeprazole - Bundle medicationRequest = (Bundle) client.search().forResource(MedicationRequest.class).prettyPrint() - .execute(); - Assert.assertEquals(1, medicationRequest.getTotal()); - - // 1 Medication statement, esomeprazole - Bundle medicationStatement = (Bundle) client.search().forResource(MedicationStatement.class).prettyPrint() - .execute(); - Assert.assertEquals(1, medicationStatement.getTotal()); - - // 2 Conditions (4 problem list, 1 imm, 1 med, 1 encounter diagnosis) - Bundle conditionResults = (Bundle) client.search().forResource(Condition.class).prettyPrint().execute(); - Assert.assertEquals(2, conditionResults.getTotal()); - - // 1 Immunization - Bundle immunizationResults = (Bundle) client.search().forResource(Immunization.class).prettyPrint().execute(); - Assert.assertEquals(1, immunizationResults.getTotal()); - - // 1 Allergy - Bundle allergyResults = (Bundle) client.search().forResource(AllergyIntolerance.class).prettyPrint().execute(); - Assert.assertEquals(1, allergyResults.getTotal()); - - // 1 Encounter - Bundle encounterResults = (Bundle) client.search().forResource(Encounter.class).prettyPrint().execute(); - Assert.assertEquals(1, encounterResults.getTotal()); - - // 5 Observations (5 Vitals) - Bundle observationResults = (Bundle) client.search().forResource(Observation.class).prettyPrint().execute(); - Assert.assertEquals(5, observationResults.getTotal()); - - // 1 medication - Bundle medicationResults = (Bundle) client.search().forResource(Medication.class).prettyPrint().execute(); - Assert.assertEquals(1, medicationResults.getTotal()); - - // 2 practitioners - Bundle practitionerResults = (Bundle) client.search().forResource(Practitioner.class).prettyPrint().execute(); - Assert.assertEquals(2, practitionerResults.getTotal()); - - // 2 practitioner roles (re-enable once afsin's fixes are merged). - // Bundle practitionerRoleResults = (Bundle) - // client.search().forResource(PractitionerRole.class).prettyPrint() - // .execute(); - // Assert.assertEquals(2, practitionerRoleResults.getTotal()); - - // 2 devices - Bundle deviceResults = (Bundle) client.search().forResource(Device.class).prettyPrint().execute(); - Assert.assertEquals(2, deviceResults.getTotal()); - - // 1 location - Bundle locationResults = (Bundle) client.search().forResource(Location.class).prettyPrint().execute(); - Assert.assertEquals(1, locationResults.getTotal()); - - /** - * Document Reference will not de-duplicate, no query mechanism to hash. - **/ - Bundle documentReferenceResults = (Bundle) client.search().forResource(DocumentReference.class).prettyPrint() - .execute(); - Assert.assertEquals(2, documentReferenceResults.getTotal()); - - /** - * These should duplicate for attribution purposes. - **/ - Bundle provenanceResults = (Bundle) client.search().forResource(Provenance.class).prettyPrint().execute(); - Assert.assertEquals(2, provenanceResults.getTotal()); - - Bundle compositionResults = (Bundle) client.search().forResource(Composition.class).prettyPrint().execute(); - Assert.assertEquals(1, compositionResults.getTotal()); - - } - - @Ignore - public void rakiaIntegration() throws Exception { - String sourceName = "Cerner/Person-RAKIA_TEST_DOC00001 (1).XML"; - String documentBody = "RAKIA"; - Identifier assemblerDevice = new Identifier(); - assemblerDevice.setValue("Data Transformer Three"); - assemblerDevice.setSystem("http://www.amida.com"); - - // create transaction bundle from ccda bundle - Bundle transactionBundle = ccdTransformer.transformDocument("src/test/resources/" + sourceName, - BundleType.TRANSACTION, null, documentBody, assemblerDevice); - - // print pre-post bundle - FHIRUtil.printJSON(transactionBundle, "src/test/resources/output/Person-RAKIA_TEST_DOC00001 (1).json"); - - // Send transaction bundle to server. - Bundle resp = client.transaction().withBundle(transactionBundle).execute(); - - for (BundleEntryComponent entry : resp.getEntry()) { - BundleEntryResponseComponent entryResp = entry.getResponse(); - - Assert.assertEquals("201 Created", entryResp.getStatus()); - } - - Bundle patientResults = (Bundle) client.search().forResource(Patient.class).prettyPrint().execute(); - - Bundle practitionerResults = (Bundle) client.search().forResource(Practitioner.class).prettyPrint().execute(); - - Bundle medicationResults = (Bundle) client.search().forResource(Medication.class).prettyPrint().execute(); - - Bundle provenanceResults = (Bundle) client.search().forResource(Provenance.class).prettyPrint().execute(); - - Bundle docRefresults = (Bundle) client.search().forResource(DocumentReference.class).prettyPrint().execute(); - - Bundle deviceResults = (Bundle) client.search().forResource(Device.class).prettyPrint().execute(); - - Bundle organizationResults = (Bundle) client.search().forResource(Organization.class).prettyPrint().execute(); - - Assert.assertEquals(1, patientResults.getTotal()); - Assert.assertEquals(32, practitionerResults.getTotal()); - Assert.assertEquals(13, medicationResults.getTotal()); - Assert.assertEquals(1, provenanceResults.getTotal()); - Assert.assertEquals(1, docRefresults.getTotal()); - Assert.assertEquals(2, deviceResults.getTotal()); - Assert.assertEquals(1, organizationResults.getTotal()); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/LocationTest.java b/src/test/java/tr/com/srdc/cda2fhir/LocationTest.java deleted file mode 100644 index bce0e891c..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/LocationTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package tr.com.srdc.cda2fhir; - -/* - * #%L - * CDA to FHIR Transformer Library - * %% - * Copyright (C) 2019 Amida Technology Solutions, Inc. - * %% - * 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 org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.impl.CDAFactoryImpl; -import org.openhealthtools.mdht.uml.cda.impl.ParticipantRoleImpl; -import org.openhealthtools.mdht.uml.cda.impl.PlayingEntityImpl; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.impl.DatatypesFactoryImpl; - -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; - -public class LocationTest { - - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - private static DatatypesFactory cdaTypeFactory; - private static CDAFactoryImpl cdaFactory; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - cdaTypeFactory = DatatypesFactoryImpl.init(); - cdaFactory = (CDAFactoryImpl) CDAFactoryImpl.init(); - } - - @Test - public void testLocations() throws Exception { - - // Make a participant. - ParticipantRoleImpl pr = (ParticipantRoleImpl) cdaFactory.createParticipantRole(); - PlayingEntityImpl pe = (PlayingEntityImpl) cdaFactory.createPlayingEntity(); - - II identifier = cdaTypeFactory.createII(); - identifier.setRoot("sampleRoot"); - - pr.getIds().add(identifier); - - pr.setPlayingEntity(pe); - - // Transform from CDA to FHIR. - org.hl7.fhir.dstu3.model.Location fhirLocation = rt.tParticipantRole2Location(pr); - - Assert.assertEquals("Identifier on FHIR Object", 1, fhirLocation.getIdentifier().size()); - - } - -} \ No newline at end of file diff --git a/src/test/java/tr/com/srdc/cda2fhir/MedicationRequestTest.java b/src/test/java/tr/com/srdc/cda2fhir/MedicationRequestTest.java deleted file mode 100644 index a2690b1c7..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/MedicationRequestTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.MedicationRequest; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.codesystems.MedicationRequestIntent; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.Supply; -import org.openhealthtools.mdht.uml.cda.consol.MedicationActivity; -import org.openhealthtools.mdht.uml.cda.consol.MedicationSupplyOrder; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.ManufacturedProductGenerator; -import tr.com.srdc.cda2fhir.testutil.MedicationSupplyOrderGenerator; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.ValueSetsTransformerImpl; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntryResult; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class MedicationRequestTest { - - private static MedicationSupplyOrderGenerator medSupplyOrderGenerator; - private static CDAFactories factories; - private static ResourceTransformerImpl rt; - private static ValueSetsTransformerImpl vst; - - @BeforeClass - public static void init() { - - CDAUtil.loadPackages(); - factories = CDAFactories.init(); - medSupplyOrderGenerator = new MedicationSupplyOrderGenerator(factories); - rt = new ResourceTransformerImpl(); - vst = new ValueSetsTransformerImpl(); - } - - @Test - public void testMedicationSupplyOrder2MedicationRequest() throws Exception { - - BundleInfo bInfo = new BundleInfo(rt); - MedicationSupplyOrder defaultMedSupplyOrder = medSupplyOrderGenerator.generateDefaultMedicationSupplyOrder(); - EntryResult entryResult = rt.medicationSupplyOrder2MedicationRequest(defaultMedSupplyOrder, bInfo); - Bundle resultBundle = entryResult.getBundle(); - MedicationRequest medRequest = BundleUtil.findOneResource(resultBundle, MedicationRequest.class); - Medication medication = BundleUtil.findOneResource(resultBundle, Medication.class); - Practitioner practitioner = BundleUtil.findOneResource(resultBundle, Practitioner.class); - - Assert.assertEquals("MedicationRequest", medRequest.getResourceType().toString()); - Assert.assertEquals(MedicationSupplyOrderGenerator.DEFAULT_ROOT_ID, - medRequest.getIdentifierFirstRep().getValue()); - Assert.assertEquals(MedicationSupplyOrderGenerator.DEFAULT_STATUS_CODE, medRequest.getStatus().toCode()); - Assert.assertEquals(MedicationRequestIntent.INSTANCEORDER.toCode(), medRequest.getIntent().toCode()); - Assert.assertEquals(medication.getId(), medRequest.getMedicationReference().getReference()); - Assert.assertEquals("Patient/0", medRequest.getSubject().getReference()); - Assert.assertEquals(1, medRequest.getDispenseRequest().getNumberOfRepeatsAllowed()); - - Assert.assertEquals(MedicationSupplyOrderGenerator.DEFAULT_QUANTITY_UNIT, - medRequest.getDispenseRequest().getQuantity().getUnit()); - Assert.assertEquals(MedicationSupplyOrderGenerator.DEFAULT_QUANTITY_VALUE, - medRequest.getDispenseRequest().getQuantity().getValue().toString()); - Assert.assertEquals("2019-01-01T00:00:00.000-05:00", - medRequest.getDispenseRequest().getValidityPeriod().getStartElement().getValueAsString()); - Assert.assertEquals("2019-01-01T12:34:56.000-05:00", - medRequest.getDispenseRequest().getValidityPeriod().getEndElement().getValueAsString()); - Assert.assertEquals(MedicationSupplyOrderGenerator.DEFAULT_INSTRUCTION, medRequest.getNoteFirstRep().getText()); - Assert.assertEquals(medRequest.getRequester().getAgent().getReference(), practitioner.getId()); - - Assert.assertEquals(ManufacturedProductGenerator.DEFAULT_MANU_MATERIAL_CODE_CODE, - medication.getCode().getCodingFirstRep().getCode()); - Assert.assertEquals("urn:oid:" + vst.tOid2Url(ManufacturedProductGenerator.DEFAULT_MANU_MATERIAL_CODE_SYSTEM), - vst.tOid2Url(medication.getCode().getCodingFirstRep().getSystem())); - Assert.assertEquals(ManufacturedProductGenerator.DEFAULT_MANU_MATERIAL_DISPLAY_NAME, - medication.getCode().getCodingFirstRep().getDisplay()); - Assert.assertEquals(ManufacturedProductGenerator.DEFAULT_TRANSLATION_CODE, - medication.getCode().getCoding().get(1).getCode()); - Assert.assertEquals("urn:oid:" + vst.tOid2Url(ManufacturedProductGenerator.DEFAULT_TRANSLATION_CODE_SYSTEM), - vst.tOid2Url(medication.getCode().getCoding().get(1).getSystem())); - Assert.assertEquals(ManufacturedProductGenerator.DEFAULT_TRANSLATION_DISPLAY_NAME, - medication.getCode().getCoding().get(1).getDisplay()); - - } - - @Test - public void testMedicationActivity() throws Exception { - BundleInfo bInfo = new BundleInfo(rt); - MedicationActivity medActivity = factories.consol.createMedicationActivity(); - Supply supply = medSupplyOrderGenerator.generateDefaultMedicationSupplyOrder(); - medActivity.addSupply(supply); - EntryResult entryResult = rt.tMedicationActivity2MedicationStatement(medActivity, bInfo); - List medRequests = BundleUtil.findResources(entryResult.getBundle(), MedicationRequest.class, - 1); - List medications = BundleUtil.findResources(entryResult.getBundle(), Medication.class, 1); - List practitioners = BundleUtil.findResources(entryResult.getBundle(), Practitioner.class, 1); - List organizations = BundleUtil.findResources(entryResult.getBundle(), Organization.class, 1); - - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/MedicationStatementTest.java b/src/test/java/tr/com/srdc/cda2fhir/MedicationStatementTest.java deleted file mode 100644 index 2c6731ffe..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/MedicationStatementTest.java +++ /dev/null @@ -1,188 +0,0 @@ -package tr.com.srdc.cda2fhir; - -/* - * #%L - * CDA to FHIR Transformer Library - * %% - * Copyright (C) 2019 Amida Technology Solutions, Inc. - * %% - * 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.util.List; - -import org.hl7.fhir.dstu3.model.Base; -import org.hl7.fhir.dstu3.model.Dosage; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.EntryRelationship; -import org.openhealthtools.mdht.uml.cda.Observation; -import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; -import org.openhealthtools.mdht.uml.cda.consol.impl.MedicationActivityImpl; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.vocab.ActClass; -import org.openhealthtools.mdht.uml.hl7.vocab.ActClassObservation; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActMoodDocumentObservation; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; -import org.openhealthtools.mdht.uml.hl7.vocab.x_DocumentSubstanceMood; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class MedicationStatementTest { - - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - - private static CDAFactories factories; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - factories = CDAFactories.init(); - } - - @Test - public void testMedicationStatus() throws Exception { - - // Make a medication activity. - MedicationActivityImpl medAct = (MedicationActivityImpl) factories.consol.createMedicationActivity(); - - // Transform from CDA to FHIR. - BundleInfo bundleInfo = new BundleInfo(rt); - org.hl7.fhir.dstu3.model.Bundle fhirBundle = rt.tMedicationActivity2MedicationStatement(medAct, bundleInfo) - .getBundle(); - - org.hl7.fhir.dstu3.model.Resource fhirResource = fhirBundle.getEntry().get(0).getResource(); - List takenCodes = fhirResource.getNamedProperty("taken").getValues(); - - // Make assertions. - Assert.assertEquals("Taken code defaults to UNK", "unk", takenCodes.get(0).primitiveValue()); - - } - - private Observation getCdaFrequencyObservation(String frequency) { - Observation obs = factories.base.createObservation(); - ANY value = factories.datatype.createED(frequency); - obs.setClassCode(ActClassObservation.OBS); - obs.setMoodCode(x_ActMoodDocumentObservation.EVN); - CD code = factories.datatype.createCD(); - code.setCode("FREQUENCY"); - obs.setCode(code); - obs.getValues().add(value); - return obs; - } - - private EntryRelationship getFrequencyEntryRelationship(Observation observation) { - EntryRelationship er = factories.base.createEntryRelationship(); - er.setTypeCode(x_ActRelationshipEntryRelationship.SUBJ); - er.setInversionInd(true); - er.setObservation(observation); - return er; - } - - private SubstanceAdministration getFreeTextSignatureSubstanceAdministration(String sig) { - SubstanceAdministration sa = factories.base.createSubstanceAdministration(); - sa.setClassCode(ActClass.SBADM); - sa.setMoodCode(x_DocumentSubstanceMood.EVN); - ED text = factories.datatype.createED(); - TEL sigRef = factories.datatype.createTEL("#" + sig); - text.setReference(sigRef); - sa.setText(text); - return sa; - - } - - private EntryRelationship getFreeTextSignatureEntryRelationship(SubstanceAdministration sa) { - EntryRelationship er = factories.base.createEntryRelationship(); - er.setTypeCode(x_ActRelationshipEntryRelationship.COMP); - er.setSubstanceAdministration(sa); - return er; - } - - private IVL_PQ getDoseQuantity(String unit, Double value) { - IVL_PQ doseQuantity = factories.datatype.createIVL_PQ(); - doseQuantity.setUnit("mg"); - doseQuantity.setValue(100.000); - return doseQuantity; - } - - @Test - public void testMedicationDosage() throws Exception { - String freeTextInstruction = "Take with 4 pints of rocky road icream and 3 cupcakes"; - String frequency = "2 times daily."; - String sig = "sig"; - - // Create substance administration signature reference - SubstanceAdministration sa = getFreeTextSignatureSubstanceAdministration(sig); - - // Create entry relationship containing signature reference - EntryRelationship freeTextEntryRelationship = getFreeTextSignatureEntryRelationship(sa); - - // Create Frequency Observation - Observation obs = getCdaFrequencyObservation(frequency); - - // Create Entry Relationship containing frequency observation - EntryRelationship frequencyEntryRelationship = getFrequencyEntryRelationship(obs); - - // Make a medication activity. - MedicationActivityImpl medAct = (MedicationActivityImpl) factories.consol.createMedicationActivity(); - - // Make Dosage Quantity - IVL_PQ doseQuantity = getDoseQuantity("mg", 100.000); - - // Set Dosage - medAct.setDoseQuantity(doseQuantity); - // Set Signature Reference - medAct.getEntryRelationships().add(freeTextEntryRelationship); - // Set frequency observation - medAct.getEntryRelationships().add(frequencyEntryRelationship); - - // Transform from CDA to FHIR. - BundleInfo bundleInfo = new BundleInfo(rt); - - // Create signature to free text mapping in Bundle Info - bundleInfo.getIdedAnnotations().put(sig, freeTextInstruction); - - org.hl7.fhir.dstu3.model.Bundle fhirBundle = rt.tMedicationActivity2MedicationStatement(medAct, bundleInfo) - .getBundle(); - - org.hl7.fhir.dstu3.model.Resource fhirResource = fhirBundle.getEntry().get(0).getResource(); - - List doses = fhirResource.getNamedProperty("dosage").getValues().get(0).getNamedProperty("dose") - .getValues(); - Dosage dosage = (Dosage) fhirResource.getNamedProperty("dosage").getValues().get(0); - - // Make assertions. - Assert.assertEquals("URI attached for ucum", "UriType[http://unitsofmeasure.org/ucum.html]", - doses.get(0).getNamedProperty("system").getValues().get(0).toString()); - - Assert.assertEquals("sig1 free text instruction included in dosage text", freeTextInstruction, - dosage.getText()); - - Assert.assertEquals("sig1 free text instruction included in dosage patientInstruction", freeTextInstruction, - dosage.getPatientInstruction()); - - Assert.assertEquals("Frequency: " + frequency + " included in dosage timing timing", - dosage.getTiming().getCode().getText(), frequency); - - } - -} \ No newline at end of file diff --git a/src/test/java/tr/com/srdc/cda2fhir/MedicationTest.java b/src/test/java/tr/com/srdc/cda2fhir/MedicationTest.java deleted file mode 100644 index 90869b956..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/MedicationTest.java +++ /dev/null @@ -1,208 +0,0 @@ -package tr.com.srdc.cda2fhir; - -/* - * #%L - * CDA to FHIR Transformer Library - * %% - * Copyright (C) 2019 Amida Technology Solutions, Inc. - * %% - * 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.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Base; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.UriType; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.impl.CDAFactoryImpl; -import org.openhealthtools.mdht.uml.cda.impl.ManufacturedProductImpl; -import org.openhealthtools.mdht.uml.cda.impl.MaterialImpl; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.datatypes.impl.DatatypesFactoryImpl; - -import com.helger.commons.collection.attr.StringMap; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class MedicationTest { - - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - - private static DatatypesFactory cdaTypeFactory; - private static CDAFactoryImpl cdaFactory; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - cdaTypeFactory = DatatypesFactoryImpl.init(); - cdaFactory = (CDAFactoryImpl) CDAFactoryImpl.init(); - } - - @Test - public void testMedications() throws Exception { - - BundleInfo bundleInfo = new BundleInfo(rt); - - // Make a manufactured product. - ManufacturedProductImpl product = (ManufacturedProductImpl) cdaFactory.createManufacturedProduct(); - MaterialImpl material = (MaterialImpl) cdaFactory.createMaterial(); - - // get one test encoding. - CE codeOne = cdaTypeFactory.createCE(); - codeOne.setCode("863669"); - codeOne.setCodeSystem("2.16.840.1.113883.6.88"); - codeOne.setCodeSystemName("RxNorm"); - codeOne.setDisplayName("Tamsulosin hydrochloride 0.4 MG Oral Capsule"); - - // get second test translation. - CE codeTwo = cdaTypeFactory.createCE(); - codeTwo.setCode("863671"); - codeTwo.setCodeSystem("2.16.840.1.113883.6.88"); - codeTwo.setCodeSystemName("RxNorm"); - codeTwo.setDisplayName("Tamsulosin hydrochloride 0.4 MG Oral Capsule [Flomax]"); - - // set material on product. - codeOne.getTranslations().add(codeTwo); - material.basicSetCode(codeOne, null); - product.setManufacturedMaterial(material); - - // Transform from CDA to FHIR. - org.hl7.fhir.dstu3.model.Resource fhirResource = rt.tManufacturedProduct2Medication(product, bundleInfo) - .getBundle().getEntryFirstRep().getResource(); - - List fhirCodes = fhirResource.getNamedProperty("code").getValues(); - List fhirCodings = fhirCodes.get(0).getNamedProperty("coding").getValues(); - - // Make assertions. - Assert.assertEquals("Two Codes on FHIR Object", 2, fhirCodings.size()); - Assert.assertEquals("Medication Code One set on FHIR Object", codeOne.getDisplayName(), - fhirCodings.get(0).getNamedProperty("display").getValues().get(0).toString()); - Assert.assertEquals("Medication Code Two set on FHIR Object", codeTwo.getDisplayName(), - fhirCodings.get(1).getNamedProperty("display").getValues().get(0).toString()); - Assert.assertTrue("No ingredient present", fhirResource.getNamedProperty("ingredient").getValues().isEmpty()); - } - - @Test // UPMCFHIR-216 - public void testMultumMedications() { - - BundleInfo bundleInfo = new BundleInfo(rt); - - // Make a manufactured product. - ManufacturedProductImpl product = (ManufacturedProductImpl) cdaFactory.createManufacturedProduct(); - MaterialImpl material = (MaterialImpl) cdaFactory.createMaterial(); - - // get one test encoding. - CE codeOne = cdaTypeFactory.createCE(); - codeOne.setCode("d00769"); - codeOne.setCodeSystem("2.16.840.1.113883.6.314"); - codeOne.setCodeSystemName("multum-drug-id"); - codeOne.setDisplayName("pseudoephedrine"); - - // set material on product. - material.basicSetCode(codeOne, null); - product.setManufacturedMaterial(material); - - // Transform from CDA to FHIR. - org.hl7.fhir.dstu3.model.Resource fhirResource = rt.tManufacturedProduct2Medication(product, bundleInfo) - .getBundle().getEntryFirstRep().getResource(); - - List fhirCodes = fhirResource.getNamedProperty("code").getValues(); - List fhirCodings = fhirCodes.get(0).getNamedProperty("coding").getValues(); - - UriType systemUri = (UriType) fhirCodings.get(0).getNamedProperty("system").getValues().get(0); - - Assert.assertEquals("Medication Code One set on FHIR Object", codeOne.getDisplayName(), - fhirCodings.get(0).getNamedProperty("display").getValues().get(0).toString()); - Assert.assertEquals("Medication System set on FHIR Object", "http://www.nlm.nih.gov/research/umls/mmsl", - systemUri.asStringValue()); - } - - @Test // UPMCFHIR-216 - public void testNCIMedications() { - - BundleInfo bundleInfo = new BundleInfo(rt); - - // Make a manufactured product. - ManufacturedProductImpl product = (ManufacturedProductImpl) cdaFactory.createManufacturedProduct(); - MaterialImpl material = (MaterialImpl) cdaFactory.createMaterial(); - - // get one test encoding. - CE codeOne = cdaTypeFactory.createCE(); - codeOne.setCode("C38288"); - codeOne.setCodeSystem("2.16.840.1.113883.3.26.1.1"); - codeOne.setCodeSystemName("NCI Thesaurus"); - - // set material on product. - material.basicSetCode(codeOne, null); - product.setManufacturedMaterial(material); - - // Transform from CDA to FHIR. - org.hl7.fhir.dstu3.model.Resource fhirResource = rt.tManufacturedProduct2Medication(product, bundleInfo) - .getBundle().getEntryFirstRep().getResource(); - - List fhirCodes = fhirResource.getNamedProperty("code").getValues(); - List fhirCodings = fhirCodes.get(0).getNamedProperty("coding").getValues(); - - UriType systemUri = (UriType) fhirCodings.get(0).getNamedProperty("system").getValues().get(0); - - Assert.assertEquals("Medication Code One set on FHIR Object", codeOne.getCode(), - fhirCodings.get(0).getNamedProperty("code").getValues().get(0).toString()); - Assert.assertEquals("Medication System set on FHIR Object", "http://www.nlm.nih.gov/research/umls/nci", - systemUri.asStringValue()); - } - - @Test - public void testMedicationOriginalText() throws Exception { - - // Make a manufactured product. - ManufacturedProductImpl product = (ManufacturedProductImpl) cdaFactory.createManufacturedProduct(); - MaterialImpl material = (MaterialImpl) cdaFactory.createMaterial(); - - BundleInfo bundleInfo = new BundleInfo(rt); - String expectedValue = "freetext entry"; - String referenceValue = "fakeid1"; - CE ce = cdaTypeFactory.createCE(); - ED ed = cdaTypeFactory.createED(); - TEL tel = cdaTypeFactory.createTEL(); - tel.setValue("#" + referenceValue); - ed.setReference(tel); - ce.setCode("code"); - ce.setCodeSystem("codeSystem"); - ce.setOriginalText(ed); - Map idedAnnotations = new StringMap(); - idedAnnotations.put(referenceValue, expectedValue); - bundleInfo.mergeIdedAnnotations(idedAnnotations); - - material.setCode(ce); - product.setManufacturedMaterial(material); - Bundle bundle = rt.tManufacturedProduct2Medication(product, bundleInfo).getBundle(); - Medication medication = BundleUtil.findOneResource(bundle, Medication.class); - CodeableConcept cc = medication.getCode(); - Assert.assertEquals("Medication Code text value assigned", expectedValue, cc.getText()); - - } - -} \ No newline at end of file diff --git a/src/test/java/tr/com/srdc/cda2fhir/ObservationTest.java b/src/test/java/tr/com/srdc/cda2fhir/ObservationTest.java deleted file mode 100644 index 1e5f722c4..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ObservationTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.Map; - -import org.hl7.fhir.dstu3.model.BooleanType; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Observation; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.BL; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -import com.helger.commons.collection.attr.StringMap; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class ObservationTest { - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - private static CDAFactories factories; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - - factories = CDAFactories.init(); - } - - public static void verifyBooleanValue(boolean value) throws Exception { - org.openhealthtools.mdht.uml.cda.Observation observation = factories.base.createObservation(); - BL bl = factories.datatype.createBL(value); - observation.getValues().add(bl); - - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tObservation2Observation(observation, bundleInfo).getBundle(); - org.hl7.fhir.dstu3.model.Observation fhirObservation = BundleUtil.findOneResource(bundle, - org.hl7.fhir.dstu3.model.Observation.class); - BooleanType bt = fhirObservation.getValueBooleanType(); - Assert.assertEquals("Pull back the observation " + value + " boolean value", value, - bt.getValue().booleanValue()); - } - - @Test - public void valueBooleanTest() throws Exception { - verifyBooleanValue(true); - verifyBooleanValue(false); - } - - @Test - public void testObservationOriginalText() throws Exception { - - org.openhealthtools.mdht.uml.cda.Observation observation = factories.base.createObservation(); - - BundleInfo bundleInfo = new BundleInfo(rt); - String expectedValue = "freetext entry"; - String referenceValue = "fakeid1"; - CE ce = factories.datatype.createCE(); - ED ed = factories.datatype.createED(); - TEL tel = factories.datatype.createTEL(); - tel.setValue("#" + referenceValue); - ed.setReference(tel); - ce.setCode("code"); - ce.setCodeSystem("codeSystem"); - ce.setOriginalText(ed); - Map idedAnnotations = new StringMap(); - idedAnnotations.put(referenceValue, expectedValue); - bundleInfo.mergeIdedAnnotations(idedAnnotations); - - observation.setCode(ce); - Bundle bundle = rt.tObservation2Observation(observation, bundleInfo).getBundle(); - Observation fhirObservation = BundleUtil.findOneResource(bundle, Observation.class); - CodeableConcept cc = fhirObservation.getCode(); - Assert.assertEquals("Observation Code text value assigned", expectedValue, cc.getText()); - - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/PatientTests.java b/src/test/java/tr/com/srdc/cda2fhir/PatientTests.java deleted file mode 100644 index 6da0db3b6..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/PatientTests.java +++ /dev/null @@ -1,97 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.LanguageCommunication; -import org.openhealthtools.mdht.uml.cda.impl.CDAFactoryImpl; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.impl.DatatypesFactoryImpl; - -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.ValueSetsTransformerImpl; - -public class PatientTests { - static CDAFactoryImpl cdaFactory; - static DatatypesFactoryImpl dataTypesFactory; - - @BeforeClass - public static void init() { - // 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. - cdaFactory = new CDAFactoryImpl(); - dataTypesFactory = new DatatypesFactoryImpl(); - CDAUtil.loadPackages(); - } - - @Test - public void testPatientContactRelationship() { - ValueSetsTransformerImpl vst = new ValueSetsTransformerImpl(); - Assert.assertEquals("http://hl7.org/fhir/v2/0131", - vst.tRoleCode2PatientContactRelationshipCode("econ").getSystem()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("econ").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("econ").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("ext").getDisplay()); - ; - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("ext").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("guard").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("guard").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("frnd").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("frnd").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("sps").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("sps").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("husb").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("husb").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("wife").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("wife").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("prn").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("prn").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("fth").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("fth").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("mth").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("mth").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("nprn").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("nprn").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("nmth").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("nmth").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("prinlaw").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("prinlaw").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("fthinlaw").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("fthinlaw").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("mthinlaw").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("mthinlaw").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("stpprn").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("stpprn").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("stpfth").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("stpfth").getCode()); - Assert.assertEquals("Emergency Contact", vst.tRoleCode2PatientContactRelationshipCode("stpmth").getDisplay()); - Assert.assertEquals("C", vst.tRoleCode2PatientContactRelationshipCode("stpmth").getCode()); - Assert.assertEquals("Other", vst.tRoleCode2PatientContactRelationshipCode("gt").getDisplay()); - Assert.assertEquals("O", vst.tRoleCode2PatientContactRelationshipCode("gt").getCode()); - Assert.assertEquals("Employer", vst.tRoleCode2PatientContactRelationshipCode("work").getDisplay()); - Assert.assertEquals("E", vst.tRoleCode2PatientContactRelationshipCode("work").getCode()); - Assert.assertEquals("Next-of-Kin", vst.tRoleCode2PatientContactRelationshipCode("fammemb").getDisplay()); - Assert.assertEquals("N", vst.tRoleCode2PatientContactRelationshipCode("fammemb").getCode()); - } - - @Test - public void patientLanguageCommunicationTest() { - String languageCode = "fr-BE"; - String system = "http://hl7.org/fhir/ValueSet/languages"; - String display = "French (Belgium)"; - LanguageCommunication cdaLanguageCommunication = cdaFactory.createLanguageCommunication(); - CS frenchBelgian = dataTypesFactory.createCS(); - frenchBelgian.setDisplayName(display); - frenchBelgian.setCode(languageCode); - cdaLanguageCommunication.setLanguageCode(frenchBelgian); - ResourceTransformerImpl impl = new ResourceTransformerImpl(); - PatientCommunicationComponent comm = impl.tLanguageCommunication2Communication(cdaLanguageCommunication); - Assert.assertEquals(comm.getLanguage().getCodingFirstRep().getCode(), languageCode); - Assert.assertEquals(comm.getLanguage().getCodingFirstRep().getSystem(), system); - Assert.assertEquals(comm.getLanguage().getCodingFirstRep().getDisplay(), display); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/ProblemConcernActTest.java b/src/test/java/tr/com/srdc/cda2fhir/ProblemConcernActTest.java deleted file mode 100644 index e9f90acc8..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ProblemConcernActTest.java +++ /dev/null @@ -1,242 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.List; -import java.util.Map; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.DiagnosticChain; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus; -import org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.consol.ProblemConcernAct; -import org.openhealthtools.mdht.uml.cda.consol.impl.ConsolFactoryImpl; -import org.openhealthtools.mdht.uml.cda.consol.impl.ProblemConcernActImpl; -import org.openhealthtools.mdht.uml.cda.consol.impl.ProblemObservationImpl; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.datatypes.impl.CDImpl; -import org.openhealthtools.mdht.uml.hl7.datatypes.impl.DatatypesFactoryImpl; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; - -import com.bazaarvoice.jolt.JsonUtils; -import com.helger.commons.collection.attr.StringMap; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class ProblemConcernActTest { - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - - private static ConsolFactoryImpl cdaObjFactory; - private static DatatypesFactory cdaTypeFactory; - - private static Map verificationStatusMap = JsonUtils - .filepathToMap("src/test/resources//value-maps/ConditionVerificationStatus.json"); - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - - cdaObjFactory = (ConsolFactoryImpl) ConsolFactoryImpl.init(); - cdaTypeFactory = DatatypesFactoryImpl.init(); - } - - private static ProblemConcernActImpl createProblemConcernAct() { - ProblemConcernActImpl act = (ProblemConcernActImpl) cdaObjFactory.createProblemConcernAct(); - ProblemObservationImpl observation = (ProblemObservationImpl) cdaObjFactory.createProblemObservation(); - act.addObservation(observation); - act.getEntryRelationships().stream().filter(r -> (r.getObservation() == observation)) - .forEach(r -> r.setTypeCode(x_ActRelationshipEntryRelationship.SUBJ)); - return act; - } - - static private void verifyCoding(Coding coding, String code, String displayName, String system) { - Assert.assertEquals("Unexpected Coding code", code, coding.getCode()); - Assert.assertEquals("Unexpected Coding display name", displayName, coding.getDisplay()); - Assert.assertEquals("Unexpected Coding system", system, coding.getSystem()); - } - - @Test - public void testProblemObservationCode() throws Exception { - ProblemConcernActImpl act = createProblemConcernAct(); - ProblemObservationImpl observation = (ProblemObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - DiagnosticChain dxChain = new BasicDiagnostic(); - BundleInfo bundleInfo = new BundleInfo(rt); - - String code = "404684003"; // From CCDA Specification - String displayName = "Finding"; - CDImpl cd = (CDImpl) cdaTypeFactory.createCD(code, "2.16.840.1.113883.6.96", "SNOMED CT", displayName); - observation.setCode(cd); - - Boolean validation = act.validateProblemConcernActProblemObservation(dxChain, null); - Assert.assertTrue("Invalid Problem Concern Act in Test", validation); - - Bundle bundle = rt.tProblemConcernAct2Condition(act, bundleInfo).getBundle(); - Condition condition = BundleUtil.findOneResource(bundle, Condition.class); - List category = condition.getCategory().get(0).getCoding(); - Assert.assertEquals("Unexpected number of category codings", 1, category.size()); - verifyCoding(category.get(0), "problem-list-item", "Problem List Item", - "http://hl7.org/fhir/condition-category"); - - String translationCode = "75321-0"; // From CCDA Specification - String translationDisplayName = "Clinical finding HL7.CCDAR2"; - CD translationCd = cdaTypeFactory.createCD(translationCode, "2.16.840.1.113883.6.1", "LOINC", - translationDisplayName); - cd.getTranslations().add(translationCd); - - Boolean validation2 = act.validateProblemConcernActProblemObservation(dxChain, null); - Assert.assertTrue("Invalid Problem Concern Act in Test", validation2); - - Bundle bundle2 = rt.tProblemConcernAct2Condition(act, bundleInfo).getBundle(); - Condition condition2 = BundleUtil.findOneResource(bundle2, Condition.class); - List category2 = condition2.getCategory().get(0).getCoding(); - Assert.assertEquals("Unexpected number of category codings", 1, category2.size()); - verifyCoding(category2.get(0), "problem-list-item", "Problem List Item", - "http://hl7.org/fhir/condition-category"); - - } - - @Test - public void testProblemObservationProblemStatusInactive() throws Exception { - ProblemConcernActImpl act = createProblemConcernAct(); - ProblemObservationImpl observation = (ProblemObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - - String low = "2018-01-01"; - String high = "2019-01-01"; - - IVL_TS interval = cdaTypeFactory.createIVL_TS(low, high); - - observation.setEffectiveTime(interval); - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tProblemConcernAct2Condition(act, bundleInfo).getBundle(); - Condition condition = BundleUtil.findOneResource(bundle, Condition.class); - ConditionClinicalStatus clinicalStatus = condition.getClinicalStatus(); - String actual = clinicalStatus.toCode(); - Assert.assertEquals("Inactive Problem with high value", "inactive", actual); - - } - - @Test - public void testProblemObservationProblemStatusActive() throws Exception { - ProblemConcernActImpl act = createProblemConcernAct(); - ProblemObservationImpl observation = (ProblemObservationImpl) act.getEntryRelationships().get(0) - .getObservation(); - - String low = "2018-01-01"; - - IVL_TS interval = cdaTypeFactory.createIVL_TS(low); - - observation.setEffectiveTime(interval); - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tProblemConcernAct2Condition(act, bundleInfo).getBundle(); - Condition condition = BundleUtil.findOneResource(bundle, Condition.class); - ConditionClinicalStatus clinicalStatus = condition.getClinicalStatus(); - String actual = clinicalStatus.toCode(); - Assert.assertEquals("Active Problem without high value", "active", actual); - - } - - @Test - public void testProblemObservationProblemStatusActiveNoDate() throws Exception { - ProblemConcernActImpl act = createProblemConcernAct(); - - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tProblemConcernAct2Condition(act, bundleInfo).getBundle(); - Condition condition = BundleUtil.findOneResource(bundle, Condition.class); - ConditionClinicalStatus clinicalStatus = condition.getClinicalStatus(); - String actual = clinicalStatus.toCode(); - Assert.assertEquals("Active Problem without no value defaults to active", "active", actual); - - } - - static private void verifyConditionVerificationStatus(ProblemConcernAct act, String expected) throws Exception { - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle bundle = rt.tProblemConcernAct2Condition(act, bundleInfo).getBundle(); - Condition condition = BundleUtil.findOneResource(bundle, Condition.class); - - ConditionVerificationStatus verificationStatus = condition.getVerificationStatus(); - String actual = verificationStatus == null ? null : verificationStatus.toCode(); - Assert.assertEquals(expected, actual); - } - - @Test - public void testStatusCode() throws Exception { - ProblemConcernActImpl act = (ProblemConcernActImpl) cdaObjFactory.createProblemConcernAct(); - ProblemObservationImpl observation = (ProblemObservationImpl) cdaObjFactory.createProblemObservation(); - act.addObservation(observation); - - DiagnosticChain dxChain = new BasicDiagnostic(); - verifyConditionVerificationStatus(act, "unknown"); - - act.setStatusCode(null); - verifyConditionVerificationStatus(act, "unknown"); - - act.setStatusCode(cdaTypeFactory.createCS("invalid")); - Boolean invalidation = act.validateProblemConcernActStatusCode(null, null); - Assert.assertFalse("Unexpected Valid Problem Concern Act in Test", invalidation); - - CS csNullFlavor = cdaTypeFactory.createCS(); - csNullFlavor.setNullFlavor(NullFlavor.UNK); - act.setStatusCode(csNullFlavor); - Boolean validationNF = act.validateProblemConcernActStatusCode(dxChain, null); - Assert.assertTrue("Invalid Problem Concern Act in Test", validationNF); - verifyConditionVerificationStatus(act, "unknown"); - - for (Map.Entry entry : verificationStatusMap.entrySet()) { - String cdaStatusCode = entry.getKey(); - String fhirStatus = (String) entry.getValue(); - - CS cs = cdaTypeFactory.createCS(cdaStatusCode); - act.setStatusCode(cs); - Boolean validation = act.validateProblemConcernActStatusCode(dxChain, null); - Assert.assertTrue("Invalid Problem Concern Act in Test", validation); - - verifyConditionVerificationStatus(act, fhirStatus); - } - } - - @Test - public void testCodeOriginalText() throws Exception { - - ProblemConcernActImpl act = (ProblemConcernActImpl) cdaObjFactory.createProblemConcernAct(); - ProblemObservationImpl observation = (ProblemObservationImpl) cdaObjFactory.createProblemObservation(); - - BundleInfo bundleInfo = new BundleInfo(rt); - String expectedValue = "freetext entry"; - String referenceValue = "fakeid1"; - CD cd = cdaTypeFactory.createCD(); - ED ed = cdaTypeFactory.createED(); - TEL tel = cdaTypeFactory.createTEL(); - tel.setValue("#" + referenceValue); - ed.setReference(tel); - cd.setCode("code"); - cd.setCodeSystem("codeSystem"); - cd.setOriginalText(ed); - Map idedAnnotations = new StringMap(); - idedAnnotations.put(referenceValue, expectedValue); - bundleInfo.mergeIdedAnnotations(idedAnnotations); - - observation.getValues().add(cd); - act.addObservation(observation); - Bundle bundle = rt.tProblemConcernAct2Condition(act, bundleInfo).getBundle(); - Condition condition = BundleUtil.findOneResource(bundle, Condition.class); - CodeableConcept cc = condition.getCode(); - Assert.assertEquals("Condition Code text value assigned", expectedValue, cc.getText()); - - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/ProcedureActivityProcedureTest.java b/src/test/java/tr/com/srdc/cda2fhir/ProcedureActivityProcedureTest.java deleted file mode 100644 index 3e1c10e97..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ProcedureActivityProcedureTest.java +++ /dev/null @@ -1,125 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.Map; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.DiagnosticChain; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Procedure; -import org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.consol.ProcedureActivityProcedure; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -import com.bazaarvoice.jolt.JsonUtils; -import com.helger.commons.collection.attr.StringMap; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.generator.ProcedureActivityProcedureGenerator; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntryResult; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class ProcedureActivityProcedureTest { - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - - private static CDAFactories factories; - - private static Map statusMap = JsonUtils - .filepathToMap("src/test/resources//value-maps/ProcedureStatus.json"); - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - factories = CDAFactories.init(); - } - - @Test - public void testDefault() throws Exception { - ProcedureActivityProcedureGenerator generator = ProcedureActivityProcedureGenerator.getDefaultInstance(); - - ProcedureActivityProcedure pap = generator.generate(factories); - - DiagnosticChain dxChain = new BasicDiagnostic(); - pap.validateProcedureActivityProcedureIndication(dxChain, null); - - BundleInfo bundleInfo = new BundleInfo(rt); - EntryResult entryResult = rt.tProcedure2Procedure(pap, bundleInfo); - Bundle bundle = entryResult.getBundle(); - - generator.verify(bundle); - } - - static private void verifyProcedureStatus(ProcedureActivityProcedure pap, String expected) throws Exception { - BundleInfo bundleInfo = new BundleInfo(rt); - EntryResult entryResult = rt.tProcedure2Procedure(pap, bundleInfo); - Bundle bundle = entryResult.getBundle(); - Procedure procedure = BundleUtil.findOneResource(bundle, Procedure.class); - - ProcedureStatus status = procedure.getStatus(); - String actual = status == null ? null : status.toCode(); - Assert.assertEquals("Expect correct procedure status", expected, actual); - } - - @Test - public void testStatusCode() throws Exception { - ProcedureActivityProcedure pap = factories.consol.createProcedureActivityProcedure(); - verifyProcedureStatus(pap, null); - - DiagnosticChain dxChain = new BasicDiagnostic(); - - pap.setStatusCode(factories.datatype.createCS("invalid")); - Assert.assertFalse("Expect Procedure Activity Procedure validation failure", - pap.validateProcedureActivityProcedureStatusCode(dxChain, null)); - verifyProcedureStatus(pap, "unknown"); - - for (Map.Entry entry : statusMap.entrySet()) { - String cdaStatusCode = entry.getKey(); - String fhirStatus = (String) entry.getValue(); - - CS cs = factories.datatype.createCS(cdaStatusCode); - pap.setStatusCode(cs); - Assert.assertTrue("Expect Procedure Activity Procedure validation", - pap.validateProcedureActivityProcedureStatusCode(dxChain, null)); - - verifyProcedureStatus(pap, fhirStatus); - } - } - - @Test - public void testProcedureOriginalText() throws Exception { - - ProcedureActivityProcedure pap = factories.consol.createProcedureActivityProcedure(); - - BundleInfo bundleInfo = new BundleInfo(rt); - String expectedValue = "freetext entry"; - String referenceValue = "fakeid1"; - CD cd = factories.datatype.createCD(); - ED ed = factories.datatype.createED(); - TEL tel = factories.datatype.createTEL(); - tel.setValue("#" + referenceValue); - ed.setReference(tel); - cd.setCode("code"); - cd.setCodeSystem("codeSystem"); - cd.setOriginalText(ed); - Map idedAnnotations = new StringMap(); - idedAnnotations.put(referenceValue, expectedValue); - bundleInfo.mergeIdedAnnotations(idedAnnotations); - - pap.setCode(cd); - Bundle bundle = rt.tProcedure2Procedure(pap, bundleInfo).getBundle(); - - Procedure proc = BundleUtil.findOneResource(bundle, Procedure.class); - CodeableConcept cc = proc.getCode(); - Assert.assertEquals("Procedure Code text value assigned", expectedValue, cc.getText()); - - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/ProceduresSectionSnippetTest.java b/src/test/java/tr/com/srdc/cda2fhir/ProceduresSectionSnippetTest.java deleted file mode 100644 index e26663dd8..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ProceduresSectionSnippetTest.java +++ /dev/null @@ -1,138 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Encounter; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Location; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.Procedure; -import org.hl7.fhir.dstu3.model.Reference; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; - -public class ProceduresSectionSnippetTest { - @BeforeClass - public static void init() { - // Load MDHT CDA packages to be able to use CCDA parsing. - CDAUtil.loadPackages(); - } - - private static Procedure findProcedureById(List procedures, String id) { - for (Procedure procedure : procedures) { - for (Identifier identifier : procedure.getIdentifier()) { - if (id.equals(identifier.getValue())) { - return procedure; - } - } - } - return null; - } - - private static void verifyProcedure(Procedure procedure, String expectedCode, String expectedAnnotation) { - Assert.assertNotNull("Expect procedure has been found by id", procedure); - - CodeableConcept code = procedure.getCode(); - - Assert.assertFalse("Expect no coding for procedure code", code.hasCoding()); - Assert.assertEquals("Expect the code text in the snippet for procedure code", expectedCode, code.getText()); - - Assert.assertTrue("Expect procedure note", procedure.hasNote()); - String actualAnnotation = procedure.getNote().get(0).getText(); - Assert.assertEquals("Expect the annotation in the snippet for procedure note", expectedAnnotation, - actualAnnotation); - } - - private static void replaceIdWithIdentifier(List procedures) { - for (Procedure procedure : procedures) { - List identifiers = procedure.getIdentifier(); - if (identifiers != null && !identifiers.isEmpty()) { - String newId = identifiers.get(0).getValue(); - procedure.setId(newId); - } - } - } - - @Test - public void testTextWithReferenceDefinitions() throws Exception { - Bundle bundle = BundleUtil.generateSnippetBundle("snippets/procedure_text.xml"); - List procedures = BundleUtil.findResources(bundle, Procedure.class, 3); - - // Looks like EMF queries messes up procedure order in the ccda so use ids - // instead - Procedure procedure0 = findProcedureById(procedures, "77baeec3-124e-4348-bcec-fbe2fd25e7ef"); - verifyProcedure(procedure0, "APPENDECTOMY LAPAROSCOPIC", "auto-populated from documented surgical case"); - Procedure procedure1 = findProcedureById(procedures, "4372357a-30bb-48d9-a612-8f459ae8c00c"); - verifyProcedure(procedure1, "REMOVAL IMPLANTED DEVICES FROM BONE", - "auto-populated from documented surgical case"); - Procedure procedure2 = findProcedureById(procedures, "e39bdae7-7b35-4ceb-88b7-8891414c3bc2"); - verifyProcedure(procedure2, "REPAIR ELBOW", "auto-populated from documented surgical case"); - - replaceIdWithIdentifier(procedures); // JSONAssert needs a unique key, id changes based on order - } - - private static Encounter findEncounterByReference(List encounters, Reference reference) { - for (Encounter encounter : encounters) { - String encounterId = encounter.getId(); - String referenceId = reference.getReference(); - if (encounterId.equals(referenceId)) { - return encounter; - } - } - return null; - } - - private static void verifyProcedureContext(Procedure procedure, List encounters, String expectedId) { - Reference reference = procedure.getContext(); - Encounter encounter = findEncounterByReference(encounters, reference); - Assert.assertNotNull("Expect procedure encounter", encounter); - Assert.assertEquals("Expect the right id for procedure encounter", expectedId, - encounter.getIdentifier().get(0).getValue()); - } - - @Test - public void testEncounterReferences() throws Exception { - Bundle bundle = BundleUtil.generateSnippetBundle("snippets/procedure_encounter.xml"); - List procedures = BundleUtil.findResources(bundle, Procedure.class, 3); - List encounters = BundleUtil.findResources(bundle, Encounter.class, 2); - - Procedure procedure0 = findProcedureById(procedures, "77baeec3-124e-4348-bcec-fbe2fd25e7ef"); - verifyProcedureContext(procedure0, encounters, "1234567"); - Procedure procedure1 = findProcedureById(procedures, "4372357a-30bb-48d9-a612-8f459ae8c00c"); - verifyProcedureContext(procedure1, encounters, "1234567"); - Procedure procedure2 = findProcedureById(procedures, "e39bdae7-7b35-4ceb-88b7-8891414c3bc2"); - verifyProcedureContext(procedure2, encounters, "987654"); - } - - @Ignore - @Test - public void testCerner() throws Exception { - String file1 = "Cerner/Person-RAKIA_TEST_DOC00001 (1).XML"; - Bundle bundle1 = BundleUtil.generateSnippetBundle(file1); - BundleUtil.printBundleResources(bundle1, file1, Procedure.class); - String file2 = "Cerner/Encounter-RAKIA_TEST_DOC00001.XML"; - Bundle bundle2 = BundleUtil.generateSnippetBundle(file2); - BundleUtil.printBundleResources(bundle2, file2, Procedure.class); - BundleUtil.printBundleResources(bundle2, file2, Encounter.class); - BundleUtil.printBundleResources(bundle2, file2, Practitioner.class); - BundleUtil.printBundleResources(bundle2, file2, Location.class); - } - - @Ignore - @Test - public void testEpic() throws Exception { - String file1 = "Epic/HannahBanana_EpicCCD.xml"; - Bundle bundle1 = BundleUtil.generateSnippetBundle(file1); - BundleUtil.printBundleResources(bundle1, file1, Procedure.class); - // String file2 = "Epic/rakia_testone_ccd_EPIC (1).xml"; - // Bundle bundle2 = BundleUtil.generateSnippetBundle(file2); - // BundleUtil.printBundleResources(bundle2, file2, Procedure.class); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/ProvenanceTest.java b/src/test/java/tr/com/srdc/cda2fhir/ProvenanceTest.java deleted file mode 100644 index bd76eb631..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ProvenanceTest.java +++ /dev/null @@ -1,104 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.security.MessageDigest; - -import org.eclipse.emf.ecore.xml.type.internal.DataValue.Base64; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Device; -import org.hl7.fhir.dstu3.model.DocumentReference; -import org.hl7.fhir.dstu3.model.IdType; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Patient; -import org.hl7.fhir.dstu3.model.Provenance; -import org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole; -import org.hl7.fhir.dstu3.model.codesystems.ProvenanceAgentRole; -import org.hl7.fhir.dstu3.model.codesystems.ProvenanceAgentType; -import org.junit.Assert; -import org.junit.Test; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; - -public class ProvenanceTest { - - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - - @Test - public void testProvenance() throws Exception { - Bundle testBundle = new Bundle(); - IdType orgId = (new IdType("Organization/1")); - IdType medId = (new IdType("Medication/1")); - IdType patientId = (new IdType("Patient/1")); - - testBundle.addEntry(new BundleEntryComponent().setResource(new Organization().setIdElement(orgId))); - testBundle.addEntry(new BundleEntryComponent().setResource(new Medication().setIdElement(medId))); - testBundle.addEntry(new BundleEntryComponent().setResource(new Patient().setIdElement(patientId))); - - Identifier assemblerDevice = new Identifier(); - assemblerDevice.setValue("Higgs"); - assemblerDevice.setSystem("http://www.amida.com"); - - String documentBody = "Meowmeowmeowmeow"; - testBundle = rt.tProvenance(testBundle, documentBody, assemblerDevice); - - // Verifies bundle contains the initial resources. - BundleUtil.findOneResource(testBundle, Organization.class); - BundleUtil.findOneResource(testBundle, Medication.class); - BundleUtil.findOneResource(testBundle, Patient.class); - - DocumentReference docRef = BundleUtil.findOneResource(testBundle, DocumentReference.class); - - // Test doc reference. - Assert.assertEquals(docRef.getStatus().toString(), "CURRENT"); - Assert.assertEquals(docRef.getContent().get(0).getAttachment().getContentType(), "text/plain"); - Assert.assertEquals(docRef.getType().getCoding().get(0).getCode(), "34133-9"); - - // Test encoding. - Assert.assertEquals(docRef.getContent().get(0).getAttachment().getDataElement().asStringValue(), - Base64.encode(documentBody.getBytes())); - - // Test hash. - MessageDigest digest = MessageDigest.getInstance("SHA-1"); - byte[] encodedHash = digest.digest(documentBody.getBytes()); - Assert.assertEquals(docRef.getContent().get(0).getAttachment().getHashElement().asStringValue(), - Base64.encode(encodedHash)); - - Device device = BundleUtil.findOneResource(testBundle, Device.class); - Assert.assertEquals(device.getText().getStatusAsString().toLowerCase(), - NarrativeStatus.GENERATED.toString().toLowerCase()); - Assert.assertEquals(device.getIdentifierFirstRep().getSystem().toLowerCase(), - assemblerDevice.getSystem().toLowerCase()); - Assert.assertEquals(device.getIdentifierFirstRep().getValue().toLowerCase(), - assemblerDevice.getValue().toLowerCase()); - - Provenance provenance = BundleUtil.findOneResource(testBundle, Provenance.class); - Assert.assertEquals(provenance.getTarget().get(0).getReference(), orgId.getValue()); - Assert.assertEquals(provenance.getTarget().get(1).getReference(), medId.getValue()); - Assert.assertEquals(provenance.getTarget().get(2).getReference(), patientId.getValue()); - Assert.assertEquals(provenance.getTarget().get(3).getReference().substring(0, 17), "DocumentReference"); - Assert.assertEquals(provenance.getTarget().get(4).getReference().substring(0, 6), "Device"); - - Coding roleDevice = provenance.getAgentFirstRep().getRelatedAgentType().getCodingFirstRep(); - Assert.assertEquals(roleDevice.getId().substring(0, 6), "Device"); - Assert.assertEquals(roleDevice.getSystem(), ProvenanceAgentType.DEVICE.getSystem()); - Assert.assertEquals(roleDevice.getCode(), ProvenanceAgentType.DEVICE.toCode()); - Assert.assertEquals(roleDevice.getDisplay(), ProvenanceAgentType.DEVICE.getDisplay()); - - Coding roleAssembler = provenance.getAgentFirstRep().getRoleFirstRep().getCodingFirstRep(); - Assert.assertEquals(roleAssembler.getId().substring(0, 6), "Device"); - Assert.assertEquals(roleAssembler.getSystem(), ProvenanceAgentRole.ASSEMBLER.getSystem()); - Assert.assertEquals(roleAssembler.getCode(), ProvenanceAgentRole.ASSEMBLER.toCode()); - Assert.assertEquals(roleAssembler.getDisplay(), ProvenanceAgentRole.ASSEMBLER.getDisplay()); - - Assert.assertEquals(provenance.getAgentFirstRep().getWhoReference().getReference().substring(0, 6), "Device"); - - Assert.assertEquals(provenance.getEntityFirstRep().getWhatReference().getReference().substring(0, 17), - "DocumentReference"); - Assert.assertEquals(provenance.getEntityFirstRep().getRole(), ProvenanceEntityRole.SOURCE); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/ResourceTransformerTest.java b/src/test/java/tr/com/srdc/cda2fhir/ResourceTransformerTest.java deleted file mode 100644 index 275554a98..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ResourceTransformerTest.java +++ /dev/null @@ -1,1138 +0,0 @@ -package tr.com.srdc.cda2fhir; - -/* - * #%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.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Composition.SectionComponent; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Extension; -import org.hl7.fhir.dstu3.model.FamilyMemberHistory; -import org.hl7.fhir.dstu3.model.HumanName; -import org.hl7.fhir.dstu3.model.IdType; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Patient; -import org.hl7.fhir.dstu3.model.Patient.ContactComponent; -import org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.hl7.fhir.dstu3.model.Procedure; -import org.hl7.fhir.dstu3.model.Reference; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.Organizer; -import org.openhealthtools.mdht.uml.cda.PatientRole; -import org.openhealthtools.mdht.uml.cda.consol.AllergyProblemAct; -import org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument; -import org.openhealthtools.mdht.uml.cda.consol.FunctionalStatusResultOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.FunctionalStatusSection; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationActivity; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationsSectionEntriesOptional; -import org.openhealthtools.mdht.uml.cda.consol.MedicationActivity; -import org.openhealthtools.mdht.uml.cda.consol.ProblemConcernAct; -import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.ResultsSection; -import org.openhealthtools.mdht.uml.cda.consol.SocialHistorySection; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignObservation; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSectionEntriesOptional; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -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 ca.uhn.fhir.model.api.IResource; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.ValueSetsTransformerImpl; -import tr.com.srdc.cda2fhir.transform.entry.IEntryResult; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntryResult; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class ResourceTransformerTest { - - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - private static final ValueSetsTransformerImpl vsti = new ValueSetsTransformerImpl(); - private static FileInputStream fisCCD; - private static FileInputStream fisCCD2; - private static FileWriter resultFW; - private static ContinuityOfCareDocument ccd; - private static ContinuityOfCareDocument ccd2; - private static final String resultFilePath = "src/test/resources/output/ResourceTransformerTest.txt"; - private static final String transformationStartMsg = "\n# TRANSFORMATION STARTING..\n"; - private static final String transformationEndMsg = "# END OF TRANSFORMATION.\n"; - private static final String endOfTestMsg = "\n## END OF TEST\n"; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - - // read the input test file - try { - fisCCD = new FileInputStream("src/test/resources/C-CDA_R2-1_CCD.xml"); - fisCCD2 = new FileInputStream("src/test/resources/C-CDA_R2-1_CCD2.xml"); // Original does not have authoring - // device. - ccd = (ContinuityOfCareDocument) CDAUtil.load(fisCCD); - ccd2 = (ContinuityOfCareDocument) CDAUtil.load(fisCCD2); - } catch (Exception ex) { - ex.printStackTrace(); - } - - // init the output file writer - File resultFile = new File(resultFilePath); - resultFile.getParentFile().mkdirs(); - try { - resultFW = new FileWriter(resultFile); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @AfterClass - public static void finalise() { - try { - resultFW.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Test - public void referenceOrgNameStringTest() { - String name = "Organization Name"; - Organization org = new Organization(); - org.setName(name); - Reference ref = rt.getReference(org); - Assert.assertEquals("Organization name becomes reference display", ref.getDisplay(), name); - } - - @Test - public void referenceHumanNameTest() { - String firstName = "Homer"; - String lastName = "Simpson"; - HumanName name = new HumanName(); - name.setFamily(lastName); - name.addGiven(firstName); - Patient patient = new Patient(); - patient.addName(name); - - Reference ref = rt.getReference(patient); - Assert.assertEquals("Organization name becomes reference display", ref.getDisplay(), - name.getNameAsSingleString()); - } - - @Test - public void referenceImmunizationTest() { - CodeableConcept cc = new CodeableConcept(); - String expectedDisplay = "expected display"; - cc.setText(expectedDisplay); - - Immunization immunization = new Immunization(); - - immunization.setVaccineCode(cc); - - Reference ref = rt.getReference(immunization); - Assert.assertEquals("Organization name becomes reference display", ref.getDisplay(), expectedDisplay); - } - - @Test - public void referenceDisplayFirstRepTest() { - Reference ref; - CodeableConcept cc = new CodeableConcept(); - String expectedDisplay = "expected display"; - Coding coding = new Coding(); - coding.setDisplay(expectedDisplay); - cc.addCoding(coding); - - PractitionerRole pracRole = new PractitionerRole(); - Procedure procedure = new Procedure(); - pracRole.addCode(cc); - procedure.setCode(cc); - - ref = rt.getReference(pracRole); - Assert.assertEquals("Organization name becomes reference display", ref.getDisplay(), expectedDisplay); - - ref = rt.getReference(procedure); - Assert.assertEquals("Organization name becomes reference display", ref.getDisplay(), expectedDisplay); - } - - @Test - public void referenceCodeTest() { - Reference ref; - String expectedTestID = "testID/0"; - String expectedDisplay = "expected display"; - - CodeableConcept cc = new CodeableConcept(); - cc.setText(expectedDisplay); - - Medication med = new Medication(); - - IdType id = new IdType("testID", "0"); - med.setId(id); - med.setCode(cc); - - ref = rt.getReference(med); - - Assert.assertTrue(ref.getReference().contentEquals(expectedTestID)); - - MedicationStatement medStatement = new MedicationStatement(); - - medStatement.setId(id); - - ref = rt.getReference(medStatement); - - Assert.assertTrue(ref.getReference().contentEquals(expectedTestID)); - - Condition condition = new Condition(); - - condition.setId(id); - condition.setCode(cc); - - ref = rt.getReference(condition); - - Assert.assertTrue(ref.getReference().contentEquals(expectedTestID)); - - } - - // Most of the test methods just print the transformed object in JSON form. - - @Test - public void testAllergyProblemAct2AllergyIntolerance() { - appendToResultFile("## TEST: AllergyProblemAct2AllergyIntolerance\n"); - // null instance test - AllergyProblemAct cdaNull = null; - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle fhirNull = rt.tAllergyProblemAct2AllergyIntolerance(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - for (AllergyProblemAct cdaAPA : ResourceTransformerTest.ccd.getAllergiesSection().getAllergyProblemActs()) { - appendToResultFile(transformationStartMsg); - Bundle allergyBundle = rt.tAllergyProblemAct2AllergyIntolerance(cdaAPA, bundleInfo).getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(allergyBundle); - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testAssignedAuthor2Device() { - appendToResultFile("## TEST: AssignedAuthor2Device\n"); - // null instance test - BundleInfo bundleInfo = new BundleInfo(rt); - org.openhealthtools.mdht.uml.cda.AssignedAuthor cdaNull = null; - Bundle fhirNull = rt.tAssignedAuthor2Device(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - if (ResourceTransformerTest.ccd2.getAuthors() != null) { - for (org.openhealthtools.mdht.uml.cda.Author author : ResourceTransformerTest.ccd2.getAuthors()) { - // traversing authors - if (author != null && author.getAssignedAuthor() != null) { - appendToResultFile(transformationStartMsg); - Bundle deviceBundle = rt.tAssignedAuthor2Device(author.getAssignedAuthor(), bundleInfo).getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(deviceBundle); - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testAssignedAuthor2Practitioner() { - appendToResultFile("## TEST: AssignedAuthor2Practitioner\n"); - // null instance test - BundleInfo bundleInfo = new BundleInfo(rt); - org.openhealthtools.mdht.uml.cda.AssignedAuthor cdaNull = null; - Bundle fhirNull = rt.tAssignedAuthor2Practitioner(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - if (ResourceTransformerTest.ccd.getAuthors() != null) { - for (org.openhealthtools.mdht.uml.cda.Author author : ResourceTransformerTest.ccd.getAuthors()) { - // traversing authors - if (author != null && author.getAssignedAuthor() != null) { - appendToResultFile(transformationStartMsg); - Bundle practitionerBundle = rt.tAssignedAuthor2Practitioner(author.getAssignedAuthor(), bundleInfo) - .getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(practitionerBundle); - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testAssignedEntity2Practitioner() { - appendToResultFile("## TEST: AssignedEntity2Practitioner\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.AssignedEntity cdaNull = null; - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle fhirNull = rt.tAssignedEntity2Practitioner(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - if (ResourceTransformerTest.ccd.getProceduresSection() != null - && !ResourceTransformerTest.ccd.getProceduresSection().isSetNullFlavor()) { - if (ResourceTransformerTest.ccd.getProceduresSection().getProcedures() != null - && !ResourceTransformerTest.ccd.getProceduresSection().getProcedures().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Procedure procedure : ResourceTransformerTest.ccd - .getProceduresSection().getProcedures()) { - // traversing procedures - if (procedure.getPerformers() != null && !procedure.getPerformers().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Performer2 performer : procedure.getPerformers()) { - if (performer.getAssignedEntity() != null - && !performer.getAssignedEntity().isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle fhirPractitionerBundle = rt - .tAssignedEntity2Practitioner(performer.getAssignedEntity(), bundleInfo) - .getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirPractitionerBundle); - } - } - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testClinicalDocument2Composition() { - appendToResultFile("## TEST: ClinicalDocument2Composition\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument cdaNull = null; - Bundle fhirNull = rt.tClinicalDocument2Composition(cdaNull).getBundle(); - Assert.assertNull(fhirNull); - - // instance from file - if (ResourceTransformerTest.ccd != null && !ResourceTransformerTest.ccd.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle fhirComp = rt.tClinicalDocument2Composition(ResourceTransformerTest.ccd).getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirComp); - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testEncounterActivity2Encounter() { - appendToResultFile("## TEST: EncounterActivity2Encounter\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.consol.EncounterActivities cdaNull = null; - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle fhirNull = rt.tEncounterActivity2Encounter(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - if (ResourceTransformerTest.ccd.getEncountersSection() != null - && !ResourceTransformerTest.ccd.getEncountersSection().isSetNullFlavor()) { - if (ResourceTransformerTest.ccd.getEncountersSection().getEncounterActivitiess() != null - && !ResourceTransformerTest.ccd.getEncountersSection().getEncounterActivitiess().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.consol.EncounterActivities encounterActivity : ResourceTransformerTest.ccd - .getEncountersSection().getEncounterActivitiess()) { - if (encounterActivity != null && !encounterActivity.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle fhirEncounterBundle = rt.tEncounterActivity2Encounter(encounterActivity, bundleInfo) - .getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirEncounterBundle); - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testFamilyHistoryOrganizer2FamilyMemberHistory() { - appendToResultFile("## TEST: FamilyHistoryOrganizer2FamilyMemberHistory\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.consol.FamilyHistoryOrganizer cdaNull = null; - FamilyMemberHistory fhirNull = rt.tFamilyHistoryOrganizer2FamilyMemberHistory(cdaNull); - Assert.assertNull(fhirNull); - - // instances from file - if (ResourceTransformerTest.ccd.getFamilyHistorySection() != null - && ResourceTransformerTest.ccd.getFamilyHistorySection().getFamilyHistories() != null) { - for (org.openhealthtools.mdht.uml.cda.consol.FamilyHistoryOrganizer familyHistoryOrganizer : ResourceTransformerTest.ccd - .getFamilyHistorySection().getFamilyHistories()) { - if (familyHistoryOrganizer != null) { - appendToResultFile(transformationStartMsg); - FamilyMemberHistory fmHistory = rt - .tFamilyHistoryOrganizer2FamilyMemberHistory(familyHistoryOrganizer); - appendToResultFile(transformationEndMsg); - appendToResultFile(fmHistory); - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testFunctionalStatus2Observation() { - appendToResultFile("## TEST: FunctionalStatus2Observation\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.Observation cdaNull = null; - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle fhirNull = rt.tFunctionalStatus2Observation(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instance from file - FunctionalStatusSection funcStatSec = ResourceTransformerTest.ccd.getFunctionalStatusSection(); - - if (funcStatSec != null && !funcStatSec.isSetNullFlavor()) { - if (funcStatSec.getOrganizers() != null && !funcStatSec.getOrganizers().isEmpty()) { - for (Organizer funcStatOrg : funcStatSec.getOrganizers()) { - if (funcStatOrg != null && !funcStatOrg.isSetNullFlavor()) { - if (funcStatOrg instanceof FunctionalStatusResultOrganizer) { - if (((FunctionalStatusResultOrganizer) funcStatOrg).getObservations() != null - && !((FunctionalStatusResultOrganizer) funcStatOrg).getObservations().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Observation cdaObs : ((FunctionalStatusResultOrganizer) funcStatOrg) - .getObservations()) { - appendToResultFile(transformationStartMsg); - Bundle fhirObs = rt.tFunctionalStatus2Observation(cdaObs, bundleInfo).getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirObs); - } - } - } - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testGuardian2Contact() { - appendToResultFile("## TEST: Guardian2Contact\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.Guardian cdaNull = null; - ContactComponent fhirNull = rt.tGuardian2Contact(cdaNull); - Assert.assertNull(fhirNull); - - // instances from file - if (ResourceTransformerTest.ccd.getPatientRoles() != null - && !ResourceTransformerTest.ccd.getPatientRoles().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.PatientRole patientRole : ResourceTransformerTest.ccd - .getPatientRoles()) { - if (patientRole != null && !patientRole.isSetNullFlavor() && patientRole.getPatient() != null - && !patientRole.getPatient().isSetNullFlavor()) { - for (org.openhealthtools.mdht.uml.cda.Guardian guardian : patientRole.getPatient().getGuardians()) { - if (guardian != null && !guardian.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - ContactComponent contact = rt.tGuardian2Contact(guardian); - appendToResultFile(transformationEndMsg); - org.hl7.fhir.dstu3.model.Patient patient = new Patient().addContact(contact); - appendToResultFile(patient); - } - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testImmunizationActivity2Immunization() { - appendToResultFile("## TEST: ImmunizationActivity2Immunization\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.consol.ImmunizationActivity cdaNull = null; - BundleInfo bundleInfo = new BundleInfo(rt); - Bundle fhirNull = rt.tImmunizationActivity2Immunization(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - ImmunizationsSectionEntriesOptional immSec = ResourceTransformerTest.ccd - .getImmunizationsSectionEntriesOptional(); - - if (immSec != null && !immSec.isSetNullFlavor()) { - for (ImmunizationActivity immAct : immSec.getImmunizationActivities()) { - if (immAct != null && !immAct.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle fhirImm = rt.tImmunizationActivity2Immunization(immAct, bundleInfo).getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirImm); - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testLanguageCommunication2Communication() { - appendToResultFile("## TEST: LanguageCommunication2Communication\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.LanguageCommunication cdaNull = null; - PatientCommunicationComponent fhirNull = rt.tLanguageCommunication2Communication(cdaNull); - Assert.assertNull(fhirNull); - - // instances from file - for (org.openhealthtools.mdht.uml.cda.Patient patient : ResourceTransformerTest.ccd.getPatients()) { - for (org.openhealthtools.mdht.uml.cda.LanguageCommunication LC : patient.getLanguageCommunications()) { - appendToResultFile(transformationStartMsg); - PatientCommunicationComponent fhirCommunication = rt.tLanguageCommunication2Communication(LC); - appendToResultFile(transformationEndMsg); - org.hl7.fhir.dstu3.model.Patient fhirPatient = new org.hl7.fhir.dstu3.model.Patient(); - fhirPatient.addCommunication(fhirCommunication); - appendToResultFile(fhirPatient); - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testManufacturedProduct2Medication() { - appendToResultFile("## TEST: ManufacturedProduct2Medication\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.ManufacturedProduct cdaNull = null; - BundleInfo bundleInfo = new BundleInfo(rt); - EntryResult nullResult = rt.tManufacturedProduct2Medication(cdaNull, bundleInfo); - Assert.assertFalse(nullResult.hasResult()); - - // instances from file - ImmunizationsSectionEntriesOptional immSection = ResourceTransformerTest.ccd - .getImmunizationsSectionEntriesOptional(); - if (immSection != null && !immSection.isSetNullFlavor()) { - if (immSection.getImmunizationActivities() != null && !immSection.getImmunizationActivities().isEmpty()) { - for (ImmunizationActivity immAct : immSection.getImmunizationActivities()) { - if (immAct != null && !immAct.isSetNullFlavor()) { - if (immAct.getConsumable() != null && !immAct.getConsumable().isSetNullFlavor()) { - if (immAct.getConsumable().getManufacturedProduct() != null - && !immAct.getConsumable().getManufacturedProduct().isSetNullFlavor()) { - // immAct.immSection.immAct.consumable.manuProd - appendToResultFile(transformationStartMsg); - - EntryResult fhirMed = rt.tManufacturedProduct2Medication( - immAct.getConsumable().getManufacturedProduct(), bundleInfo); - - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirMed.getBundle()); - } - } - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testMedicationActivity2MedicationStatement() { - BundleInfo bundleInfo = new BundleInfo(rt); - appendToResultFile("## TEST: MedicationActivity2MedicationStatement\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.consol.MedicationActivity cdaNull = null; - Bundle fhirNull = rt.tMedicationActivity2MedicationStatement(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - if (ResourceTransformerTest.ccd.getMedicationsSection() != null - && !ResourceTransformerTest.ccd.getMedicationsSection().isSetNullFlavor()) { - if (ResourceTransformerTest.ccd.getMedicationsSection().getMedicationActivities() != null - && !ResourceTransformerTest.ccd.getMedicationsSection().getMedicationActivities().isEmpty()) { - for (MedicationActivity cdaMedAct : ResourceTransformerTest.ccd.getMedicationsSection() - .getMedicationActivities()) { - if (cdaMedAct != null && !cdaMedAct.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle fhirMedStBundle = rt.tMedicationActivity2MedicationStatement(cdaMedAct, bundleInfo) - .getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirMedStBundle); - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testMedicationDispense2MedicationDispense() { - BundleInfo bundleInfo = new BundleInfo(rt); - appendToResultFile("## TEST: MedicationDispense2MedicationDispense\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.consol.MedicationDispense cdaNull = null; - Bundle fhirNull = rt.tMedicationDispense2MedicationDispense(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - // medicationsSection.medicationActivities.medicationDispense - if (ResourceTransformerTest.ccd.getMedicationsSection() != null - && !ResourceTransformerTest.ccd.getMedicationsSection().isSetNullFlavor()) { - org.openhealthtools.mdht.uml.cda.consol.MedicationsSection medSec = ResourceTransformerTest.ccd - .getMedicationsSection(); - if (medSec.getMedicationActivities() != null && !medSec.getMedicationActivities().isEmpty()) { - for (MedicationActivity medAct : medSec.getMedicationActivities()) { - if (medAct != null && !medAct.isSetNullFlavor()) { - if (medAct.getMedicationDispenses() != null && !medAct.getMedicationDispenses().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.consol.MedicationDispense medDisp : medAct - .getMedicationDispenses()) { - if (medDisp != null && !medDisp.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle fhirMedDispBundle = rt - .tMedicationDispense2MedicationDispense(medDisp, bundleInfo).getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirMedDispBundle); - } - } - } - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testObservation2Observation() { - appendToResultFile("## TEST: Observation2Observation\n"); - BundleInfo bundleInfo = new BundleInfo(rt); - // null instance test - org.openhealthtools.mdht.uml.cda.Observation cdaNull = null; - Bundle fhirNull = rt.tObservation2Observation(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - if (ResourceTransformerTest.ccd.getSocialHistorySection() != null - && !ResourceTransformerTest.ccd.getSocialHistorySection().isSetNullFlavor()) { - if (ResourceTransformerTest.ccd.getSocialHistorySection().getObservations() != null - && !ResourceTransformerTest.ccd.getSocialHistorySection().getObservations().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Observation cdaObs : ResourceTransformerTest.ccd - .getSocialHistorySection().getObservations()) { - if (cdaObs != null && !cdaObs.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle obsBundle = rt.tObservation2Observation(cdaObs, bundleInfo).getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(obsBundle); - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testOrganization2Organization() { - appendToResultFile("## TEST: Organization2Organization\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.Organization cdaNull = null; - IEntryResult result1 = rt.tOrganization2Organization(cdaNull, new BundleInfo(rt)); - Assert.assertFalse(result1.hasResult()); - - // instances from file - for (org.openhealthtools.mdht.uml.cda.PatientRole patRole : ResourceTransformerTest.ccd.getPatientRoles()) { - org.openhealthtools.mdht.uml.cda.Organization cdaOrg = patRole.getProviderOrganization(); - appendToResultFile(transformationStartMsg); - IEntryResult result2 = rt.tOrganization2Organization(cdaOrg, new BundleInfo(rt)); - org.hl7.fhir.dstu3.model.Organization fhirOrg = FHIRUtil.findFirstResource(result2.getBundle(), - org.hl7.fhir.dstu3.model.Organization.class); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirOrg); - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testPatientRole2Patient() { - appendToResultFile("## TEST: PatientRole2Patient\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.PatientRole cdaNull = null; - IEntryResult patientResult1 = rt.tPatientRole2Patient(cdaNull, new BundleInfo(rt)); - Assert.assertFalse(patientResult1.hasResult()); - - // instances from file - for (PatientRole pr : ResourceTransformerTest.ccd.getPatientRoles()) { - - // here we do the transformation by calling the method rt.PatientRole2Patient - - Patient patient = null; - - appendToResultFile(transformationStartMsg); - IEntryResult patientResult2 = rt.tPatientRole2Patient(pr, new BundleInfo(rt)); - appendToResultFile(transformationEndMsg); - appendToResultFile(patientResult2.getBundle()); - - for (BundleEntryComponent entry : patientResult2.getFullBundle().getEntry()) { - if (entry.getResource() instanceof Patient) { - patient = (Patient) entry.getResource(); - } - } - - // patient.identifier - int idCount = 0; - for (II id : pr.getIds()) { - if (id.getRoot() != null && id.getExtension() != null) { - // since extension may contain "urn:oid:" or "urn:uuid:", assertion is about - // containing the value as a piece - Assert.assertTrue("pr.id.extension #" + idCount + " was not transformed", - patient.getIdentifier().get(idCount).getValue().contains(id.getExtension())); - Assert.assertTrue("pr.id.root #" + idCount + " was not transformed", - patient.getIdentifier().get(idCount).getSystem().contains(id.getRoot())); - } else if (id.getRoot() != null) { - Assert.assertTrue("pr.id.root #" + idCount + " was not transformed", - patient.getIdentifier().get(idCount).getValue().contains(id.getRoot())); - } else if (id.getExtension() != null) { - Assert.assertTrue("pr.id.root #" + idCount + " was not transformed", - patient.getIdentifier().get(idCount).getValue().contains(id.getExtension())); - } - // codeSystem method is changed and tested - - idCount++; - } - // patient.name - // Notice that patient.name is fullfilled by the method EN2HumanName. - int nameCount = 0; - for (EN pn : pr.getPatient().getNames()) { - - // patient.name.use - if (pn.getUses() == null || pn.getUses().isEmpty()) { - Assert.assertNull(patient.getName().get(nameCount).getUse().toCode()); - } else { - Assert.assertEquals("pr.patient.name[" + nameCount + "]" + ".use was not transformed", - vsti.tEntityNameUse2NameUse(pn.getUses().get(0)).toString().toLowerCase(), - patient.getName().get(nameCount).getUse().toCode()); - } - - // patient.name.text - Assert.assertEquals("pr.patient.name[" + nameCount + "].text was not transformed", pn.getText(), - patient.getName().get(nameCount).getText()); - - // patient.name.family - for (ENXP family : pn.getFamilies()) { - if (family == null || family.isSetNullFlavor()) { - // It can return null or an empty list - Assert.assertTrue(patient.getName().get(nameCount).getFamily() == null - || !patient.getName().get(nameCount) - .hasFamily()/* patient.getName().get(nameCount).getFamily().size() == 0 */); - } else { - Assert.assertEquals("pr.patient.name[" + nameCount + "].family was not transformed", - family.getText(), - patient.getName().get(nameCount).getFamily()/* .get(familyCount).getValue() */); - } - } - - // patient.name.given - int givenCount = 0; - for (ENXP given : pn.getGivens()) { - if (given == null || given.isSetNullFlavor()) { - // It can return null or an empty list - Assert.assertTrue(patient.getName().get(nameCount).getGiven() == null - || patient.getName().get(nameCount).getGiven().size() == 0); - } else { - Assert.assertEquals("pr.patient.name[" + nameCount + "].given was not transformed", - given.getText(), - patient.getName().get(nameCount).getGiven().get(givenCount).getValue()); - } - givenCount++; - } - - // patient.name.prefix - int prefixCount = 0; - for (ENXP prefix : pn.getPrefixes()) { - if (prefix == null || prefix.isSetNullFlavor()) { - // It can return null or an empty list - Assert.assertTrue(patient.getName().get(nameCount).getPrefix() == null - || patient.getName().get(nameCount).getPrefix().size() == 0); - } else { - Assert.assertEquals("pr.patient.name[" + nameCount + "].prefix was not transformed", - prefix.getText(), - patient.getName().get(nameCount).getPrefix().get(prefixCount).getValue()); - } - prefixCount++; - } - - // patient.name.suffix - int suffixCount = 0; - for (ENXP suffix : pn.getPrefixes()) { - if (suffix == null || suffix.isSetNullFlavor()) { - // It can return null or an empty list - Assert.assertTrue(patient.getName().get(nameCount).getSuffix() == null - || patient.getName().get(nameCount).getSuffix().size() == 0); - } else { - Assert.assertEquals("pr.patient.name[" + nameCount + "].suffix was not transformed", - suffix.getText(), - patient.getName().get(nameCount).getSuffix().get(suffixCount).getValue()); - } - suffixCount++; - } - - // patient.name.period - if (pn.getValidTime() == null || pn.getValidTime().isSetNullFlavor()) { - // It can return null or an empty list - Assert.assertTrue(patient.getName().get(nameCount).getPeriod() == null - || patient.getName().get(nameCount).getPeriod().isEmpty()); - } - } - - // patient.telecom - // Notice that patient.telecom is fullfilled by the method dtt.TEL2ContactPoint - if (pr.getTelecoms() == null || pr.getTelecoms().isEmpty()) { - Assert.assertTrue(patient.getTelecom() == null || patient.getTelecom().isEmpty()); - } else { - // size check - Assert.assertTrue(pr.getTelecoms().size() == patient.getTelecom().size()); - // We have already tested the method TEL2ContactPoint. Therefore, null-check and - // size-check is enough for now. - } - - // patient.gender - // vst.AdministrativeGenderCode2AdministrativeGenderEnum is used in this - // transformation. - // Following test aims to test that ValueSetTransformer method. - if (pr.getPatient().getAdministrativeGenderCode() == null - || pr.getPatient().getAdministrativeGenderCode().isSetNullFlavor()) { - Assert.assertTrue(patient.getGender() == null || !patient.getGenderElement().hasValue()); - } - - // patient.birthDate - // Notice that patient.birthDate is fullfilled by the method dtt.TS2Date - if (pr.getPatient().getBirthTime() == null || pr.getPatient().getBirthTime().isSetNullFlavor()) { - Assert.assertTrue(patient.getBirthDate() == null); - } - - // patient.address - // Notice that patient.address is fullfilled by the method dtt.AD2Address - if (pr.getAddrs() == null || pr.getAddrs().isEmpty()) { - Assert.assertTrue(patient.getAddress() == null || patient.getAddress().isEmpty()); - } else { - // We have already tested the method AD2Address. Therefore, null-check and - // size-check is enough for now. - Assert.assertTrue(pr.getAddrs().size() == patient.getAddress().size()); - } - - // patient.maritalStatus - // vst.MaritalStatusCode2MaritalStatusCodesEnum is used in this transformation. - // Following test aims to test that ValueSetTransformer method. - if (pr.getPatient().getMaritalStatusCode() == null - || pr.getPatient().getMaritalStatusCode().isSetNullFlavor()) { - Assert.assertTrue(patient.getMaritalStatus() == null || patient.getMaritalStatus().isEmpty()); - } else { - Assert.assertTrue(patient.getMaritalStatus().getCoding().get(0).getCode().toLowerCase().charAt(0) == pr - .getPatient().getMaritalStatusCode().getCode().toLowerCase().charAt(0)); - } - - // patient.languageCommunication - if (pr.getPatient().getLanguageCommunications() == null - || pr.getPatient().getLanguageCommunications().isEmpty()) { - Assert.assertTrue(patient.getCommunication() == null || patient.getCommunication().isEmpty()); - } else { - Assert.assertTrue( - pr.getPatient().getLanguageCommunications().size() == patient.getCommunication().size()); - - int sizeCommunication = pr.getPatient().getLanguageCommunications().size(); - while (sizeCommunication != 0) { - - // language - if (pr.getPatient().getLanguageCommunications().get(sizeCommunication - 1).getLanguageCode() == null - || pr.getPatient().getLanguageCommunications().get(0).getLanguageCode().isSetNullFlavor()) { - Assert.assertTrue(patient.getCommunication().get(sizeCommunication - 1).getLanguage() == null - || patient.getCommunication().get(sizeCommunication - 1).getLanguage().isEmpty()); - } else { - // We have already tested the method CD2CodeableConcept. Therefore, null-check - // is enough for now. - } - - // preference - if (pr.getPatient().getLanguageCommunications().get(sizeCommunication - 1) - .getPreferenceInd() == null - || pr.getPatient().getLanguageCommunications().get(sizeCommunication - 1).getPreferenceInd() - .isSetNullFlavor()) { - // Assert.assertTrue(patient.getCommunication().get(sizeCommunication - - // 1).getPreferred() == null); - Assert.assertTrue(!patient.getCommunication().get(sizeCommunication - 1).hasPreferred()); - } else { - Assert.assertEquals( - pr.getPatient().getLanguageCommunications().get(sizeCommunication - 1) - .getPreferenceInd().getValue(), - patient.getCommunication().get(sizeCommunication - 1).getPreferred()); - } - sizeCommunication--; - } - - } - - // providerOrganization - if (pr.getProviderOrganization() == null || pr.getProviderOrganization().isSetNullFlavor()) { - Assert.assertTrue( - patient.getManagingOrganization() == null || patient.getManagingOrganization().isEmpty()); - } else { - if (pr.getProviderOrganization().getNames() == null) { - Assert.assertTrue(patient.getManagingOrganization().getDisplay() == null); - } - } - - // guardian - if (pr.getPatient().getGuardians() == null || pr.getPatient().getGuardians().isEmpty()) { - Assert.assertTrue(patient.getContact() == null || patient.getContact().isEmpty()); - } else { - // Notice that, inside this mapping, the methods dtt.TEL2ContactPoint and - // dtt.AD2Address are used. - // Therefore, null-check and size-check are enough - Assert.assertTrue(pr.getPatient().getGuardians().size() == patient.getContact().size()); - } - - // extensions - for (Extension extension : patient.getExtension()) { - Assert.assertTrue(extension.getUrl() != null); - Assert.assertTrue(extension.getValue() != null); - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testProblemConcernAct2Condition() { - BundleInfo bundleInfo = new BundleInfo(rt); - appendToResultFile("## TEST: ProblemConcernAct2Condition\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.consol.ProblemConcernAct cdaNull = null; - Bundle fhirNull = rt.tProblemConcernAct2Condition(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - if (ResourceTransformerTest.ccd.getProblemSection() != null - && !ResourceTransformerTest.ccd.getProblemSection().isSetNullFlavor()) { - if (ResourceTransformerTest.ccd.getProblemSection().getProblemConcerns() != null - && !ResourceTransformerTest.ccd.getProblemSection().getProblemConcerns().isEmpty()) { - for (ProblemConcernAct problemConcernAct : ResourceTransformerTest.ccd.getProblemSection() - .getProblemConcerns()) { - if (problemConcernAct != null && !problemConcernAct.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle fhirConditionBundle = rt.tProblemConcernAct2Condition(problemConcernAct, bundleInfo) - .getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirConditionBundle); - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testProcedure2Procedure() { - BundleInfo bundleInfo = new BundleInfo(rt); - appendToResultFile("## TEST: Procedure2Procedure\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.Procedure cdaNull = null; - EntryResult entryResultNull = rt.tProcedure2Procedure(cdaNull, bundleInfo); - Assert.assertNull(entryResultNull.getBundle()); - - // instances from file - if (ResourceTransformerTest.ccd.getProceduresSection() != null - && !ResourceTransformerTest.ccd.getProceduresSection().isSetNullFlavor()) { - if (ResourceTransformerTest.ccd.getProceduresSection().getProcedures() != null - && !ResourceTransformerTest.ccd.getProceduresSection().getProcedures().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Procedure cdaProcedure : ResourceTransformerTest.ccd - .getProceduresSection().getProcedures()) { - // traversing procedures - appendToResultFile(transformationStartMsg); - EntryResult entryResult = rt.tProcedure2Procedure(cdaProcedure, bundleInfo); - Bundle fhirProcedureBundle = entryResult.getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirProcedureBundle); - } - } - } - - if (ResourceTransformerTest.ccd.getEncountersSection() != null - && !ResourceTransformerTest.ccd.getEncountersSection().isSetNullFlavor()) { - if (ResourceTransformerTest.ccd.getEncountersSection().getProcedures() != null - && !ResourceTransformerTest.ccd.getEncountersSection().getProcedures().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Procedure cdaProcedure : ResourceTransformerTest.ccd - .getEncountersSection().getProcedures()) { - // traversing procedures - appendToResultFile(transformationStartMsg); - EntryResult entryResult = rt.tProcedure2Procedure(cdaProcedure, bundleInfo); - Bundle fhirProcedureBundle = entryResult.getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirProcedureBundle); - } - } - } - - if (ResourceTransformerTest.ccd.getAllSections() != null - && !ResourceTransformerTest.ccd.getAllSections().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Section section : ResourceTransformerTest.ccd.getAllSections()) { - if (section.getProcedures() != null && !section.getProcedures().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Procedure cdaProcedure : section.getProcedures()) { - // traversing procedures - appendToResultFile(transformationStartMsg); - EntryResult entryResult = rt.tProcedure2Procedure(cdaProcedure, bundleInfo); - Bundle fhirProcedureBundle = entryResult.getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirProcedureBundle); - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testResultOrganizer2DiagnosticReport() { - BundleInfo bundleInfo = new BundleInfo(rt); - appendToResultFile("## TEST: ResultOrganizer2DiagnosticReport\n"); - // null instance test - ResultOrganizer cdaNull = null; - Bundle fhirNull = rt.tResultOrganizer2DiagnosticReport(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instance from file - ResultsSection resultsSec = ResourceTransformerTest.ccd.getResultsSection(); - - if (resultsSec != null && !resultsSec.isSetNullFlavor()) { - if (resultsSec.getOrganizers() != null && !resultsSec.getOrganizers().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Organizer cdaOrganizer : resultsSec.getOrganizers()) { - if (cdaOrganizer != null && !cdaOrganizer.isSetNullFlavor()) { - if (cdaOrganizer instanceof ResultOrganizer) { - appendToResultFile(transformationStartMsg); - Bundle fhirDiagReport = rt - .tResultOrganizer2DiagnosticReport((ResultOrganizer) cdaOrganizer, bundleInfo) - .getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirDiagReport); - } - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testSection2Section() { - appendToResultFile("## TEST: Section2Section\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.Section cdaNull = null; - SectionComponent fhirNull = rt.tSection2Section(cdaNull); - Assert.assertNull(fhirNull); - - // instances from file - org.openhealthtools.mdht.uml.cda.Section sampleSection = null; - - // assigning sampleSection to one sample section - if (ResourceTransformerTest.ccd.getEncountersSection() != null - && !ResourceTransformerTest.ccd.getEncountersSection().isSetNullFlavor()) { - if (ResourceTransformerTest.ccd.getEncountersSection().getAllSections() != null - && !ResourceTransformerTest.ccd.getEncountersSection().getAllSections().isEmpty()) { - if (ResourceTransformerTest.ccd.getEncountersSection().getAllSections().get(0) != null - && !ResourceTransformerTest.ccd.getEncountersSection().getAllSections().get(0) - .isSetNullFlavor()) { - sampleSection = ResourceTransformerTest.ccd.getEncountersSection().getAllSections().get(0); - } - } - } - if (sampleSection != null) { - org.hl7.fhir.dstu3.model.Composition fhirComposition = new org.hl7.fhir.dstu3.model.Composition(); - appendToResultFile(transformationStartMsg); - SectionComponent fhirSection = rt.tSection2Section(sampleSection); - appendToResultFile(transformationEndMsg); - fhirComposition.addSection(fhirSection); - appendToResultFile(fhirComposition); - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testSocialHistory() { - BundleInfo bundleInfo = new BundleInfo(rt); - appendToResultFile("## TEST: SocialHistory\n"); - SocialHistorySection socialHistSec = ResourceTransformerTest.ccd.getSocialHistorySection(); - - if (socialHistSec != null && !socialHistSec.isSetNullFlavor()) { - if (socialHistSec.getObservations() != null && !socialHistSec.getObservations().isEmpty()) { - for (org.openhealthtools.mdht.uml.cda.Observation cdaObs : socialHistSec.getObservations()) { - if (cdaObs != null && !cdaObs.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle fhirObs = rt.tObservation2Observation(cdaObs, bundleInfo).getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirObs); - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - @Test - public void testVitalSignObservation2Observation() { - BundleInfo bundleInfo = new BundleInfo(rt); - appendToResultFile("## TEST: VitalSignObservation2Observation\n"); - // null instance test - org.openhealthtools.mdht.uml.cda.consol.VitalSignObservation cdaNull = null; - Bundle fhirNull = rt.tVitalSignObservation2Observation(cdaNull, bundleInfo).getBundle(); - Assert.assertNull(fhirNull); - - // instances from file - VitalSignsSectionEntriesOptional vitalSignsSec = ResourceTransformerTest.ccd - .getVitalSignsSectionEntriesOptional(); - if (vitalSignsSec != null && !vitalSignsSec.isSetNullFlavor()) { - if (vitalSignsSec.getVitalSignsOrganizers() != null && !vitalSignsSec.getVitalSignsOrganizers().isEmpty()) { - for (VitalSignsOrganizer vitalSignOrganizer : vitalSignsSec.getVitalSignsOrganizers()) { - if (vitalSignOrganizer != null && !vitalSignOrganizer.isSetNullFlavor()) { - if (vitalSignOrganizer.getVitalSignObservations() != null - && !vitalSignOrganizer.getVitalSignObservations().isEmpty()) { - for (VitalSignObservation vitalSignObservation : vitalSignOrganizer - .getVitalSignObservations()) { - if (vitalSignObservation != null && !vitalSignObservation.isSetNullFlavor()) { - appendToResultFile(transformationStartMsg); - Bundle fhirObservation = rt - .tVitalSignObservation2Observation(vitalSignObservation, bundleInfo) - .getBundle(); - appendToResultFile(transformationEndMsg); - appendToResultFile(fhirObservation); - } - } - } - } - } - } - } - appendToResultFile(endOfTestMsg); - } - - private void appendToResultFile(Object param) { - try { - if (param instanceof String) { - resultFW.append((String) param); - } else if (param instanceof IResource) { - FHIRUtil.printJSON((IResource) param, resultFW); - } - } catch (IOException e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/src/test/java/tr/com/srdc/cda2fhir/ResultsOrganizerTest.java b/src/test/java/tr/com/srdc/cda2fhir/ResultsOrganizerTest.java deleted file mode 100644 index bed484fce..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ResultsOrganizerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -import com.helger.commons.collection.attr.StringMap; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class ResultsOrganizerTest { - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - private static CDAFactories factories; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - - factories = CDAFactories.init(); - } - - @Test - public void testDiagnosticReportOriginalText() throws Exception { - - org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer org = factories.consol.createResultOrganizer(); - - BundleInfo bundleInfo = new BundleInfo(rt); - String expectedValue = "freetext entry"; - String referenceValue = "fakeid1"; - CD cd = factories.datatype.createCD(); - ED ed = factories.datatype.createED(); - TEL tel = factories.datatype.createTEL(); - tel.setValue("#" + referenceValue); - ed.setReference(tel); - cd.setCode("code"); - cd.setCodeSystem("codeSystem"); - cd.setOriginalText(ed); - Map idedAnnotations = new StringMap(); - idedAnnotations.put(referenceValue, expectedValue); - bundleInfo.mergeIdedAnnotations(idedAnnotations); - - org.setCode(cd); - Bundle bundle = rt.tResultOrganizer2DiagnosticReport(org, bundleInfo).getBundle(); - - DiagnosticReport report = BundleUtil.findOneResource(bundle, DiagnosticReport.class); - CodeableConcept cc = report.getCode(); - Assert.assertEquals("Diagnostic Report Code text value assigned", expectedValue, cc.getText()); - - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/ResultsTest.java b/src/test/java/tr/com/srdc/cda2fhir/ResultsTest.java deleted file mode 100644 index 9e0388be5..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ResultsTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import java.util.Date; -import java.util.List; - -import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.consol.ResultObservation; -import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.impl.ConsolFactoryImpl; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.impl.DatatypesFactoryImpl; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; -import tr.com.srdc.cda2fhir.transform.entry.impl.EntryResult; -import tr.com.srdc.cda2fhir.transform.util.impl.BundleInfo; - -public class ResultsTest { - - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - private static ConsolFactoryImpl cdaObjFactory; - private static DatatypesFactory cdaTypeFactory; - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - - cdaObjFactory = (ConsolFactoryImpl) ConsolFactoryImpl.init(); - cdaTypeFactory = DatatypesFactoryImpl.init(); - } - - @Test - public void testResultsIssuedNotPresent() throws Exception { - ResultOrganizer org = cdaObjFactory.createResultOrganizer(); - - String low = "2018-01-01"; - String high = "2019-01-01"; - - IVL_TS interval = cdaTypeFactory.createIVL_TS(low, high); - - org.setEffectiveTime(interval); - - BundleInfo bundleInfo = new BundleInfo(rt); - EntryResult result = rt.tResultOrganizer2DiagnosticReport(org, bundleInfo); - DiagnosticReport report = BundleUtil.findOneResource(result.getBundle(), DiagnosticReport.class); - Date issuedDate = report.getIssued(); - Assert.assertEquals("Report issued date not populated", null, issuedDate); - } - - @Test - public void testNoNewPractitioner() throws Exception { - ResultOrganizer org = cdaObjFactory.createResultOrganizer(); - - BundleInfo bundleInfo = new BundleInfo(rt); - EntryResult result = rt.tResultOrganizer2DiagnosticReport(org, bundleInfo); - List prac = BundleUtil.findResources(result.getBundle(), Practitioner.class, 0); - Assert.assertEquals("Practitioner is not created when not present", 0, prac.size()); - } - - @Test - public void testResultsPopulation() throws Exception { - ResultOrganizer org = cdaObjFactory.createResultOrganizer(); - - ResultObservation result = cdaObjFactory.createResultObservation(); - CD code = cdaTypeFactory.createCD(); - - code.setCode("6690-2"); - result.setCode(code); - org.addObservation(result); - - BundleInfo bundleInfo = new BundleInfo(rt); - EntryResult resultBundle = rt.tResultOrganizer2DiagnosticReport(org, bundleInfo); - DiagnosticReport report = BundleUtil.findOneResource(resultBundle.getBundle(), DiagnosticReport.class); - Assert.assertEquals("Result Observations is getting populated", 1, report.getResult().size()); - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/SectionTest.java b/src/test/java/tr/com/srdc/cda2fhir/SectionTest.java deleted file mode 100644 index cb3717e78..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/SectionTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import org.hl7.fhir.dstu3.model.Composition.SectionComponent; -import org.hl7.fhir.dstu3.model.Composition.SectionMode; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openhealthtools.mdht.uml.cda.Section; -import org.openhealthtools.mdht.uml.cda.StrucDocText; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; - -import tr.com.srdc.cda2fhir.conf.Config; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.transform.ResourceTransformerImpl; - -public class SectionTest { - private static final ResourceTransformerImpl rt = new ResourceTransformerImpl(); - private static CDAFactories factories; - private static String tableText = "\n" + " \n" - + " \n" + " \n" - + " \n" - + " \n" - + " \n" + " \n" - + " \n" + " \n" - + " \n" - + " \n" - + " \n" - + " \n" + " \n" - + " \n" + " \n" - + " \n" + " \n" - + " \n" + " \n" + " \n" + " " - + " " + "
SubstanceReactionSeverityStatus
\n" - + " amoxicillin1\n" - + " \n" + " \n" - + " Mild\n" - + " \n" - + " Active\n" - + "
"; - - @BeforeClass - public static void init() { - // 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(); - factories = CDAFactories.init(); - } - - @Test - public void testGenNarrativeFalse() { - Config.setGenerateNarrative(false); - Section cdaSection = factories.base.createSection(); - StrucDocText strucDocText = factories.base.createStrucDocText(); - - strucDocText.addText(tableText); - cdaSection.setText(strucDocText); - SectionComponent fhirSection = rt.tSection2Section(cdaSection); - - Assert.assertFalse(fhirSection.hasText()); - - } - - @Test - public void testGenNarrativeTrue() { - Config.setGenerateNarrative(true); - Section cdaSection = factories.base.createSection(); - StrucDocText strucDocText = factories.base.createStrucDocText(); - - strucDocText.addText(tableText); - cdaSection.setText(strucDocText); - SectionComponent fhirSection = rt.tSection2Section(cdaSection); - - Assert.assertTrue(fhirSection.hasText()); - } - - @Test - public void testSectionMode() { - Config.setGenerateNarrative(false); - Section cdaSection = factories.base.createSection(); - - SectionComponent fhirSection = rt.tSection2Section(cdaSection); - - Assert.assertEquals("Expect fhir section mode to equal", SectionMode.SNAPSHOT.toCode(), - fhirSection.getMode().toCode()); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/ValidatorTest.java b/src/test/java/tr/com/srdc/cda2fhir/ValidatorTest.java deleted file mode 100644 index c20bf5b80..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ValidatorTest.java +++ /dev/null @@ -1,270 +0,0 @@ -package tr.com.srdc.cda2fhir; - -/* - * #%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.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleType; -import org.hl7.fhir.dstu3.model.Identifier; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -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 tr.com.srdc.cda2fhir.conf.Config; -import tr.com.srdc.cda2fhir.transform.CCDTransformerImpl; -import tr.com.srdc.cda2fhir.transform.ICDATransformer; -import tr.com.srdc.cda2fhir.util.FHIRUtil; -import tr.com.srdc.cda2fhir.util.IdGeneratorEnum; -import tr.com.srdc.cda2fhir.validation.IValidator; -import tr.com.srdc.cda2fhir.validation.ValidatorImpl; - -public class ValidatorTest { - - @BeforeClass - public static void init() { - // 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(); - } - - // 170.315_b1_toc_gold_sample2_v1.xml without profile - @Test - public void testGoldSampleBundleWithoutProfile() throws Exception { - String cdaResourcePath = "src/test/resources/170.315_b1_toc_gold_sample2_v1.xml"; - String targetPathForFHIRResource = "src/test/resources/output/170.315_b1_toc_gold_sample2_v1-wo-profile-validation.xml"; - String targetPathForResultFile = "src/test/resources/output/validation-result-wo-profile-for-170.315_b1_toc_gold_sample2_v1.html"; - boolean generateDAFProfileMetadata = false; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, true); - } - - // 170.315_b1_toc_gold_sample2_v1.xml with profile - @Ignore - public void testGoldSampleBundleWithProfile() throws Exception { - String cdaResourcePath = "src/test/resources/170.315_b1_toc_gold_sample2_v1.xml"; - String targetPathForFHIRResource = "src/test/resources/output/170.315_b1_toc_gold_sample2_v1-w-profile-validation.xml"; - String targetPathForResultFile = "src/test/resources/output/validation-result-w-profile-for-170.315_b1_toc_gold_sample2_v1.html"; - boolean generateDAFProfileMetadata = true; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - // 170.315_b1_toc_inp_ccd_r21_sample1_v5.xml without profile - @Ignore - public void testInpSampleBundleWithoutProfile() throws Exception { - String cdaResourcePath = "src/test/resources/170.315_b1_toc_inp_ccd_r21_sample1_v5.xml"; - String targetPathForFHIRResource = "src/test/resources/output/170.315_b1_toc_inp_ccd_r21_sample1_v5-wo-profile-validation.xml"; - String targetPathForResultFile = "src/test/resources/output/validation-result-wo-profile-for-170.315_b1_toc_inp_ccd_r21_sample1_v5.html"; - boolean generateDAFProfileMetadata = false; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - // 170.315_b1_toc_inp_ccd_r21_sample1_v5.xml without profile - @Ignore - public void testInpSampleBundleWithProfile() throws Exception { - String cdaResourcePath = "src/test/resources/170.315_b1_toc_inp_ccd_r21_sample1_v5.xml"; - String targetPathForFHIRResource = "src/test/resources/output/170.315_b1_toc_inp_ccd_r21_sample1_v5-w-profile-validation.xml"; - String targetPathForResultFile = "src/test/resources/output/validation-result-w-profile-for-170.315_b1_toc_inp_ccd_r21_sample1_v5.html"; - boolean generateDAFProfileMetadata = true; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - // C-CDA_R2-1_CCD.xml without DAF profile - @Ignore - public void testReferenceCCDBundleWithoutProfile() throws Exception { - String cdaResourcePath = "src/test/resources/C-CDA_R2-1_CCD.xml"; - String targetPathForFHIRResource = "src/test/resources/output/C-CDA_R2-1_CCD-wo-profile-validation.xml"; - String targetPathForResultFile = "src/test/resources/output/validation-result-wo-profile-for-C-CDA_R2-1_CCD.html"; - boolean generateDAFProfileMetadata = false; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - // C-CDA_R2-1_CCD.xml with provenance - @Ignore - public void testReferenceCCDBundleWithProvenance() throws Exception { - String cdaResourcePath = "src/test/resources/C-CDA_R2-1_CCD.xml"; - String targetPathForFHIRResource = "src/test/resources/output/C-CDA_R2-1_CCD-w-provenance.xml"; - String targetPathForResultFile = "src/test/resources/output/validation-result-w-provenance-for-C-CDA_R2-1_CCD.html"; - boolean generateDAFProfileMetadata = false; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, true); - } - - // C-CDA_R2-1_CCD.xml with DAF profile - @Ignore - public void testReferenceCCDBundleWithProfile() throws Exception { - String cdaResourcePath = "src/test/resources/C-CDA_R2-1_CCD.xml"; - String targetPathForFHIRResource = "src/test/resources/output/C-CDA_R2-1_CCD-w-profile-validation.xml"; - String targetPathForResultFile = "src/test/resources/output/validation-result-w-profile-for-C-CDA_R2-1_CCD.html"; - boolean generateDAFProfileMetadata = false; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - // Vitera_CCDA_SMART_Sample.xml without profile - @Ignore - public void testViteraBundleWithoutProfile() throws Exception { - String cdaResourcePath = "src/test/resources/Vitera_CCDA_SMART_Sample.xml"; - String targetPathForFHIRResource = "src/test/resources/output/Vitera_CCDA_SMART_Sample-wo-profile-validation.xml"; - String targetPathForResultFile = "src/test/resources/output/validation-result-wo-profile-for-Vitera_CCDA_SMART_Sample.html"; - boolean generateDAFProfileMetadata = false; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - // Vitera_CCDA_SMART_Sample.xml with profile - @Ignore - public void testViteraBundleWithProfile() throws Exception { - String cdaResourcePath = "src/test/resources/Vitera_CCDA_SMART_Sample.xml"; - String targetPathForFHIRResource = "src/test/resources/output/Vitera_CCDA_SMART_Sample-w-profile-validation.xml"; - String targetPathForResultFile = "src/test/resources/output/validation-result-w-profile-for-Vitera_CCDA_SMART_Sample.html"; - boolean generateDAFProfileMetadata = true; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - // HannahBanana_EpicCCD.xml - @Ignore - public void testHannahBanana() throws Exception { - String cdaResourcePath = "src/test/resources/Epic/HannahBanana_EpicCCD-pretty.xml"; - String targetPathForFHIRResource = "src/test/resources/output/Epic/HannahBanana_EpicCCD-pretty.fhir.xml"; - String targetPathForResultFile = "src/test/resources/output/Epic/HannahBanana_EpicCCD-pretty.validation-result.html"; - boolean generateDAFProfileMetadata = true; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - // robust CCD.XML - @Ignore - public void testRobust() throws Exception { - String cdaResourcePath = "src/test/resources/Epic/robust CCD.XML"; - String targetPathForFHIRResource = "src/test/resources/output/Epic/robust CCD.fhir.xml"; - String targetPathForResultFile = "src/test/resources/output/Epic/robust CCD.validation-result.html"; - boolean generateDAFProfileMetadata = true; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - // Person-RAKIA_TEST_DOC0001 (1).xml - @Ignore - public void testRakia() throws Exception { - String cdaResourcePath = "src/test/resources/Cerner/Person-RAKIA_TEST_DOC00001 (1).xml"; - String targetPathForFHIRResource = "src/test/resources/output/Cerner/Person-RAKIA_TEST_DOC00001 (1).fhir.xml"; - String targetPathForResultFile = "src/test/resources/output/Cerner/Person-RAKIA_TEST_DOC00001 (1).validation-result.html"; - boolean generateDAFProfileMetadata = true; - transformAndValidate(cdaResourcePath, targetPathForFHIRResource, targetPathForResultFile, - generateDAFProfileMetadata, false); - } - - /** - * Transforms a CDA resource to a FHIR resource, validates the FHIR resource and - * prints the validation result to the target path. - * - * @param cdaResourcePath A file path of the CDA resource that is to - * be transformed - * @param targetPathForFHIRResource A file path where the FHIR resource is to - * be created - * @param targetPathForResultFile A file path where the validation result - * file is to be created - * @param generateDAFProfileMetadata A boolean indicating whether the generated - * resources will include DAF profile - * declarations in meta.profile - * @throws Exception - */ - private void transformAndValidate(String cdaResourcePath, String targetPathForFHIRResource, - String targetPathForResultFile, boolean generateDAFProfileMetadata, boolean generateProvenance) - throws Exception { - IValidator validator = new ValidatorImpl(); - ByteArrayOutputStream os = null; - - // file to be transformed - FileInputStream fis = new FileInputStream(cdaResourcePath); - - ContinuityOfCareDocument cda = (ContinuityOfCareDocument) CDAUtil.loadAs(fis, - ConsolPackage.eINSTANCE.getContinuityOfCareDocument()); - ICDATransformer ccdTransformer = new CCDTransformerImpl(IdGeneratorEnum.COUNTER); - - // set whether DAF Profile URLs will be created in meta.profile of relevant - // resources - Config.setGenerateDafProfileMetadata(generateDAFProfileMetadata); - - Bundle bundle = null; - - if (generateProvenance) { - - // CDAUtil closes the stream, re-open it. - FileInputStream fisStream = new FileInputStream(cdaResourcePath); - byte[] buffer = new byte[10]; - StringBuilder sb = new StringBuilder(); - while (fisStream.read(buffer) != -1) { - sb.append(new String(buffer)); - buffer = new byte[10]; - } - fisStream.close(); - - String content = sb.toString(); - - Identifier assemblerDevice = new Identifier(); - assemblerDevice.setValue("Higgs"); - assemblerDevice.setSystem("http://www.amida.com"); - bundle = ccdTransformer.transformDocument(cda, BundleType.TRANSACTION, null, content, assemblerDevice); - } else { - bundle = ccdTransformer.transformDocument(cda, null, null); - } - - Assert.assertNotNull(bundle); - - // print the bundle for checking against validation results - // printed as XML, because HL7 FHIR Validator works with XML encoded resources - FHIRUtil.printXML(bundle, targetPathForFHIRResource); - os = (ByteArrayOutputStream) validator.validateBundle(bundle); - - // ValidationResult fileResult = - // validator.validateFile(targetPathForFHIRResource); - // Assert.assertNotNull(fileResult); - // Assert.assertTrue(fileResult.isSuccessful()); TODO: Investigate and fix why - // this is failing - - if (os != null) { - File validationFile = new File(targetPathForResultFile); - validationFile.getParentFile().mkdirs(); - - FileOutputStream fos = new FileOutputStream(validationFile); - os.writeTo(fos); - os.close(); - fos.close(); - } - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/ValueSetTransformationTest.java b/src/test/java/tr/com/srdc/cda2fhir/ValueSetTransformationTest.java deleted file mode 100644 index df34e2133..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/ValueSetTransformationTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package tr.com.srdc.cda2fhir; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.Assert; - -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.hl7.fhir.dstu3.model.Configuration; -import org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.transform.ValueSetsTransformerImpl; - -public class ValueSetTransformationTest { - private static CDAFactories factories; - private static ValueSetsTransformerImpl vst; - - private static enum ActStatus { - NORMAL, - ABORTED, - ACTIVE, - CANCELLED, - COMPLETED, - HELD, - NEW, - SUSPENDED, - NULLIFIED, - OBSOLETE; - public String toCode() { - switch (this) { - case NORMAL: return "normal"; - case ABORTED: return "aborted"; - case ACTIVE: return "active"; - case CANCELLED: return "cancelled"; - case COMPLETED: return "completed"; - case HELD: return "held"; - case NEW: return "new"; - case SUSPENDED: return "suspended"; - case NULLIFIED: return "nullified"; - case OBSOLETE: return "obsolete"; - default: return "?"; - } - } - } - - @BeforeClass - public static void init() { - CDAUtil.loadPackages(); - factories = CDAFactories.init(); - vst = new ValueSetsTransformerImpl(); - } - - @Test - public void testtActStatus2MedicationRequestStatus() { - String normalResult = vst.tActStatus2MedicationRequestStatus(ActStatus.NORMAL.toCode()).toCode(); - String abortedResult = vst.tActStatus2MedicationRequestStatus(ActStatus.ABORTED.toCode()).toCode(); - String activeResult = vst.tActStatus2MedicationRequestStatus(ActStatus.ACTIVE.toCode()).toCode(); - String cancelledResult = vst.tActStatus2MedicationRequestStatus(ActStatus.CANCELLED.toCode()).toCode(); - String completedResult = vst.tActStatus2MedicationRequestStatus(ActStatus.COMPLETED.toCode()).toCode(); - String heldResult = vst.tActStatus2MedicationRequestStatus(ActStatus.HELD.toCode()).toCode(); - String newResult = vst.tActStatus2MedicationRequestStatus(ActStatus.NEW.toCode()).toCode(); - String suspendedResult = vst.tActStatus2MedicationRequestStatus(ActStatus.SUSPENDED.toCode()).toCode(); - String nullifiedResult = vst.tActStatus2MedicationRequestStatus(ActStatus.NULLIFIED.toCode()).toCode(); - String obsoleteResult = vst.tActStatus2MedicationRequestStatus(ActStatus.OBSOLETE.toCode()).toCode(); - - Assert.assertEquals(normalResult,"unknown"); - Assert.assertEquals(abortedResult,"cancelled"); - Assert.assertEquals(activeResult,"active"); - Assert.assertEquals(cancelledResult,"cancelled"); - Assert.assertEquals(completedResult,"completed"); - Assert.assertEquals(heldResult,"on-hold"); - Assert.assertEquals(newResult,"unknown"); - Assert.assertEquals(suspendedResult,"on-hold"); - Assert.assertEquals(nullifiedResult,"cancelled"); - Assert.assertEquals(obsoleteResult,"unknown"); - - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/AuthorGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/AuthorGenerator.java deleted file mode 100644 index 860ed1f18..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/AuthorGenerator.java +++ /dev/null @@ -1,84 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import org.openhealthtools.mdht.uml.cda.AssignedAuthor; -import org.openhealthtools.mdht.uml.cda.AssignedEntity; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.hl7.datatypes.TS; - -import tr.com.srdc.cda2fhir.testutil.generator.AssignedEntityGenerator; - -public class AuthorGenerator { - private AssignedEntityGenerator assignedEntityGenerator; - private CDAFactories factories; - - private String time; - - static final private String DEFAULT_TIME = "20190101"; - - public AuthorGenerator() { - this.factories = CDAFactories.init(); - this.assignedEntityGenerator = new AssignedEntityGenerator(); - } - - public AuthorGenerator(CDAFactories factories) { - this.factories = factories; - - } - - public AuthorGenerator(AssignedEntityGenerator assignedEntityGenerator) { - this.assignedEntityGenerator = assignedEntityGenerator; - } - - public AuthorGenerator(AssignedEntityGenerator assignedEntityGenerator, CDAFactories factories) { - this.factories = factories; - this.assignedEntityGenerator = assignedEntityGenerator; - } - - public Author generateDefaultAuthor() { - Author author = factories.base.createAuthor(); - author.setTime(generateTime(DEFAULT_TIME)); - author.setAssignedAuthor(generateAssignedAuthor()); - return author; - } - - public Author generateAuthor() { - Author author = factories.base.createAuthor(); - author.setTime(time == null ? generateTime(DEFAULT_TIME) : generateTime(time)); - author.setAssignedAuthor(generateAssignedAuthor()); - return author; - } - - private AssignedAuthor generateAssignedAuthor() { - AssignedEntity entity = assignedEntityGenerator.generate(factories); - AssignedAuthor assignedAuthor = factories.base.createAssignedAuthor(); - if (entity.getAssignedPerson() != null) { - assignedAuthor.setAssignedPerson(entity.getAssignedPerson()); - } - if (entity.getIds() != null) { - assignedAuthor.getIds().addAll(entity.getIds()); - } - if (entity.getRepresentedOrganizations() != null && !entity.getRepresentedOrganizations().isEmpty()) { - assignedAuthor.setRepresentedOrganization(entity.getRepresentedOrganizations().get(0)); - } - if (entity.getAddrs() != null) { - assignedAuthor.getAddrs().addAll(entity.getAddrs()); - } - if (entity.getTelecoms() != null) { - assignedAuthor.getTelecoms().addAll(entity.getTelecoms()); - } - return assignedAuthor; - } - - private TS generateTime(String time) { - return factories.datatype.createTS(time); - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/BasicObjectGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/BasicObjectGenerator.java deleted file mode 100644 index 9c7250d09..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/BasicObjectGenerator.java +++ /dev/null @@ -1,104 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVXB_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.ON; -import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -public class BasicObjectGenerator { - - private CDAFactories factories; - - public BasicObjectGenerator(CDAFactories factories) { - this.factories = factories; - } - - public BasicObjectGenerator() { - this.factories = CDAFactories.init(); - } - - public II genTemplateId(String Id) { - return factories.datatype.createII(Id); - } - - public II genTemplateId(String Id, String IdExt) { - return factories.datatype.createII(Id, IdExt); - } - - public IVL_TS generateEffectiveTime(String low, String high) { - return factories.datatype.createIVL_TS(low, high); - } - - public IVL_TS generateEffectiveTime(String low) { - IVL_TS lowEffTime = factories.datatype.createIVL_TS(); - IVXB_TS lowVal = factories.datatype.createIVXB_TS(); - lowVal.setValue(low); - lowEffTime.setLow(lowVal); - lowEffTime.setHigh(getNullHigh()); - return lowEffTime; - } - - public IVL_TS generateEffectiveTime() { - IVL_TS effTime = factories.datatype.createIVL_TS(); - effTime.setHigh(getNullHigh()); - return effTime; - } - - private IVXB_TS getNullHigh() { - IVXB_TS highVal = factories.datatype.createIVXB_TS(); - highVal.setNullFlavor(NullFlavor.NI); - return highVal; - } - - public CS genStatusCode(String code) { - return factories.datatype.createCS(code); - } - - public CS genStatusCodeNullFlavor(NullFlavor nf) { - CS code = factories.datatype.createCS(); - code.setNullFlavor(nf); - return code; - } - - public PQ genQuantity(String value) { - PQ quantity = factories.datatype.createPQ(); - quantity.setValue(Double.parseDouble(value)); - return quantity; - } - - public PQ genQuantity(String value, String unit) { - return factories.datatype.createPQ(Double.parseDouble(value), unit); - } - - public TEL generateReference(String val) { - return factories.datatype.createTEL(val); - } - - public ED generateOriginalText(TEL ref) { - ED originalText = factories.datatype.createED(); - originalText.setReference(ref); - return originalText; - } - - public ON getName(String nameStr) { - ON nameON = factories.datatype.createON(); - nameON.addText(nameStr); - return nameON; - } - - public AD getAddress(String street, String city, String state, String postal) { - AD addr = factories.datatype.createAD(); - addr.addStreetAddressLine(street); - addr.addCity(city); - addr.addState(state); - addr.addPostalCode(postal); - return addr; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/BundleUtil.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/BundleUtil.java deleted file mode 100644 index 5662a1556..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/BundleUtil.java +++ /dev/null @@ -1,275 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import java.io.FileInputStream; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.dstu3.model.Composition; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Encounter; -import org.hl7.fhir.dstu3.model.IdType; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.hl7.fhir.dstu3.model.Observation; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.hl7.fhir.dstu3.model.Procedure; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.dstu3.model.Resource; -import org.junit.Assert; -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 tr.com.srdc.cda2fhir.conf.Config; -import tr.com.srdc.cda2fhir.transform.CCDTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.IIdentifierMap; -import tr.com.srdc.cda2fhir.transform.util.IdentifierMapFactory; -import tr.com.srdc.cda2fhir.util.FHIRUtil; -import tr.com.srdc.cda2fhir.util.IdGeneratorEnum; - -public class BundleUtil { - private Bundle bundle; - private IIdentifierMap identifierMap; - private Map idMap; - - public BundleUtil(Bundle bundle) { - this.bundle = bundle; - identifierMap = IdentifierMapFactory.bundleToResource(bundle); - idMap = FHIRUtil.getIdResourceMap(bundle); - } - - public Bundle getBundle() { - return bundle; - } - - public Resource getFromJSONArray(String fhirType, List identifiers) { - return identifierMap.getFromJSONArray(fhirType, identifiers); - } - - public IIdentifierMap getIdentifierMap() { - return identifierMap; - } - - public T getResourceFromReference(String reference, Class type) { - Resource resource = idMap.get(reference); - if (resource == null) { - return null; - } - return type.cast(resource); - } - - public PractitionerRole getPractitionerRole(String practitionerId) { - List roles = FHIRUtil.findResources(bundle, PractitionerRole.class); - Optional result = roles.stream().filter(role -> { - if (!role.hasOrganization() || !role.hasPractitioner()) { - return false; - } - String localPractitionerId = role.getPractitioner().getReference(); - return practitionerId.equals(localPractitionerId); - }).findFirst(); - return result.orElse(null); - } - - public void spotCheckAssignedPractitioner(String reference, String familyName, String roleCode, - String organizationName) { - Practitioner p = (Practitioner) idMap.get(reference); - if (familyName == null) { - Assert.assertFalse("Practioner has name", p.hasName()); - } else { - Assert.assertEquals("The family name", familyName, p.getName().get(0).getFamily()); - } - if (organizationName != null) { - PractitionerRole role = BundleUtil.findPractitionersRole(bundle, p); - String actualRoleCode = role.getCodeFirstRep().getCodingFirstRep().getCode(); - Assert.assertEquals("The role code", roleCode, actualRoleCode); - Assert.assertTrue("Role has a organization", role.hasOrganization()); - String refOrg = role.getOrganization().getReference(); - Organization org = (Organization) idMap.get(refOrg); - Assert.assertEquals("The organization name", organizationName, org.getName()); - } else { - findPractitionersRoles(bundle, p, 0); - } - } - - public void checkResourceCount(Class type, int count) throws Exception { - List resources = FHIRUtil.findResources(bundle, type); - String msg = String.format("Expect %d %s resources in the bundle", count, type.getSimpleName()); - Assert.assertEquals(msg, count, resources.size()); - } - - public List getSectionResources(String sectionCode) { - Composition composition = FHIRUtil.findFirstResource(bundle, Composition.class); - List references = composition.getSection().stream().filter(r -> { - String code = r.getCode().getCodingFirstRep().getCode(); - return code.equals(sectionCode); - }).flatMap(r -> r.getEntry().stream()).map(r -> r.getReference()).collect(Collectors.toList()); - return references.stream().map(r -> { - return idMap.get(r); - }).filter(r -> r != null).collect(Collectors.toList()); - } - - public void spotCheckImmunizationPractitioner(String identifier, String familyName, String roleCode, - String organizationName) { - Immunization imm = (Immunization) identifierMap.get("Immunization", identifier); - Assert.assertTrue("Immunization has a practitioner", imm.hasPractitioner()); - String ref = imm.getPractitioner().get(0).getActor().getReference(); - spotCheckAssignedPractitioner(ref, familyName, roleCode, organizationName); - } - - public void spotCheckEncounterPractitioner(String identifier, String familyName, String roleCode, - String organizationName) { - Encounter enc = (Encounter) identifierMap.get("Encounter", identifier); - Assert.assertTrue("Encounter has a participant", enc.hasParticipant()); - String ref = enc.getParticipant().get(0).getIndividual().getReference(); - spotCheckAssignedPractitioner(ref, familyName, roleCode, organizationName); - } - - public void spotCheckProcedurePractitioner(String identifier, String familyName, String roleCode, - String organizationName) { - Procedure proc = (Procedure) identifierMap.get("Procedure", identifier); - Assert.assertTrue("Procedure has a performer", proc.hasPerformer()); - String ref = proc.getPerformer().get(0).getActor().getReference(); - spotCheckAssignedPractitioner(ref, familyName, roleCode, organizationName); - } - - public void spotCheckObservationPractitioner(String identifier, String familyName, String roleCode, - String organizationName) { - Observation obs = (Observation) identifierMap.get("Observation", identifier); - Assert.assertTrue("Observation has a performer", obs.hasPerformer()); - String ref = obs.getPerformer().get(0).getReference(); - spotCheckAssignedPractitioner(ref, familyName, roleCode, organizationName); - } - - public void spotCheckMedStatementPractitioner(String identifier, String familyName, String roleCode, - String organizationName) { - MedicationStatement obs = (MedicationStatement) identifierMap.get("MedicationStatement", identifier); - Assert.assertTrue("Medication statement has an author", obs.hasInformationSource()); - String ref = obs.getInformationSource().getReference(); - spotCheckAssignedPractitioner(ref, familyName, roleCode, organizationName); - } - - public void spotCheckConditionPractitioner(String identifier, String familyName, String roleCode, - String organizationName) { - Condition cond = (Condition) identifierMap.get("Condition", identifier); - Assert.assertTrue("Condition has an asserter", cond.hasAsserter()); - String ref = cond.getAsserter().getReference(); - spotCheckAssignedPractitioner(ref, familyName, roleCode, organizationName); - } - - public void spotCheckAllergyPractitioner(String identifier, String familyName, String roleCode, - String organizationName) { - AllergyIntolerance allergy = (AllergyIntolerance) identifierMap.get("AllergyIntolerance", identifier); - Assert.assertTrue("Allergy has a recorder", allergy.hasRecorder()); - String ref = allergy.getRecorder().getReference(); - spotCheckAssignedPractitioner(ref, familyName, roleCode, organizationName); - } - - public void spotCheckPractitioner(String root, String extension, String familyName, String address) { - Practitioner p = (Practitioner) identifierMap.get("Practitioner", root, extension); - if (familyName == null) { - Assert.assertFalse("Practioner has name", p.hasName()); - } else { - Assert.assertEquals("The family name", familyName, p.getName().get(0).getFamily()); - } - Assert.assertTrue("Practioner has address", p.hasAddress()); - Assert.assertEquals("The address line", address, p.getAddress().get(0).getLine().get(0).getValue()); - } - - public void spotCheckAttesterPractitioner(Composition.CompositionAttestationMode mode, String familyName, - String roleCode, String organizationName) { - Composition composition = (Composition) bundle.getEntry().get(0).getResource(); - Optional ref = composition.getAttester().stream() - .filter(a -> a.getMode().get(0).getValue().equals(mode)).map(a -> a.getParty().getReference()) - .findFirst(); - Assert.assertTrue("Attester exists", ref.isPresent()); - spotCheckAssignedPractitioner(ref.get(), familyName, roleCode, organizationName); - } - - public void spotCheckAuthorPractitioner(String familyName, String roleCode, String organizationName) { - Composition composition = (Composition) bundle.getEntry().get(0).getResource(); - Assert.assertTrue("Has author", composition.hasAuthor()); - String ref = composition.getAuthor().get(0).getReference(); - spotCheckAssignedPractitioner(ref, familyName, roleCode, organizationName); - } - - static public List findResources(Bundle bundle, Class type, int count) throws Exception { - List resources = FHIRUtil.findResources(bundle, type); - - String msg = String.format("Expect %d %s resources in the bundle", count, type.getSimpleName()); - Assert.assertEquals(msg, count, resources.size()); - return resources; - } - - static public T findOneResource(Bundle bundle, Class type) throws Exception { - List resources = findResources(bundle, type, 1); - if (!resources.isEmpty()) - return resources.get(0); - else - return null; - } - - private static Bundle generateBundle(String sourceName, boolean includeComposition) throws Exception { - FileInputStream fis = new FileInputStream("src/test/resources/" + sourceName); - ContinuityOfCareDocument cda = (ContinuityOfCareDocument) CDAUtil.loadAs(fis, - ConsolPackage.eINSTANCE.getContinuityOfCareDocument()); - CCDTransformerImpl ccdTransformer = new CCDTransformerImpl(IdGeneratorEnum.COUNTER); - Reference dummyPatientRef = new Reference(new IdType("Patient", "0")); - ccdTransformer.setPatientRef(dummyPatientRef); - Config.setGenerateDafProfileMetadata(false); - Config.setGenerateNarrative(false); // TODO: Make this an argument to ccdTransformer - Bundle bundle = ccdTransformer.transformDocument(cda, includeComposition); - return bundle; - } - - public static Bundle generateSnippetBundle(String sourceName) throws Exception { - return generateBundle(sourceName, false); - } - - public static BundleUtil getInstance(String sourceName) throws Exception { - Bundle bundle = generateBundle(sourceName, true); - return new BundleUtil(bundle); - } - - public static void printBundleResources(Bundle bundle, String sourceName, Class cls) - throws Exception { - List procedures = FHIRUtil.findResources(bundle, cls); - String baseName = sourceName.substring(0, sourceName.length() - 4); - String addlName = cls.getSimpleName(); - String outputName = String.format("src/test/resources/output/%s.%s.json", baseName, addlName); - FHIRUtil.printJSON(procedures, outputName); - } - - public static List findPractitionersRoles(Bundle bundle, Practitioner practitioner, int count) { - String id = practitioner.getId(); - List roles = bundle.getEntry().stream().map(r -> r.getResource()) - .filter(r -> r instanceof PractitionerRole).map(r -> (PractitionerRole) r) - .filter(r -> id.equals(r.getPractitioner().getReference())).collect(Collectors.toList()); - Assert.assertEquals("Practitioner role count", count, roles.size()); - return roles; - } - - public static PractitionerRole findPractitionersRole(Bundle bundle, Practitioner practitioner) { - List roles = findPractitionersRoles(bundle, practitioner, 1); - return roles.get(0); - } - - public static void verifyIdsUnique(Bundle bundle) { - Set set = new HashSet(); - for (BundleEntryComponent entry : bundle.getEntry()) { - Resource resource = entry.getResource(); - String id = resource.getId(); - Assert.assertNotNull("Id is null for " + resource.getResourceType(), id); - Assert.assertFalse("Previous resource with id: " + id, set.contains(id)); - set.add(id); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/CDAFactories.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/CDAFactories.java deleted file mode 100644 index f71e7e452..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/CDAFactories.java +++ /dev/null @@ -1,25 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import org.openhealthtools.mdht.uml.cda.consol.impl.ConsolFactoryImpl; -import org.openhealthtools.mdht.uml.cda.impl.CDAFactoryImpl; -import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory; -import org.openhealthtools.mdht.uml.hl7.datatypes.impl.DatatypesFactoryImpl; - -public class CDAFactories { - public ConsolFactoryImpl consol; - public DatatypesFactory datatype; - public CDAFactoryImpl base; - - private CDAFactories() { - }; - - static public CDAFactories init() { - CDAFactories factories = new CDAFactories(); - - factories.consol = (ConsolFactoryImpl) ConsolFactoryImpl.init(); - factories.datatype = DatatypesFactoryImpl.init(); - factories.base = (CDAFactoryImpl) CDAFactoryImpl.init(); - - return factories; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/CDAUtilExtension.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/CDAUtilExtension.java deleted file mode 100644 index db42b9519..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/CDAUtilExtension.java +++ /dev/null @@ -1,100 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import java.io.File; -import java.io.FileWriter; -import java.util.Optional; - -import org.eclipse.emf.common.util.EList; -import org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument; -import org.openhealthtools.mdht.uml.cda.consol.EncountersSectionEntriesOptional; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationsSection; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSection; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSectionEntriesOptional; -import org.openhealthtools.mdht.uml.cda.util.CDAUtil; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.rim.InfrastructureRoot; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.transform.ValueSetsTransformerImpl; -import tr.com.srdc.cda2fhir.transform.util.impl.IdentifierMap; - -public class CDAUtilExtension { - public static final String ALLERGIES_CODE = "48765-2"; - public static final String MEDICATIONS_CODE = "10160-0"; - public static final String IMMUNIZATIONS_CODE = "11369-6"; - public static final String RESULTS_CODE = "30954-2"; - public static final String VITALS_CODE = "8716-3"; - public static final String CONDITIONS_CODE = "11450-4"; - public static final String ENCOUNTERS_CODE = "46240-8"; - public static final String PROCEDURES_CODE = "47519-4"; - - public static File writeAsXML(InfrastructureRoot infrastructureRoot, String outputPath, String caseName) - throws Exception { - File xmlFile = new File(outputPath, caseName + ".xml"); - xmlFile.getParentFile().mkdirs(); - FileWriter fw = new FileWriter(xmlFile); - CDAUtil.saveSnippet(infrastructureRoot, fw); - fw.close(); - return xmlFile; - } - - public static NullFlavor toNullFlavor(String nullFlavor) { - NullFlavor nf = NullFlavor.get(nullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - return nf; - } - - public static int idValue(String fhirType, EList iis, IdentifierMap orderMap) { - ValueSetsTransformerImpl vst = new ValueSetsTransformerImpl(); - II ii = iis.get(0); - String root = ii.getRoot(); - String extension = ii.getExtension(); - if (extension == null) { - Integer index = orderMap.get(fhirType, root); - return index.intValue(); - } else { - String value = extension; - String system = vst.tOid2Url(root); - Integer index = orderMap.get(fhirType, system, value); - return index.intValue(); - } - } - - public static EncountersSectionEntriesOptional getEncountersSection(ContinuityOfCareDocument cda) { - EncountersSectionEntriesOptional section = cda.getEncountersSection(); - if (section != null) { - return section; - } - Optional sectionOptional = cda.getSections().stream() - .filter(s -> s instanceof EncountersSectionEntriesOptional) - .map(s -> (EncountersSectionEntriesOptional) s).findFirst(); - if (!sectionOptional.isPresent()) { - return null; - } - return sectionOptional.get(); - } - - public static VitalSignsSectionEntriesOptional getVitalSignsSection(ContinuityOfCareDocument cda) { - VitalSignsSectionEntriesOptional section = cda.getVitalSignsSectionEntriesOptional(); - if (section != null) { - return section; - } - Optional sectionOptional = cda.getSections().stream() - .filter(s -> s instanceof VitalSignsSection).map(s -> (VitalSignsSection) s).findFirst(); - if (!sectionOptional.isPresent()) { - return null; - } - return sectionOptional.get(); - } - - public static ImmunizationsSection getImmunizationsSection(ContinuityOfCareDocument cda) { - Optional sectionOptional = cda.getSections().stream() - .filter(s -> s instanceof ImmunizationsSection).map(s -> (ImmunizationsSection) s).findFirst(); - if (!sectionOptional.isPresent()) { - return null; - } - return sectionOptional.get(); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/CdaOrganizationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/CdaOrganizationGenerator.java deleted file mode 100644 index 5fa5b4ca4..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/CdaOrganizationGenerator.java +++ /dev/null @@ -1,104 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import org.openhealthtools.mdht.uml.cda.Organization; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; - -public class CdaOrganizationGenerator { - - private CDAFactories factories; - - private BasicObjectGenerator basicObjectGenerator = new BasicObjectGenerator(); - private String name; - - private String street; - private String city; - private String state; - private String postalCode; - - static final public String DEFAULT_NAME = "Aperture Science"; - static final public String DEFAULT_STREET = "100 Aperture Drive"; - static final public String DEFAULT_CITY = "Cleveland"; - static final public String DEFAULT_STATE = "Ohio"; - static final public String DEFAULT_POSTAL_CODE = "44101"; - - public CdaOrganizationGenerator() { - this.factories = CDAFactories.init(); - } - - public CdaOrganizationGenerator(CDAFactories factories) { - this.factories = factories; - - } - - public Organization generateDefault() { - Organization org = factories.base.createOrganization(); - org.getNames().add(basicObjectGenerator.getName(DEFAULT_NAME)); - org.getAddrs().add(generateDefaultAddress()); - return org; - } - - public Organization generate() { - Organization org = factories.base.createOrganization(); - org.getNames().add(basicObjectGenerator.getName(name == null ? DEFAULT_NAME : name)); - org.getAddrs().add(generateAddress()); - return org; - } - - public void setbasicObjectGenerator(BasicObjectGenerator basicObjectGenerator) { - this.basicObjectGenerator = basicObjectGenerator; - } - - public AD generateDefaultAddress() { - return basicObjectGenerator.getAddress(DEFAULT_STREET, DEFAULT_CITY, DEFAULT_STATE, DEFAULT_POSTAL_CODE); - } - - public AD generateAddress() { - AD addr = factories.datatype.createAD(); - addr.addStreetAddressLine(street == null ? DEFAULT_STREET : street); - addr.addCity(city == null ? DEFAULT_CITY : city); - addr.addState(state == null ? DEFAULT_STATE : state); - addr.addPostalCode(postalCode == null ? DEFAULT_POSTAL_CODE : postalCode); - return addr; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getStreet() { - return street; - } - - public void setStreet(String street) { - this.street = street; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getPostal_code() { - return postalCode; - } - - public void setPostal_code(String postalCode) { - this.postalCode = postalCode; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/FhirOrganizationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/FhirOrganizationGenerator.java deleted file mode 100644 index 243a51bc0..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/FhirOrganizationGenerator.java +++ /dev/null @@ -1,36 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import org.hl7.fhir.dstu3.model.Address; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent; -import org.hl7.fhir.dstu3.model.codesystems.ContactentityType; -import org.hl7.fhir.dstu3.model.codesystems.OrganizationType; - -public class FhirOrganizationGenerator { - public Organization generate() { - Organization organization = new Organization(); - organization.setName("Aperture Science"); - organization.setActive(true); - - Coding typeCoding = new Coding(OrganizationType.BUS.getSystem(), OrganizationType.BUS.toCode(), - OrganizationType.BUS.getDisplay()); - organization.addType(new CodeableConcept().addCoding(typeCoding)); - - OrganizationContactComponent occ = new OrganizationContactComponent(); - Coding purposeCoding = new Coding(ContactentityType.ADMIN.getSystem(), ContactentityType.ADMIN.toCode(), - ContactentityType.ADMIN.getDisplay()); - occ.setPurpose(new CodeableConcept().addCoding(purposeCoding)); - - Address address = new Address(); - address.addLine("100 Aperture Drive"); - address.setCity("Cleveland"); - address.setState("Ohio"); - address.setPostalCode("44101"); - occ.setAddress(address); - - organization.addContact(occ); - return organization; - } -} \ No newline at end of file diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/ManufacturedProductGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/ManufacturedProductGenerator.java deleted file mode 100644 index b7d758908..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/ManufacturedProductGenerator.java +++ /dev/null @@ -1,156 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import java.util.ArrayList; -import java.util.List; - -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.Material; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.vocab.EntityClassManufacturedMaterial; -import org.openhealthtools.mdht.uml.hl7.vocab.EntityDeterminerDetermined; - -public class ManufacturedProductGenerator { - - private BasicObjectGenerator basicObjectGenerator; - private CdaOrganizationGenerator orgGenerator; - private CDAFactories factories; - - private String manuMaterialCodeCode; - private String manuMaterialCodeSystem; - private String manuMaterialDisplayName; - private String originalTextReference; - - static final public String DEFAULT_TEMPLATE_ID = "2.16.840.1.113883.10.20.22.4.23"; - static final public String DEFAULT_TEMPLATE_ID_EXT = "2014-06-09"; - static final public String DEFAULT_ROOT_ID = "2a620155-9d11-439e-92b3-5d9815ff4ee8"; - static final public String DEFAULT_MANU_MATERIAL_TEMPLATE_ID = "2.16.840.1.113883.10.20.22.4.23"; - static final public String DEFAULT_MANU_MATERIAL_TEMPLATE_ID_EXT = "2.16.840.1.113883.10.20.22.4.23"; - static final public String DEFAULT_MANU_MATERIAL_CODE_CODE = "123456"; - static final public String DEFAULT_MANU_MATERIAL_CODE_SYSTEM = "2.16.840.1.113883.6.88"; - static final public String DEFAULT_MANU_MATERIAL_DISPLAY_NAME = "default display"; - static final public String DEFAULT_ORIGINAL_TEXT_REFERENCE = "#MEDPROD12345"; - static final public String DEFAULT_TRANSLATION_CODE = "a1b2c3"; - static final public String DEFAULT_TRANSLATION_CODE_SYSTEM = "2.16.840.1.113883.6.314"; - static final public String DEFAULT_TRANSLATION_CODE_SYSTEM_NAME = "code system display name"; - static final public String DEFAULT_TRANSLATION_DISPLAY_NAME = "drug display name"; - - private List translationCodes = new ArrayList(); - - public ManufacturedProductGenerator(CDAFactories factories) { - this.factories = factories; - this.basicObjectGenerator = new BasicObjectGenerator(factories); - this.orgGenerator = new CdaOrganizationGenerator(factories); - - } - - public ManufacturedProductGenerator() { - this.factories = CDAFactories.init(); - this.basicObjectGenerator = new BasicObjectGenerator(factories); - this.orgGenerator = new CdaOrganizationGenerator(factories); - } - - public ManufacturedProduct generateManufacturedProduct() { - ManufacturedProduct manProd = factories.base.createManufacturedProduct(); - manProd.getTemplateIds().add(basicObjectGenerator.genTemplateId(DEFAULT_TEMPLATE_ID, DEFAULT_TEMPLATE_ID_EXT)); - manProd.getIds().add(factories.datatype.createII(DEFAULT_ROOT_ID)); - manProd.setManufacturedMaterial(generateManuMaterial()); - return manProd; - } - - public ManufacturedProduct generateDefaultManufacturedProduct() { - ManufacturedProduct manProd = factories.base.createManufacturedProduct(); - manProd.getTemplateIds().add(basicObjectGenerator.genTemplateId(DEFAULT_TEMPLATE_ID, DEFAULT_TEMPLATE_ID_EXT)); - manProd.getIds().add(factories.datatype.createII(DEFAULT_ROOT_ID)); - manProd.setManufacturedMaterial(generateDefautManuMaterial()); - if (orgGenerator != null) { - manProd.setManufacturerOrganization(orgGenerator.generateDefault()); - } - return manProd; - } - - public Material generateDefautManuMaterial() { - CE defaultManuMaterialCode = factories.datatype.createCE(DEFAULT_MANU_MATERIAL_CODE_CODE, - DEFAULT_MANU_MATERIAL_CODE_SYSTEM); - defaultManuMaterialCode.setDisplayName(DEFAULT_MANU_MATERIAL_DISPLAY_NAME); - TEL defaultRef = basicObjectGenerator.generateReference(DEFAULT_ORIGINAL_TEXT_REFERENCE); - ED defaultOriginalText = basicObjectGenerator.generateOriginalText(defaultRef); - defaultManuMaterialCode.setOriginalText(defaultOriginalText); - II defaultTempId = basicObjectGenerator.genTemplateId(DEFAULT_MANU_MATERIAL_TEMPLATE_ID, - DEFAULT_MANU_MATERIAL_TEMPLATE_ID_EXT); - Material manuMaterial = genManuMaterial(defaultTempId, defaultManuMaterialCode); - manuMaterial.getCode().getTranslations().add(generateDefaultTranslation()); - return manuMaterial; - } - - private Material generateManuMaterial() { - CE manuMaterialCode = factories.datatype.createCE(); - - manuMaterialCode.setCode(manuMaterialCodeCode != null ? manuMaterialCodeCode : DEFAULT_MANU_MATERIAL_CODE_CODE); - manuMaterialCode.setCodeSystem( - manuMaterialCodeSystem != null ? manuMaterialCodeSystem : DEFAULT_MANU_MATERIAL_CODE_SYSTEM); - manuMaterialCode.setDisplayName( - manuMaterialDisplayName != null ? manuMaterialDisplayName : DEFAULT_MANU_MATERIAL_DISPLAY_NAME); - - TEL ref = basicObjectGenerator.generateReference( - originalTextReference != null ? originalTextReference : DEFAULT_ORIGINAL_TEXT_REFERENCE); - ED originalText = basicObjectGenerator.generateOriginalText(ref); - manuMaterialCode.setOriginalText(originalText); - - II tempId = basicObjectGenerator.genTemplateId(DEFAULT_MANU_MATERIAL_TEMPLATE_ID, - DEFAULT_MANU_MATERIAL_TEMPLATE_ID_EXT); - - Material manuMaterial; - if (translationCodes == null && !translationCodes.isEmpty()) { - manuMaterial = genManuMaterial(tempId, manuMaterialCode); - } else { - manuMaterial = genManuMaterial(tempId, manuMaterialCode, translationCodes); - } - - return manuMaterial; - } - - private Material genManuMaterial(II tempId, CE code, List translationList) { - Material manuMaterial = genManuMaterial(tempId, code); - manuMaterial.getCode().getTranslations().addAll(translationList); - return manuMaterial; - } - - private Material genManuMaterial(II tempId, CE code) { - Material manuMaterial = factories.base.createMaterial(); - manuMaterial.setClassCode(EntityClassManufacturedMaterial.MMAT); - manuMaterial.setDeterminerCode(EntityDeterminerDetermined.KIND); - manuMaterial.setCode(code); - return manuMaterial; - - } - - private CD generateDefaultTranslation() { - CD defaultTranslation = factories.datatype.createCD(); - defaultTranslation.setCode(DEFAULT_TRANSLATION_CODE); - defaultTranslation.setCodeSystem(DEFAULT_TRANSLATION_CODE_SYSTEM); - defaultTranslation.setCodeSystemName(DEFAULT_TRANSLATION_CODE_SYSTEM_NAME); - defaultTranslation.setDisplayName(DEFAULT_TRANSLATION_DISPLAY_NAME); - return defaultTranslation; - - } - - public void addTranslationCode(CE code) { - translationCodes.add(code); - } - - public void addTranslationCodes(List code) { - translationCodes.addAll(code); - } - - public void clearTranslationCodes() { - translationCodes.clear(); - } - - public void setOrganizationGenerator(CdaOrganizationGenerator orgGenerator) { - this.orgGenerator = orgGenerator; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/MedicationSupplyOrderGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/MedicationSupplyOrderGenerator.java deleted file mode 100644 index a7b629c0a..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/MedicationSupplyOrderGenerator.java +++ /dev/null @@ -1,332 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import java.util.ArrayList; -import java.util.List; - -import org.openhealthtools.mdht.uml.cda.Act; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.Product; -import org.openhealthtools.mdht.uml.cda.consol.Instructions; -import org.openhealthtools.mdht.uml.cda.consol.MedicationSupplyOrder; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_INT; -import org.openhealthtools.mdht.uml.hl7.vocab.ActClassSupply; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActClassDocumentEntryAct; -import org.openhealthtools.mdht.uml.hl7.vocab.x_DocumentActMood; -import org.openhealthtools.mdht.uml.hl7.vocab.x_DocumentSubstanceMood; - -public class MedicationSupplyOrderGenerator { - - private ManufacturedProductGenerator manProductGenerator; - private CDAFactories factories; - private BasicObjectGenerator basicObjectGenerator; - private AuthorGenerator authorGenerator; - - private NullFlavor highNullFlvr; - private NullFlavor lowNullFlvr; - private String templateId; - private String templateIdExt; - private String rootId; - private String statusCode; - private NullFlavor statusCodeNullFlavor; - private String effectiveTimeLow; - private String effectiveTimeHigh; - private Boolean effectiveTimeNull; - private String quantityValue; - private String quantityUnit; - private String repeatNumber; - private ManufacturedProduct manuProduct; - private List instructions; - - static final public String DEFAULT_TEMPLATE_ID = "2.16.840.1.113883.10.20.22.4.17"; - static final public String DEFAULT_TEMPLATE_ID_EXT = "2019-01-01"; - static final public String DEFAULT_ROOT_ID = "12345678-1234-1234-1234-123456789012"; - static final public String DEFAULT_STATUS_CODE = "completed"; - static final public String DEFAULT_EFFECTIVE_TIME_LOW = "20190101000000.000-0500"; - static final public String DEFAULT_EFFECTIVE_TIME_HIGH = "20190101123456.000-0500"; - static final public String DEFAULT_QUANTITY_VALUE = "30.0"; - static final public String DEFAULT_QUANTITY_UNIT = "caps"; - static final public String DEFAULT_REPEAT_NUMBER = "1"; - static final public String DEFAULT_INSTRUCTION = "Toss pills into patients' mouth from a minimum of 5 feet away"; - - public MedicationSupplyOrderGenerator(ManufacturedProductGenerator manProductGenerator, CDAFactories factories) { - this.factories = factories; - this.manProductGenerator = manProductGenerator; - this.basicObjectGenerator = new BasicObjectGenerator(factories); - this.authorGenerator = new AuthorGenerator(); - } - - public MedicationSupplyOrderGenerator(CDAFactories factories) { - this.factories = factories; - this.basicObjectGenerator = new BasicObjectGenerator(factories); - this.manProductGenerator = new ManufacturedProductGenerator(factories); - this.authorGenerator = new AuthorGenerator(); - } - - public MedicationSupplyOrderGenerator() { - this.factories = CDAFactories.init(); - this.basicObjectGenerator = new BasicObjectGenerator(factories); - this.manProductGenerator = new ManufacturedProductGenerator(factories); - this.authorGenerator = new AuthorGenerator(); - - } - - public MedicationSupplyOrder generateDefaultMedicationSupplyOrder() { - - MedicationSupplyOrder supplyOrder = factories.consol.createMedicationSupplyOrder(); - - supplyOrder.setClassCode(ActClassSupply.SPLY); - supplyOrder.setMoodCode(x_DocumentSubstanceMood.INT); - - supplyOrder.getTemplateIds() - .add(basicObjectGenerator.genTemplateId(DEFAULT_TEMPLATE_ID, DEFAULT_TEMPLATE_ID_EXT)); - supplyOrder.getIds().add(generateId(DEFAULT_ROOT_ID)); - supplyOrder.setStatusCode(factories.datatype.createCS(DEFAULT_STATUS_CODE)); - supplyOrder.getEffectiveTimes().add( - basicObjectGenerator.generateEffectiveTime(DEFAULT_EFFECTIVE_TIME_LOW, DEFAULT_EFFECTIVE_TIME_HIGH)); - supplyOrder.setRepeatNumber(genRepeatValue(DEFAULT_REPEAT_NUMBER)); - supplyOrder.setQuantity(basicObjectGenerator.genQuantity(DEFAULT_QUANTITY_VALUE, DEFAULT_QUANTITY_UNIT)); - supplyOrder.setProduct(generateProduct(manProductGenerator.generateDefaultManufacturedProduct())); - supplyOrder.getAuthors().add(authorGenerator.generateDefaultAuthor()); - - supplyOrder.addAct(generateInstruction(DEFAULT_INSTRUCTION)); - return supplyOrder; - } - - public MedicationSupplyOrder generateMedicationSupplyOrder() { - - MedicationSupplyOrder supplyOrder = factories.consol.createMedicationSupplyOrder(); - - supplyOrder.setClassCode(ActClassSupply.SPLY); - supplyOrder.setMoodCode(x_DocumentSubstanceMood.INT); - if (templateId != null && templateIdExt != null) { - supplyOrder.getTemplateIds().add(basicObjectGenerator.genTemplateId(templateId, templateIdExt)); - } else if (templateId != null && templateIdExt == null) { - supplyOrder.getTemplateIds().add(basicObjectGenerator.genTemplateId(templateId)); - } else if (templateId == null && templateIdExt != null) { - supplyOrder.getTemplateIds().add(basicObjectGenerator.genTemplateId(DEFAULT_TEMPLATE_ID, templateIdExt)); - } else { - supplyOrder.getTemplateIds() - .add(basicObjectGenerator.genTemplateId(DEFAULT_TEMPLATE_ID, DEFAULT_TEMPLATE_ID_EXT)); - } - - supplyOrder.getIds().add(generateId(rootId == null ? DEFAULT_ROOT_ID : rootId)); - if (statusCodeNullFlavor != null) { - supplyOrder.setStatusCode(basicObjectGenerator.genStatusCodeNullFlavor(statusCodeNullFlavor)); - } else { - supplyOrder.setStatusCode( - basicObjectGenerator.genStatusCode(statusCode != null ? statusCode : DEFAULT_STATUS_CODE)); - } - - if (effectiveTimeNull) { - supplyOrder.getEffectiveTimes().add(basicObjectGenerator.generateEffectiveTime()); - } else if (effectiveTimeLow != null && effectiveTimeHigh != null) { - supplyOrder.getEffectiveTimes() - .add(basicObjectGenerator.generateEffectiveTime(effectiveTimeLow, effectiveTimeHigh)); - } else if (effectiveTimeLow != null && effectiveTimeHigh == null) { - supplyOrder.getEffectiveTimes().add(basicObjectGenerator.generateEffectiveTime(effectiveTimeLow)); - } else if (effectiveTimeLow == null && effectiveTimeHigh == null) { - supplyOrder.getEffectiveTimes().add(basicObjectGenerator.generateEffectiveTime(DEFAULT_EFFECTIVE_TIME_LOW, - DEFAULT_EFFECTIVE_TIME_HIGH)); - } - - supplyOrder.setRepeatNumber(genRepeatValue(repeatNumber != null ? repeatNumber : DEFAULT_REPEAT_NUMBER)); - - if (quantityValue != null && quantityUnit != null) { - supplyOrder.setQuantity(basicObjectGenerator.genQuantity(quantityValue, quantityUnit)); - } else if (quantityValue != null && quantityUnit == null) { - supplyOrder.setQuantity(basicObjectGenerator.genQuantity(quantityValue)); - } - supplyOrder.setProduct(generateProduct( - manuProduct == null ? manProductGenerator.generateDefaultManufacturedProduct() : manuProduct)); - - supplyOrder.getAuthors().add(authorGenerator.generateAuthor()); - - if (instructions != null) { - supplyOrder.addAct(generateInstruction(instructions)); - } - return supplyOrder; - } - - public Instructions generateInstruction(String instruction) { - Instructions instructions = factories.consol.createInstructions(); - Act act = factories.base.createAct(); - act.setClassCode(x_ActClassDocumentEntryAct.ACT); - act.setMoodCode(x_DocumentActMood.INT); - act.setText(factories.datatype.createED(instruction)); - instructions.addAct(act); - return instructions; - } - - public Instructions generateInstruction(List instructionsStrArr) { - Instructions instructions = factories.consol.createInstructions(); - for (String instructionStr : instructionsStrArr) { - Act act = factories.base.createAct(); - act.setClassCode(x_ActClassDocumentEntryAct.ACT); - act.setMoodCode(x_DocumentActMood.INT); - act.setText(factories.datatype.createED(instructionStr)); - instructions.addAct(act); - } - return instructions; - } - - public II generateId(String id) { - return factories.datatype.createII(id); - } - - public Product generateProduct(ManufacturedProduct manuProd) { - Product prod = factories.base.createProduct(); - prod.setManufacturedProduct(manuProd); - return prod; - } - - public IVL_INT genRepeatValue(String value) { - IVL_INT repeatValue = factories.datatype.createIVL_INT(); - repeatValue.setValue(Integer.parseInt(value)); - return repeatValue; - } - - public NullFlavor getHighNullFlvr() { - return highNullFlvr; - } - - public void setHighNullFlvr(NullFlavor highNullFlvr) { - this.highNullFlvr = highNullFlvr; - } - - public ManufacturedProductGenerator getManuProductGenerator() { - return manProductGenerator; - } - - public void setManuProductGenerator(ManufacturedProductGenerator manProductGenerator) { - this.manProductGenerator = manProductGenerator; - } - - public NullFlavor getLowNullFlvr() { - return lowNullFlvr; - } - - public void setLowNullFlvr(NullFlavor lowNullFlvr) { - this.lowNullFlvr = lowNullFlvr; - } - - public String getTemplateId() { - return templateId; - } - - public void setTemplateId(String templateId) { - this.templateId = templateId; - } - - public String getTemplateIdExt() { - return templateIdExt; - } - - public void setTemplateIdExt(String templateIdExt) { - this.templateIdExt = templateIdExt; - } - - public String getRootId() { - return rootId; - } - - public void setRootId(String rootId) { - this.rootId = rootId; - } - - public String getStatusCode() { - return statusCode; - } - - public void setStatusCode(String statusCode) { - this.statusCode = statusCode; - } - - public String getEffectiveTimeLow() { - return effectiveTimeLow; - } - - public void setEffectiveTimeLow(String effectiveTimeLow) { - this.effectiveTimeLow = effectiveTimeLow; - } - - public String getEffectiveTimeHigh() { - return effectiveTimeHigh; - } - - public void setEffectiveTimeHigh(String effectiveTimeHigh) { - this.effectiveTimeHigh = effectiveTimeHigh; - } - - public ManufacturedProduct getManufacturedProduct() { - return manuProduct; - } - - public void setManufacturedProduct(ManufacturedProduct manuProduct) { - this.manuProduct = manuProduct; - } - - public String getQuantityUnit() { - return quantityUnit; - } - - public void setQuantityUnit(String quantityUnit) { - this.quantityUnit = quantityUnit; - } - - public String getQuantityValue() { - return quantityValue; - } - - public void setQuantityValue(String quantityValue) { - this.quantityValue = quantityValue; - } - - public String getRepeatNumber() { - return repeatNumber; - } - - public void setRepeatNumber(String repeatNumber) { - this.repeatNumber = repeatNumber; - } - - public NullFlavor getStatusCodeNullFlavor() { - return statusCodeNullFlavor; - } - - public void setStatusCodeNullFlavor(NullFlavor statusCodeNullFlavor) { - this.statusCodeNullFlavor = statusCodeNullFlavor; - } - - public Boolean getEffectiveTimeNull() { - return effectiveTimeNull; - } - - public void setEffectiveTimeNull(Boolean effectiveTimeNull) { - this.effectiveTimeNull = effectiveTimeNull; - } - - public void setAuthorGenerator(AuthorGenerator authorGenerator) { - this.authorGenerator = authorGenerator; - } - - public void setManufacturedProductGenerator(ManufacturedProductGenerator manufacturedProductGenerator) { - this.manProductGenerator = manufacturedProductGenerator; - } - - public List getInstructions() { - return this.instructions; - } - - public void setInstructions(List instructions) { - this.instructions = instructions; - } - - public void addInstruction(String instruction) { - if (this.instructions == null) { - this.instructions = new ArrayList(); - } - this.instructions.add(instruction); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/TestSetupException.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/TestSetupException.java deleted file mode 100644 index 05e4e6408..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/TestSetupException.java +++ /dev/null @@ -1,13 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -public class TestSetupException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public TestSetupException() { - super(); - } - - public TestSetupException(String message) { - super(message); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/ValueMapUtil.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/ValueMapUtil.java deleted file mode 100644 index 2c2255019..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/ValueMapUtil.java +++ /dev/null @@ -1,21 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil; - -import java.util.List; -import java.util.Map; - -public class ValueMapUtil { - - @SuppressWarnings("unchecked") - public static void copyStringArray(Map source, List target, String key) { - List sourceArray = (List) source.get(key); - if (sourceArray != null) { - sourceArray.forEach(e -> { - String value = (String) e; - if (value != null) { - target.add(value); - } - }); - } - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ADGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ADGenerator.java deleted file mode 100644 index d345fa8d5..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ADGenerator.java +++ /dev/null @@ -1,261 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.hl7.fhir.dstu3.model.Address; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.ADXP; -import org.openhealthtools.mdht.uml.hl7.vocab.PostalAddressUse; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ADGenerator { - private static Map ADDRESS_TYPE = JsonUtils - .filepathToMap("src/test/resources//value-maps/AddressType.json"); - private static Map ADDRESS_USE = JsonUtils - .filepathToMap("src/test/resources//value-maps/AddressUse.json"); - - private static final String LINE = "100 Aperture Drive"; - private static final String LINE_2 = "Suite #1245"; - private static final String CITY = "Cleveland"; - private static final String STATE = "Ohio"; - private static final String COUNTY = "Montgomery"; - private static final String POSTAL_CODE = "44101"; - - private String text; - private String use; - - private List lines = new ArrayList<>(); - private ADXPGenerator city; - private ADXPGenerator county; - private ADXPGenerator country; - private ADXPGenerator state; - private ADXPGenerator postalCode; - - public ADGenerator() { - } - - public void setLine(ADXPGenerator line) { - lines.clear(); - lines.add(line); - } - - public void setCity(ADXPGenerator city) { - this.city = city; - } - - public void setCounty(ADXPGenerator county) { - this.county = county; - } - - public void setCountry(ADXPGenerator country) { - this.country = country; - } - - public void setState(ADXPGenerator state) { - this.state = state; - } - - public void setPostalCode(ADXPGenerator postalCode) { - this.postalCode = postalCode; - } - - @SuppressWarnings("unchecked") - public ADGenerator(Map json) { - city = new ADXPGenerator((String) json.get("city")); - Object rawPostalCode = json.get("postalCode"); - postalCode = rawPostalCode == null ? null : new ADXPGenerator(rawPostalCode.toString()); - county = new ADXPGenerator((String) json.get("county")); - state = new ADXPGenerator((String) json.get("state")); - List lineObject = (List) json.get("streetAddressLine"); - if (lineObject != null) { - lineObject.forEach(element -> lines.add(new ADXPGenerator((String) element))); - } - } - - public void setUse(String use) { - this.use = use; - } - - public AD generate(CDAFactories factories) { - AD address = factories.datatype.createAD(); - - if (text != null) { - address.addText(text); - } - - if (use != null) { - PostalAddressUse addressUse = PostalAddressUse.get(use); - address.getUses().add(addressUse); - } - - lines.forEach(line -> { - ADXP adxp = line.generate(factories); - address.getStreetAddressLines().add(adxp); - }); - - if (city != null) { - address.getCities().add(city.generate(factories)); - } - - if (county != null) { - address.getCounties().add(county.generate(factories)); - } - - if (country != null) { - address.getCountries().add(country.generate(factories)); - } - - if (state != null) { - address.getStates().add(state.generate(factories)); - } - - if (postalCode != null) { - address.getPostalCodes().add(postalCode.generate(factories)); - } - - return address; - } - - public static ADGenerator getDefaultInstance() { - ADGenerator ag = new ADGenerator(); - - ag.lines.add(new ADXPGenerator(LINE)); - ag.city = new ADXPGenerator(CITY); - ag.state = new ADXPGenerator(STATE); - ag.postalCode = new ADXPGenerator(POSTAL_CODE); - - return ag; - } - - public static ADGenerator getFullInstance() { - ADGenerator ag = new ADGenerator(); - - ag.lines.add(new ADXPGenerator(LINE)); - ag.lines.add(new ADXPGenerator(LINE_2)); - ag.city = new ADXPGenerator(CITY); - ag.state = new ADXPGenerator(STATE); - ag.county = new ADXPGenerator(COUNTY); - ag.postalCode = new ADXPGenerator(POSTAL_CODE); - ag.use = "H"; - - return ag; - } - - public void verify(Address address) { - if (text == null) { - Assert.assertTrue("Missing address text", !address.hasText()); - } else { - Assert.assertEquals("Address text", text, address.getText()); - } - - BaseStringGenerator.verifyList(address.getLine(), lines); - - if (city == null) { - Assert.assertTrue("Mssing address city", !address.hasCity()); - } else { - city.verify(address.getCity()); - } - - if (county == null) { - Assert.assertTrue("Missing address county", !address.hasDistrictElement()); - } else { - county.verify(address.getDistrict()); - } - - if (country == null) { - Assert.assertTrue("Missing address country", !address.hasCountry()); - } else { - country.verify(address.getCountry()); - } - - if (state == null) { - Assert.assertTrue("Missing address state", !address.hasState()); - } else { - state.verify(address.getState()); - } - - if (postalCode == null) { - Assert.assertTrue("Missing address postalCode", !address.hasPostalCode()); - } else { - postalCode.verify(address.getPostalCode()); - } - - if (use != null) { - String addressType = (String) ADDRESS_TYPE.get(use); - if (addressType != null) { - Assert.assertEquals("Address type", addressType, address.getType().toCode()); - } else { - String addressUse = (String) ADDRESS_USE.get(use); - if (addressUse != null) { - Assert.assertEquals("Address use", addressUse, address.getUse().toCode()); - } else { - Assert.assertEquals("Address default use", "temp", address.getUse().toCode()); - } - } - } - } - - public Map toJson() { - Map result = new LinkedHashMap<>(); - - if (!lines.isEmpty()) { - List list = lines.stream().map(r -> r.getValue()).collect(Collectors.toList()); - result.put("line", list); - } - if (city != null) { - result.put("city", city.getValue()); - } - if (county != null) { - result.put("district", county.getValue()); - } - if (country != null) { - result.put("country", country.getValue()); - } - if (state != null) { - result.put("state", state.getValue()); - } - if (postalCode != null) { - result.put("postalCode", postalCode.getValue()); - } - if (use != null) { - String addressType = (String) ADDRESS_TYPE.get(use); - if (addressType != null) { - result.put("type", addressType); - } else { - String addressUse = (String) ADDRESS_USE.get(use); - if (addressUse == null) { - addressUse = "temp"; - } - result.put("use", addressUse); - } - } - if (result.isEmpty()) { - return null; - } - return result; - } - - public static Set getAvailableUses() { - Set result = new HashSet<>(); - result.addAll(ADDRESS_TYPE.keySet()); - result.addAll(ADDRESS_USE.keySet()); - return result; - } - - public static void verifyList(List
actual, List expected) { - Assert.assertEquals("Address count", expected.size(), actual.size()); - for (int index = 0; index < actual.size(); ++index) { - expected.get(index).verify(actual.get(index)); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ADXPGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ADXPGenerator.java deleted file mode 100644 index 3145b93e0..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ADXPGenerator.java +++ /dev/null @@ -1,29 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.openhealthtools.mdht.uml.hl7.datatypes.ADXP; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ADXPGenerator extends BaseStringGenerator { - public ADXPGenerator(boolean nullFlavorOK) { - super(nullFlavorOK); - } - - public ADXPGenerator(String value) { - super(value); - } - - public ADXPGenerator(String value, boolean nullFlavorOK) { - super(value, nullFlavorOK); - } - - @Override - public ADXP create(CDAFactories factories) { - return factories.datatype.createADXP(); - } - - public static ADXPGenerator getNextInstance(boolean nullFlavorOK) { - String value = BaseStringGenerator.getNextValue(); - return new ADXPGenerator(value, nullFlavorOK); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AllergyConcernActGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AllergyConcernActGenerator.java deleted file mode 100644 index 6298fde6a..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AllergyConcernActGenerator.java +++ /dev/null @@ -1,188 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -import org.hl7.fhir.dstu3.model.Bundle; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.consol.AllergyProblemAct; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class AllergyConcernActGenerator { - private static final Map VERIFICATION_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/AllergyIntoleranceVerificationStatus.json"); - - private List idGenerators = new ArrayList<>(); - private CSCodeGenerator statusCodeGenerator; - private EffectiveTimeGenerator effectiveTimeGenerator; - private List observationGenerators = new ArrayList<>(); - - private String nullFlavor; - - public void setNullFlavor() { - this.nullFlavor = "UNK"; - } - - public void setAuthorGenerator(AuthorGenerator authorGenerator) { - if (observationGenerators.isEmpty()) { - observationGenerators.add(new AllergyObservationGenerator()); - } - observationGenerators.get(observationGenerators.size() - 1).setAuthorGenerator(authorGenerator); - } - - public AllergyProblemAct generate(CDAFactories factories) { - AllergyProblemAct apa = factories.consol.createAllergyProblemAct(); - - idGenerators.forEach(g -> { - II ii = g.generate(factories); - apa.getIds().add(ii); - }); - - if (statusCodeGenerator != null) { - CS cs = statusCodeGenerator.generate(factories); - apa.setStatusCode(cs); - } - - if (effectiveTimeGenerator != null) { - IVL_TS ivlTs = effectiveTimeGenerator.generate(factories); - apa.setEffectiveTime(ivlTs); - } - - observationGenerators.forEach(g -> apa.addObservation(g.generate(factories))); - - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - apa.setNullFlavor(nf); - } - - return apa; - } - - public void setObservationGenerator(AllergyObservationGenerator observationGenerator) { - observationGenerators.clear(); - observationGenerators.add(observationGenerator); - } - - public static AllergyConcernActGenerator getDefaultInstance() { - AllergyConcernActGenerator acag = new AllergyConcernActGenerator(); - - acag.idGenerators.add(IDGenerator.getNextInstance()); - acag.statusCodeGenerator = new CSCodeGenerator(VERIFICATION_STATUS); - acag.statusCodeGenerator.set("active"); - acag.effectiveTimeGenerator = new EffectiveTimeGenerator("20171108", "20181223"); - acag.observationGenerators.add(AllergyObservationGenerator.getDefaultInstance()); - - return acag; - } - - public void verify(AllergyIntolerance allergy) { - if (nullFlavor != null) { - Assert.assertNull("Null flavor", allergy); - return; - } - - if (idGenerators.isEmpty()) { - Assert.assertTrue("No patient identifier", !allergy.hasIdentifier()); - } else { - IDGenerator.verifyList(allergy.getIdentifier(), idGenerators); - } - - if (statusCodeGenerator == null) { - Assert.assertEquals("Default verification status", "unconfirmed", allergy.getVerificationStatus().toCode()); - } else { - statusCodeGenerator.verify(allergy.getVerificationStatus().toCode()); - } - - if (effectiveTimeGenerator == null) { - Assert.assertTrue("No asserted date", !allergy.hasAssertedDate()); - } else { - String value = effectiveTimeGenerator.getLowOrValue(); - if (value == null) { - Assert.assertTrue("No asserted date", !allergy.hasAssertedDate()); - } else { - String actual = FHIRUtil.toCDADatetime(allergy.getAssertedDateElement().asStringValue()); - Assert.assertEquals("Allergy asserted date", value, actual); - } - } - - if (observationGenerators.isEmpty()) { - Assert.assertTrue("No allergy code", !allergy.hasCode()); - Assert.assertTrue("No type", !allergy.hasType()); - Assert.assertTrue("No onset", !allergy.hasOnset()); - Assert.assertEquals("Default clinical status", "active", allergy.getClinicalStatus().toCode()); - Assert.assertTrue("No reaction", !allergy.hasReaction()); - Assert.assertTrue("No category", !allergy.hasCategory()); - return; - } - - AllergyObservationGenerator aog = observationGenerators.get(observationGenerators.size() - 1); - aog.verify(allergy); - - int actualIndex = 0; - for (int index = 0; index < observationGenerators.size(); ++index) { - AllergyObservationGenerator g = observationGenerators.get(index); - if (g.hasCategoryGenerator()) { - g.verifyCategory(allergy.getCategory().get(actualIndex).asStringValue()); - ++actualIndex; - } - } - if (actualIndex == 0) { - Assert.assertTrue("No categories exist", !allergy.hasCategory()); - } else { - Assert.assertEquals("Category count", actualIndex, allergy.getCategory().size()); - } - - { - List gs = new ArrayList<>(); - observationGenerators.forEach(og -> { - gs.addAll(og.getReactionGenerators()); - }); - - AllergyReactionObservationGenerator.verifyList(allergy.getReaction(), gs); - } - } - - public void verify(Bundle bundle, AllergyIntolerance allergy) throws Exception { - if (nullFlavor != null) { - Assert.assertNull("Null flavor", allergy); - return; - } - - verify(allergy); - - if (observationGenerators.isEmpty()) { - Assert.assertTrue("No recorder", !allergy.hasRecorder()); - } else { - AllergyObservationGenerator aog = observationGenerators.get(observationGenerators.size() - 1); - aog.verify(bundle); - } - } - - public void verify(Bundle bundle) throws Exception { - if (nullFlavor != null) { - AllergyIntolerance allergy = FHIRUtil.findFirstResource(bundle, AllergyIntolerance.class); - verify(bundle, allergy); - return; - } - - AllergyIntolerance allergy = BundleUtil.findOneResource(bundle, AllergyIntolerance.class); - verify(bundle, allergy); - } - - public static Set getPossibleClinicalStatusCodes() { - return AllergyObservationGenerator.getPossibleClinicalStatusCodes(); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AllergyObservationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AllergyObservationGenerator.java deleted file mode 100644 index 77ad53486..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AllergyObservationGenerator.java +++ /dev/null @@ -1,241 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -import org.hl7.fhir.dstu3.model.Bundle; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.EntryRelationship; -import org.openhealthtools.mdht.uml.cda.Observation; -import org.openhealthtools.mdht.uml.cda.Participant2; -import org.openhealthtools.mdht.uml.cda.ParticipantRole; -import org.openhealthtools.mdht.uml.cda.PlayingEntity; -import org.openhealthtools.mdht.uml.cda.consol.AllergyObservation; -import org.openhealthtools.mdht.uml.cda.consol.ReactionObservation; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.vocab.ParticipationType; -import org.openhealthtools.mdht.uml.hl7.vocab.RoleClassRoot; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class AllergyObservationGenerator { - private static final Map ALLERGY_INTOLERANCE_TYPE = JsonUtils - .filepathToMap("src/test/resources//value-maps/AllergyIntoleranceType.json"); - private static final Map ALLERGY_INTOLERANCE_CATEGORY = JsonUtils - .filepathToMap("src/test/resources//value-maps/AllergyIntoleranceCategory.json"); - private static final Map ALLERGY_INTOLERANCE_CRITICALITY = JsonUtils - .filepathToMap("src/test/resources//value-maps/AllergyIntoleranceCriticality.json"); - private static final Map ALLERGY_INTOLERANCE_CLINICAL_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/AllergyIntoleranceClinicalStatus.json"); - - private List authorGenerators = new ArrayList<>(); - private List codeGenerators = new ArrayList<>(); - - private CECodeGenerator typeGenerator; - private CECodeGenerator categoryGenerator; - - private List reactionGenerators = new ArrayList<>(); - - private EffectiveTimeGenerator effectiveTimeGenerator; - - private CECodeGenerator criticalityGenerator; - - private CECodeGenerator clinicalStatusGenerator; - - public List getReactionGenerators() { - return Collections.unmodifiableList(reactionGenerators); - } - - public void setClinicalStatusCode(String code) { - if (clinicalStatusGenerator == null) { - clinicalStatusGenerator = new CECodeGenerator(ALLERGY_INTOLERANCE_CLINICAL_STATUS); - } - clinicalStatusGenerator.set(code); - } - - public boolean hasCategoryGenerator() { - return categoryGenerator != null; - } - - public void setAuthorGenerator(AuthorGenerator authorGenerator) { - authorGenerators.clear(); - authorGenerators.add(authorGenerator); - } - - public AllergyObservation generate(CDAFactories factories) { - AllergyObservation ao = factories.consol.createAllergyObservation(); - - authorGenerators.forEach(g -> ao.getAuthors().add(g.generate(factories))); - - codeGenerators.forEach(g -> { - Participant2 p2 = factories.base.createParticipant2(); - ParticipationType pt = ParticipationType.CSM; - p2.setTypeCode(pt); - ParticipantRole pr = factories.base.createParticipantRole(); - p2.setParticipantRole(pr); - RoleClassRoot rcr = RoleClassRoot.MANU; - pr.setClassCode(rcr); - PlayingEntity pe = g.generate(factories); - pr.setPlayingEntity(pe); - ao.getParticipants().add(p2); - }); - - if (typeGenerator != null && categoryGenerator != null) { - if (typeGenerator.get() != categoryGenerator.get()) { - throw new TestSetupException("Category and type generators must generate the same."); - } - CE ce = typeGenerator.generate(factories); - ao.getValues().add(ce); - } else if (typeGenerator != categoryGenerator) { - throw new TestSetupException("Category and type generators must generate the same."); - } - - if (effectiveTimeGenerator != null) { - IVL_TS ivlTs = effectiveTimeGenerator.generate(factories); - ao.setEffectiveTime(ivlTs); - } - - if (clinicalStatusGenerator != null) { - EntryRelationship er = factories.base.createEntryRelationship(); - ao.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.SUBJ); - er.setInversionInd(true); - Observation o = factories.consol.createAllergyStatusObservation(); - II templateId = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.28"); - o.getTemplateIds().add(templateId); - CE ce = clinicalStatusGenerator.generate(factories); - o.getValues().add(ce); - er.setObservation(o); - } - - reactionGenerators.forEach(g -> { - EntryRelationship er = factories.base.createEntryRelationship(); - ao.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.MFST); - er.setInversionInd(true); - ReactionObservation ro = g.generate(factories); - II templateId = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.9"); - ro.getTemplateIds().add(templateId); - er.setObservation(ro); - }); - - if (criticalityGenerator != null) { - EntryRelationship er = factories.base.createEntryRelationship(); - ao.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.SUBJ); - er.setInversionInd(true); - Observation o = factories.base.createObservation(); - II templateId = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.145"); - o.getTemplateIds().add(templateId); - CE ce = criticalityGenerator.generate(factories); - o.getValues().add(ce); - er.setObservation(o); - } - - return ao; - } - - public static AllergyObservationGenerator getDefaultInstance() { - AllergyObservationGenerator aog = new AllergyObservationGenerator(); - - aog.authorGenerators.add(AuthorGenerator.getDefaultInstance()); - aog.codeGenerators.add(PlayingEntityGenerator.getDefaultInstance()); - - aog.typeGenerator = new CECodeGenerator(ALLERGY_INTOLERANCE_TYPE); - aog.typeGenerator.set("419511003"); - aog.categoryGenerator = new CECodeGenerator(ALLERGY_INTOLERANCE_CATEGORY); - aog.categoryGenerator.set("419511003"); - aog.effectiveTimeGenerator = new EffectiveTimeGenerator("20161008", "20181128"); - aog.reactionGenerators.add(AllergyReactionObservationGenerator.getDefaultInstance()); - aog.criticalityGenerator = new CECodeGenerator(ALLERGY_INTOLERANCE_CRITICALITY); - aog.criticalityGenerator.set("crith"); - aog.clinicalStatusGenerator = new CECodeGenerator(ALLERGY_INTOLERANCE_CLINICAL_STATUS); - aog.clinicalStatusGenerator.set("55561003"); - - return aog; - } - - public void verify(AllergyIntolerance allergyIntolerance) { - if (codeGenerators.isEmpty()) { - Assert.assertTrue("No allergy code", !allergyIntolerance.hasCode()); - } else { - PlayingEntityGenerator peg = codeGenerators.get(codeGenerators.size() - 1); - peg.verify(allergyIntolerance.getCode()); - } - - if (typeGenerator == null) { - Assert.assertTrue("No type", !allergyIntolerance.hasType()); - } else { - typeGenerator.verify(allergyIntolerance.getType().toCode()); - } - - Assert.assertNotNull("Clinical status exists", allergyIntolerance.hasClinicalStatus()); - if (effectiveTimeGenerator == null) { - Assert.assertTrue("No allergy onset", !allergyIntolerance.hasOnset()); - } else { - String value = effectiveTimeGenerator.getLowOrValue(); - if (value == null) { - Assert.assertTrue("No allergy onset", !allergyIntolerance.hasOnset()); - } else { - String actual = FHIRUtil.toCDADatetime(allergyIntolerance.getOnsetDateTimeType().asStringValue()); - Assert.assertEquals("Allergy offset", value, actual); - } - } - - if (clinicalStatusGenerator == null) { - Assert.assertTrue("Clinical status exists", allergyIntolerance.hasClinicalStatus()); - Assert.assertEquals("Default clinical status", "active", allergyIntolerance.getClinicalStatus().toCode()); - } else { - Assert.assertTrue("Clinical status exists", allergyIntolerance.hasClinicalStatus()); - clinicalStatusGenerator.verify(allergyIntolerance.getClinicalStatus().toCode()); - } - - if (reactionGenerators.isEmpty()) { - Assert.assertTrue("No reaction", !allergyIntolerance.hasReaction()); - } - - if (criticalityGenerator == null) { - Assert.assertTrue("No criticality", !allergyIntolerance.hasCriticality()); - } else { - Assert.assertTrue("Has criticality", allergyIntolerance.hasCriticality()); - criticalityGenerator.verify(allergyIntolerance.getCriticality().toCode()); - } - } - - public void verifyCategory(String category) { - if (categoryGenerator == null) { - Assert.assertNull("No category", category); - } else { - categoryGenerator.verify(category); - } - } - - public void verify(Bundle bundle) throws Exception { - AllergyIntolerance allergyIntolerance = BundleUtil.findOneResource(bundle, AllergyIntolerance.class); - verify(allergyIntolerance); - - if (authorGenerators.isEmpty()) { - Assert.assertTrue("No recorder", !allergyIntolerance.hasRecorder()); - } else { - AuthorGenerator ag = authorGenerators.get(authorGenerators.size() - 1); - String practitionerId = allergyIntolerance.getRecorder().getReference(); - ag.verifyFromPractionerId(bundle, practitionerId); - } - } - - public static Set getPossibleClinicalStatusCodes() { - return Collections.unmodifiableSet(ALLERGY_INTOLERANCE_CLINICAL_STATUS.keySet()); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AllergyReactionObservationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AllergyReactionObservationGenerator.java deleted file mode 100644 index 049700aa4..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AllergyReactionObservationGenerator.java +++ /dev/null @@ -1,104 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.EntryRelationship; -import org.openhealthtools.mdht.uml.cda.consol.ReactionObservation; -import org.openhealthtools.mdht.uml.cda.consol.SeverityObservation; -import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class AllergyReactionObservationGenerator { - private static final Map ALLERGY_INTOLERANCE_SEVERITY = JsonUtils - .filepathToMap("src/test/resources//value-maps/AllergyIntoleranceSeverity.json"); - - private List valueGenerators = new ArrayList<>(); - - private EffectiveTimeGenerator effectiveTimeGenerator; - - private CECodeGenerator severityGenerator; - - public ReactionObservation generate(CDAFactories factories) { - ReactionObservation obs = factories.consol.createReactionObservation(); - - if (effectiveTimeGenerator != null) { - IVL_TS ivlTs = effectiveTimeGenerator.generate(factories); - obs.setEffectiveTime(ivlTs); - } - - valueGenerators.forEach(vg -> { - ANY any = vg.generate(factories); - obs.getValues().add(any); - }); - - if (severityGenerator != null) { - EntryRelationship er = factories.base.createEntryRelationship(); - obs.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.SUBJ); - er.setInversionInd(true); - SeverityObservation so = factories.consol.createSeverityObservation(); - CE severity = severityGenerator.generate(factories); - so.getValues().add(severity); - II templateId = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.8"); - so.getTemplateIds().add(templateId); - er.setObservation(so); - } - - return obs; - } - - public static AllergyReactionObservationGenerator getDefaultInstance() { - AllergyReactionObservationGenerator arog = new AllergyReactionObservationGenerator(); - - arog.effectiveTimeGenerator = new EffectiveTimeGenerator("20150712"); - - arog.severityGenerator = new CECodeGenerator(ALLERGY_INTOLERANCE_SEVERITY); - arog.severityGenerator.set("24484000"); - - arog.valueGenerators.add(CDGenerator.getNextInstance()); - - return arog; - } - - public void verify(AllergyIntoleranceReactionComponent reaction) { - if (valueGenerators.isEmpty()) { - Assert.assertTrue("No manifestation", !reaction.hasManifestation()); - } else { - CDGenerator.verifyList(reaction.getManifestation(), valueGenerators); - } - - if (severityGenerator == null) { - Assert.assertTrue("No severity", !reaction.hasSeverity()); - } else { - severityGenerator.verify(reaction.getSeverity().toCode()); - } - - String value = effectiveTimeGenerator.getLowOrValue(); - if (value == null) { - Assert.assertTrue("No onset", !reaction.hasOnset()); - } else { - String actual = FHIRUtil.toCDADatetime(reaction.getOnsetElement().asStringValue()); - Assert.assertEquals("Onset", value, actual); - } - } - - public static void verifyList(List actual, - List expected) { - Assert.assertEquals("Reaction count", expected.size(), actual.size()); - for (int index = 0; index < actual.size(); ++index) { - expected.get(index).verify(actual.get(index)); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AnyGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AnyGenerator.java deleted file mode 100644 index 104a4539d..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AnyGenerator.java +++ /dev/null @@ -1,148 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.hl7.fhir.dstu3.model.Attachment; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.DateTimeType; -import org.hl7.fhir.dstu3.model.Quantity; -import org.hl7.fhir.dstu3.model.Range; -import org.hl7.fhir.dstu3.model.Ratio; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class AnyGenerator { - private CDGenerator cdGenerator; - private PQGenerator pqGenerator; - private STGenerator stGenerator; - private IVL_PQRangeGenerator ivlPqGenerator; - private RTOGenerator rtoGenerator; - private EDGenerator edGenerator; - private TSGenerator tsGenerator; - private BLGenerator blGenerator; - - public AnyGenerator(CDGenerator cdGenerator) { - this.cdGenerator = cdGenerator; - } - - public AnyGenerator(PQGenerator pqGenerator) { - this.pqGenerator = pqGenerator; - } - - public AnyGenerator(STGenerator stGenerator) { - this.stGenerator = stGenerator; - } - - public AnyGenerator(IVL_PQRangeGenerator ivlPqGenerator) { - this.ivlPqGenerator = ivlPqGenerator; - } - - public AnyGenerator(RTOGenerator rtoGenerator) { - this.rtoGenerator = rtoGenerator; - } - - public AnyGenerator(EDGenerator edGenerator) { - this.edGenerator = edGenerator; - } - - public AnyGenerator(TSGenerator tsGenerator) { - this.tsGenerator = tsGenerator; - } - - public AnyGenerator(BLGenerator blGenerator) { - this.blGenerator = blGenerator; - } - - public ANY generate(CDAFactories factories) { - if (cdGenerator != null) { - return cdGenerator.generate(factories); - } - if (pqGenerator != null) { - return pqGenerator.generate(factories); - } - if (stGenerator != null) { - return stGenerator.generate(factories); - } - if (ivlPqGenerator != null) { - return ivlPqGenerator.generate(factories); - } - if (rtoGenerator != null) { - return rtoGenerator.generate(factories); - } - if (edGenerator != null) { - return edGenerator.generate(factories); - } - if (tsGenerator != null) { - return tsGenerator.generate(factories); - } - if (blGenerator != null) { - return blGenerator.generate(factories); - } - - return null; - } - - public void verify(CodeableConcept codeableConcept) { - if (cdGenerator == null) { - Assert.assertNull("No codeable concept", codeableConcept); - } else { - cdGenerator.verify(codeableConcept); - } - } - - public void verify(Quantity quantity) { - if (pqGenerator == null) { - Assert.assertNull("No quantity", quantity); - } else { - pqGenerator.verify(quantity); - } - } - - public void verify(String string) { - if (stGenerator == null) { - Assert.assertNull("No string", string); - } else { - stGenerator.verify(string); - } - } - - public void verify(Range range) { - if (ivlPqGenerator == null) { - Assert.assertNull("No range", range); - } else { - ivlPqGenerator.verify(range); - } - } - - public void verify(Ratio ratio) { - if (rtoGenerator == null) { - Assert.assertNull("No ratio", ratio); - } else { - rtoGenerator.verify(ratio); - } - } - - public void verify(Attachment attachment) { - if (edGenerator == null) { - Assert.assertNull("No attachement", attachment); - } else { - edGenerator.verify(attachment.getData()); - } - } - - public void verify(DateTimeType dateTime) { - if (tsGenerator == null) { - Assert.assertNull("No date time", dateTime); - } else { - tsGenerator.verify(dateTime.getValueAsString()); - } - } - - public void verify(boolean bl) { - if (blGenerator == null) { - Assert.assertNull("No boolean", bl); - } else { - blGenerator.verify(bl); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AssignedEntityGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AssignedEntityGenerator.java deleted file mode 100644 index f45ca412f..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AssignedEntityGenerator.java +++ /dev/null @@ -1,78 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.openhealthtools.mdht.uml.cda.AssignedEntity; -import org.openhealthtools.mdht.uml.cda.Organization; -import org.openhealthtools.mdht.uml.cda.Person; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class AssignedEntityGenerator extends EntityGenerator { - private static class CDAEntity implements ICDAEntity { - private AssignedEntity entity; - - public CDAEntity(AssignedEntity entity) { - this.entity = entity; - } - - @Override - public void addII(II ii) { - entity.getIds().add(ii); - - } - - @Override - public void setCode(CE ce) { - entity.setCode(ce); - } - - @Override - public void setPerson(Person person) { - entity.setAssignedPerson(person); - } - - @Override - public void setOrganization(Organization organization) { - entity.getRepresentedOrganizations().add(organization); - } - - @Override - public void addAD(AD ad) { - entity.getAddrs().add(ad); - } - - @Override - public void addTEL(TEL tel) { - entity.getTelecoms().add(tel); - } - } - - public AssignedEntityGenerator() { - } - - public AssignedEntityGenerator(EntityGenerator generator) { - super(generator); - } - - public AssignedEntity generate(CDAFactories factories) { - AssignedEntity entity = factories.base.createAssignedEntity(); - fillEntity(factories, new CDAEntity(entity)); - return entity; - } - - public static AssignedEntityGenerator getDefaultInstance() { - AssignedEntityGenerator aeg = new AssignedEntityGenerator(); - fillDefaultInstance(aeg); - return aeg; - } - - public static AssignedEntityGenerator getFullInstance() { - AssignedEntityGenerator aeg = new AssignedEntityGenerator(); - fillFullInstance(aeg); - return aeg; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AuthorGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AuthorGenerator.java deleted file mode 100644 index 5e3315d8f..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/AuthorGenerator.java +++ /dev/null @@ -1,99 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.openhealthtools.mdht.uml.cda.AssignedAuthor; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.Organization; -import org.openhealthtools.mdht.uml.cda.Person; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.datatypes.TS; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class AuthorGenerator extends EntityGenerator { - - private static class CDAEntity implements ICDAEntity { - private AssignedAuthor assignedAuthor; - - public CDAEntity(AssignedAuthor assignedAuthor) { - this.assignedAuthor = assignedAuthor; - } - - @Override - public void addII(II ii) { - assignedAuthor.getIds().add(ii); - - } - - @Override - public void setCode(CE ce) { - assignedAuthor.setCode(ce); - - } - - @Override - public void setPerson(Person person) { - assignedAuthor.setAssignedPerson(person); - - } - - @Override - public void setOrganization(Organization organization) { - assignedAuthor.setRepresentedOrganization(organization); - - } - - @Override - public void addAD(AD ad) { - assignedAuthor.getAddrs().add(ad); - } - - @Override - public void addTEL(TEL tel) { - assignedAuthor.getTelecoms().add(tel); - } - } - - private TSGenerator timeGenerator; - - public void setTimeGenerator(TSGenerator timeGenerator) { - this.timeGenerator = timeGenerator; - } - - public TSGenerator getTimeGenerator() { - return this.timeGenerator; - } - - public Author generate(CDAFactories factories) { - AssignedAuthor assignedAuthor = factories.base.createAssignedAuthor(); - - Author author = factories.base.createAuthor(); - - if (timeGenerator != null) { - TS ts = timeGenerator.generate(factories); - author.setTime(ts); - } - - author.setAssignedAuthor(assignedAuthor); - fillEntity(factories, new CDAEntity(assignedAuthor)); - return author; - } - - public static AuthorGenerator getDefaultInstance() { - AuthorGenerator ag = new AuthorGenerator(); - - fillDefaultInstance(ag); - - return ag; - } - - public static AuthorGenerator getFullInstance() { - AuthorGenerator ag = new AuthorGenerator(); - - fillFullInstance(ag); - - return ag; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/BLGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/BLGenerator.java deleted file mode 100644 index 1619731ce..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/BLGenerator.java +++ /dev/null @@ -1,44 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.BL; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; - -public class BLGenerator { - private Boolean value; - private String nullFlavor; - - public BLGenerator(boolean value) { - this.value = value; - } - - public void setNullFlavor(String nullFlavor) { - this.nullFlavor = nullFlavor; - } - - public BL generate(CDAFactories factories) { - BL bl = factories.datatype.createBL(value); - - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - bl.setNullFlavor(nf); - } - - return bl; - } - - public static BLGenerator getNextInstance() { - return new BLGenerator(true); - } - - public void verify(Boolean v) { - if (value == null || nullFlavor != null) { - Assert.assertNull("No boolean", v); - } else { - Assert.assertEquals("BL value", value.booleanValue(), v.booleanValue()); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/BaseStringGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/BaseStringGenerator.java deleted file mode 100644 index b492b3744..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/BaseStringGenerator.java +++ /dev/null @@ -1,96 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.StringType; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; - -public abstract class BaseStringGenerator { - private static int INDEX = 1; - - private String value; - private String nullFlavor; - private boolean nullFlavorOK = false; - - public BaseStringGenerator(boolean nullFlavorOK) { - this.nullFlavorOK = nullFlavorOK; - } - - public BaseStringGenerator(String value) { - this.value = value; - } - - public BaseStringGenerator(String value, boolean nullFlavorOK) { - this.value = value; - this.nullFlavorOK = nullFlavorOK; - } - - public void setNullFlavor(String nullFlavor) { - this.nullFlavor = nullFlavor; - } - - protected abstract T create(CDAFactories factories); - - public T generate(CDAFactories factories) { - T t = create(factories); - - if (value != null) { - t.addText(value); - } - - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - t.setNullFlavor(nf); - } - - return t; - } - - public String getValue() { - return this.value; - } - - public static String getNextValue() { - String value = "CDA Text " + INDEX; - ++INDEX; - return value; - } - - public void verify(String text) { - if (!hasValue()) { - Assert.assertNull("No text", text); - } else { - Assert.assertEquals("Text", value, text); - } - } - - public boolean hasValue() { - return value != null && (nullFlavorOK || nullFlavor == null); - } - - public static void verifyList(List actual, - List> expected) { - int actualIndex = 0; - for (BaseStringGenerator expectedElement : expected) { - if (expectedElement.hasValue()) { - StringType actualElement = actual.get(actualIndex); - Assert.assertNotNull("String type element exists", actualElement); - expectedElement.verify(actualElement.asStringValue()); - ++actualIndex; - } - } - if (actualIndex > 0) { - Assert.assertEquals("String type count", actualIndex, actual.size()); - } else { - Assert.assertTrue("Default element", actual.size() <= 1); - if (actual.size() == 1) { - Assert.assertTrue("No string type", !actual.get(0).hasValue()); - } - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CCDGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CCDGenerator.java deleted file mode 100644 index 26c664a2d..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CCDGenerator.java +++ /dev/null @@ -1,640 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.AllergyIntolerance; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Composition; -import org.hl7.fhir.dstu3.model.Composition.CompositionAttestationMode; -import org.hl7.fhir.dstu3.model.Composition.CompositionAttesterComponent; -import org.hl7.fhir.dstu3.model.Composition.CompositionEventComponent; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.hl7.fhir.dstu3.model.Encounter; -import org.hl7.fhir.dstu3.model.Identifier; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.hl7.fhir.dstu3.model.Patient; -import org.hl7.fhir.dstu3.model.Procedure; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.AssignedCustodian; -import org.openhealthtools.mdht.uml.cda.AssignedEntity; -import org.openhealthtools.mdht.uml.cda.Authenticator; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.Component2; -import org.openhealthtools.mdht.uml.cda.Component3; -import org.openhealthtools.mdht.uml.cda.Custodian; -import org.openhealthtools.mdht.uml.cda.CustodianOrganization; -import org.openhealthtools.mdht.uml.cda.DocumentationOf; -import org.openhealthtools.mdht.uml.cda.Entry; -import org.openhealthtools.mdht.uml.cda.LegalAuthenticator; -import org.openhealthtools.mdht.uml.cda.PatientRole; -import org.openhealthtools.mdht.uml.cda.RecordTarget; -import org.openhealthtools.mdht.uml.cda.StructuredBody; -import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; -import org.openhealthtools.mdht.uml.cda.consol.AllergiesSection; -import org.openhealthtools.mdht.uml.cda.consol.AllergyProblemAct; -import org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument; -import org.openhealthtools.mdht.uml.cda.consol.EncounterActivities; -import org.openhealthtools.mdht.uml.cda.consol.EncountersSection; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationsSection; -import org.openhealthtools.mdht.uml.cda.consol.MedicationsSection; -import org.openhealthtools.mdht.uml.cda.consol.ProblemConcernAct; -import org.openhealthtools.mdht.uml.cda.consol.ProblemSection; -import org.openhealthtools.mdht.uml.cda.consol.ProcedureActivityProcedure; -import org.openhealthtools.mdht.uml.cda.consol.ProceduresSection; -import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.ResultsSection; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsOrganizer; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsSection; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class CCDGenerator { - private IDGenerator idGenerator; - private TSGenerator effectiveTimeGenerator; - private CEGenerator codeGenerator; - private STGenerator titleGenerator; - private CEGenerator confidentialityGenerator; - - private AuthorGenerator authorGenerator; - private AssignedEntityGenerator legalAuthenticatorGenerator; - private TSGenerator legalAuthenticatorTimeGenerator; - private List authenticatorGenerators = new ArrayList<>(); - private List authenticatorTimeGenerators = new ArrayList<>(); - private List documentOfGenerators = new ArrayList<>(); - private CustodianOrganizationGenerator organizationGenerator; - - private PatientRoleGenerator patientRoleGenerator; - - private List allergyGenerators = new ArrayList<>(); - private List medActivityGenerators = new ArrayList<>(); - private List immActivityGenerators = new ArrayList<>(); - private List resultGenerators = new ArrayList<>(); - private List vitalsGenerators = new ArrayList<>(); - private List problemListGenerators = new ArrayList<>(); - private List procedureGenerators = new ArrayList<>(); - private List encounterGenerators = new ArrayList<>(); - - public AuthorGenerator getAuthorGenerator() { - return authorGenerator; - } - - public void setLegalAuthenticatorGenerator(AssignedEntityGenerator generator) { - this.legalAuthenticatorGenerator = generator; - } - - public ContinuityOfCareDocument generate(CDAFactories factories) { - ContinuityOfCareDocument ccd = factories.consol.createContinuityOfCareDocument(); - - if (idGenerator != null) { - ccd.setId(idGenerator.generate(factories)); - } - - if (effectiveTimeGenerator != null) { - ccd.setEffectiveTime(effectiveTimeGenerator.generate(factories)); - } - - if (codeGenerator != null) { - ccd.setCode(codeGenerator.generate(factories)); - } - - if (titleGenerator != null) { - ccd.setTitle(titleGenerator.generate(factories)); - } - - if (confidentialityGenerator != null) { - CE ce = confidentialityGenerator.generate(factories); - ccd.setConfidentialityCode(ce); - } - - if (authorGenerator != null) { - Author author = authorGenerator.generate(factories); - ccd.getAuthors().add(author); - } - - if (legalAuthenticatorGenerator != null) { - LegalAuthenticator legalAuthenticator = factories.base.createLegalAuthenticator(); - AssignedEntity ae = legalAuthenticatorGenerator.generate(factories); - legalAuthenticator.setAssignedEntity(ae); - if (legalAuthenticatorTimeGenerator != null) { - legalAuthenticator.setTime(legalAuthenticatorTimeGenerator.generate(factories)); - } - ccd.setLegalAuthenticator(legalAuthenticator); - } - - for (int index = 0; index < authenticatorGenerators.size(); ++index) { - AssignedEntityGenerator ag = authenticatorGenerators.get(index); - Authenticator authenticator = factories.base.createAuthenticator(); - AssignedEntity ae = ag.generate(factories); - authenticator.setAssignedEntity(ae); - - TSGenerator tsg = authenticatorTimeGenerators.get(index); - if (tsg != null) { - authenticator.setTime(tsg.generate(factories)); - } - - ccd.getAuthenticators().add(authenticator); - } - - documentOfGenerators.forEach(dog -> { - DocumentationOf docOf = dog.generate(factories); - ccd.getDocumentationOfs().add(docOf); - }); - - if (organizationGenerator != null) { - Custodian custodian = factories.base.createCustodian(); - AssignedCustodian assignedCustodian = factories.base.createAssignedCustodian(); - CustodianOrganization custodianOrganization = organizationGenerator.generate(factories); - assignedCustodian.setRepresentedCustodianOrganization(custodianOrganization); - custodian.setAssignedCustodian(assignedCustodian); - ccd.setCustodian(custodian); - } - - if (patientRoleGenerator != null) { - PatientRole patientRole = patientRoleGenerator.generate(factories); - RecordTarget recordTarget = factories.base.createRecordTarget(); - recordTarget.setPatientRole(patientRole); - ccd.getRecordTargets().add(recordTarget); - } - - if (!allergyGenerators.isEmpty()) { - AllergiesSection section = factories.consol.createAllergiesSection(); - CE ce = factories.datatype.createCE("48765-2", "2.16.840.1.113883.6.1"); - section.setCode(ce); - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.2.6.1"); - section.getTemplateIds().add(ii); - allergyGenerators.forEach(ag -> { - AllergyProblemAct act = ag.generate(factories); - Entry entry = factories.base.createEntry(); - entry.setAct(act); - section.getEntries().add(entry); - }); - Component3 component3 = factories.base.createComponent3(); - component3.setSection(section); - if (ccd.getComponent() == null) { - Component2 component2 = factories.base.createComponent2(); - StructuredBody structuredBody = factories.base.createStructuredBody(); - component2.setStructuredBody(structuredBody); - ccd.setComponent(component2); - structuredBody.getComponents().add(component3); - } else { - ccd.getComponent().getStructuredBody().getComponents().add(component3); - } - } - - if (!medActivityGenerators.isEmpty()) { - MedicationsSection section = factories.consol.createMedicationsSection(); - CE ce = factories.datatype.createCE("10160-0", "2.16.840.1.113883.6.1"); - section.setCode(ce); - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.2.1.1"); - section.getTemplateIds().add(ii); - medActivityGenerators.forEach(ma -> { - SubstanceAdministration sa = ma.generate(factories); - Entry entry = factories.base.createEntry(); - entry.setSubstanceAdministration(sa); - section.getEntries().add(entry); - }); - Component3 component3 = factories.base.createComponent3(); - component3.setSection(section); - if (ccd.getComponent() == null) { - Component2 component2 = factories.base.createComponent2(); - StructuredBody structuredBody = factories.base.createStructuredBody(); - component2.setStructuredBody(structuredBody); - ccd.setComponent(component2); - structuredBody.getComponents().add(component3); - } else { - ccd.getComponent().getStructuredBody().getComponents().add(component3); - } - } - - if (!immActivityGenerators.isEmpty()) { - ImmunizationsSection section = factories.consol.createImmunizationsSection(); - CE ce = factories.datatype.createCE("11369-6", "2.16.840.1.113883.6.1"); - section.setCode(ce); - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.2.2.1"); - section.getTemplateIds().add(ii); - immActivityGenerators.forEach(immg -> { - SubstanceAdministration sa = immg.generate(factories); - Entry entry = factories.base.createEntry(); - entry.setSubstanceAdministration(sa); - section.getEntries().add(entry); - }); - Component3 component3 = factories.base.createComponent3(); - component3.setSection(section); - if (ccd.getComponent() == null) { - Component2 component2 = factories.base.createComponent2(); - StructuredBody structuredBody = factories.base.createStructuredBody(); - component2.setStructuredBody(structuredBody); - ccd.setComponent(component2); - structuredBody.getComponents().add(component3); - } else { - ccd.getComponent().getStructuredBody().getComponents().add(component3); - } - } - - if (!resultGenerators.isEmpty()) { - ResultsSection section = factories.consol.createResultsSection(); - CE ce = factories.datatype.createCE("30954-2", "2.16.840.1.113883.6.1"); - section.setCode(ce); - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.2.3.1"); - section.getTemplateIds().add(ii); - resultGenerators.forEach(rg -> { - ResultOrganizer sa = rg.generate(factories); - Entry entry = factories.base.createEntry(); - entry.setOrganizer(sa); - section.getEntries().add(entry); - }); - Component3 component3 = factories.base.createComponent3(); - component3.setSection(section); - if (ccd.getComponent() == null) { - Component2 component2 = factories.base.createComponent2(); - StructuredBody structuredBody = factories.base.createStructuredBody(); - component2.setStructuredBody(structuredBody); - ccd.setComponent(component2); - structuredBody.getComponents().add(component3); - } else { - ccd.getComponent().getStructuredBody().getComponents().add(component3); - } - } - - if (!vitalsGenerators.isEmpty()) { - VitalSignsSection section = factories.consol.createVitalSignsSection(); - CE ce = factories.datatype.createCE("8716-3", "2.16.840.1.113883.6.1"); - section.setCode(ce); - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.2.4.1"); - section.getTemplateIds().add(ii); - vitalsGenerators.forEach(vg -> { - VitalSignsOrganizer vso = vg.generate(factories); - Entry entry = factories.base.createEntry(); - entry.setOrganizer(vso); - section.getEntries().add(entry); - }); - Component3 component3 = factories.base.createComponent3(); - component3.setSection(section); - if (ccd.getComponent() == null) { - Component2 component2 = factories.base.createComponent2(); - StructuredBody structuredBody = factories.base.createStructuredBody(); - component2.setStructuredBody(structuredBody); - ccd.setComponent(component2); - structuredBody.getComponents().add(component3); - } else { - ccd.getComponent().getStructuredBody().getComponents().add(component3); - } - } - - if (!problemListGenerators.isEmpty()) { - ProblemSection section = factories.consol.createProblemSection(); - CE ce = factories.datatype.createCE("11450-4", "2.16.840.1.113883.6.1"); - section.setCode(ce); - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.2.5.1"); - section.getTemplateIds().add(ii); - problemListGenerators.forEach(pg -> { - ProblemConcernAct pca = pg.generate(factories); - Entry entry = factories.base.createEntry(); - entry.setAct(pca); - section.getEntries().add(entry); - }); - Component3 component3 = factories.base.createComponent3(); - component3.setSection(section); - if (ccd.getComponent() == null) { - Component2 component2 = factories.base.createComponent2(); - StructuredBody structuredBody = factories.base.createStructuredBody(); - component2.setStructuredBody(structuredBody); - ccd.setComponent(component2); - structuredBody.getComponents().add(component3); - } else { - ccd.getComponent().getStructuredBody().getComponents().add(component3); - } - } - - if (!procedureGenerators.isEmpty()) { - ProceduresSection section = factories.consol.createProceduresSection(); - CE ce = factories.datatype.createCE("47519-4", "2.16.840.1.113883.6.1"); - section.setCode(ce); - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.2.7.1"); - section.getTemplateIds().add(ii); - procedureGenerators.forEach(pg -> { - ProcedureActivityProcedure pa = pg.generate(factories); - Entry entry = factories.base.createEntry(); - entry.setProcedure(pa); - section.getEntries().add(entry); - }); - Component3 component3 = factories.base.createComponent3(); - component3.setSection(section); - if (ccd.getComponent() == null) { - Component2 component2 = factories.base.createComponent2(); - StructuredBody structuredBody = factories.base.createStructuredBody(); - component2.setStructuredBody(structuredBody); - ccd.setComponent(component2); - structuredBody.getComponents().add(component3); - } else { - ccd.getComponent().getStructuredBody().getComponents().add(component3); - } - } - - if (!encounterGenerators.isEmpty()) { - EncountersSection section = factories.consol.createEncountersSection(); - CE ce = factories.datatype.createCE("46240-8", "2.16.840.1.113883.6.1"); - section.setCode(ce); - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.2.22.1"); - section.getTemplateIds().add(ii); - encounterGenerators.forEach(eg -> { - EncounterActivities ee = eg.generate(factories); - Entry entry = factories.base.createEntry(); - entry.setEncounter(ee); - section.getEntries().add(entry); - }); - Component3 component3 = factories.base.createComponent3(); - component3.setSection(section); - if (ccd.getComponent() == null) { - Component2 component2 = factories.base.createComponent2(); - StructuredBody structuredBody = factories.base.createStructuredBody(); - component2.setStructuredBody(structuredBody); - ccd.setComponent(component2); - structuredBody.getComponents().add(component3); - } else { - ccd.getComponent().getStructuredBody().getComponents().add(component3); - } - } - - return ccd; - } - - public static CCDGenerator getDefaultInstance() { - CCDGenerator generator = new CCDGenerator(); - - generator.idGenerator = IDGenerator.getNextInstance(); - generator.effectiveTimeGenerator = TSGenerator.getNextInstance(); - generator.codeGenerator = CEGenerator.getNextInstance(); - generator.titleGenerator = STGenerator.getNextInstance(); - generator.confidentialityGenerator = new CEGenerator("L"); - generator.authorGenerator = AuthorGenerator.getDefaultInstance(); - generator.legalAuthenticatorGenerator = AssignedEntityGenerator.getDefaultInstance(); - generator.legalAuthenticatorTimeGenerator = TSGenerator.getNextInstance(); - generator.authenticatorGenerators.add(AssignedEntityGenerator.getDefaultInstance()); - generator.authenticatorTimeGenerators.add(TSGenerator.getNextInstance()); - generator.documentOfGenerators.add(DocumentationOfGenerator.getDefaultInstance()); - generator.organizationGenerator = CustodianOrganizationGenerator.getDefaultInstance(); - generator.patientRoleGenerator = PatientRoleGenerator.getDefaultInstance(); - generator.allergyGenerators.add(AllergyConcernActGenerator.getDefaultInstance()); - generator.medActivityGenerators.add(MedicationActivityGenerator.getDefaultInstance()); - generator.immActivityGenerators.add(ImmunizationActivityGenerator.getDefaultInstance()); - generator.resultGenerators.add(ResultOrganizerGenerator.getDefaultInstance()); - generator.vitalsGenerators.add(VitalSignsOrganizerGenerator.getDefaultInstance()); - generator.problemListGenerators.add(ProblemConcernActGenerator.getDefaultInstance()); - generator.encounterGenerators.add(EncounterActivityGenerator.getDefaultInstance()); - generator.procedureGenerators.add(ProcedureActivityProcedureGenerator.getDefaultInstance()); - - return generator; - } - - public void verify(Composition composition) { - Assert.assertEquals("Composition status", "preliminary", composition.getStatus().toCode()); - - if (idGenerator == null) { - Assert.assertTrue("No composition identifier", !composition.hasIdentifier()); - } else { - Identifier identifier = composition.getIdentifier(); - idGenerator.verify(identifier); - } - - if (effectiveTimeGenerator == null) { - Assert.assertTrue("No composition date", !composition.hasDate()); - } else { - effectiveTimeGenerator.verify(composition.getDateElement().asStringValue()); - } - - if (codeGenerator == null) { - Assert.assertTrue("No composition type", !composition.hasType()); - } else { - codeGenerator.verify(composition.getType()); - } - - if (titleGenerator == null) { - Assert.assertTrue("No composition title", !composition.hasTitle()); - } else { - titleGenerator.verify(composition.getTitle()); - } - - if (confidentialityGenerator == null) { - Assert.assertTrue("No composition confidentiality", !composition.hasConfidentiality()); - } else { - String actual = composition.getConfidentiality().toCode(); - Assert.assertEquals("Composition confidentiality code", confidentialityGenerator.getCode(), actual); - } - } - - private Composition.SectionComponent findCompositionSection(Composition composition, String sectionCode) { - for (Composition.SectionComponent section : composition.getSection()) { - if (section.hasCode()) { - List codings = section.getCode().getCoding(); - if (!codings.isEmpty()) { - Coding coding = codings.get(0); - String code = coding.getCode(); - if (sectionCode.equals(code)) { - return section; - } - } - } - } - return null; - } - - public void verify(Bundle bundle) throws Exception { - Composition composition = BundleUtil.findOneResource(bundle, Composition.class); - - verify(composition); - - BundleUtil bundleUtil = new BundleUtil(bundle); - - if (authorGenerator == null) { - Assert.assertTrue("No composition author", !composition.hasAuthor()); - } else { - String practitionerId = composition.getAuthor().get(0).getReference(); - authorGenerator.verifyFromPractionerId(bundle, practitionerId); - } - - if (legalAuthenticatorGenerator == null && authenticatorGenerators.isEmpty()) { - Assert.assertTrue("No composition attester", !composition.hasAttester()); - } else { - int count = authenticatorGenerators.size() + (legalAuthenticatorGenerator == null ? 0 : 1); - Assert.assertEquals("Attester count", count, composition.getAttester().size()); - - List attesters = composition.getAttester(); - - int authenticatorIndex = 0; - for (int index = 0; index < count; ++index) { - CompositionAttesterComponent attester = attesters.get(index); - CompositionAttestationMode mode = attester.getMode().get(0).getValue(); - if (mode == CompositionAttestationMode.LEGAL) { - Assert.assertNotNull("Legal asserter expected", legalAuthenticatorGenerator); - String attesterId = attester.getParty().getReference(); - legalAuthenticatorGenerator.verifyFromPractionerId(bundle, attesterId); - if (legalAuthenticatorTimeGenerator == null) { - Assert.assertTrue("No legal attester time", !attester.hasTime()); - } else { - legalAuthenticatorTimeGenerator.verify(attester.getTimeElement().asStringValue()); - } - } else { - String attesterId = attester.getParty().getReference(); - Assert.assertTrue("Mode professional", CompositionAttestationMode.PROFESSIONAL == mode); - authenticatorGenerators.get(authenticatorIndex).verifyFromPractionerId(bundle, attesterId); - TSGenerator tsg = authenticatorTimeGenerators.get(authenticatorIndex); - if (tsg == null) { - Assert.assertTrue("No attester time", !attester.hasTime()); - } else { - tsg.verify(attester.getTimeElement().asStringValue()); - } - - authenticatorIndex += 1; - } - } - } - - if (documentOfGenerators.isEmpty()) { - Assert.assertTrue("No event", !composition.hasEvent()); - } else { - int count = documentOfGenerators.size(); - Assert.assertEquals("Documentation of count", count, composition.getEvent().size()); - List events = composition.getEvent(); - for (int index = 0; index < count; ++index) { - CompositionEventComponent event = events.get(index); - documentOfGenerators.get(index).verify(bundle, event); - } - } - - if (organizationGenerator == null) { - Assert.assertTrue("No custodian", !composition.hasCustodian()); - } else { - String organizationId = composition.getCustodian().getReference(); - org.hl7.fhir.dstu3.model.Organization organization = bundleUtil.getResourceFromReference(organizationId, - org.hl7.fhir.dstu3.model.Organization.class); - organizationGenerator.verify(organization); - } - - if (patientRoleGenerator == null) { - Assert.assertTrue("No subject", !composition.hasSubject()); - } else { - String patientId = composition.getSubject().getReference(); - Patient patient = bundleUtil.getResourceFromReference(patientId, Patient.class); - Assert.assertNotNull("Patient exists", patient); - patientRoleGenerator.verify(bundle); - } - - Composition.SectionComponent allergiesSection = findCompositionSection(composition, "48765-2"); - if (allergyGenerators.isEmpty()) { - Assert.assertTrue("No allergies section", allergiesSection == null || !allergiesSection.hasEntry()); - } else { - Assert.assertNotNull("Allergies section exists", allergiesSection); - int count = allergyGenerators.size(); - Assert.assertEquals("Allergies entry count", count, allergiesSection.getEntry().size()); - for (int index = 0; index < count; ++index) { - String reference = allergiesSection.getEntry().get(index).getReference(); - AllergyIntolerance allergy = bundleUtil.getResourceFromReference(reference, AllergyIntolerance.class); - allergyGenerators.get(index).verify(bundle, allergy); - } - } - - Composition.SectionComponent medicationsSection = findCompositionSection(composition, "10160-0"); - if (medActivityGenerators.isEmpty()) { - Assert.assertTrue("No medications section", medicationsSection == null || !medicationsSection.hasEntry()); - } else { - Assert.assertNotNull("MedicationsSection section exists", medicationsSection); - int count = medActivityGenerators.size(); - Assert.assertEquals("Medication entry count", count, medicationsSection.getEntry().size()); - for (int index = 0; index < count; ++index) { - String reference = medicationsSection.getEntry().get(index).getReference(); - MedicationStatement medStatement = bundleUtil.getResourceFromReference(reference, - MedicationStatement.class); - medActivityGenerators.get(index).verify(bundle, medStatement); - } - } - - Composition.SectionComponent immunizationsSection = findCompositionSection(composition, "11369-6"); - if (immActivityGenerators.isEmpty()) { - Assert.assertTrue("No immunizations section", - immunizationsSection == null || !immunizationsSection.hasEntry()); - } else { - Assert.assertNotNull("ImmunizationsSection section exists", immunizationsSection); - int count = immActivityGenerators.size(); - Assert.assertEquals("Immunization entry count", count, immunizationsSection.getEntry().size()); - for (int index = 0; index < count; ++index) { - String reference = immunizationsSection.getEntry().get(index).getReference(); - Immunization immunization = bundleUtil.getResourceFromReference(reference, Immunization.class); - immActivityGenerators.get(index).verify(bundle, immunization); - } - } - - Composition.SectionComponent resultsSection = findCompositionSection(composition, "30954-2"); - if (resultGenerators.isEmpty()) { - Assert.assertTrue("No result section", resultsSection == null || !resultsSection.hasEntry()); - } else { - Assert.assertNotNull("ResultsSection section exists", resultsSection); - int count = resultGenerators.size(); - Assert.assertEquals("Results entry count", count, resultsSection.getEntry().size()); - for (int index = 0; index < count; ++index) { - String reference = resultsSection.getEntry().get(index).getReference(); - DiagnosticReport report = bundleUtil.getResourceFromReference(reference, DiagnosticReport.class); - resultGenerators.get(index).verify(bundle, report); - } - } - - Composition.SectionComponent proceduresSection = findCompositionSection(composition, "47519-4"); - if (procedureGenerators.isEmpty()) { - Assert.assertTrue("No procedure section", proceduresSection == null || !proceduresSection.hasEntry()); - } else { - Assert.assertNotNull("Procedures section exists", proceduresSection); - int count = procedureGenerators.size(); - Assert.assertEquals("Procedures entry count", count, proceduresSection.getEntry().size()); - for (int index = 0; index < count; ++index) { - String reference = proceduresSection.getEntry().get(index).getReference(); - Procedure procedure = bundleUtil.getResourceFromReference(reference, Procedure.class); - procedureGenerators.get(index).verify(bundle, procedure); - } - } - - Composition.SectionComponent encountersSection = findCompositionSection(composition, "46240-8"); - if (encounterGenerators.isEmpty()) { - Assert.assertTrue("No encounter section", encountersSection == null || !encountersSection.hasEntry()); - } else { - Assert.assertNotNull("Encounters ection sexists", encountersSection); - int count = encounterGenerators.size(); - Assert.assertEquals("Results entry count", count, encountersSection.getEntry().size()); - for (int index = 0; index < count; ++index) { - String reference = encountersSection.getEntry().get(index).getReference(); - Encounter encounter = bundleUtil.getResourceFromReference(reference, Encounter.class); - encounterGenerators.get(index).verify(bundle, encounter); - } - } - - Composition.SectionComponent vitalsSection = findCompositionSection(composition, "8716-3"); - if (vitalsGenerators.isEmpty()) { - Assert.assertTrue("No vitals section", vitalsSection == null || !vitalsSection.hasEntry()); - } else { - Assert.assertNotNull("Vitals Section section exists", vitalsSection); - int count = vitalsGenerators.size(); - Assert.assertEquals("Vitals entry count", count, vitalsSection.getEntry().size()); - } - - Composition.SectionComponent problemListSection = findCompositionSection(composition, "11450-4"); - if (problemListSection.isEmpty()) { - Assert.assertTrue("No problem section", problemListSection == null || !problemListSection.hasEntry()); - } else { - Assert.assertNotNull("ProblemListSection section exists", problemListSection); - int count = problemListGenerators.size(); - Assert.assertEquals("Problem List entry count", count, problemListSection.getEntry().size()); - for (int index = 0; index < count; ++index) { - String reference = problemListSection.getEntry().get(index).getReference(); - Condition condition = bundleUtil.getResourceFromReference(reference, Condition.class); - Assert.assertNotNull("Condition exists", condition); - } - } - - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAEncouncersSectionComponentGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAEncouncersSectionComponentGenerator.java deleted file mode 100644 index 688f4228f..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAEncouncersSectionComponentGenerator.java +++ /dev/null @@ -1,51 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.openhealthtools.mdht.uml.cda.Component3; -import org.openhealthtools.mdht.uml.cda.consol.ProblemSection; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.vocab.ActClass; -import org.openhealthtools.mdht.uml.hl7.vocab.ActMood; -import org.openhealthtools.mdht.uml.hl7.vocab.ActRelationshipHasComponent; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class CDAEncouncersSectionComponentGenerator { - private List encounterGenerators; - static final public String DEFAULT_TEMPLATE_ID = "2.16.840.1.113883.10.20.22.2.22.1"; - static final public String DEFAULT_TEMPLATE_ID_EXT = "2019-01-01"; - static final public String DEFAULT_CODE = "46240-8"; - static final public String DEFAULT_CODE_SYSTEM = "2.16.840.1.113883.6.1"; - static final public String DEFAULT_DISPLAY_NAME = "History of encounters"; - static final public String DEFAULT_CODE_SYSTEM_NAME = "LOINC"; - - public Component3 generate(CDAFactories factories) { - - Component3 component = factories.base.createComponent3(); - component.setTypeCode(ActRelationshipHasComponent.COMP); - ProblemSection section = factories.consol.createProblemSection(); - CE code = factories.datatype.createCE(DEFAULT_CODE, DEFAULT_CODE_SYSTEM, DEFAULT_CODE_SYSTEM_NAME, - DEFAULT_DISPLAY_NAME); - II templateId = factories.datatype.createII(DEFAULT_TEMPLATE_ID, DEFAULT_TEMPLATE_ID_EXT); - section.setClassCode(ActClass.DOCSECT); - section.setMoodCode(ActMood.EVN); - section.setCode(code); - section.getTemplateIds().add(templateId); - - if (encounterGenerators != null && !encounterGenerators.isEmpty()) { - for (EncounterActivityGenerator encounterGen : encounterGenerators) { - section.addEncounter(encounterGen.generate(factories)); - } - } - - component.setSection(section); - return component; - } - - public void setEncounterActivities(List encounterGens) { - this.encounterGenerators = encounterGens; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAImmunizationSectionComponentGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAImmunizationSectionComponentGenerator.java deleted file mode 100644 index 17fa7fb4a..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAImmunizationSectionComponentGenerator.java +++ /dev/null @@ -1,55 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.openhealthtools.mdht.uml.cda.Component3; -import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationsSection; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.vocab.ActClass; -import org.openhealthtools.mdht.uml.hl7.vocab.ActMood; -import org.openhealthtools.mdht.uml.hl7.vocab.ActRelationshipHasComponent; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class CDAImmunizationSectionComponentGenerator { - - private List substanceAdministrations; - static final public String DEFAULT_TEMPLATE_ID = "2.16.840.1.113883.10.20.22.2.2.1"; - static final public String DEFAULT_TEMPLATE_ID_EXT = "2019-01-01"; - static final public String DEFAULT_CODE = "11369-6"; - static final public String DEFAULT_CODE_SYSTEM = "2.16.840.1.113883.6.1"; - static final public String DEFAULT_DISPLAY_NAME = "History of Immunization Narrative"; - static final public String DEFAULT_CODE_SYSTEM_NAME = "LOINC"; - static final public String DEFAULT_ID = "D0FA39F0-3099-11E9-BCAA-5102195700F0"; - - public Component3 generate(CDAFactories factories) { - - Component3 component = factories.base.createComponent3(); - component.setTypeCode(ActRelationshipHasComponent.COMP); - ImmunizationsSection section = factories.consol.createImmunizationsSection(); - CE code = factories.datatype.createCE(DEFAULT_CODE, DEFAULT_CODE_SYSTEM, DEFAULT_CODE_SYSTEM_NAME, - DEFAULT_DISPLAY_NAME); - II templateId = factories.datatype.createII(DEFAULT_TEMPLATE_ID, DEFAULT_TEMPLATE_ID_EXT); - section.setClassCode(ActClass.DOCSECT); - section.setMoodCode(ActMood.EVN); - section.setCode(code); - section.getTemplateIds().add(templateId); - section.setId(factories.datatype.createII(DEFAULT_ID)); - - if (substanceAdministrations != null && !substanceAdministrations.isEmpty()) { - for (SubstanceAdministration sa : substanceAdministrations) { - section.addSubstanceAdministration(sa); - } - } - - component.setSection(section); - return component; - } - - public void setSubstanceAdministrations(List substanceAdministrations) { - this.substanceAdministrations = substanceAdministrations; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAMedicationSectionComponentGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAMedicationSectionComponentGenerator.java deleted file mode 100644 index 663e7692f..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAMedicationSectionComponentGenerator.java +++ /dev/null @@ -1,53 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.openhealthtools.mdht.uml.cda.Component3; -import org.openhealthtools.mdht.uml.cda.SubstanceAdministration; -import org.openhealthtools.mdht.uml.cda.consol.MedicationsSection; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.vocab.ActClass; -import org.openhealthtools.mdht.uml.hl7.vocab.ActMood; -import org.openhealthtools.mdht.uml.hl7.vocab.ActRelationshipHasComponent; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class CDAMedicationSectionComponentGenerator { - - private List substanceAdministrations; - static final public String DEFAULT_TEMPLATE_ID = "2.16.840.1.113883.10.20.22.2.1"; - static final public String DEFAULT_TEMPLATE_ID_EXT = "2019-01-01"; - static final public String DEFAULT_CODE = "10160-0"; - static final public String DEFAULT_CODE_SYSTEM = "2.16.840.1.113883.6.1"; - static final public String DEFAULT_DISPLAY_NAME = "History of Medication Use"; - static final public String DEFAULT_CODE_SYSTEM_NAME = "LOINC"; - - public Component3 generate(CDAFactories factories) { - - Component3 component = factories.base.createComponent3(); - component.setTypeCode(ActRelationshipHasComponent.COMP); - MedicationsSection section = factories.consol.createMedicationsSection(); - CE code = factories.datatype.createCE(DEFAULT_CODE, DEFAULT_CODE_SYSTEM, DEFAULT_CODE_SYSTEM_NAME, - DEFAULT_DISPLAY_NAME); - II templateId = factories.datatype.createII(DEFAULT_TEMPLATE_ID, DEFAULT_TEMPLATE_ID_EXT); - section.setClassCode(ActClass.DOCSECT); - section.setMoodCode(ActMood.EVN); - section.setCode(code); - section.getTemplateIds().add(templateId); - - if (substanceAdministrations != null && !substanceAdministrations.isEmpty()) { - for (SubstanceAdministration sa : substanceAdministrations) { - section.addSubstanceAdministration(sa); - } - } - - component.setSection(section); - return component; - } - - public void setSubstanceAdministrations(List substanceAdministrations) { - this.substanceAdministrations = substanceAdministrations; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAProblemsListSectionComponentGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAProblemsListSectionComponentGenerator.java deleted file mode 100644 index 7fc2a9ed0..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDAProblemsListSectionComponentGenerator.java +++ /dev/null @@ -1,52 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.openhealthtools.mdht.uml.cda.Component3; -import org.openhealthtools.mdht.uml.cda.consol.ProblemSection; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.vocab.ActClass; -import org.openhealthtools.mdht.uml.hl7.vocab.ActMood; -import org.openhealthtools.mdht.uml.hl7.vocab.ActRelationshipHasComponent; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class CDAProblemsListSectionComponentGenerator { - - private List problemConcernActGens; - static final public String DEFAULT_TEMPLATE_ID = "2.16.840.1.113883.10.20.22.2.5.1"; - static final public String DEFAULT_TEMPLATE_ID_EXT = "2019-01-01"; - static final public String DEFAULT_CODE = "11450-4"; - static final public String DEFAULT_CODE_SYSTEM = "2.16.840.1.113883.6.1"; - static final public String DEFAULT_DISPLAY_NAME = "PROBLEM LIST"; - static final public String DEFAULT_CODE_SYSTEM_NAME = "LOINC"; - - public Component3 generate(CDAFactories factories) { - - Component3 component = factories.base.createComponent3(); - component.setTypeCode(ActRelationshipHasComponent.COMP); - ProblemSection section = factories.consol.createProblemSection(); - CE code = factories.datatype.createCE(DEFAULT_CODE, DEFAULT_CODE_SYSTEM, DEFAULT_CODE_SYSTEM_NAME, - DEFAULT_DISPLAY_NAME); - II templateId = factories.datatype.createII(DEFAULT_TEMPLATE_ID, DEFAULT_TEMPLATE_ID_EXT); - section.setClassCode(ActClass.DOCSECT); - section.setMoodCode(ActMood.EVN); - section.setCode(code); - section.getTemplateIds().add(templateId); - - if (problemConcernActGens != null && !problemConcernActGens.isEmpty()) { - for (ProblemConcernActGenerator actGen : problemConcernActGens) { - section.addAct(actGen.generate(factories)); - } - } - - component.setSection(section); - return component; - } - - public void setProblemConcernActsGenerators(List problemConcernActGens) { - this.problemConcernActGens = problemConcernActGens; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDASectionGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDASectionGenerator.java deleted file mode 100644 index 0b712eb39..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDASectionGenerator.java +++ /dev/null @@ -1,5 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -public class CDASectionGenerator { - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDGenerator.java deleted file mode 100644 index 99aab6859..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CDGenerator.java +++ /dev/null @@ -1,94 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class CDGenerator { - private static final String[] SYSTEMS = { "2.16.840.1.113883.6.96", "4.5.2.4", "4.1.12.67", "43.45.78.12" }; - - private static int NEXT_INDEX = 1; - - private String code; - private String codeSystem; - private String codeSystemName; - private String displayName; - - public CDGenerator(String code, String codeSystem, String codeSystemName, String displayName) { - this.code = code; - this.codeSystem = codeSystem; - this.codeSystemName = codeSystemName; - this.displayName = displayName; - } - - public CD generate(CDAFactories factories) { - CD cd = factories.datatype.createCD(); - - if (code != null) { - cd.setCode(code); - } - if (codeSystem != null) { - cd.setCodeSystem(codeSystem); - } - if (codeSystemName != null) { - cd.setCodeSystemName(codeSystemName); - } - if (displayName != null) { - cd.setDisplayName(displayName); - } - return cd; - } - - public void verify(CodeableConcept codeableConcept) { - List codings = codeableConcept.getCoding(); - Assert.assertEquals("Number of coding", 1, codings.size()); - - Coding coding = codings.get(0); - - if (code != null) { - Assert.assertEquals("Coding code", code, coding.getCode()); - } else { - Assert.assertTrue("Missing coding code", !coding.hasCode()); - } - - if (displayName != null) { - Assert.assertEquals("Coding display", displayName, coding.getDisplay()); - } else { - Assert.assertTrue("Missing coding display", !coding.hasDisplay()); - } - - if (codeSystem != null) { - String system = codeSystem.equals("2.16.840.1.113883.6.96") ? "http://snomed.info/sct" - : "urn:oid:" + codeSystem; - Assert.assertEquals("Coding system", system, coding.getSystem()); - - } else { - Assert.assertTrue("Missing coding system", !coding.hasSystem()); - - } - } - - public static CDGenerator getNextInstance() { - int codeIndex = NEXT_INDEX % SYSTEMS.length; - ++NEXT_INDEX; - - String code = "code_" + String.valueOf(codeIndex); - String codeSystem = SYSTEMS[codeIndex]; - String codeSystemName = "systemname_" + String.valueOf(codeIndex); - String displayName = "display_" + codeIndex; - - return new CDGenerator(code, codeSystem, codeSystemName, displayName); - } - - public static void verifyList(List actual, List expected) { - Assert.assertEquals("Codeable concept count", expected.size(), actual.size()); - for (int index = 0; index < actual.size(); ++index) { - expected.get(index).verify(actual.get(index)); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CECodeGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CECodeGenerator.java deleted file mode 100644 index 095d83fc0..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CECodeGenerator.java +++ /dev/null @@ -1,22 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.Map; - -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class CECodeGenerator extends CodeGenerator { - public CECodeGenerator(Map map, String defaultCode) { - super(map, defaultCode); - } - - public CECodeGenerator(Map map) { - super(map); - } - - @Override - protected CE create(CDAFactories factories) { - return factories.datatype.createCE(); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CEGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CEGenerator.java deleted file mode 100644 index 980502cb0..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CEGenerator.java +++ /dev/null @@ -1,95 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class CEGenerator { - private static final String[] SYSTEMS = { "2.16.840.1.113883.6.96", "4.5.2.4", "4.1.12.67", "43.45.78.12", - "3.5.6.8", "12.12.12.1", "9.0.3.6", "12.34.56.78", "3.4.5.2", "9.98.0.9", "12.11.45.33" }; - - private static int NEXT_INDEX = 100; - - private String code; - private String codeSystem; - private String codeSystemName; - private String displayName; - - public CEGenerator(String code) { - this.code = code; - } - - public CEGenerator(String code, String codeSystem, String codeSystemName, String displayName) { - this.code = code; - this.codeSystem = codeSystem; - this.codeSystemName = codeSystemName; - this.displayName = displayName; - } - - public String getCode() { - return this.code; - } - - public CE generate(CDAFactories factories) { - CE ce = factories.datatype.createCE(); - - if (code != null) { - ce.setCode(code); - } - if (codeSystem != null) { - ce.setCodeSystem(codeSystem); - } - if (codeSystemName != null) { - ce.setCodeSystemName(codeSystemName); - } - if (displayName != null) { - ce.setDisplayName(displayName); - } - return ce; - } - - public void verify(CodeableConcept codeableConcept) { - List codings = codeableConcept.getCoding(); - Assert.assertEquals("Number of coding", 1, codings.size()); - - Coding coding = codings.get(0); - - if (code != null) { - Assert.assertEquals("Coding code", code, coding.getCode()); - } else { - Assert.assertTrue("Missing coding code", !coding.hasCode()); - } - - if (displayName != null) { - Assert.assertEquals("Coding display", displayName, coding.getDisplay()); - } else { - Assert.assertTrue("Missing coding display", !coding.hasDisplay()); - } - - if (codeSystem != null) { - String system = codeSystem.equals("2.16.840.1.113883.6.96") ? "http://snomed.info/sct" - : "urn:oid:" + codeSystem; - Assert.assertEquals("Coding system", system, coding.getSystem()); - - } else { - Assert.assertTrue("Missing coding system", !coding.hasSystem()); - } - } - - public static CEGenerator getNextInstance() { - int codeIndex = NEXT_INDEX % SYSTEMS.length; - ++NEXT_INDEX; - - String code = "code_" + String.valueOf(codeIndex); - String codeSystem = SYSTEMS[codeIndex]; - String codeSystemName = "systemname_" + String.valueOf(codeIndex); - String displayName = "display_" + codeIndex; - - return new CEGenerator(code, codeSystem, codeSystemName, displayName); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CSCodeGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CSCodeGenerator.java deleted file mode 100644 index b1aca3e94..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CSCodeGenerator.java +++ /dev/null @@ -1,32 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.Map; - -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class CSCodeGenerator extends CodeGenerator { - public CSCodeGenerator(String code) { - super(code); - } - - public CSCodeGenerator(Map map, String defaultCode) { - super(map, defaultCode); - } - - public CSCodeGenerator(Map map) { - super(map); - } - - @Override - protected CS create(CDAFactories factories) { - return factories.datatype.createCS(); - } - - public static CSCodeGenerator getInstanceWithValue(Map map, String value) { - CSCodeGenerator result = new CSCodeGenerator(map); - result.set(value); - return result; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ClinicalDocumentMetadataGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ClinicalDocumentMetadataGenerator.java deleted file mode 100644 index 299760609..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ClinicalDocumentMetadataGenerator.java +++ /dev/null @@ -1,188 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.openhealthtools.mdht.uml.cda.AssignedEntity; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.ClinicalDocument; -import org.openhealthtools.mdht.uml.cda.Component2; -import org.openhealthtools.mdht.uml.cda.Component3; -import org.openhealthtools.mdht.uml.cda.Custodian; -import org.openhealthtools.mdht.uml.cda.DocumentationOf; -import org.openhealthtools.mdht.uml.cda.PatientRole; -import org.openhealthtools.mdht.uml.cda.Performer1; -import org.openhealthtools.mdht.uml.cda.RecordTarget; -import org.openhealthtools.mdht.uml.cda.ServiceEvent; -import org.openhealthtools.mdht.uml.cda.StructuredBody; -import org.openhealthtools.mdht.uml.cda.consol.ContinuityOfCareDocument; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.INT; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.ST; -import org.openhealthtools.mdht.uml.hl7.datatypes.TS; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ClinicalDocumentMetadataGenerator { - - ContinuityOfCareDocument doc; - CDAFactories factories; - - private AssignedEntityGenerator assignedEntityGenerator = new AssignedEntityGenerator(); - - static final public String DEFAULT_REALM_CODE = "US"; - static final public String DEFAULT_ID_ROOT = "1.2.345.678901.7.89.10.1.2.3.123456.12345678"; - static final public String DEFAULT_ASSN_AUTH = "Assigning Authority"; - static final public String DEFAULT_CODE_CODE = "34133-9"; - static final public String DEFAULT_CODE_SYSTEM = "2.16.840.1.113883.6.1"; - static final public String DEFAULT_CODE_SYSTEM_NAME = "LOINC"; - static final public String DEFAULT_CODE_DISPLAY = "Summarization of Episode Note"; - static final public String DEFAULT_TITLE = "Patient Health Summary"; - static final public String DEFAULT_EFFCT_TIME = "20190119161413-0500"; - static final public String DEFAULT_EVENT_TIME_LOW = "19700919"; - static final public String DEFAULT_EVENT_TIME_HIGH = "20190214"; - static final public String DEFAULT_CONF_CODE_CODE = "N"; - static final public String DEFAULT_CONF_CODE_SYSTEM = "1.23.456.7.890123.4.56"; - static final public String DEFAULT_CONF_CODE_DSP = "Normal"; - static final public String DEFAULT_LANG_CODE = "en-US"; - static final public String DEFAULT_SET_ID_EXT = "12345678-9012-3456-7890-123456789012"; - static final public String DEFAULT_SET_ID_ROOT = "1.2.345.678901.2.34.56.7.8.9.0"; - static final public String DEFAULT_VERSION_NUMBER = "1"; - - public ClinicalDocumentMetadataGenerator() { - factories = CDAFactories.init(); - } - - public ContinuityOfCareDocument generateClinicalDoc(CDAFactories factories) { - - doc = factories.consol.createContinuityOfCareDocument(); - // No way to set realm code? - // CS realmCode = genRealmCode(factories, DEFAULT_REALM_CODE); - II id = genId(factories, DEFAULT_ID_ROOT, DEFAULT_ASSN_AUTH); - CS code = genCode(factories, DEFAULT_CODE_CODE, DEFAULT_CODE_SYSTEM, DEFAULT_CODE_SYSTEM_NAME, - DEFAULT_CODE_DISPLAY); - ST title = genTitle(factories, DEFAULT_TITLE); - TS effTime = genTime(factories, DEFAULT_EFFCT_TIME); - CE confidentiality = genConfidentiality(factories, DEFAULT_CONF_CODE_CODE, DEFAULT_CONF_CODE_SYSTEM, - DEFAULT_CONF_CODE_DSP); - CS langCode = genLangCode(factories, DEFAULT_LANG_CODE); - II setId = genSetId(factories, DEFAULT_ASSN_AUTH, DEFAULT_SET_ID_ROOT, DEFAULT_SET_ID_EXT); - INT version = genVersion(factories, DEFAULT_VERSION_NUMBER); - - IVL_TS eventEffTime = genTime(factories, DEFAULT_EVENT_TIME_LOW, DEFAULT_EVENT_TIME_HIGH); - if (assignedEntityGenerator != null) { - DocumentationOf docOf = genDocumentationOf(eventEffTime, assignedEntityGenerator.generate(factories)); - doc.getDocumentationOfs().add(docOf); - - } - doc.setId(id); - doc.setCode(code); - doc.setTitle(title); - doc.setEffectiveTime(effTime); - doc.setConfidentialityCode(confidentiality); - doc.setLanguageCode(langCode); - doc.setSetId(setId); - doc.setVersionNumber(version); - return doc; - } - - public DocumentationOf genDocumentationOf(IVL_TS effTime, AssignedEntity assignedEntity) { - DocumentationOf docOf = factories.base.createDocumentationOf(); - ServiceEvent event = factories.base.createServiceEvent(); - event.setEffectiveTime(effTime); - Performer1 performer = factories.base.createPerformer1(); - performer.setAssignedEntity(assignedEntity); - event.getPerformers().add(performer); - docOf.setServiceEvent(event); - return docOf; - } - - public CS genRealmCode(CDAFactories factories, String code) { - CS realmCode = factories.datatype.createCS(); - realmCode.setCode(code); - return realmCode; - } - - public II genId(CDAFactories factories, String root, String assnAuth) { - II id = factories.datatype.createII(root); - id.setAssigningAuthorityName(assnAuth); - return id; - } - - public CS genCode(CDAFactories factories, String codeCode, String codeSystem, String codeSystemName, - String displayName) { - CS code = factories.datatype.createCS(codeCode); - code.setCodeSystem(codeSystem); - code.setCodeSystemName(codeSystemName); - code.setDisplayName(displayName); - return code; - } - - public ST genTitle(CDAFactories factories, String titleTxt) { - ST title = factories.datatype.createST(); - title.addText(titleTxt); - return title; - } - - public TS genTime(CDAFactories factories, String dttm) { - return factories.datatype.createTS(dttm); - } - - public IVL_TS genTime(CDAFactories factories, String timeLow, String timeHigh) { - return factories.datatype.createIVL_TS(timeLow, timeHigh); - } - - public CE genConfidentiality(CDAFactories factories, String code, String codeSystem, String codeDisp) { - CE confidentiality = factories.datatype.createCE(code, codeSystem); - confidentiality.setDisplayName(codeDisp); - return confidentiality; - } - - public CS genLangCode(CDAFactories factories, String code) { - return factories.datatype.createCS(code); - } - - public II genSetId(CDAFactories factories, String root, String assnAuth, String ext) { - II setId = factories.datatype.createII(root); - setId.setAssigningAuthorityName(assnAuth); - setId.setExtension(ext); - return setId; - } - - public INT genVersion(CDAFactories factories, String versionNum) { - INT version = factories.datatype.createINT(); - version.setValue(Integer.getInteger(versionNum)); - return version; - } - - // TODO: Refactor these last three static methods into generators. - public static void setStructuredBody(CDAFactories factories, ClinicalDocument document, - List components) { - Component2 component2 = factories.base.createComponent2(); - StructuredBody structuredBody = factories.base.createStructuredBody(); - structuredBody.getComponents().addAll(components); - component2.setStructuredBody(structuredBody); - document.setComponent(component2); - } - - public static void setRecordTarget(CDAFactories factories, ClinicalDocument document, PatientRole patientRole) { - RecordTarget recordTarget = factories.base.createRecordTarget(); - recordTarget.setPatientRole(patientRole); - document.getRecordTargets().add(recordTarget); - } - - public static void setAuthor(CDAFactories factories, ClinicalDocument document, Author author) { - document.getAuthors().add(author); - } - - public static void setCustodian(CDAFactories factories, ClinicalDocument document, Custodian custodian) { - document.setCustodian(custodian); - } - - public void setAssignedEntityGenerator(AssignedEntityGenerator assignedEntityGenerator) { - this.assignedEntityGenerator = assignedEntityGenerator; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CodeGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CodeGenerator.java deleted file mode 100644 index 96ffd1cbd..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CodeGenerator.java +++ /dev/null @@ -1,88 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Coding; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; - -public abstract class CodeGenerator { - private String code; - private String nullFlavor; - - private Map map; - private String defaultCode; - - public CodeGenerator(String code) { - this.code = code; - } - - public CodeGenerator(Map map, String defaultCode) { - this.map = map; - this.defaultCode = defaultCode; - } - - public CodeGenerator(Map map) { - this.map = map; - } - - public void set(String code) { - this.code = code; - } - - public String get() { - return this.code; - } - - protected abstract T create(CDAFactories factories); - - public T generate(CDAFactories factories) { - T result = create(factories); - if (code != null || nullFlavor != null) { - if (code != null) { - result.setCode(code); - } - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - result.setNullFlavor(nf); - } - } - return result; - } - - public void verify(String code) { - if (this.code == null || nullFlavor != null) { - Assert.assertNull("No code", code); - } else { - String expected = map != null ? (String) map.get(this.code) : code; - if (expected == null) { - expected = defaultCode; - } - Assert.assertEquals("Code", expected, code); - } - } - - @SuppressWarnings("unchecked") - public void verify(CodeableConcept codeableConcept) { - if (this.code == null || nullFlavor != null) { - Assert.assertNull("No code", code); - } else { - List expectedParent = (List) map.get(this.code); - if (expectedParent == null) { - expectedParent = (List) map.get("_"); - } - Map expected = (Map) expectedParent.get(0); - - Coding coding = codeableConcept.getCoding().get(0); - Assert.assertEquals("Code", expected.get("code"), coding.getCode()); - Assert.assertEquals("System", expected.get("system"), coding.getSystem()); - Assert.assertEquals("Display", expected.get("display"), coding.getDisplay()); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CustodianOrganizationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CustodianOrganizationGenerator.java deleted file mode 100644 index 3a2f9eb71..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/CustodianOrganizationGenerator.java +++ /dev/null @@ -1,132 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Identifier; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.CustodianOrganization; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.ON; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; - -public class CustodianOrganizationGenerator { - private static final String NAME = "The Organization"; - - private String nullFlavor; - - private String name; - - private List idGenerators = new ArrayList<>(); - private ADGenerator adGenerator; - private TELGenerator telGenerator; - - public CustodianOrganizationGenerator() { - } - - public CustodianOrganizationGenerator(String name) { - this.name = name; - } - - public void setADGenerator(ADGenerator adGenerator) { - this.adGenerator = adGenerator; - } - - public void setNullFlavor() { - nullFlavor = "UNK"; - } - - public boolean isNullFlavor() { - return nullFlavor != null; - } - - public CustodianOrganization generate(CDAFactories factories) { - CustodianOrganization organization = factories.base.createCustodianOrganization(); - - if (name != null) { - ON on = factories.datatype.createON(); - on.addText(name); - organization.setName(on); - } - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - organization.getIds().add(ii); - }); - - if (adGenerator != null) { - AD ad = adGenerator.generate(factories); - organization.setAddr(ad); - } - - if (telGenerator != null) { - TEL tel = telGenerator.generate(factories); - organization.setTelecom(tel); - } - - if (nullFlavor != null) { - NullFlavor nf = NullFlavor.get(nullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - organization.setNullFlavor(nf); - } - - return organization; - } - - public static CustodianOrganizationGenerator getDefaultInstance() { - CustodianOrganizationGenerator og = new CustodianOrganizationGenerator(); - - og.name = NAME; - - og.adGenerator = ADGenerator.getDefaultInstance(); - og.telGenerator = TELGenerator.getDefaultInstance(); - - return og; - } - - public static CustodianOrganizationGenerator getFullInstance() { - CustodianOrganizationGenerator og = new CustodianOrganizationGenerator(); - - og.name = NAME; - - og.idGenerators.add(IDGenerator.getNextInstance()); - og.idGenerators.add(IDGenerator.getNextInstance()); - og.idGenerators.add(IDGenerator.getNextInstance()); - - og.adGenerator = ADGenerator.getDefaultInstance(); - og.telGenerator = TELGenerator.getDefaultInstance(); - - return og; - } - - public void verify(org.hl7.fhir.dstu3.model.Organization organization) { - Assert.assertEquals("Organization name", name, organization.getName()); - - List identifiers = organization.getIdentifier(); - Assert.assertEquals("Organization identifier count", identifiers.size(), idGenerators.size()); - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(identifiers.get(index)); - } - - if (adGenerator == null) { - Assert.assertTrue("No address", !organization.hasAddress()); - } else { - Assert.assertEquals("Address count", 1, organization.getAddress().size()); - adGenerator.verify(organization.getAddress().get(0)); - } - - if (telGenerator == null) { - Assert.assertTrue("No telecom", !organization.hasTelecom()); - } else { - Assert.assertEquals("Telecom count", 1, organization.getTelecom().size()); - telGenerator.verify(organization.getTelecom().get(0)); - } - } -} \ No newline at end of file diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/DocumentationOfGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/DocumentationOfGenerator.java deleted file mode 100644 index e6b744e31..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/DocumentationOfGenerator.java +++ /dev/null @@ -1,38 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Composition.CompositionEventComponent; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.DocumentationOf; -import org.openhealthtools.mdht.uml.cda.ServiceEvent; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class DocumentationOfGenerator { - private ServiceEventGenerator eventGenerator; - - public DocumentationOf generate(CDAFactories factories) { - DocumentationOf docOf = factories.base.createDocumentationOf(); - - if (eventGenerator != null) { - ServiceEvent se = eventGenerator.generate(factories); - docOf.setServiceEvent(se); - } - - return docOf; - } - - public static DocumentationOfGenerator getDefaultInstance() { - DocumentationOfGenerator g = new DocumentationOfGenerator(); - g.eventGenerator = ServiceEventGenerator.getDefaultInstance(); - return g; - } - - public void verify(Bundle bundle, CompositionEventComponent event) throws Exception { - if (eventGenerator == null) { - Assert.assertNull("No event", event); - } else { - eventGenerator.verify(bundle, event); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EDGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EDGenerator.java deleted file mode 100644 index 677096d96..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EDGenerator.java +++ /dev/null @@ -1,60 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; - -public class EDGenerator { - private static int INDEX = 1; - - private String value; - private String nullFlavor; - - public EDGenerator(String value) { - this.value = value; - } - - public void setNullFlavor(String nullFlavor) { - this.nullFlavor = nullFlavor; - } - - public ED generate(CDAFactories factories) { - ED ed = factories.datatype.createED(); - - if (value != null) { - ed.addText(value); - } - - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - ed.setNullFlavor(nf); - } - - return ed; - } - - public static EDGenerator getNextInstance() { - String value = "ED Text " + INDEX; - ++INDEX; - return new EDGenerator(value); - } - - public void verify(byte[] content) { - if (value == null || nullFlavor != null) { - Assert.assertNull("No text", content); - } else { - Assert.assertEquals("Text", value, new String(content)); - } - } - - public void verify(String content) { - if (value == null || nullFlavor != null) { - Assert.assertNull("No text", content); - } else { - Assert.assertEquals("Text", value, content); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ENXPGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ENXPGenerator.java deleted file mode 100644 index fd71bbaef..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ENXPGenerator.java +++ /dev/null @@ -1,29 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.openhealthtools.mdht.uml.hl7.datatypes.ENXP; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ENXPGenerator extends BaseStringGenerator { - public ENXPGenerator(boolean nullFlavorOK) { - super(nullFlavorOK); - } - - public ENXPGenerator(String value) { - super(value); - } - - public ENXPGenerator(String value, boolean nullFlavorOK) { - super(value, nullFlavorOK); - } - - @Override - public ENXP create(CDAFactories factories) { - return factories.datatype.createENXP(); - } - - public static ENXPGenerator getNextInstance(boolean nullFlavorOK) { - String value = BaseStringGenerator.getNextValue(); - return new ENXPGenerator(value, nullFlavorOK); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EffectiveTimeGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EffectiveTimeGenerator.java deleted file mode 100644 index ab2f4f8ad..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EffectiveTimeGenerator.java +++ /dev/null @@ -1,130 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.Map; - -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVXB_TS; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class EffectiveTimeGenerator { - private String lowNullFlavor; - private String highNullFlavor; - private String nullFlavor; - - private String lowValue; - private String highValue; - private String value; - - public EffectiveTimeGenerator() { - } - - public EffectiveTimeGenerator(String lowValue) { - this.lowValue = lowValue; - } - - public EffectiveTimeGenerator(String lowValue, String highValue) { - this.lowValue = lowValue; - this.highValue = highValue; - } - - @SuppressWarnings("unchecked") - public EffectiveTimeGenerator(Map json) { - nullFlavor = (String) json.get("nullFlavor"); - value = (String) json.get("value"); - Map low = (Map) json.get("low"); - if (low != null) { - lowNullFlavor = (String) low.get("nullFlavor"); - lowValue = (String) low.get("value"); - } - Map high = (Map) json.get("high"); - if (high != null) { - highNullFlavor = (String) high.get("nullFlavor"); - highValue = (String) high.get("value"); - } - } - - public String getLowOrValue() { - if (nullFlavor == null) { - if (lowValue != null && lowNullFlavor == null) { - return lowValue; - } - if (value != null) { - return value; - } - } - return null; - } - - public boolean hasHigh() { - return highValue != null && highNullFlavor == null; - } - - public IVL_TS generate(CDAFactories factories) { - IVL_TS ivlTs = factories.datatype.createIVL_TS(); - if (lowValue != null) { - IVXB_TS ivxbTs = factories.datatype.createIVXB_TS(); - ivxbTs.setValue(lowValue); - if (lowNullFlavor != null) { - NullFlavor nf = NullFlavor.get(lowNullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - ivxbTs.setNullFlavor(nf); - } - ivlTs.setLow(ivxbTs); - } - if (highValue != null) { - IVXB_TS ivxbTs = factories.datatype.createIVXB_TS(); - ivxbTs.setValue(highValue); - if (highNullFlavor != null) { - NullFlavor nf = NullFlavor.get(highNullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - ivxbTs.setNullFlavor(nf); - } - ivlTs.setHigh(ivxbTs); - } - if (value != null) { - ivlTs.setValue(value); - if (nullFlavor != null) { - NullFlavor nf = NullFlavor.get(nullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - ivlTs.setNullFlavor(nf); - } - } - return ivlTs; - } - - public void verifyLowOrValue(String fhirValue) { - String lowOrValue = getLowOrValue(); - if (lowOrValue == null) { - Assert.assertNull("No date or time", fhirValue); - } else { - String expected = FHIRUtil.toFHIRDatetime(lowOrValue); - Assert.assertEquals("Effective time value", expected, fhirValue); - } - } - - public void verifyValue(String fhirValue) { - if (this.value == null) { - Assert.assertNull("No date or time", fhirValue); - } else { - String expected = FHIRUtil.toFHIRDatetime(value); - Assert.assertEquals("Effective time value", expected, fhirValue); - } - } - - public static EffectiveTimeGenerator getValueOnlyInstance(String value) { - EffectiveTimeGenerator result = new EffectiveTimeGenerator(); - result.value = value; - return result; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EncounterActivityGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EncounterActivityGenerator.java deleted file mode 100644 index 66e995e56..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EncounterActivityGenerator.java +++ /dev/null @@ -1,335 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Encounter; -import org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent; -import org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent; -import org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent; -import org.hl7.fhir.dstu3.model.Location; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.EntryRelationship; -import org.openhealthtools.mdht.uml.cda.Participant2; -import org.openhealthtools.mdht.uml.cda.ParticipantRole; -import org.openhealthtools.mdht.uml.cda.Performer2; -import org.openhealthtools.mdht.uml.cda.consol.EncounterActivities; -import org.openhealthtools.mdht.uml.cda.consol.Indication; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; -import org.openhealthtools.mdht.uml.hl7.vocab.ParticipationType; -import org.openhealthtools.mdht.uml.hl7.vocab.RoleClassRoot; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.conf.Config; -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class EncounterActivityGenerator { - private static final Map ENCOUNTER_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/EncounterStatus.json"); - - private List idGenerators = new ArrayList<>(); - - private String statusCode; - private String statusNullFlavor; - - private CDGenerator codeGenerator; - private CEGenerator priorityCodeGenerator; - - private IVL_TSPeriodGenerator effectiveTimeGenerator; - - private List performerGenerators = new ArrayList<>(); - - private List indicationGenerators = new ArrayList<>(); - - private List serviceDeliveryLocationGenerators = new ArrayList<>(); - - private String nullFlavor; - - public void setNullFlavor() { - this.nullFlavor = "UNK"; - } - - public void setIDGenerator(IDGenerator idGenerator) { - this.idGenerators.clear(); - this.idGenerators.add(idGenerator); - } - - public void setStatusCode(String statusCode) { - this.statusCode = statusCode; - } - - public EncounterActivities generate(CDAFactories factories) { - EncounterActivities ec = factories.consol.createEncounterActivities(); - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - ec.getIds().add(ii); - }); - - if (statusCode != null || statusNullFlavor != null) { - CS cs = factories.datatype.createCS(); - if (statusCode != null) { - cs.setCode(statusCode); - } - if (statusNullFlavor != null) { - NullFlavor nf = NullFlavor.get(statusNullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - cs.setNullFlavor(nf); - } - ec.setStatusCode(cs); - } - - if (codeGenerator != null) { - CD cd = codeGenerator.generate(factories); - ec.setCode(cd); - } - - if (priorityCodeGenerator != null) { - CE ce = priorityCodeGenerator.generate(factories); - ec.setPriorityCode(ce); - } - - if (effectiveTimeGenerator != null) { - IVL_TS ivlTs = effectiveTimeGenerator.generate(factories); - ec.setEffectiveTime(ivlTs); - } - - performerGenerators.forEach(pg -> { - Performer2 performer = pg.generate(factories); - ec.getPerformers().add(performer); - }); - - indicationGenerators.forEach(ig -> { - EntryRelationship er = factories.base.createEntryRelationship(); - ec.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.RSON); - Indication indication = ig.generate(factories); - er.setObservation(indication); - }); - - serviceDeliveryLocationGenerators.forEach(sdlg -> { - Participant2 p2 = factories.base.createParticipant2(); - ParticipationType pt = ParticipationType.LOC; - p2.setTypeCode(pt); - ParticipantRole pr = sdlg.generate(factories); - p2.setParticipantRole(pr); - RoleClassRoot rcr = RoleClassRoot.SDLOC; - pr.setClassCode(rcr); - ec.getParticipants().add(p2); - }); - - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - ec.setNullFlavor(nf); - } - - return ec; - } - - private void updateIndicationGenerators() { - indicationGenerators.forEach(ig -> { - ig.setConstantCode("encounter-diagnosis", "Encounter Diagnosis", "http://hl7.org/fhir/condition-category"); - }); - } - - public static EncounterActivityGenerator getDefaultInstance() { - EncounterActivityGenerator ecg = new EncounterActivityGenerator(); - - ecg.idGenerators.add(IDGenerator.getNextInstance()); - ecg.statusCode = "active"; - ecg.codeGenerator = CDGenerator.getNextInstance(); - ecg.priorityCodeGenerator = CEGenerator.getNextInstance(); - ecg.effectiveTimeGenerator = IVL_TSPeriodGenerator.getDefaultInstance(); - ecg.performerGenerators.add(PerformerGenerator.getDefaultInstance()); - ecg.indicationGenerators.add(IndicationGenerator.getDefaultInstance()); - ecg.serviceDeliveryLocationGenerators.add(ServiceDeliveryLocationGenerator.getDefaultInstance()); - - ecg.updateIndicationGenerators(); - - return ecg; - } - - public static EncounterActivityGenerator getFullInstance() { - EncounterActivityGenerator ecg = new EncounterActivityGenerator(); - - ecg.idGenerators.add(IDGenerator.getNextInstance()); - ecg.statusCode = "active"; - ecg.codeGenerator = CDGenerator.getNextInstance(); - ecg.priorityCodeGenerator = CEGenerator.getNextInstance(); - ecg.effectiveTimeGenerator = IVL_TSPeriodGenerator.getDefaultInstance(); - - ecg.performerGenerators.add(PerformerGenerator.getDefaultInstance()); - ecg.performerGenerators.add(PerformerGenerator.getFullInstance()); - - ecg.indicationGenerators.add(IndicationGenerator.getDefaultInstance()); - ecg.serviceDeliveryLocationGenerators.add(ServiceDeliveryLocationGenerator.getDefaultInstance()); - - ecg.updateIndicationGenerators(); - - return ecg; - } - - public void verify(Encounter encounter) { - if (nullFlavor != null) { - Assert.assertNull("Null flavor", encounter); - return; - } - - if (!idGenerators.isEmpty()) { - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(encounter.getIdentifier().get(index)); - } - } else { - Assert.assertTrue("No encounter identifier", !encounter.hasIdentifier()); - } - - if (statusCode == null || statusNullFlavor != null) { - Assert.assertTrue("Default encounter status exists", encounter.hasStatus()); - String expected = Config.DEFAULT_ENCOUNTER_STATUS.toCode(); - Assert.assertEquals("Default encounter status", expected, encounter.getStatus().toCode()); - } else { - String expected = (String) ENCOUNTER_STATUS.get(statusCode); - if (expected == null) { - Assert.assertTrue("Missing encounter status", !encounter.hasStatus()); - } else { - Assert.assertEquals("Encounter status", expected, encounter.getStatus().toCode()); - } - } - - if (codeGenerator == null) { - Assert.assertTrue("Missing encounter type", !encounter.hasType()); - } else { - Assert.assertTrue("One encounter type", encounter.getType().size() == 1); - codeGenerator.verify(encounter.getType().get(0)); - } - - if (priorityCodeGenerator == null) { - Assert.assertTrue("Missing encounter priority", !encounter.hasPriority()); - } else { - priorityCodeGenerator.verify(encounter.getPriority()); - } - - if (effectiveTimeGenerator == null) { - Assert.assertTrue("Missing encounter period", !encounter.hasPeriod()); - } else { - effectiveTimeGenerator.verify(encounter.getPeriod()); - } - - if (performerGenerators.isEmpty()) { - Assert.assertTrue("Missing encounter participant individual", !encounter.hasParticipant()); - } else { - Assert.assertEquals("Encounter performer count", performerGenerators.size(), - encounter.getParticipant().size()); - } - } - - public void verify(Bundle bundle, Encounter encounter) throws Exception { - if (nullFlavor != null) { - Assert.assertNull("Null flavor", encounter); - return; - } - - verify(encounter); - - BundleUtil util = new BundleUtil(bundle); - - if (performerGenerators.isEmpty()) { - Assert.assertTrue("Missing encounter participant", !encounter.hasParticipant()); - } else { - for (int index = 0; index < performerGenerators.size(); ++index) { - PerformerGenerator pg = performerGenerators.get(index); - EncounterParticipantComponent epc = encounter.getParticipant().get(index); - - String practitionerId = epc.getIndividual().getReference(); - Practitioner practitioner = util.getResourceFromReference(practitionerId, Practitioner.class); - pg.verify(practitioner); - - PractitionerRole role = util.getPractitionerRole(practitionerId); - pg.verify(role); - - if (!role.hasOrganization()) { - pg.verify((Organization) null); - } else { - String reference = role.getOrganization().getReference(); - Organization organization = util.getResourceFromReference(reference, Organization.class); - pg.verify(organization); - } - - Coding coding = epc.getType().get(0).getCoding().get(0); - Coding expectedCoding = Config.DEFAULT_ENCOUNTER_PARTICIPANT_TYPE_CODE; - Assert.assertEquals("Encounter participant type code", expectedCoding.getCode(), coding.getCode()); - Assert.assertEquals("Encounter participant type system", expectedCoding.getSystem(), - coding.getSystem()); - Assert.assertEquals("Encounter participant type display", expectedCoding.getDisplay(), - coding.getDisplay()); - } - } - - if (indicationGenerators.isEmpty()) { - Assert.assertTrue("Missing encounter diagnosis", !encounter.hasDiagnosis()); - } else { - for (int index = 0; index < indicationGenerators.size(); ++index) { - IndicationGenerator ig = indicationGenerators.get(index); - DiagnosisComponent dxComponent = encounter.getDiagnosis().get(index); - - String conditionId = dxComponent.getCondition().getReference(); - Condition condition = util.getResourceFromReference(conditionId, Condition.class); - ig.verify(condition); - } - } - - if (serviceDeliveryLocationGenerators.isEmpty()) { - Assert.assertTrue("Missing encounter locations", !encounter.hasLocation()); - } else { - for (int index = 0; index < serviceDeliveryLocationGenerators.size(); ++index) { - ServiceDeliveryLocationGenerator sdlg = serviceDeliveryLocationGenerators.get(index); - EncounterLocationComponent locationComponent = encounter.getLocation().get(index); - - String locationId = locationComponent.getLocation().getReference(); - Location location = util.getResourceFromReference(locationId, Location.class); - sdlg.verify(location); - } - } - } - - public void verify(Bundle bundle) throws Exception { - if (nullFlavor != null) { - Encounter encounter = FHIRUtil.findFirstResource(bundle, Encounter.class); - verify(bundle, encounter); - return; - } - - Encounter encounter = BundleUtil.findOneResource(bundle, Encounter.class); - verify(bundle, encounter); - } - - public void setIndicationGenerator(List indGenerators) { - this.indicationGenerators = indGenerators; - } - - public static Set getAvailableStatusCodes() { - return Collections.unmodifiableSet(ENCOUNTER_STATUS.keySet()); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EntityGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EntityGenerator.java deleted file mode 100644 index a85fedd38..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/EntityGenerator.java +++ /dev/null @@ -1,205 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.HumanName; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Organization; -import org.openhealthtools.mdht.uml.cda.Person; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.PN; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class EntityGenerator { - private static final String DEFAULT_CODE_CODE = "363LA2100X"; - private static final String DEFAULT_CODE_PRINTNAME = "Nurse Practitioner - Acute Care"; - - private List idGenerators = new ArrayList<>(); - - private String codeCode; - private String codePrintName; - - private List adGenerators = new ArrayList<>(); - private List telGenerators = new ArrayList<>(); - - private PNGenerator pnGenerator; - private OrganizationGenerator organizationGenerator; - - public EntityGenerator() { - } - - public EntityGenerator(EntityGenerator generator) { - this.idGenerators = generator.idGenerators; - this.codeCode = generator.codeCode; - this.codePrintName = generator.codePrintName; - this.adGenerators = generator.adGenerators; - this.telGenerators = generator.telGenerators; - this.pnGenerator = generator.pnGenerator; - this.organizationGenerator = generator.organizationGenerator; - } - - protected void fillEntity(CDAFactories factories, ICDAEntity entity) { - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - entity.addII(ii); - }); - - if (codeCode != null) { - CE ce = factories.datatype.createCE(codeCode, "2.16.840.1.11388 3.6.101", - "Healthcare Provider Taxonomy (HIPAA)", codePrintName); - entity.setCode(ce); - } - - adGenerators.forEach(adGenerator -> { - AD ad = adGenerator.generate(factories); - entity.addAD(ad); - }); - - telGenerators.forEach(telGenerator -> { - TEL tel = telGenerator.generate(factories); - entity.addTEL(tel); - }); - - if (pnGenerator != null) { - PN pn = pnGenerator.generate(factories); - Person person = factories.base.createPerson(); - person.getNames().add(pn); - entity.setPerson(person); - } - - if (organizationGenerator != null) { - Organization organization = organizationGenerator.generate(factories); - entity.setOrganization(organization); - } - } - - public void setCode(String code, String printName) { - codeCode = code; - codePrintName = printName; - } - - public void setPNGenerator(PNGenerator pnGenerator) { - this.pnGenerator = pnGenerator; - } - - public void setOrganizationGenerator(OrganizationGenerator organizationGenerator) { - this.organizationGenerator = organizationGenerator; - } - - public String getCodeCode() { - return codeCode; - } - - public PNGenerator getPNGenerator() { - return pnGenerator; - } - - public OrganizationGenerator getOrganizationGenerator() { - return organizationGenerator; - } - - public void removeOrganizationGenerator() { - organizationGenerator = null; - } - - protected static void fillDefaultInstance(EntityGenerator eg) { - eg.idGenerators.add(IDGenerator.getNextInstance()); - - eg.setCode(DEFAULT_CODE_CODE, DEFAULT_CODE_PRINTNAME); - - eg.adGenerators.add(ADGenerator.getDefaultInstance()); - eg.telGenerators.add(TELGenerator.getDefaultInstance()); - - eg.pnGenerator = PNGenerator.getDefaultInstance(); - eg.organizationGenerator = OrganizationGenerator.getDefaultInstance(); - } - - protected static void fillFullInstance(EntityGenerator eg) { - eg.idGenerators.add(IDGenerator.getNextInstance()); - eg.idGenerators.add(IDGenerator.getNextInstance()); - eg.idGenerators.add(IDGenerator.getNextInstance()); - eg.idGenerators.add(IDGenerator.getNextInstance()); - - eg.setCode(DEFAULT_CODE_CODE, DEFAULT_CODE_PRINTNAME); - - eg.adGenerators.add(ADGenerator.getFullInstance()); - eg.telGenerators.add(TELGenerator.getFullInstance()); - - eg.pnGenerator = PNGenerator.getFullInstance(); - eg.organizationGenerator = OrganizationGenerator.getFullInstance(); - } - - public void verify(Practitioner practitioner) { - if (pnGenerator == null || pnGenerator.hasNullFlavor()) { - Assert.assertTrue("Missing practioner name", !practitioner.hasName()); - } else { - HumanName humanName = practitioner.getName().get(0); - pnGenerator.verify(humanName); - } - - if (!idGenerators.isEmpty()) { - IDGenerator.verifyList(practitioner.getIdentifier(), idGenerators); - } else { - Assert.assertTrue("No practitioner identifier", !practitioner.hasIdentifier()); - } - - if (adGenerators.isEmpty()) { - Assert.assertTrue("Missing practioner address", !practitioner.hasAddress()); - } else { - ADGenerator.verifyList(practitioner.getAddress(), adGenerators); - } - - if (telGenerators.isEmpty()) { - Assert.assertTrue("Missing practioner telecom", !practitioner.hasTelecom()); - } else { - TELGenerator.verifyList(practitioner.getTelecom(), telGenerators); - } - } - - public void verify(PractitionerRole role) { - if (organizationGenerator == null || !organizationGenerator.shouldExists()) { - Assert.assertNull("Role when null flavored or no org", role); - } else { - Coding code = role.getCode().get(0).getCoding().get(0); - Assert.assertEquals("Role code", codeCode, code.getCode()); - Assert.assertEquals("Role print name", codePrintName, code.getDisplay()); - } - } - - public void verify(org.hl7.fhir.dstu3.model.Organization organization) { - if (organizationGenerator == null || !organizationGenerator.shouldExists()) { - Assert.assertNull("Author organization", organization); - return; - } - organizationGenerator.verify(organization); - } - - public void verifyFromPractionerId(Bundle bundle, String practitionerId) { - BundleUtil util = new BundleUtil(bundle); - Practitioner practitioner = util.getResourceFromReference(practitionerId, Practitioner.class); - verify(practitioner); - - PractitionerRole role = util.getPractitionerRole(practitionerId); - verify(role); - - if (organizationGenerator == null || !role.hasOrganization()) { - verify((org.hl7.fhir.dstu3.model.Organization) null); - } else { - String reference = role.getOrganization().getReference(); - org.hl7.fhir.dstu3.model.Organization organization = util.getResourceFromReference(reference, - org.hl7.fhir.dstu3.model.Organization.class); - verify(organization); - } - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/GuardianGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/GuardianGenerator.java deleted file mode 100644 index 2099bdd88..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/GuardianGenerator.java +++ /dev/null @@ -1,105 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Patient.ContactComponent; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Guardian; -import org.openhealthtools.mdht.uml.cda.Person; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.PN; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class GuardianGenerator { - private static final Map CONTACT_RLATIONSHIP = JsonUtils - .filepathToMap("src/test/resources//value-maps/ContactRelationship.json"); - - private List addrGenerators = new ArrayList<>(); - private List telecomGenerators = new ArrayList<>(); - private List personNameGenerators = new ArrayList<>(); - private CECodeGenerator codeGenerator; - - public Guardian generate(CDAFactories factories) { - Guardian guardian = factories.base.createGuardian(); - - addrGenerators.forEach(g -> { - AD ad = g.generate(factories); - guardian.getAddrs().add(ad); - }); - - telecomGenerators.forEach(g -> { - TEL tel = g.generate(factories); - guardian.getTelecoms().add(tel); - }); - - if (!personNameGenerators.isEmpty()) { - Person person = factories.base.createPerson(); - guardian.setGuardianPerson(person); - personNameGenerators.forEach(g -> { - PN pn = g.generate(factories); - person.getNames().add(pn); - }); - } - - if (codeGenerator != null) { - CE ce = codeGenerator.generate(factories); - guardian.setCode(ce); - } - - return guardian; - } - - public static GuardianGenerator getDefaultInstance() { - GuardianGenerator gg = new GuardianGenerator(); - - gg.addrGenerators.add(ADGenerator.getDefaultInstance()); - gg.telecomGenerators.add(TELGenerator.getDefaultInstance()); - gg.personNameGenerators.add(PNGenerator.getDefaultInstance()); - gg.codeGenerator = new CECodeGenerator(CONTACT_RLATIONSHIP); - gg.codeGenerator.set("work"); - - return gg; - } - - public void verify(ContactComponent contactComponent) { - if (addrGenerators.isEmpty()) { - Assert.assertTrue("No addresses", !contactComponent.hasAddress()); - } else { - ADGenerator addrGenerator = addrGenerators.get(0); - addrGenerator.verify(contactComponent.getAddress()); - } - - if (telecomGenerators.isEmpty()) { - Assert.assertTrue("No telecoms", !contactComponent.hasTelecom()); - } else { - TELGenerator.verifyList(contactComponent.getTelecom(), telecomGenerators); - } - - if (personNameGenerators.isEmpty()) { - Assert.assertTrue("No names", !contactComponent.hasName()); - } else { - PNGenerator pnGenerator = personNameGenerators.get(personNameGenerators.size() - 1); - pnGenerator.verify(contactComponent.getName()); - } - - if (codeGenerator == null) { - Assert.assertTrue("No code", !contactComponent.hasRelationship()); - } else { - codeGenerator.verify(contactComponent.getRelationship().get(0)); - } - } - - public static void verifyList(List actual, List expected) { - Assert.assertEquals("Guardian contact", expected.size(), actual.size()); - for (int index = 0; index < actual.size(); ++index) { - expected.get(index).verify(actual.get(index)); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ICDAEntity.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ICDAEntity.java deleted file mode 100644 index 08f5657cd..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ICDAEntity.java +++ /dev/null @@ -1,22 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.openhealthtools.mdht.uml.cda.Organization; -import org.openhealthtools.mdht.uml.cda.Person; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -public interface ICDAEntity { - void addII(II ii); - - void setCode(CE ce); - - void setPerson(Person person); - - void setOrganization(Organization organization); - - void addAD(AD ad); - - void addTEL(TEL tel); -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IDGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IDGenerator.java deleted file mode 100644 index 410416228..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IDGenerator.java +++ /dev/null @@ -1,74 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Identifier; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class IDGenerator { - private static final String[] ROOTS = { "1.3.5.7", "4.5.2.4", "4.1.12.67", "43.45.78.12", "3.5.6.8", "12.12.12.1", - "9.0.3.6", "12.34.56.78", "3.5.4.2", "20.20.20.20", "30.50.60.70" }; - - private static int NEXT_INDEX = 1; - - private String root; - private String extension; - - public IDGenerator(String root, String extension) { - this.root = root; - this.extension = extension; - } - - public String getSystem() { - if (root != null && extension != null) { - return "urn:oid:" + root; - } - return null; - } - - public String getValue() { - if (root != null && extension != null) { - return extension; - } - return root; - } - - public II generate(CDAFactories factories) { - if (extension == null) { - return factories.datatype.createII(root); - } else { - return factories.datatype.createII(root, extension); - } - } - - public void verify(Identifier identifier) { - if (root != null && extension != null) { - Assert.assertEquals("Identifier system", "urn:oid:" + root, identifier.getSystem()); - Assert.assertEquals("Identifier value", extension, identifier.getValue()); - } else if (root != null) { - Assert.assertEquals("Identifier value", root, identifier.getValue()); - } else { - Assert.assertNull("No identifier", identifier); - } - } - - public static IDGenerator getNextInstance() { - int rootIndex = NEXT_INDEX % 8; - ++NEXT_INDEX; - - String root = ROOTS[rootIndex]; - String extension = String.valueOf(1000 + NEXT_INDEX); - - return new IDGenerator(root, extension); - } - - public static void verifyList(List actual, List expected) { - Assert.assertEquals("Identifier count", expected.size(), actual.size()); - for (int index = 0; index < actual.size(); ++index) { - expected.get(index).verify(actual.get(index)); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVL_PQRangeGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVL_PQRangeGenerator.java deleted file mode 100644 index 9c8ca47fa..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVL_PQRangeGenerator.java +++ /dev/null @@ -1,85 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.math.BigDecimal; - -import org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent; -import org.hl7.fhir.dstu3.model.Range; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVXB_PQ; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class IVL_PQRangeGenerator { - private IVXB_PQGenerator low; - private IVXB_PQGenerator high; - - private BigDecimal value; - - public IVL_PQRangeGenerator() { - } - - public IVL_PQ generate(CDAFactories factories) { - IVL_PQ ivlPq = factories.datatype.createIVL_PQ(); - - if (low != null) { - IVXB_PQ pq = low.generate(factories); - ivlPq.setLow(pq); - } - if (high != null) { - IVXB_PQ pq = high.generate(factories); - ivlPq.setHigh(pq); - } - if (value != null) { - ivlPq.setValue(value); - } - - return ivlPq; - } - - public static IVL_PQRangeGenerator getDefaultInstance() { - IVL_PQRangeGenerator ptg = new IVL_PQRangeGenerator(); - - ptg.low = new IVXB_PQGenerator(150, "ml"); - ptg.high = new IVXB_PQGenerator(500, "ml"); - - return ptg; - } - - public static IVL_PQRangeGenerator getFullInstance() { - IVL_PQRangeGenerator ptg = new IVL_PQRangeGenerator(); - - ptg.low = new IVXB_PQGenerator(150, "ml"); - ptg.high = new IVXB_PQGenerator(500, "ml"); - - return ptg; - } - - public void verify(Range range) { - if (high == null) { - Assert.assertTrue("No range high value", !range.hasHigh()); - } else { - high.verify(range.getHigh()); - } - - if (low == null) { - Assert.assertTrue("No range low value", !range.hasLow()); - } else { - low.verify(range.getLow()); - } - } - - public void verify(ObservationReferenceRangeComponent range) { - if (high == null) { - Assert.assertTrue("No range high value", !range.hasHigh()); - } else { - high.verify(range.getHigh()); - } - - if (low == null) { - Assert.assertTrue("No range low value", !range.hasLow()); - } else { - low.verify(range.getLow()); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVL_PQSimpleQuantityGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVL_PQSimpleQuantityGenerator.java deleted file mode 100644 index 38f7fa3ef..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVL_PQSimpleQuantityGenerator.java +++ /dev/null @@ -1,61 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.math.BigDecimal; - -import org.hl7.fhir.dstu3.model.SimpleQuantity; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class IVL_PQSimpleQuantityGenerator { - private BigDecimal value; - private String unit; - - public IVL_PQSimpleQuantityGenerator() { - } - - public IVL_PQ generate(CDAFactories factories) { - IVL_PQ pq = factories.datatype.createIVL_PQ(); - - if (value != null) { - pq.setValue(value); - } - if (unit != null) { - pq.setUnit(unit); - } - return pq; - } - - public static IVL_PQSimpleQuantityGenerator getDefaultInstance() { - IVL_PQSimpleQuantityGenerator ptg = new IVL_PQSimpleQuantityGenerator(); - - ptg.value = new BigDecimal(124); - ptg.unit = "kg"; - - return ptg; - } - - public static IVL_PQSimpleQuantityGenerator getFullInstance() { - IVL_PQSimpleQuantityGenerator ptg = new IVL_PQSimpleQuantityGenerator(); - - ptg.value = new BigDecimal(1289); - ptg.unit = "kg"; - - return ptg; - } - - public void verify(SimpleQuantity quantity) { - if (value == null) { - Assert.assertTrue("No value", !quantity.hasValue()); - } else { - Assert.assertEquals("Quantity value", value, quantity.getValue()); - } - - if (unit == null) { - Assert.assertTrue("No quantity unit", !quantity.hasUnit()); - } else { - Assert.assertEquals("Quantity unit", unit, quantity.getUnit()); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVL_TSPeriodGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVL_TSPeriodGenerator.java deleted file mode 100644 index 06c4c580b..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVL_TSPeriodGenerator.java +++ /dev/null @@ -1,147 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Period; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVXB_TS; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class IVL_TSPeriodGenerator { - private String lowNullFlavor; - private String highNullFlavor; - private String nullFlavor; - - private String lowValue; - private String highValue; - private String value; - - public IVL_TSPeriodGenerator() { - } - - public IVL_TSPeriodGenerator(String lowValue, String highValue) { - this.lowValue = lowValue; - this.highValue = highValue; - } - - @SuppressWarnings("unchecked") - public IVL_TSPeriodGenerator(Map json) { - nullFlavor = (String) json.get("nullFlavor"); - value = (String) json.get("value"); - Map low = (Map) json.get("low"); - if (low != null) { - lowNullFlavor = (String) low.get("nullFlavor"); - lowValue = (String) low.get("value"); - } - Map high = (Map) json.get("high"); - if (high != null) { - highNullFlavor = (String) high.get("nullFlavor"); - highValue = (String) high.get("value"); - } - } - - public IVL_TS generate(CDAFactories factories) { - IVL_TS ivlTs = factories.datatype.createIVL_TS(); - if (lowValue != null) { - IVXB_TS ivxbTs = factories.datatype.createIVXB_TS(); - ivxbTs.setValue(lowValue); - if (lowNullFlavor != null) { - NullFlavor nf = NullFlavor.get(lowNullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - ivxbTs.setNullFlavor(nf); - } - ivlTs.setLow(ivxbTs); - } - if (highValue != null) { - IVXB_TS ivxbTs = factories.datatype.createIVXB_TS(); - ivxbTs.setValue(highValue); - if (highNullFlavor != null) { - NullFlavor nf = NullFlavor.get(highNullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - ivxbTs.setNullFlavor(nf); - } - ivlTs.setHigh(ivxbTs); - } - if (value != null) { - ivlTs.setValue(value); - if (nullFlavor != null) { - NullFlavor nf = NullFlavor.get(nullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - ivlTs.setNullFlavor(nf); - } - } - return ivlTs; - } - - public static IVL_TSPeriodGenerator getDefaultInstance() { - IVL_TSPeriodGenerator ivlTs = new IVL_TSPeriodGenerator(); - - ivlTs.lowValue = "20080501114500-0800"; - ivlTs.highValue = "20110812170500-0800"; - - return ivlTs; - } - - public static IVL_TSPeriodGenerator getFullInstance() { - return getDefaultInstance(); - } - - public void verify(Period period) { - if (nullFlavor != null) { - Assert.assertTrue("Missing period start", !period.hasStartElement()); - Assert.assertTrue("Missing period end", !period.hasEndElement()); - return; - } - - if (lowNullFlavor == null && lowValue != null) { - String startValue = FHIRUtil.toCDADatetime(period.getStartElement().asStringValue()); - Assert.assertEquals("Period start value", lowValue, startValue); - } else if (lowNullFlavor == null && lowValue == null && highNullFlavor == null && highValue == null - && value != null) { - String startValue = FHIRUtil.toCDADatetime(period.getStartElement().asStringValue()); - Assert.assertEquals("Period start value", value, startValue); - } else { - Assert.assertTrue("Missing period start", !period.hasStartElement()); - } - - if (highNullFlavor == null && nullFlavor == null && highValue != null) { - String endValue = FHIRUtil.toCDADatetime(period.getEndElement().asStringValue()); - Assert.assertEquals("Period end value", highValue, endValue); - } else { - Assert.assertTrue("Missing period end", !period.hasEndElement()); - } - } - - public Map toJson() { - if (nullFlavor != null) { - return null; - } - - Map result = new LinkedHashMap<>(); - - if (lowNullFlavor == null && lowValue != null) { - result.put("start", FHIRUtil.toFHIRDatetime(lowValue)); - } - if (highNullFlavor == null && highValue != null) { - result.put("end", FHIRUtil.toFHIRDatetime(highValue)); - } - if (lowNullFlavor == null && lowValue == null && highNullFlavor == null && highValue == null && value != null) { - result.put("start", FHIRUtil.toFHIRDatetime(value)); - } - if (result.isEmpty()) - return null; - return result; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVXB_PQGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVXB_PQGenerator.java deleted file mode 100644 index b102b8a44..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IVXB_PQGenerator.java +++ /dev/null @@ -1,70 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.math.BigDecimal; - -import org.hl7.fhir.dstu3.model.SimpleQuantity; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVXB_PQ; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class IVXB_PQGenerator { - private BigDecimal value; - private String unit; - - public IVXB_PQGenerator() { - } - - public IVXB_PQGenerator(BigDecimal value, String unit) { - this.value = value; - this.unit = unit; - } - - public IVXB_PQGenerator(int value, String unit) { - this(new BigDecimal(value), unit); - } - - public IVXB_PQ generate(CDAFactories factories) { - IVXB_PQ pq = factories.datatype.createIVXB_PQ(); - - if (value != null) { - pq.setValue(value); - } - if (unit != null) { - pq.setUnit(unit); - } - return pq; - } - - public static IVXB_PQGenerator getDefaultInstance() { - IVXB_PQGenerator ptg = new IVXB_PQGenerator(); - - ptg.value = new BigDecimal(124); - ptg.unit = "kg"; - - return ptg; - } - - public static IVXB_PQGenerator getFullInstance() { - IVXB_PQGenerator ptg = new IVXB_PQGenerator(); - - ptg.value = new BigDecimal(1289); - ptg.unit = "kg"; - - return ptg; - } - - public void verify(SimpleQuantity quantity) { - if (value == null) { - Assert.assertTrue("No value", !quantity.hasValue()); - } else { - Assert.assertEquals("Quantity value", value, quantity.getValue()); - } - - if (unit == null) { - Assert.assertTrue("No quantity unit", !quantity.hasUnit()); - } else { - Assert.assertEquals("Quantity unit", unit, quantity.getUnit()); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ImmunizationActivityGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ImmunizationActivityGenerator.java deleted file mode 100644 index 36689dea4..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ImmunizationActivityGenerator.java +++ /dev/null @@ -1,326 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.Immunization.ImmunizationReactionComponent; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Consumable; -import org.openhealthtools.mdht.uml.cda.EntryRelationship; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.Observation; -import org.openhealthtools.mdht.uml.cda.Performer2; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationActivity; -import org.openhealthtools.mdht.uml.cda.consol.ImmunizationRefusalReason; -import org.openhealthtools.mdht.uml.cda.consol.Indication; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class ImmunizationActivityGenerator { - private static final Map IMMUNIZATION_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/ImmunizationStatus.json"); - - private List idGenerators = new ArrayList<>(); - - private Boolean negationInd; - - private List effectiveTimeGenerators = new ArrayList<>(); - - private ImmunizationMedicationInformationGenerator medInfoGenerator; - - private List performerGenerators = new ArrayList<>(); - - private List approachSiteCodeGenerators = new ArrayList<>(); - - private CEGenerator routeCodeGenerator; - - private IVL_PQSimpleQuantityGenerator doseQuantityGenerator; - - private CSCodeGenerator statusCodeGenerator; - - private CDGenerator refusalReasonGenerator; - - private CDGenerator indicationGenerator; - - private ReactionObservationGenerator reactionObservationGenerator; - - private String nullFlavor; - - public void setNullFlavor() { - this.nullFlavor = "UNK"; - } - - public void convertToRefused() { - negationInd = true; - indicationGenerator = null; - if (refusalReasonGenerator == null) { - refusalReasonGenerator = CDGenerator.getNextInstance(); - } - } - - public ImmunizationActivity generate(CDAFactories factories) { - ImmunizationActivity ia = factories.consol.createImmunizationActivity(); - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - ia.getIds().add(ii); - }); - - if (negationInd != null) { - ia.setNegationInd(negationInd.booleanValue()); - } - - if (effectiveTimeGenerators != null) { - effectiveTimeGenerators.forEach(ef -> { - IVL_TS ivlTs = ef.generate(factories); - ia.getEffectiveTimes().add(ivlTs); - }); - } - - if (medInfoGenerator != null) { - ManufacturedProduct mp = medInfoGenerator.generate(factories); - Consumable consumable = factories.base.createConsumable(); - consumable.setManufacturedProduct(mp); - ia.setConsumable(consumable); - } - - if (!performerGenerators.isEmpty()) { - performerGenerators.forEach(pg -> { - Performer2 performer = pg.generate(factories); - ia.getPerformers().add(performer); - }); - } - - if (!approachSiteCodeGenerators.isEmpty()) { - approachSiteCodeGenerators.forEach(ascg -> { - CD cd = ascg.generate(factories); - ia.getApproachSiteCodes().add(cd); - }); - } - - if (routeCodeGenerator != null) { - CE ce = routeCodeGenerator.generate(factories); - ia.setRouteCode(ce); - } - - if (doseQuantityGenerator != null) { - IVL_PQ ivlPq = doseQuantityGenerator.generate(factories); - ia.setDoseQuantity(ivlPq); - } - - if (statusCodeGenerator != null) { - CS cs = statusCodeGenerator.generate(factories); - ia.setStatusCode(cs); - } - - if (refusalReasonGenerator != null) { - EntryRelationship er = factories.base.createEntryRelationship(); - ia.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.RSON); - CD refusalReason = refusalReasonGenerator.generate(factories); - ImmunizationRefusalReason irr = factories.consol.createImmunizationRefusalReason(); - irr.setCode(refusalReason); - II templateId = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.53"); - irr.getTemplateIds().add(templateId); - er.setObservation(irr); - } - - if (indicationGenerator != null) { - EntryRelationship er = factories.base.createEntryRelationship(); - ia.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.RSON); - CD indicationCode = indicationGenerator.generate(factories); - Indication indication = factories.consol.createIndication(); - indication.getValues().add(indicationCode); - II templateId = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.19"); - indication.getTemplateIds().add(templateId); - er.setObservation(indication); - } - - if (reactionObservationGenerator != null) { - EntryRelationship er = factories.base.createEntryRelationship(); - ia.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.CAUS); - Observation obs = reactionObservationGenerator.generate(factories); - II templateId = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.9"); - obs.getTemplateIds().add(templateId); - er.setObservation(obs); - } - - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - ia.setNullFlavor(nf); - } - - return ia; - } - - public static ImmunizationActivityGenerator getDefaultInstance() { - ImmunizationActivityGenerator ma = new ImmunizationActivityGenerator(); - - ma.idGenerators.add(IDGenerator.getNextInstance()); - ma.negationInd = false; - ma.effectiveTimeGenerators.add(EffectiveTimeGenerator.getValueOnlyInstance("20190204")); - ma.medInfoGenerator = ImmunizationMedicationInformationGenerator.getDefaultInstance(); - ma.performerGenerators.add(PerformerGenerator.getDefaultInstance()); - ma.approachSiteCodeGenerators.add(CDGenerator.getNextInstance()); - ma.routeCodeGenerator = CEGenerator.getNextInstance(); - ma.doseQuantityGenerator = IVL_PQSimpleQuantityGenerator.getDefaultInstance(); - ma.statusCodeGenerator = new CSCodeGenerator(IMMUNIZATION_STATUS); - ma.statusCodeGenerator.set("active"); - ma.indicationGenerator = CDGenerator.getNextInstance(); - ma.reactionObservationGenerator = ReactionObservationGenerator.getDefaultInstance(); - - return ma; - } - - public void verify(Immunization immunization) { - if (nullFlavor != null) { - Assert.assertNull("Null flavor", immunization); - return; - } - - if (idGenerators.isEmpty()) { - Assert.assertTrue("No immunization identifier", !immunization.hasIdentifier()); - } else { - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(immunization.getIdentifier().get(index)); - } - } - - if (negationInd == null) { - Assert.assertTrue("No immunization not given", !immunization.hasNotGiven()); - } else { - Assert.assertEquals("Immunization not given", negationInd.booleanValue(), immunization.getNotGiven()); - } - - if (effectiveTimeGenerators.isEmpty()) { - Assert.assertTrue("No immunization date", !immunization.hasDate()); - } else { - EffectiveTimeGenerator etg = effectiveTimeGenerators.get(effectiveTimeGenerators.size() - 1); - etg.verifyValue(immunization.getDateElement().asStringValue()); - } - - if (approachSiteCodeGenerators.isEmpty()) { - Assert.assertTrue("No immunization site", !immunization.hasSite()); - } else { - CDGenerator cdg = approachSiteCodeGenerators.get(approachSiteCodeGenerators.size() - 1); - cdg.verify(immunization.getSite()); - } - - if (routeCodeGenerator == null) { - Assert.assertTrue("No immunization route", !immunization.hasRoute()); - } else { - routeCodeGenerator.verify(immunization.getRoute()); - } - - if (doseQuantityGenerator == null) { - Assert.assertTrue("No immunization dose quantity", !immunization.hasDoseQuantity()); - } else { - doseQuantityGenerator.verify(immunization.getDoseQuantity()); - } - - if (refusalReasonGenerator == null) { - boolean hasRefusal = immunization.hasExplanation() && immunization.getExplanation().hasReasonNotGiven(); - Assert.assertTrue("No immunization refusal reason", !hasRefusal); - } else { - CodeableConcept cc = immunization.getExplanation().getReasonNotGiven().get(0); - refusalReasonGenerator.verify(cc); - } - - if (indicationGenerator == null) { - boolean hasReason = immunization.hasExplanation() && immunization.getExplanation().hasReason(); - Assert.assertTrue("No immunization reason", !hasReason); - } else { - boolean hasReason = immunization.hasExplanation() && immunization.getExplanation().hasReason(); - Assert.assertTrue("Has immunization reason", hasReason); - CodeableConcept cc = immunization.getExplanation().getReason().get(0); - indicationGenerator.verify(cc); - } - - if (statusCodeGenerator == null) { - Assert.assertTrue("No immunization status", !immunization.hasStatus()); - } else { - statusCodeGenerator.verify(immunization.getStatus().toCode()); - } - } - - public void verify(Bundle bundle, Immunization immunization) throws Exception { - if (nullFlavor != null) { - Assert.assertNull("Null flavor", immunization); - return; - } - - verify(immunization); - - if (medInfoGenerator == null) { - Assert.assertTrue("No vaccine code", !immunization.hasVaccineCode()); - Assert.assertTrue("No manufacturer", !immunization.hasManufacturer()); - Assert.assertTrue("No lot number", !immunization.hasLotNumber()); - } else { - medInfoGenerator.verify(bundle); - } - - if (performerGenerators.isEmpty()) { - Assert.assertTrue("No practitioner", !immunization.hasPractitioner()); - } else { - Assert.assertEquals("Practitioner count", 1, immunization.getPractitioner().size()); - String practitionerId = immunization.getPractitioner().get(0).getActor().getReference(); - PerformerGenerator pg = performerGenerators.get(performerGenerators.size() - 1); - pg.verifyFromPractionerId(bundle, practitionerId); - } - - if (reactionObservationGenerator == null) { - Assert.assertTrue("No reaction observation", !immunization.hasReaction()); - } else { - List reactions = immunization.getReaction(); - Assert.assertEquals("Reaction count", 1, reactions.size()); - ImmunizationReactionComponent reaction = reactions.get(0); - String observationId = reaction.getDetail().getReference(); - BundleUtil util = new BundleUtil(bundle); - org.hl7.fhir.dstu3.model.Observation observation = util.getResourceFromReference(observationId, - org.hl7.fhir.dstu3.model.Observation.class); - reactionObservationGenerator.verify(observation); - } - } - - public void verify(Bundle bundle) throws Exception { - if (nullFlavor != null) { - Immunization immunization = FHIRUtil.findFirstResource(bundle, Immunization.class); - verify(bundle, immunization); - return; - } - - Immunization immunization = BundleUtil.findOneResource(bundle, Immunization.class); - verify(bundle, immunization); - } - - public void setMedicationInformationGenerator(ImmunizationMedicationInformationGenerator medInfoGenerator) { - this.medInfoGenerator = medInfoGenerator; - } - - public void setReactionObservationGenerator(ReactionObservationGenerator reactObsGen) { - this.reactionObservationGenerator = reactObsGen; - } - - public List getPerformerGenerators() { - return this.performerGenerators; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ImmunizationMedicationInformationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ImmunizationMedicationInformationGenerator.java deleted file mode 100644 index a72c800b7..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ImmunizationMedicationInformationGenerator.java +++ /dev/null @@ -1,99 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Immunization; -import org.hl7.fhir.dstu3.model.Organization; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.Material; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.ST; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ImmunizationMedicationInformationGenerator { - private CEGenerator codeGenerator; - private OrganizationGenerator orgGenerator; - private STGenerator lotNumberGenerator; - - public ManufacturedProduct generate(CDAFactories factories) { - ManufacturedProduct mf = factories.base.createManufacturedProduct(); - - if (codeGenerator != null) { - Material material = factories.base.createMaterial(); - CE ce = codeGenerator.generate(factories); - material.setCode(ce); - mf.setManufacturedMaterial(material); - } - - if (orgGenerator != null) { - org.openhealthtools.mdht.uml.cda.Organization org = orgGenerator.generate(factories); - mf.setManufacturerOrganization(org); - } - - if (lotNumberGenerator != null) { - Material material = mf.getManufacturedMaterial(); - if (material == null) { - material = factories.base.createMaterial(); - mf.setManufacturedMaterial(material); - } - ST st = lotNumberGenerator.generate(factories); - material.setLotNumberText(st); - } - - return mf; - } - - public static ImmunizationMedicationInformationGenerator getDefaultInstance() { - ImmunizationMedicationInformationGenerator imig = new ImmunizationMedicationInformationGenerator(); - - imig.codeGenerator = CEGenerator.getNextInstance(); - imig.orgGenerator = OrganizationGenerator.getDefaultInstance(); - imig.lotNumberGenerator = STGenerator.getNextInstance(); - - return imig; - } - - public void verify(Immunization immunization) { - if (codeGenerator == null) { - Assert.assertTrue("No vaccine code", !immunization.hasVaccineCode()); - } else { - codeGenerator.verify(immunization.getVaccineCode()); - } - - if (lotNumberGenerator == null) { - Assert.assertTrue("No vaccine code", !immunization.hasLotNumber()); - } else { - lotNumberGenerator.verify(immunization.getLotNumber()); - } - } - - public void verify(Organization organization) { - if (orgGenerator == null) { - Assert.assertNull("No immunization manufacturer", organization); - } else { - orgGenerator.verify(organization); - } - } - - public void verify(Bundle bundle) throws Exception { - Immunization immunization = BundleUtil.findOneResource(bundle, Immunization.class); - - verify(immunization); - - BundleUtil util = new BundleUtil(bundle); - - if (orgGenerator == null) { - Assert.assertTrue("No immunization manufacturer", immunization.hasManufacturer()); - } else { - String orgId = immunization.getManufacturer().getReference(); - Organization org = util.getResourceFromReference(orgId, Organization.class); - orgGenerator.verify(org); - } - } - - public void setOrganizationGenerator(OrganizationGenerator orgGenerator) { - this.orgGenerator = orgGenerator; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IndicationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IndicationGenerator.java deleted file mode 100644 index 892a21bb5..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/IndicationGenerator.java +++ /dev/null @@ -1,131 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Condition; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.consol.Indication; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class IndicationGenerator { - - private List idGenerators = new ArrayList<>(); - - private String code; - private String constCodeCode; - private String constCodeDisplay; - private String constCodeSystem; - - private List valueGenerators = new ArrayList<>(); - - private EffectiveTimeGenerator effectiveTimeGenerator; - - private String statusCode; - - public Indication generate(CDAFactories factories) { - Indication indication = factories.consol.createIndication(); - - { - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.19"); - indication.getTemplateIds().add(ii); - } - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - indication.getIds().add(ii); - }); - - if (code != null && constCodeCode != null) { - CD cd = factories.datatype.createCD(); - cd.setCode(code); - indication.setCode(cd); - } - - valueGenerators.forEach(vg -> { - CD value = vg.generate(factories); - indication.getValues().add(value); - }); - - if (effectiveTimeGenerator != null) { - - IVL_TS ivlTs = effectiveTimeGenerator.generate(factories); - indication.setEffectiveTime(ivlTs); - } - - if (statusCode != null) { - CS cs = factories.datatype.createCS(statusCode); - indication.setStatusCode(cs); - } - - return indication; - } - - public void setConstantCode(String constCodeCode, String constCodeDisplay, String constCodeSystem) { - this.constCodeCode = constCodeCode; - this.constCodeDisplay = constCodeDisplay; - this.constCodeSystem = constCodeSystem; - } - - public static IndicationGenerator getDefaultInstance() { - IndicationGenerator indication = new IndicationGenerator(); - - indication.idGenerators.add(IDGenerator.getNextInstance()); - indication.code = "75321-0"; - indication.valueGenerators.add(CDGenerator.getNextInstance()); - indication.effectiveTimeGenerator = new EffectiveTimeGenerator("20171008", "20190110"); - indication.statusCode = "active"; - - return indication; - } - - public void verify(Condition condition) { - if (!idGenerators.isEmpty()) { - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(condition.getIdentifier().get(index)); - } - } else { - Assert.assertTrue("No condition identifier", !condition.hasIdentifier()); - } - - if (code != null && constCodeCode == null) { - Assert.assertEquals("Condition category count", 1, condition.getCategory().size()); - // throw new NotImplementedException("NOt yet implemented"); - } else if (constCodeCode != null) { - Assert.assertEquals("Condition category count", 1, condition.getCategory().size()); - Coding actual = condition.getCategory().get(0).getCoding().get(0); - Assert.assertEquals("Condition category code", constCodeCode, actual.getCode()); - Assert.assertEquals("Condition category system", constCodeSystem, actual.getSystem()); - Assert.assertEquals("Condition category display", constCodeDisplay, actual.getDisplay()); - } else { - Assert.assertTrue("No condition category", !condition.hasCategory()); - } - - if (valueGenerators.isEmpty()) { - Assert.assertTrue("No condition code", !condition.hasCode()); - } else { - CDGenerator valueGenerator = valueGenerators.get(valueGenerators.size() - 1); - valueGenerator.verify(condition.getCode()); - } - - if (effectiveTimeGenerator == null) { - Assert.assertTrue("No condition onset", !condition.hasOnset()); - } else { - String value = effectiveTimeGenerator.getLowOrValue(); - if (value == null) { - Assert.assertTrue("No condition onset", !condition.hasOnset()); - } else { - String actual = FHIRUtil.toCDADatetime(condition.getOnsetDateTimeType().asStringValue()); - Assert.assertEquals("Condition onset", value, actual); - } - } - - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/LanguageCommunicationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/LanguageCommunicationGenerator.java deleted file mode 100644 index 489afaf98..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/LanguageCommunicationGenerator.java +++ /dev/null @@ -1,75 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.List; - -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.LanguageCommunication; -import org.openhealthtools.mdht.uml.hl7.datatypes.BL; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class LanguageCommunicationGenerator { - private static final String[] CODES = { "en", "fr", "tr" }; - - private static int NEXT_INDEX = 1; - - private CSCodeGenerator languageCodeGenerator; - private BLGenerator preferenceIndGenerator; - - public LanguageCommunication generate(CDAFactories factories) { - LanguageCommunication lc = factories.base.createLanguageCommunication(); - - if (languageCodeGenerator != null) { - CS cs = languageCodeGenerator.generate(factories); - lc.setLanguageCode(cs); - } - - if (preferenceIndGenerator != null) { - BL bl = preferenceIndGenerator.generate(factories); - lc.setPreferenceInd(bl); - } - - return lc; - } - - public static LanguageCommunicationGenerator getNextInstance() { - int codeIndex = NEXT_INDEX % CODES.length; - ++NEXT_INDEX; - - String code = CODES[codeIndex]; - - LanguageCommunicationGenerator lcg = new LanguageCommunicationGenerator(); - - lcg.languageCodeGenerator = new CSCodeGenerator(code); - lcg.preferenceIndGenerator = BLGenerator.getNextInstance(); - - return lcg; - } - - public void verify(PatientCommunicationComponent pcc) { - if (languageCodeGenerator == null) { - Assert.assertTrue("No language", !pcc.hasLanguage()); - } else { - Coding coding = pcc.getLanguage().getCoding().get(0); - Assert.assertEquals("Communication system", "http://hl7.org/fhir/ValueSet/languages", coding.getSystem()); - languageCodeGenerator.verify(coding.getCode()); - } - - if (preferenceIndGenerator == null) { - Assert.assertTrue("No preference ind", !pcc.hasPreferred()); - } else { - preferenceIndGenerator.verify(pcc.getPreferred()); - } - } - - public static void verifyList(List actual, - List expected) { - Assert.assertEquals("Language communication size", expected.size(), actual.size()); - for (int index = 0; index < actual.size(); ++index) { - expected.get(index).verify(actual.get(index)); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationActivityGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationActivityGenerator.java deleted file mode 100644 index 260cbb91d..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationActivityGenerator.java +++ /dev/null @@ -1,380 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.MedicationDispense; -import org.hl7.fhir.dstu3.model.MedicationRequest; -import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.hl7.fhir.dstu3.model.SimpleQuantity; -import org.hl7.fhir.dstu3.model.Timing; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.Consumable; -import org.openhealthtools.mdht.uml.cda.EntryRelationship; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.consol.Indication; -import org.openhealthtools.mdht.uml.cda.consol.MedicationActivity; -import org.openhealthtools.mdht.uml.cda.consol.MedicationSupplyOrder; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -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.RTO; -import org.openhealthtools.mdht.uml.hl7.datatypes.RTO_PQ_PQ; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class MedicationActivityGenerator { - private static final Map MED_STATEMENT_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/MedicationStatementStatus.json"); - - private List idGenerators = new ArrayList<>(); - - private String statusCode; - private String statusCodeNullFlavor; - - private AuthorGenerator authorGenerator; - private MedicationInformationGenerator medInfoGenerator; - - private IVL_TSPeriodGenerator ivlTsPeriodGenerator; - private PIVL_TSTimingGenerator pivlTsTimingGenerator; - - private IVL_PQSimpleQuantityGenerator ivlPqGenerator; - - private CEGenerator routeCodeGenerator; - - private IVL_PQRangeGenerator rateQuantityGenerator; - - private RTOGenerator maxDoseGenerator; - - private List indicationGenerators = new ArrayList<>(); - - private MedicationSupplyOrderGenerator medicationSupplyOrderGenerator; - - private MedicationDispenseGenerator medicationDispenseGenerator; - - private String nullFlavor; - - public void setNullFlavor() { - this.nullFlavor = "UNK"; - } - - public void setIDGenerator(IDGenerator idGenerator) { - idGenerators.add(idGenerator); - } - - public MedicationActivity generate(CDAFactories factories) { - MedicationActivity ma = factories.consol.createMedicationActivity(); - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - ma.getIds().add(ii); - }); - - if (statusCode != null || statusCodeNullFlavor != null) { - CS cs = factories.datatype.createCS(); - if (statusCode != null) { - cs.setCode(statusCode); - } - if (statusCodeNullFlavor != null) { - NullFlavor nf = NullFlavor.get(statusCodeNullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - cs.setNullFlavor(nf); - } - ma.setStatusCode(cs); - } - - if (authorGenerator != null) { - Author author = authorGenerator.generate(factories); - ma.getAuthors().add(author); - } - - if (medInfoGenerator != null) { - ManufacturedProduct med = medInfoGenerator.generate(factories); - Consumable consumable = factories.base.createConsumable(); - consumable.setManufacturedProduct(med); - ma.setConsumable(consumable); - } - - if (ivlTsPeriodGenerator != null) { - IVL_TS ivlTs = ivlTsPeriodGenerator.generate(factories); - ma.getEffectiveTimes().add(ivlTs); - } - - if (pivlTsTimingGenerator != null) { - PIVL_TS pivlTs = pivlTsTimingGenerator.generate(factories); - ma.getEffectiveTimes().add(pivlTs); - } - - if (ivlPqGenerator != null) { - IVL_PQ ivlPq = ivlPqGenerator.generate(factories); - ma.setDoseQuantity(ivlPq); - } - - if (routeCodeGenerator != null) { - CE ce = routeCodeGenerator.generate(factories); - ma.setRouteCode(ce); - } - - if (rateQuantityGenerator != null) { - IVL_PQ pq = rateQuantityGenerator.generate(factories); - ma.setRateQuantity(pq); - } - - if (maxDoseGenerator != null) { - RTO pq = maxDoseGenerator.generate(factories); - ma.setMaxDoseQuantity((RTO_PQ_PQ) pq); - } - - indicationGenerators.forEach(ig -> { - EntryRelationship er = factories.base.createEntryRelationship(); - ma.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.RSON); - Indication indication = ig.generate(factories); - er.setObservation(indication); - }); - - if (medicationSupplyOrderGenerator != null) { - MedicationSupplyOrder mso = medicationSupplyOrderGenerator.generate(factories); - EntryRelationship er = factories.base.createEntryRelationship(); - ma.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.REFR); - er.setSupply(mso); - } - - if (medicationDispenseGenerator != null) { - org.openhealthtools.mdht.uml.cda.consol.MedicationDispense md = medicationDispenseGenerator - .generate(factories); - EntryRelationship er = factories.base.createEntryRelationship(); - ma.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.REFR); - er.setSupply(md); - } - - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - ma.setNullFlavor(nf); - } - - return ma; - } - - private void updateIndicationGenerators() { - indicationGenerators.forEach(ig -> { - ig.setConstantCode("problem-list-item", "Problem List Item", "http://hl7.org/fhir/condition-category"); - }); - } - - public static MedicationActivityGenerator getDefaultInstance() { - MedicationActivityGenerator ma = new MedicationActivityGenerator(); - - ma.idGenerators.add(IDGenerator.getNextInstance()); - ma.statusCode = "active"; - ma.authorGenerator = AuthorGenerator.getDefaultInstance(); - ma.medInfoGenerator = MedicationInformationGenerator.getDefaultInstance(); - ma.ivlTsPeriodGenerator = IVL_TSPeriodGenerator.getDefaultInstance(); - ma.pivlTsTimingGenerator = PIVL_TSTimingGenerator.getDefaultInstance(); - ma.ivlPqGenerator = IVL_PQSimpleQuantityGenerator.getDefaultInstance(); - ma.routeCodeGenerator = CEGenerator.getNextInstance(); - ma.rateQuantityGenerator = IVL_PQRangeGenerator.getDefaultInstance(); - ma.indicationGenerators.add(IndicationGenerator.getDefaultInstance()); - ma.medicationSupplyOrderGenerator = MedicationSupplyOrderGenerator.getDefaultInstance(); - ma.medicationDispenseGenerator = MedicationDispenseGenerator.getDefaultInstance(); - - ma.updateIndicationGenerators(); - - return ma; - } - - public void verify(MedicationStatement medStatement) { - if (nullFlavor != null) { - Assert.assertNull("Null flavor", medStatement); - return; - } - - if (!idGenerators.isEmpty()) { - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(medStatement.getIdentifier().get(index)); - } - } else { - Assert.assertTrue("No condition identifier", !medStatement.hasIdentifier()); - } - - if (statusCode == null || statusCodeNullFlavor != null) { - Assert.assertEquals("Default med statement status", "active", medStatement.getStatus().toCode()); - } else { - String expected = (String) MED_STATEMENT_STATUS.get(statusCode); - if (expected == null) { - expected = "unknown"; - } - Assert.assertEquals("Med statement status", expected, medStatement.getStatus().toCode()); - } - - if (ivlTsPeriodGenerator == null) { - Assert.assertTrue("Missing med statement effective", !medStatement.hasEffectivePeriod()); - } else { - ivlTsPeriodGenerator.verify(medStatement.getEffectivePeriod()); - } - - if (pivlTsTimingGenerator == null) { - boolean hasDosageTiming = medStatement.hasDosage() && medStatement.getDosage().get(0).hasTiming(); - Assert.assertTrue("Missing med statement dosage time", !hasDosageTiming); - } else { - Timing timing = medStatement.getDosage().get(0).getTiming(); - pivlTsTimingGenerator.verify(timing); - } - - if (ivlPqGenerator == null) { - boolean hasDosageDose = medStatement.hasDosage() && medStatement.getDosage().get(0).hasDose(); - Assert.assertTrue("Missing med statement dosage time", !hasDosageDose); - } else { - SimpleQuantity sq = medStatement.getDosage().get(0).getDoseSimpleQuantity(); - ivlPqGenerator.verify(sq); - } - - if (routeCodeGenerator == null) { - boolean hasRoute = medStatement.hasDosage() && medStatement.getDosage().get(0).hasRoute(); - Assert.assertTrue("Missing med statement dosage time", !hasRoute); - } else { - routeCodeGenerator.verify(medStatement.getDosage().get(0).getRoute()); - } - - if (rateQuantityGenerator == null) { - boolean hasRate = medStatement.hasDosage() && medStatement.getDosage().get(0).hasRateRange(); - Assert.assertTrue("Missing med statement dosage time", !hasRate); - } else { - rateQuantityGenerator.verify(medStatement.getDosage().get(0).getRateRange()); - } - - if (maxDoseGenerator == null) { - boolean hasMaxDose = medStatement.hasDosage() && medStatement.getDosage().get(0).hasMaxDosePerPeriod(); - Assert.assertTrue("Missing med statement max dose per perios", !hasMaxDose); - } else { - maxDoseGenerator.verify(medStatement.getDosage().get(0).getMaxDosePerPeriod()); - } - } - - public void verify(Bundle bundle, MedicationStatement ms) throws Exception { - if (nullFlavor != null) { - Assert.assertNull("Null flavor", ms); - return; - } - - verify(ms); - - BundleUtil util = new BundleUtil(bundle); - - if (authorGenerator == null) { - Assert.assertTrue("No med statetement information source", !ms.hasInformationSource()); - } else { - String practitionerId = ms.getInformationSource().getReference(); - Practitioner practitioner = util.getResourceFromReference(practitionerId, Practitioner.class); - authorGenerator.verify(practitioner); - - PractitionerRole role = util.getPractitionerRole(practitionerId); - authorGenerator.verify(role); - - if (role.hasOrganization()) { - String reference = role.getOrganization().getReference(); - Organization organization = util.getResourceFromReference(reference, Organization.class); - authorGenerator.verify(organization); - } - } - - if (medInfoGenerator == null) { - Assert.assertTrue("No med statetement medication", !ms.hasMedication()); - } else { - String medId = ms.getMedicationReference().getReference(); - Medication medication = util.getResourceFromReference(medId, Medication.class); - medInfoGenerator.verify(medication); - // medInfoGenerator.verify(bundle); - } - - if (indicationGenerators.isEmpty()) { - Assert.assertTrue("Missing encounter diagnosis", !ms.hasReasonReference()); - } else { - for (int index = 0; index < indicationGenerators.size(); ++index) { - IndicationGenerator ig = indicationGenerators.get(index); - - String conditionId = ms.getReasonReference().get(index).getReference(); - Condition condition = util.getResourceFromReference(conditionId, Condition.class); - ig.verify(condition); - } - } - - MedicationRequest medRequest = FHIRUtil.findFirstResource(bundle, MedicationRequest.class); - if (medicationSupplyOrderGenerator == null) { - Assert.assertNull("No medication request", medRequest); - } else { - medicationSupplyOrderGenerator.verify(medRequest); - medicationSupplyOrderGenerator.verify(bundle); - } - - MedicationDispense medDispense = FHIRUtil.findFirstResource(bundle, MedicationDispense.class); - if (medicationDispenseGenerator == null) { - Assert.assertNull("No medication dispense", medDispense); - } else { - medicationDispenseGenerator.verify(medDispense); - medicationDispenseGenerator.verify(bundle); - } - } - - public void verify(Bundle bundle) throws Exception { - if (nullFlavor != null) { - MedicationStatement ms = FHIRUtil.findFirstResource(bundle, MedicationStatement.class); - verify(bundle, ms); - return; - } - - MedicationStatement ms = BundleUtil.findOneResource(bundle, MedicationStatement.class); - verify(bundle, ms); - } - - public void setMedicationInfoGenerator(MedicationInformationGenerator generator) { - this.medInfoGenerator = generator; - } - - public void setMedicationSupplyOrderGenerator(MedicationSupplyOrderGenerator medicationSupplyOrderGenerator) { - this.medicationSupplyOrderGenerator = medicationSupplyOrderGenerator; - } - - public void setAuthorGenerator(AuthorGenerator authorGenerator) { - this.authorGenerator = authorGenerator; - } - - public MedicationSupplyOrderGenerator getMedicationSupplyOrderGenerator() { - return this.medicationSupplyOrderGenerator; - } - - public MedicationDispenseGenerator getMedicationDispenseGenerator() { - return this.medicationDispenseGenerator; - } - - public void setMedicationDispenseGenerator(MedicationDispenseGenerator medicationDispenseGenerator) { - this.medicationDispenseGenerator = medicationDispenseGenerator; - } - - public void setIndicationGenerators(List indGenerator) { - this.indicationGenerators = indGenerator; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationDispenseGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationDispenseGenerator.java deleted file mode 100644 index 1e6518a43..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationDispenseGenerator.java +++ /dev/null @@ -1,185 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.MedicationDispense; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.Performer2; -import org.openhealthtools.mdht.uml.cda.Product; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; -import org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class MedicationDispenseGenerator { - private static final Map STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/MedicationDispenseStatus.json"); - - private List idGenerators = new ArrayList<>(); - - private List performerGenerators = new ArrayList<>(); - - private CSCodeGenerator statusCodeGenerator; - - private MedicationInformationGenerator medInfoGenerator; - - private IVL_PQSimpleQuantityGenerator quantityGenerator; - - private List effectiveTimeGenerators = new ArrayList<>(); - - public MedicationDispenseGenerator() { - } - - public void setIDGenerator(IDGenerator idGenerator) { - idGenerators.add(idGenerator); - } - - public void setStatusCodeGenerator(String value) { - if (statusCodeGenerator == null) { - statusCodeGenerator = CSCodeGenerator.getInstanceWithValue(STATUS, value); - } else { - statusCodeGenerator.set(value); - } - } - - public org.openhealthtools.mdht.uml.cda.consol.MedicationDispense generate(CDAFactories factories) { - org.openhealthtools.mdht.uml.cda.consol.MedicationDispense md = factories.consol.createMedicationDispense(); - - { - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.18"); - md.getTemplateIds().add(ii); - } - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - md.getIds().add(ii); - }); - - performerGenerators.forEach(performerGenerator -> { - Performer2 performer = performerGenerator.generate(factories); - md.getPerformers().add(performer); - }); - - if (statusCodeGenerator != null) { - CS cs = statusCodeGenerator.generate(factories); - md.setStatusCode(cs); - } - - if (medInfoGenerator != null) { - ManufacturedProduct med = medInfoGenerator.generate(factories); - Product product = factories.base.createProduct(); - product.setManufacturedProduct(med); - md.setProduct(product); - } - - if (quantityGenerator != null) { - PQ pq = quantityGenerator.generate(factories); - md.setQuantity(pq); - } - - effectiveTimeGenerators.forEach(effectiveTimeGenerator -> { - SXCM_TS ts = effectiveTimeGenerator.generate(factories); - md.getEffectiveTimes().add(ts); - }); - - return md; - } - - public static MedicationDispenseGenerator getDefaultInstance() { - MedicationDispenseGenerator md = new MedicationDispenseGenerator(); - - md.idGenerators.add(IDGenerator.getNextInstance()); - md.performerGenerators.add(PerformerGenerator.getDefaultInstance()); - md.statusCodeGenerator = CSCodeGenerator.getInstanceWithValue(STATUS, "completed"); - md.medInfoGenerator = MedicationInformationGenerator.getDefaultInstance(); - md.quantityGenerator = IVL_PQSimpleQuantityGenerator.getDefaultInstance(); - md.effectiveTimeGenerators.add(new SXCM_TSGenerator("20180422")); - md.effectiveTimeGenerators.add(new SXCM_TSGenerator("20190123")); - - return md; - } - - public void verify(MedicationDispense medDispense) { - if (idGenerators.isEmpty()) { - Assert.assertTrue("No med dispense identifier", !medDispense.hasIdentifier()); - } else { - IDGenerator.verifyList(medDispense.getIdentifier(), idGenerators); - } - - if (statusCodeGenerator == null) { - Assert.assertTrue("No med dispense status", !medDispense.hasStatus()); - } else { - statusCodeGenerator.verify(medDispense.getStatus().toCode()); - } - - if (quantityGenerator == null) { - Assert.assertTrue("No med dispense quantity", !medDispense.hasQuantity()); - } else { - quantityGenerator.verify(medDispense.getQuantity()); - } - - if (effectiveTimeGenerators.isEmpty()) { - Assert.assertTrue("No med dispense when prepared", !medDispense.hasWhenPrepared()); - Assert.assertTrue("No med dispense when handed over", !medDispense.hasWhenHandedOver()); - } else { - effectiveTimeGenerators.get(0).verify(medDispense.getWhenPreparedElement().asStringValue()); - int count = effectiveTimeGenerators.size(); - if (count < 2) { - Assert.assertTrue("No med dispense when handed over", !medDispense.hasWhenHandedOver()); - } else { - effectiveTimeGenerators.get(1).verify(medDispense.getWhenHandedOverElement().asStringValue()); - } - } - } - - public void verify(Bundle bundle) throws Exception { - MedicationDispense md = BundleUtil.findOneResource(bundle, MedicationDispense.class); - - verify(md); - - BundleUtil util = new BundleUtil(bundle); - - if (medInfoGenerator == null) { - Assert.assertTrue("No med dispense medication", !md.hasMedicationReference()); - } else { - String medId = md.getMedicationReference().getReference(); - Medication medication = util.getResourceFromReference(medId, Medication.class); - medInfoGenerator.verify(medication); - } - - if (performerGenerators.isEmpty()) { - Assert.assertTrue("No med dispense dispenser", !md.hasPerformer()); - } else if (!md.hasPerformer()) { - int count = performerGenerators.size(); - Assert.assertEquals("Medication count", count, md.getPerformer().size()); - for (int index = 0; index < count; ++index) { - String practitionerId = md.getPerformer().get(index).getActor().getReference(); - performerGenerators.get(index).verifyFromPractionerId(bundle, practitionerId); - } - } - } - - public static Set getAvailableStatusCodes() { - return Collections.unmodifiableSet(STATUS.keySet()); - } - - public void setMedicationInformationGenerator(MedicationInformationGenerator medInfoGen) { - this.medInfoGenerator = medInfoGen; - } - - public void setPerformerGenerators(List performerGenerators) { - this.performerGenerators = performerGenerators; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationInformationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationInformationGenerator.java deleted file mode 100644 index 98886fde1..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationInformationGenerator.java +++ /dev/null @@ -1,92 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.Organization; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.Material; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class MedicationInformationGenerator { - private CEGenerator codeGenerator; - private OrganizationGenerator orgGenerator; - - public ManufacturedProduct generate(CDAFactories factories) { - ManufacturedProduct mf = factories.base.createManufacturedProduct(); - - if (codeGenerator != null) { - Material material = factories.base.createMaterial(); - CE ce = codeGenerator.generate(factories); - material.setCode(ce); - mf.setManufacturedMaterial(material); - } - - if (orgGenerator != null) { - org.openhealthtools.mdht.uml.cda.Organization org = orgGenerator.generate(factories); - mf.setManufacturerOrganization(org); - } - - return mf; - } - - public static MedicationInformationGenerator getDefaultInstance() { - MedicationInformationGenerator mig = new MedicationInformationGenerator(); - - mig.codeGenerator = CEGenerator.getNextInstance(); - mig.orgGenerator = OrganizationGenerator.getDefaultInstance(); - - return mig; - } - - public void verify(Medication med) { - if (codeGenerator == null) { - Assert.assertTrue("No medication code", !med.hasCode()); - } else { - codeGenerator.verify(med.getCode()); - } - } - - public void verify(Organization organization) { - if (orgGenerator == null) { - Assert.assertNull("No medication manufacturer", organization); - } else { - orgGenerator.verify(organization); - } - } - - public void verify(Bundle bundle) throws Exception { - Medication med = BundleUtil.findOneResource(bundle, Medication.class); - - verify(med); - - BundleUtil util = new BundleUtil(bundle); - - if (orgGenerator == null) { - Assert.assertTrue("No medication manufacturer", med.hasManufacturer()); - } else { - String orgId = med.getManufacturer().getReference(); - Organization org = util.getResourceFromReference(orgId, Organization.class); - orgGenerator.verify(org); - } - } - - public void setOrganizationGenerator(OrganizationGenerator orgGenerator) { - this.orgGenerator = orgGenerator; - } - - public OrganizationGenerator getOrganizationGenerator() { - return this.orgGenerator; - } - - public void setCodeGenerator(CEGenerator codeGenerator) { - this.codeGenerator = codeGenerator; - } - - public CEGenerator getCodeGenerator() { - return this.codeGenerator; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationSupplyOrderGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationSupplyOrderGenerator.java deleted file mode 100644 index 8143ba76b..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/MedicationSupplyOrderGenerator.java +++ /dev/null @@ -1,244 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Annotation; -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Medication; -import org.hl7.fhir.dstu3.model.MedicationRequest; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Period; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Act; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.ManufacturedProduct; -import org.openhealthtools.mdht.uml.cda.Product; -import org.openhealthtools.mdht.uml.cda.consol.Instructions; -import org.openhealthtools.mdht.uml.cda.consol.MedicationSupplyOrder; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_INT; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; - -public class MedicationSupplyOrderGenerator { - private static final Map MED_REQUEST_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/MedicationRequestStatus.json"); - - private List idGenerators = new ArrayList<>(); - - private String statusCode; - private String statusCodeNullFlavor; - - private MedicationInformationGenerator medInfoGenerator; - - private IVL_PQSimpleQuantityGenerator quantityGenerator; - - private Integer repeat; - - private List effectiveTimeGenerators = new ArrayList<>(); - - private String annotation; - - private AuthorGenerator authorGenerator; - - public MedicationSupplyOrder generate(CDAFactories factories) { - MedicationSupplyOrder mso = factories.consol.createMedicationSupplyOrder(); - - { - II ii = factories.datatype.createII("2.16.840.1.113883.10.20.22.4.17"); - mso.getTemplateIds().add(ii); - } - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - mso.getIds().add(ii); - }); - - if (statusCode != null || statusCodeNullFlavor != null) { - CS cs = factories.datatype.createCS(); - if (statusCode != null) { - cs.setCode(statusCode); - } - if (statusCodeNullFlavor != null) { - NullFlavor nf = NullFlavor.get(statusCodeNullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - cs.setNullFlavor(nf); - } - mso.setStatusCode(cs); - } - - if (medInfoGenerator != null) { - ManufacturedProduct med = medInfoGenerator.generate(factories); - Product product = factories.base.createProduct(); - product.setManufacturedProduct(med); - mso.setProduct(product); - } - - if (quantityGenerator != null) { - PQ pq = quantityGenerator.generate(factories); - mso.setQuantity(pq); - } - - if (repeat != null) { - IVL_INT ivlInt = factories.datatype.createIVL_INT(); - ivlInt.setValue(repeat); - mso.setRepeatNumber(ivlInt); - } - - if (!effectiveTimeGenerators.isEmpty()) { - effectiveTimeGenerators.forEach(et -> { - IVL_TS ivlTs = et.generate(factories); - mso.getEffectiveTimes().add(ivlTs); - }); - } - - if (annotation != null) { - Instructions instructions = factories.consol.createInstructions(); - Act act = factories.base.createAct(); - ED ed = factories.datatype.createED(); - ed.addText(annotation); - act.setText(ed); - instructions.addAct(act); - mso.addAct(instructions); - } - - if (authorGenerator != null) { - Author author = authorGenerator.generate(factories); - mso.getAuthors().add(author); - } - - return mso; - } - - public static MedicationSupplyOrderGenerator getDefaultInstance() { - MedicationSupplyOrderGenerator mso = new MedicationSupplyOrderGenerator(); - - mso.idGenerators.add(IDGenerator.getNextInstance()); - mso.statusCode = "active"; - mso.medInfoGenerator = MedicationInformationGenerator.getDefaultInstance(); - mso.quantityGenerator = IVL_PQSimpleQuantityGenerator.getDefaultInstance(); - mso.repeat = 3; - mso.effectiveTimeGenerators.add(IVL_TSPeriodGenerator.getDefaultInstance()); - mso.authorGenerator = AuthorGenerator.getDefaultInstance(); - - return mso; - } - - public void verify(MedicationRequest medRequest) { - if (!idGenerators.isEmpty()) { - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(medRequest.getIdentifier().get(index)); - } - } else { - Assert.assertTrue("No med request identifier", !medRequest.hasIdentifier()); - } - - if (statusCode == null || statusCodeNullFlavor != null) { - Assert.assertTrue("Missing med request status", !medRequest.hasStatus()); - } else { - String expected = (String) MED_REQUEST_STATUS.get(statusCode); - if (expected == null) { - expected = "unknown"; - } - Assert.assertEquals("Med request status", expected, medRequest.getStatus().toCode()); - } - - if (quantityGenerator == null) { - boolean hasQuantity = medRequest.hasDispenseRequest() && medRequest.getDispenseRequest().hasQuantity(); - Assert.assertTrue("Missing med request dispense quantity", !hasQuantity); - } else { - quantityGenerator.verify(medRequest.getDispenseRequest().getQuantity()); - } - - if (repeat == null) { - boolean hasQuantity = medRequest.hasDispenseRequest() - && medRequest.getDispenseRequest().hasNumberOfRepeatsAllowed(); - Assert.assertTrue("Missing med request number repeats", !hasQuantity); - } else { - int actual = medRequest.getDispenseRequest().getNumberOfRepeatsAllowed(); - Assert.assertEquals("Med request number repeats", repeat.intValue(), actual); - } - - if (effectiveTimeGenerators.isEmpty()) { - boolean hasQuantity = medRequest.hasDispenseRequest() - && medRequest.getDispenseRequest().hasValidityPeriod(); - Assert.assertTrue("Missing med request dispense validity period", !hasQuantity); - } else { - Period period = medRequest.getDispenseRequest().getValidityPeriod(); - IVL_TSPeriodGenerator g = effectiveTimeGenerators.get(effectiveTimeGenerators.size() - 1); - g.verify(period); - } - - if (annotation == null) { - Assert.assertTrue("Missing med request note", !medRequest.hasNote()); - } else { - List notes = medRequest.getNote(); - Assert.assertEquals("Note annotation count", 1, notes.size()); - Assert.assertEquals("Note annotation", annotation, notes.get(0).getText()); - } - } - - public void verify(Bundle bundle) throws Exception { - MedicationRequest mr = BundleUtil.findOneResource(bundle, MedicationRequest.class); - - verify(mr); - - BundleUtil util = new BundleUtil(bundle); - - if (medInfoGenerator == null) { - Assert.assertTrue("No med statetement medication", !mr.hasMedicationReference()); - } else { - String medId = mr.getMedicationReference().getReference(); - Medication medication = util.getResourceFromReference(medId, Medication.class); - medInfoGenerator.verify(medication); - // medInfoGenerator.verify(bundle); - } - - if (authorGenerator == null) { - Assert.assertTrue("No med request requester", !mr.hasRequester()); - } else if (!mr.hasRequester()) { - authorGenerator.verify((Organization) null); - authorGenerator.verify((PractitionerRole) null); - authorGenerator.verify((Organization) null); - } else { - String practitionerId = mr.getRequester().getAgent().getReference(); - Practitioner practitioner = util.getResourceFromReference(practitionerId, Practitioner.class); - authorGenerator.verify(practitioner); - - PractitionerRole role = util.getPractitionerRole(practitionerId); - authorGenerator.verify(role); - - if (!role.hasOrganization()) { - authorGenerator.verify((Organization) null); - } else { - String reference = role.getOrganization().getReference(); - Organization organization = util.getResourceFromReference(reference, Organization.class); - authorGenerator.verify(organization); - } - } - } - - public void setMedicationInfoGenerator(MedicationInformationGenerator generator) { - this.medInfoGenerator = generator; - } - - public void setAuthorGenerator(AuthorGenerator authorGenerator) { - this.authorGenerator = authorGenerator; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ObservationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ObservationGenerator.java deleted file mode 100644 index 0c43437b9..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ObservationGenerator.java +++ /dev/null @@ -1,289 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.Observation; -import org.openhealthtools.mdht.uml.cda.ReferenceRange; -import org.openhealthtools.mdht.uml.hl7.datatypes.ANY; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; - -public class ObservationGenerator { - private static final Map OBSERVATION_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/ObservationStatus.json"); - private static final Map OBSERVATION_INTERPRETATION = JsonUtils - .filepathToMap("src/test/resources//value-maps/ObservationInterpretation.json"); - - private List idGenerators = new ArrayList<>(); - - private CDGenerator codeGenerator; - - private CSCodeGenerator statusCodeGenerator; - - private IVL_TSPeriodGenerator effectiveTimeGenerator; - - private List targetSiteCodeGenerators = new ArrayList<>(); - - private List valueGenerators = new ArrayList<>(); - - private List authorGenerators = new ArrayList<>(); - - private List methodCodeGenerators = new ArrayList<>(); - - private List interpretationCodeGenerators = new ArrayList<>(); - - private List referenceRangeGenerators = new ArrayList<>(); - - public void replaceValueGenerator(PQGenerator pqGenerator) { - valueGenerators.clear(); - AnyGenerator ag = new AnyGenerator(pqGenerator); - valueGenerators.add(ag); - } - - public void replaceValueGenerator(STGenerator stGenerator) { - valueGenerators.clear(); - AnyGenerator ag = new AnyGenerator(stGenerator); - valueGenerators.add(ag); - } - - public void replaceValueGenerator(IVL_PQRangeGenerator ivlPqRangeGenerator) { - valueGenerators.clear(); - AnyGenerator ag = new AnyGenerator(ivlPqRangeGenerator); - valueGenerators.add(ag); - } - - public void replaceValueGenerator(RTOGenerator rtoGenerator) { - valueGenerators.clear(); - AnyGenerator ag = new AnyGenerator(rtoGenerator); - valueGenerators.add(ag); - } - - public void replaceValueGenerator(EDGenerator edGenerator) { - valueGenerators.clear(); - AnyGenerator ag = new AnyGenerator(edGenerator); - valueGenerators.add(ag); - } - - public void replaceValueGenerator(TSGenerator tsGenerator) { - valueGenerators.clear(); - AnyGenerator ag = new AnyGenerator(tsGenerator); - valueGenerators.add(ag); - } - - public void replaceValueGenerator(BLGenerator blGenerator) { - valueGenerators.clear(); - AnyGenerator ag = new AnyGenerator(blGenerator); - valueGenerators.add(ag); - } - - public Observation createForGenerate(CDAFactories factories) { - return factories.base.createObservation(); - } - - public Observation generate(CDAFactories factories) { - Observation obs = createForGenerate(factories); - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - obs.getIds().add(ii); - }); - - if (codeGenerator != null) { - CD code = codeGenerator.generate(factories); - obs.setCode(code); - } - - if (statusCodeGenerator != null) { - CS cs = statusCodeGenerator.generate(factories); - obs.setStatusCode(cs); - } - - if (effectiveTimeGenerator != null) { - IVL_TS ivlTs = effectiveTimeGenerator.generate(factories); - obs.setEffectiveTime(ivlTs); - } - - targetSiteCodeGenerators.forEach(tscg -> { - CD cd = tscg.generate(factories); - obs.getTargetSiteCodes().add(cd); - }); - - valueGenerators.forEach(vg -> { - ANY any = vg.generate(factories); - obs.getValues().add(any); - }); - - authorGenerators.forEach(ag -> { - Author author = ag.generate(factories); - obs.getAuthors().add(author); - }); - - methodCodeGenerators.forEach(mcg -> { - CE ce = mcg.generate(factories); - obs.getMethodCodes().add(ce); - }); - - interpretationCodeGenerators.forEach(code -> { - CE ce = factories.datatype.createCE(); - ce.setCode(code); - obs.getInterpretationCodes().add(ce); - }); - - referenceRangeGenerators.forEach(rrg -> { - ReferenceRange rr = rrg.generate(factories); - obs.getReferenceRanges().add(rr); - }); - - return obs; - } - - public static void fillDefaultInstance(ObservationGenerator obs) { - obs.idGenerators.add(IDGenerator.getNextInstance()); - obs.codeGenerator = CDGenerator.getNextInstance(); - obs.statusCodeGenerator = new CSCodeGenerator(OBSERVATION_STATUS, "unknown"); - obs.statusCodeGenerator.set("active"); - obs.effectiveTimeGenerator = IVL_TSPeriodGenerator.getDefaultInstance(); - obs.targetSiteCodeGenerators.add(CDGenerator.getNextInstance()); - obs.valueGenerators.add(new AnyGenerator(CDGenerator.getNextInstance())); - - AuthorGenerator authorGenerator = AuthorGenerator.getDefaultInstance(); - authorGenerator.setTimeGenerator(new TSGenerator("20170122103500-0400")); - obs.authorGenerators.add(authorGenerator); - - obs.methodCodeGenerators.add(CEGenerator.getNextInstance()); - obs.interpretationCodeGenerators.add("CAR"); - obs.referenceRangeGenerators.add(ReferenceRangeGenerator.getDefaultInstance()); - } - - public static ObservationGenerator getDefaultInstance() { - ObservationGenerator generator = new ObservationGenerator(); - fillDefaultInstance(generator); - return generator; - } - - @SuppressWarnings("unchecked") - public void verify(org.hl7.fhir.dstu3.model.Observation observation) { - if (idGenerators.isEmpty()) { - Assert.assertTrue("No observation identifier", !observation.hasIdentifier()); - } else { - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(observation.getIdentifier().get(index)); - } - } - - if (codeGenerator == null) { - Assert.assertTrue("No observation status", !observation.hasCode()); - } else { - codeGenerator.verify(observation.getCode()); - } - - if (statusCodeGenerator == null) { - Assert.assertTrue("No observation status", !observation.hasStatus()); - } else { - statusCodeGenerator.verify(observation.getStatus().toCode()); - } - - if (effectiveTimeGenerator == null) { - Assert.assertTrue("No observation effective period", !observation.hasEffectivePeriod()); - } else { - effectiveTimeGenerator.verify(observation.getEffectivePeriod()); - } - - if (targetSiteCodeGenerators.isEmpty()) { - Assert.assertTrue("No observation target site code", !observation.hasBodySite()); - } else { - CDGenerator cdg = targetSiteCodeGenerators.get(targetSiteCodeGenerators.size() - 1); - cdg.verify(observation.getBodySite()); - } - - if (valueGenerators.isEmpty()) { - Assert.assertTrue("No observation value", !observation.hasValue()); - } else { - AnyGenerator ag = valueGenerators.get(valueGenerators.size() - 1); - if (observation.hasValueCodeableConcept()) { - ag.verify(observation.getValueCodeableConcept()); - } else if (observation.hasValueQuantity()) { - ag.verify(observation.getValueQuantity()); - } else if (observation.hasValueStringType()) { - ag.verify(observation.getValueStringType().getValueAsString()); - } else if (observation.hasValueRange()) { - ag.verify(observation.getValueRange()); - } else if (observation.hasValueRatio()) { - ag.verify(observation.getValueRatio()); - } else if (observation.hasValueAttachment()) { - ag.verify(observation.getValueAttachment()); - } else if (observation.hasValueDateTimeType()) { - ag.verify(observation.getValueDateTimeType()); - } else if (observation.hasValueBooleanType()) { - ag.verify(observation.getValueBooleanType().booleanValue()); - } else { - throw new TestSetupException("Invalid observation value"); - } - } - - if (methodCodeGenerators.isEmpty()) { - Assert.assertTrue("No observation method", !observation.hasMethod()); - } else { - CEGenerator ceg = methodCodeGenerators.get(methodCodeGenerators.size() - 1); - ceg.verify(observation.getMethod()); - } - - if (authorGenerators.isEmpty()) { - Assert.assertTrue("No issued element", !observation.hasIssuedElement()); - } else { - AuthorGenerator ag = authorGenerators.get(authorGenerators.size() - 1); - TSGenerator timeGenerator = ag.getTimeGenerator(); - timeGenerator.verify(observation.getIssuedElement().asStringValue()); - } - - if (interpretationCodeGenerators.isEmpty()) { - Assert.assertTrue("No interpretation", !observation.hasInterpretation()); - } else { - String input = interpretationCodeGenerators.get(interpretationCodeGenerators.size() - 1); - String expected = (String) ((Map) OBSERVATION_INTERPRETATION.get(input)).get("code"); - String actual = observation.getInterpretation().getCoding().get(0).getCode(); - Assert.assertEquals("Observation interpretation", expected, actual); - } - - if (referenceRangeGenerators.isEmpty()) { - Assert.assertTrue("No reference range", !observation.hasReferenceRange()); - } else { - int count = referenceRangeGenerators.size(); - Assert.assertEquals("Reference range count", count, observation.getReferenceRange().size()); - for (int index = 0; index < count; ++index) { - referenceRangeGenerators.get(index).verify(observation.getReferenceRange().get(index)); - } - } - } - - public void verify(Bundle bundle) throws Exception { - org.hl7.fhir.dstu3.model.Observation obs = BundleUtil.findOneResource(bundle, - org.hl7.fhir.dstu3.model.Observation.class); - verify(obs); - - if (authorGenerators.isEmpty()) { - Assert.assertTrue("No practitioner", !obs.hasPerformer()); - } else { - Assert.assertEquals("Performer count", authorGenerators.size(), obs.getPerformer().size()); - for (int index = 0; index < authorGenerators.size(); ++index) { - String practitionerId = obs.getPerformer().get(index).getReference(); - AuthorGenerator ag = authorGenerators.get(index); - ag.verifyFromPractionerId(bundle, practitionerId); - } - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/OrganizationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/OrganizationGenerator.java deleted file mode 100644 index a3d8244bc..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/OrganizationGenerator.java +++ /dev/null @@ -1,178 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Address; -import org.hl7.fhir.dstu3.model.ContactPoint; -import org.hl7.fhir.dstu3.model.Identifier; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.CustodianOrganization; -import org.openhealthtools.mdht.uml.cda.Organization; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.ON; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; - -public class OrganizationGenerator { - private static final String NAME = "The Organization"; - - private String nullFlavor; - - private String name; - - private List idGenerators = new ArrayList<>(); - private List adGenerators = new ArrayList<>(); - private List telGenerators = new ArrayList<>(); - - public OrganizationGenerator() { - } - - public OrganizationGenerator(String name) { - this.name = name; - } - - public void setADGenerator(ADGenerator adGenerator) { - adGenerators.clear(); - adGenerators.add(adGenerator); - } - - public void setNullFlavor() { - nullFlavor = "UNK"; - } - - public boolean isNullFlavor() { - return nullFlavor != null; - } - - public boolean shouldExists() { - return nullFlavor == null && (name != null || !idGenerators.isEmpty()); - } - - public CustodianOrganization generateCustodianOrg(CDAFactories factories) { - CustodianOrganization custodianOrg = factories.base.createCustodianOrganization(); - Organization org = generate(factories); - if (org.getNames() != null) { - - for (int i = 0; i < org.getNames().size(); i++) { - custodianOrg.setName(org.getNames().get(i)); - } - } - - if (org.getIds() != null) { - custodianOrg.getIds().addAll(org.getIds()); - } - - if (org.getAddrs() != null) { - for (int i = 0; i < org.getAddrs().size(); i++) { - custodianOrg.setAddr(org.getAddrs().get(i)); - } - } - - if (org.getTelecoms() != null) { - for (int i = 0; i < org.getTelecoms().size(); i++) { - custodianOrg.setTelecom(org.getTelecoms().get(i)); - } - } - - if (org.getNullFlavor() != null) { - custodianOrg.setNullFlavor(org.getNullFlavor()); - } - - return custodianOrg; - } - - public Organization generate(CDAFactories factories) { - Organization organization = factories.base.createOrganization(); - - if (name != null) { - ON on = factories.datatype.createON(); - on.addText(name); - organization.getNames().add(on); - } - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - organization.getIds().add(ii); - }); - - adGenerators.forEach(adGenerator -> { - AD ad = adGenerator.generate(factories); - organization.getAddrs().add(ad); - }); - - telGenerators.forEach(telGenerator -> { - TEL tel = telGenerator.generate(factories); - organization.getTelecoms().add(tel); - }); - - if (nullFlavor != null) { - NullFlavor nf = NullFlavor.get(nullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - organization.setNullFlavor(nf); - } - - return organization; - } - - public static OrganizationGenerator getDefaultInstance() { - OrganizationGenerator og = new OrganizationGenerator(); - - og.name = NAME; - - og.idGenerators.add(IDGenerator.getNextInstance()); - - ADGenerator adGenerator = ADGenerator.getDefaultInstance(); - TELGenerator telGenerator = TELGenerator.getDefaultInstance(); - - og.adGenerators.add(adGenerator); - og.telGenerators.add(telGenerator); - - return og; - } - - public static OrganizationGenerator getFullInstance() { - OrganizationGenerator og = new OrganizationGenerator(); - - og.name = NAME; - - og.idGenerators.add(IDGenerator.getNextInstance()); - og.idGenerators.add(IDGenerator.getNextInstance()); - og.idGenerators.add(IDGenerator.getNextInstance()); - - og.adGenerators.add(ADGenerator.getFullInstance()); - og.telGenerators.add(TELGenerator.getFullInstance()); - og.adGenerators.add(ADGenerator.getDefaultInstance()); - og.telGenerators.add(TELGenerator.getDefaultInstance()); - - return og; - } - - public void verify(org.hl7.fhir.dstu3.model.Organization organization) { - Assert.assertEquals("Organization name", name, organization.getName()); - - List identifiers = organization.getIdentifier(); - Assert.assertEquals("Organization identifier count", identifiers.size(), idGenerators.size()); - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(identifiers.get(index)); - } - - List
addresses = organization.getAddress(); - Assert.assertEquals("Organization address count", addresses.size(), adGenerators.size()); - for (int index = 0; index < adGenerators.size(); ++index) { - adGenerators.get(index).verify(addresses.get(index)); - } - - List contactPoints = organization.getTelecom(); - Assert.assertEquals("Organization telecom count", contactPoints.size(), telGenerators.size()); - for (int index = 0; index < telGenerators.size(); ++index) { - telGenerators.get(index).verify(contactPoints.get(index)); - } - } -} \ No newline at end of file diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PIVL_TSTimingGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PIVL_TSTimingGenerator.java deleted file mode 100644 index 470a5fd86..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PIVL_TSTimingGenerator.java +++ /dev/null @@ -1,80 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.math.BigDecimal; - -import org.hl7.fhir.dstu3.model.Timing; -import org.junit.Assert; -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 tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class PIVL_TSTimingGenerator { - private BigDecimal value; - private String unit; - - private IVL_TSPeriodGenerator ivlTsPeriodGenerator; - - public PIVL_TSTimingGenerator() { - } - - public PIVL_TS generate(CDAFactories factories) { - PIVL_TS pivlTs = factories.datatype.createPIVL_TS(); - PQ pq = factories.datatype.createPQ(); - pivlTs.setPeriod(pq); - - if (value != null) { - pq.setValue(value); - } - if (unit != null) { - pq.setUnit(unit); - } - if (ivlTsPeriodGenerator != null) { - IVL_TS ivlTs = ivlTsPeriodGenerator.generate(factories); - pivlTs.setPhase(ivlTs); - } - return pivlTs; - } - - public static PIVL_TSTimingGenerator getDefaultInstance() { - PIVL_TSTimingGenerator ptg = new PIVL_TSTimingGenerator(); - - ptg.value = new BigDecimal(12); - ptg.unit = "h"; - ptg.ivlTsPeriodGenerator = IVL_TSPeriodGenerator.getDefaultInstance(); - - return ptg; - } - - public static PIVL_TSTimingGenerator getFullInstance() { - PIVL_TSTimingGenerator ptg = new PIVL_TSTimingGenerator(); - - ptg.value = new BigDecimal(120); - ptg.unit = "h"; - ptg.ivlTsPeriodGenerator = IVL_TSPeriodGenerator.getFullInstance(); - - return getDefaultInstance(); - } - - public void verify(Timing timing) { - if (value == null) { - Assert.assertTrue("No timing repeat", !timing.hasRepeat()); - } else { - Assert.assertEquals("Timing repeat period", value, timing.getRepeat().getPeriod()); - } - - if (unit == null) { - Assert.assertTrue("No timing repeat unit", !timing.hasRepeat() || !timing.getRepeat().hasPeriodUnit()); - } else { - Assert.assertEquals("Timing repeat unit", unit, - timing.getRepeat().getPeriodUnit().toString().toLowerCase()); - } - - if (ivlTsPeriodGenerator == null) { - Assert.assertTrue("No timing repeat", !timing.hasRepeat() || !timing.getRepeat().hasBounds()); - } else { - ivlTsPeriodGenerator.verify(timing.getRepeat().getBoundsPeriod()); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PNGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PNGenerator.java deleted file mode 100644 index 6a5f2a0ac..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PNGenerator.java +++ /dev/null @@ -1,291 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.hl7.fhir.dstu3.model.HumanName; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.PN; -import org.openhealthtools.mdht.uml.hl7.vocab.EntityNameUse; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.ValueMapUtil; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; - -public class PNGenerator { - private static Map NAME_USE = JsonUtils - .filepathToMap("src/test/resources//value-maps/NameUse.json"); - - private static final String USE = "C"; - private static final String GIVEN = "JOE"; - private static final String FAMILY = "DOE"; - private static final String PREFIX = "Dr"; - private static final String SUFFIX = "Jr"; - - private String nullFlavor; - private List uses = new ArrayList<>();; - private String text; - - private ENXPGenerator family; - private List givens = new ArrayList<>(); - - private List prefixes = new ArrayList<>(); - private List suffixes = new ArrayList<>(); - - private IVL_TSPeriodGenerator ivlTsGenerator; - - public PNGenerator() { - } - - @SuppressWarnings("unchecked") - public static void copyStringArray(Map source, List target, String key) { - List sourceArray = (List) source.get(key); - if (sourceArray != null) { - sourceArray.forEach(e -> { - String value = (String) e; - if (value != null) { - ENXPGenerator g = new ENXPGenerator(value); - target.add(g); - } - }); - } - } - - @SuppressWarnings("unchecked") - public PNGenerator(Map json) { - ValueMapUtil.copyStringArray(json, uses, "use"); - - family = new ENXPGenerator((String) json.get("family")); - - copyStringArray(json, givens, "given"); - - copyStringArray(json, prefixes, "prefix"); - copyStringArray(json, suffixes, "suffix"); - - text = (String) json.get("content"); - - if (json.containsKey("validTime")) { - ivlTsGenerator = new IVL_TSPeriodGenerator((Map) json.get("validTime")); - } - } - - public void setNullFlavor() { - nullFlavor = "UNK"; - } - - public void setFamilyNullFlavor() { - if (family == null) { - family = ENXPGenerator.getNextInstance(true); - } - family.setNullFlavor("UNK"); - } - - public void setGivensNullFlavor() { - if (givens.isEmpty()) { - givens.add(ENXPGenerator.getNextInstance(true)); - } - givens.forEach(given -> given.setNullFlavor("UNK")); - } - - public void setFamilyGenerator(ENXPGenerator generator) { - family = generator; - } - - public void setGivensGenerator(ENXPGenerator generator) { - givens.clear(); - givens.add(generator); - } - - public void addUse(String use) { - this.uses.add(use); - } - - public boolean hasNullFlavor() { - return nullFlavor != null; - } - - public PN generate(CDAFactories factories) { - PN pn = factories.datatype.createPN(); - - uses.forEach(use -> { - EntityNameUse enu = EntityNameUse.get(use); - if (enu == null) { - throw new TestSetupException("Invalid 'use' value for PN."); - } - pn.getUses().add(enu); - }); - - if (family != null) { - pn.getFamilies().add(family.generate(factories)); - } - - givens.forEach(given -> pn.getGivens().add(given.generate(factories))); - prefixes.forEach(prefix -> pn.getPrefixes().add(prefix.generate(factories))); - suffixes.forEach(suffix -> pn.getSuffixes().add(suffix.generate(factories))); - - if (nullFlavor != null) { - NullFlavor nf = NullFlavor.get(nullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - pn.setNullFlavor(nf); - } - - if (ivlTsGenerator != null) { - IVL_TS ivlTs = ivlTsGenerator.generate(factories); - pn.setValidTime(ivlTs); - } - - if (text != null) { - pn.addText(text); - } - - return pn; - } - - public static PNGenerator getDefaultInstance() { - PNGenerator pn = new PNGenerator(); - - pn.family = new ENXPGenerator(FAMILY, true); - pn.givens.add(new ENXPGenerator(GIVEN, true)); - - return pn; - } - - public static PNGenerator getFullInstance() { - PNGenerator pn = new PNGenerator(); - - pn.uses.add(USE); - pn.family = new ENXPGenerator(FAMILY, true); - pn.givens.add(new ENXPGenerator(GIVEN + "_1", true)); - pn.givens.add(new ENXPGenerator(GIVEN + "_2", true)); - pn.prefixes.add(new ENXPGenerator(PREFIX + "_1", true)); - pn.prefixes.add(new ENXPGenerator(PREFIX + "_2", true)); - pn.suffixes.add(new ENXPGenerator(SUFFIX + "_1", true)); - pn.suffixes.add(new ENXPGenerator(SUFFIX + "_2", true)); - pn.text = "The Text"; - - pn.ivlTsGenerator = IVL_TSPeriodGenerator.getFullInstance(); - - return pn; - } - - public void verify(HumanName humanName) { - if (nullFlavor != null) { - Assert.assertNull("Human name", humanName); - return; - } - - if (uses.isEmpty()) { - Assert.assertTrue("Missing name use", !humanName.hasUse()); - } else { - String lastUse = uses.get(uses.size() - 1); - String expected = (String) NAME_USE.get(lastUse); - String actual = humanName.getUse().toCode(); - if (expected == null) { - Assert.assertEquals("Name use", actual, "usual"); - } else { - Assert.assertEquals("Name use", actual, expected); - } - } - - if (family == null) { - Assert.assertTrue("Missing family name", !humanName.hasFamily()); - } else { - family.verify(humanName.getFamily()); - } - - if (givens.isEmpty()) { - Assert.assertTrue("Missing given name", !humanName.hasGiven()); - } else { - BaseStringGenerator.verifyList(humanName.getGiven(), givens); - } - - if (prefixes.isEmpty()) { - Assert.assertTrue("Missing name prefix", !humanName.hasPrefix()); - } else { - BaseStringGenerator.verifyList(humanName.getPrefix(), prefixes); - } - - if (suffixes.isEmpty()) { - Assert.assertTrue("Missing name suffix", !humanName.hasSuffix()); - } else { - BaseStringGenerator.verifyList(humanName.getSuffix(), suffixes); - } - - if (ivlTsGenerator == null) { - Assert.assertTrue("Missing name valid time", !humanName.hasPeriod()); - } else { - ivlTsGenerator.verify(humanName.getPeriod()); - } - - if (text == null) { - Assert.assertTrue("Missing name text", !humanName.hasText()); - } else { - Assert.assertEquals("Name text", text, humanName.getText()); - - } - } - - public Map toJson() { - Map result = new LinkedHashMap<>(); - - if (!uses.isEmpty() && nullFlavor == null) { - String lastUse = uses.get(uses.size() - 1); - String field = (String) NAME_USE.get(lastUse); - if (field == null) { - field = "usual"; - } - result.put("use", field); - } - - if (family != null && nullFlavor == null) { - result.put("family", family.getValue()); - } - - if (!givens.isEmpty() && nullFlavor == null) { - List values = givens.stream().map(r -> r.getValue()).collect(Collectors.toList()); - result.put("given", new ArrayList<>(values)); - } - - if (!prefixes.isEmpty() && nullFlavor == null) { - List values = prefixes.stream().map(r -> r.getValue()).collect(Collectors.toList()); - result.put("prefix", new ArrayList<>(values)); - } - - if (!suffixes.isEmpty() && nullFlavor == null) { - List values = suffixes.stream().map(r -> r.getValue()).collect(Collectors.toList()); - result.put("suffix", new ArrayList<>(values)); - } - if (text != null && nullFlavor == null) { - result.put("text", text); - } - if (ivlTsGenerator != null) { - Map ivlTsValue = ivlTsGenerator.toJson(); - result.put("period", ivlTsValue); - } - if (result.isEmpty()) - return null; - return result; - } - - public static Set getAvailableUses() { - return Collections.unmodifiableSet(NAME_USE.keySet()); - } - - public static void verifyList(List actual, List expected) { - Assert.assertEquals("Human name count", expected.size(), actual.size()); - for (int index = 0; index < actual.size(); ++index) { - expected.get(index).verify(actual.get(index)); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PQGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PQGenerator.java deleted file mode 100644 index bac563ad2..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PQGenerator.java +++ /dev/null @@ -1,61 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.math.BigDecimal; - -import org.hl7.fhir.dstu3.model.Quantity; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.PQ; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class PQGenerator { - private BigDecimal value; - private String unit; - - public PQGenerator() { - } - - public PQ generate(CDAFactories factories) { - PQ pq = factories.datatype.createPQ(); - - if (value != null) { - pq.setValue(value); - } - if (unit != null) { - pq.setUnit(unit); - } - return pq; - } - - public static PQGenerator getDefaultInstance() { - PQGenerator ptg = new PQGenerator(); - - ptg.value = new BigDecimal(124); - ptg.unit = "kg"; - - return ptg; - } - - public static PQGenerator getFullInstance() { - PQGenerator ptg = new PQGenerator(); - - ptg.value = new BigDecimal(1289); - ptg.unit = "kg"; - - return ptg; - } - - public void verify(Quantity quantity) { - if (value == null) { - Assert.assertTrue("No value", !quantity.hasValue()); - } else { - Assert.assertEquals("Quantity value", value, quantity.getValue()); - } - - if (unit == null) { - Assert.assertTrue("No quantity unit", !quantity.hasUnit()); - } else { - Assert.assertEquals("Quantity unit", unit, quantity.getUnit()); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PatientGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PatientGenerator.java deleted file mode 100644 index 06fa943fe..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PatientGenerator.java +++ /dev/null @@ -1,156 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Patient; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Birthplace; -import org.openhealthtools.mdht.uml.cda.Guardian; -import org.openhealthtools.mdht.uml.cda.LanguageCommunication; -import org.openhealthtools.mdht.uml.cda.Place; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.PN; -import org.openhealthtools.mdht.uml.hl7.datatypes.TS; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class PatientGenerator { - private static final Map GENDER = JsonUtils - .filepathToMap("src/test/resources//value-maps/Gender.json"); - private static final Map MARITAL_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/MaritalStatus.json"); - - private List nameGenerators = new ArrayList<>(); - private CECodeGenerator genderGenerator; - private TSGenerator birthTimeGenerator; - private CECodeGenerator maritalStatusGenerator; - private List languageCommunicationGenerators = new ArrayList<>(); - private List guardianGenerators = new ArrayList<>(); - private CEGenerator raceGenerator; - private CEGenerator ethnicGroupGenerator; - private CEGenerator religiousAffiliationGenerator; - private ADGenerator birthPlaceGenerator; - - public org.openhealthtools.mdht.uml.cda.Patient generate(CDAFactories factories) { - org.openhealthtools.mdht.uml.cda.Patient p = factories.base.createPatient(); - - nameGenerators.forEach(g -> { - PN pn = g.generate(factories); - p.getNames().add(pn); - }); - - if (genderGenerator != null) { - CE ce = genderGenerator.generate(factories); - p.setAdministrativeGenderCode(ce); - } - - if (birthTimeGenerator != null) { - TS ts = birthTimeGenerator.generate(factories); - p.setBirthTime(ts); - } - - if (maritalStatusGenerator != null) { - CE ce = maritalStatusGenerator.generate(factories); - p.setMaritalStatusCode(ce); - } - - languageCommunicationGenerators.forEach(lcg -> { - LanguageCommunication lc = lcg.generate(factories); - p.getLanguageCommunications().add(lc); - }); - - guardianGenerators.forEach(g -> { - Guardian guardian = g.generate(factories); - p.getGuardians().add(guardian); - }); - - if (raceGenerator != null) { - CE ce = raceGenerator.generate(factories); - p.setRaceCode(ce); - } - - if (ethnicGroupGenerator != null) { - CE ce = ethnicGroupGenerator.generate(factories); - p.setEthnicGroupCode(ce); - } - - if (religiousAffiliationGenerator != null) { - CE ce = religiousAffiliationGenerator.generate(factories); - p.setReligiousAffiliationCode(ce); - } - - if (birthPlaceGenerator != null) { - Birthplace bp = factories.base.createBirthplace(); - p.setBirthplace(bp); - Place place = factories.base.createPlace(); - bp.setPlace(place); - AD ad = birthPlaceGenerator.generate(factories); - place.setAddr(ad); - } - - return p; - } - - public static PatientGenerator getDefaultInstance() { - PatientGenerator prg = new PatientGenerator(); - - prg.nameGenerators.add(PNGenerator.getDefaultInstance()); - prg.genderGenerator = new CECodeGenerator(GENDER, "unknown"); - prg.genderGenerator.set("f"); - prg.birthTimeGenerator = new TSGenerator("20040502"); - prg.maritalStatusGenerator = new CECodeGenerator(MARITAL_STATUS, "UNK"); - prg.maritalStatusGenerator.set("M"); - prg.languageCommunicationGenerators.add(LanguageCommunicationGenerator.getNextInstance()); - prg.guardianGenerators.add(GuardianGenerator.getDefaultInstance()); - prg.raceGenerator = CEGenerator.getNextInstance(); - prg.ethnicGroupGenerator = CEGenerator.getNextInstance(); - prg.religiousAffiliationGenerator = CEGenerator.getNextInstance(); - prg.birthPlaceGenerator = ADGenerator.getDefaultInstance(); - - return prg; - } - - public void verify(Patient patient) { - if (nameGenerators.isEmpty()) { - Assert.assertTrue("No patient name", !patient.hasName()); - } else { - PNGenerator.verifyList(patient.getName(), nameGenerators); - } - - if (genderGenerator == null) { - Assert.assertTrue("No patient gender", !patient.hasGender()); - } else { - genderGenerator.verify(patient.getGender().toCode()); - } - - if (birthTimeGenerator == null) { - Assert.assertTrue("No patient birthday", !patient.hasBirthDate()); - } else { - birthTimeGenerator.verify(patient.getBirthDateElement().asStringValue()); - } - - if (maritalStatusGenerator == null) { - Assert.assertTrue("No patient marital status", !patient.hasMaritalStatus()); - } else { - maritalStatusGenerator.verify(patient.getMaritalStatus()); - } - - if (languageCommunicationGenerators.isEmpty()) { - Assert.assertTrue("No patient language communications", !patient.hasCommunication()); - } else { - LanguageCommunicationGenerator.verifyList(patient.getCommunication(), languageCommunicationGenerators); - } - - if (guardianGenerators.isEmpty()) { - Assert.assertTrue("No patient guardians", !patient.hasContact()); - } else { - GuardianGenerator.verifyList(patient.getContact(), guardianGenerators); - } - - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PatientRoleGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PatientRoleGenerator.java deleted file mode 100644 index b7948ba28..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PatientRoleGenerator.java +++ /dev/null @@ -1,118 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Patient; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.PatientRole; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class PatientRoleGenerator { - private List idGenerators = new ArrayList<>(); - private List addrGenerators = new ArrayList<>(); - private List telecomGenerators = new ArrayList<>(); - private OrganizationGenerator providerOrgGenerator; - private PatientGenerator patientGenerator; - - public PatientRole generate(CDAFactories factories) { - PatientRole pr = factories.base.createPatientRole(); - - idGenerators.forEach(g -> { - II ii = g.generate(factories); - pr.getIds().add(ii); - }); - - addrGenerators.forEach(g -> { - AD ad = g.generate(factories); - pr.getAddrs().add(ad); - }); - - telecomGenerators.forEach(g -> { - TEL tel = g.generate(factories); - pr.getTelecoms().add(tel); - }); - - if (providerOrgGenerator != null) { - pr.setProviderOrganization(providerOrgGenerator.generate(factories)); - } - - if (patientGenerator != null) { - pr.setPatient(patientGenerator.generate(factories)); - } - - return pr; - } - - public static PatientRoleGenerator getDefaultInstance() { - PatientRoleGenerator prg = new PatientRoleGenerator(); - - prg.idGenerators.add(IDGenerator.getNextInstance()); - prg.addrGenerators.add(ADGenerator.getDefaultInstance()); - prg.telecomGenerators.add(TELGenerator.getDefaultInstance()); - prg.providerOrgGenerator = OrganizationGenerator.getDefaultInstance(); - prg.patientGenerator = PatientGenerator.getDefaultInstance(); - - return prg; - } - - public void verify(Patient patient) { - if (idGenerators.isEmpty()) { - Assert.assertTrue("No patient identifier", !patient.hasIdentifier()); - } else { - IDGenerator.verifyList(patient.getIdentifier(), idGenerators); - } - - if (addrGenerators.isEmpty()) { - Assert.assertTrue("No patient address", !patient.hasAddress()); - } else { - ADGenerator.verifyList(patient.getAddress(), addrGenerators); - } - - if (telecomGenerators.isEmpty()) { - Assert.assertTrue("No patient telecom", !patient.hasTelecom()); - } else { - TELGenerator.verifyList(patient.getTelecom(), telecomGenerators); - } - - if (providerOrgGenerator == null) { - Assert.assertTrue("No patient telecom", !patient.hasManagingOrganization()); - } else { - Assert.assertTrue("Patient telecom exists", patient.hasManagingOrganization()); - } - - if (patientGenerator == null) { - boolean other = patient.hasName(); - Assert.assertTrue("No patient name or other", !other); - } else { - patientGenerator.verify(patient); - } - } - - public void verify(Bundle bundle) throws Exception { - BundleUtil util = new BundleUtil(bundle); - Patient patient = BundleUtil.findOneResource(bundle, Patient.class); - - verify(patient); - - if (providerOrgGenerator == null) { - Assert.assertTrue("No patient telecom", !patient.hasManagingOrganization()); - } else { - String organizationId = patient.getManagingOrganization().getReference(); - Assert.assertNotNull("Patient managing organization", organizationId); - Organization organization = util.getResourceFromReference(organizationId, Organization.class); - providerOrgGenerator.verify(organization); - } - } - - public void setProviderOrgGenerator(OrganizationGenerator orgGenerator) { - this.providerOrgGenerator = orgGenerator; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PerformerGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PerformerGenerator.java deleted file mode 100644 index 1080f34d4..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PerformerGenerator.java +++ /dev/null @@ -1,68 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.openhealthtools.mdht.uml.cda.AssignedEntity; -import org.openhealthtools.mdht.uml.cda.Performer2; -import org.openhealthtools.mdht.uml.cda.impl.Performer2Impl; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class PerformerGenerator { - private AssignedEntityGenerator assignedEntityGenerator; - - public PerformerGenerator() { - assignedEntityGenerator = new AssignedEntityGenerator(); - } - - public PerformerGenerator(AssignedEntityGenerator assignedEntityGenerator) { - this.assignedEntityGenerator = assignedEntityGenerator; - } - - public Performer2 generate(CDAFactories factories) { - Performer2Impl performer = (Performer2Impl) factories.base.createPerformer2(); - AssignedEntity entity = assignedEntityGenerator.generate(factories); - performer.setAssignedEntity(entity); - return performer; - } - - public AssignedEntityGenerator getAssignedEntityGenerator() { - return assignedEntityGenerator; - } - - public static PerformerGenerator getDefaultInstance() { - AssignedEntityGenerator aeg = AssignedEntityGenerator.getDefaultInstance(); - return new PerformerGenerator(aeg); - } - - public static PerformerGenerator getFullInstance() { - AssignedEntityGenerator aeg = AssignedEntityGenerator.getFullInstance(); - return new PerformerGenerator(aeg); - } - - public String getCodeCode() { - return assignedEntityGenerator.getCodeCode(); - } - - public void verify(Practitioner practitioner) { - assignedEntityGenerator.verify(practitioner); - } - - public void verify(PractitionerRole role) { - assignedEntityGenerator.verify(role); - } - - public void verify(org.hl7.fhir.dstu3.model.Organization org) { - assignedEntityGenerator.verify(org); - } - - public void verifyFromPractionerId(Bundle bundle, String practitionerId) { - assignedEntityGenerator.verifyFromPractionerId(bundle, practitionerId); - } - - public void setAssignedEntityGenerator(AssignedEntityGenerator assignedEntityGenerator) { - this.assignedEntityGenerator = assignedEntityGenerator; - } - -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PlayingEntityGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PlayingEntityGenerator.java deleted file mode 100644 index c39b90681..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/PlayingEntityGenerator.java +++ /dev/null @@ -1,57 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.hl7.fhir.dstu3.model.CodeableConcept; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.PlayingEntity; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.PN; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class PlayingEntityGenerator { - private static int INDEX = 1; - - private String name; - - private CEGenerator codeGenerator; - - public PlayingEntity generate(CDAFactories factories) { - PlayingEntity pe = factories.base.createPlayingEntity(); - - if (name != null) { - PN pn = factories.datatype.createPN(); - pn.addText(name); - pe.getNames().add(pn); - } - - if (codeGenerator != null) { - CE ce = codeGenerator.generate(factories); - pe.setCode(ce); - } - - return pe; - } - - public static PlayingEntityGenerator getDefaultInstance() { - PlayingEntityGenerator peg = new PlayingEntityGenerator(); - - peg.name = "name_" + (++INDEX); - peg.codeGenerator = CEGenerator.getNextInstance(); - - return peg; - } - - public void verify(CodeableConcept codeableConcept) { - if (name == null) { - Assert.assertTrue("No text", !codeableConcept.hasText()); - } else { - Assert.assertEquals("Text", name, codeableConcept.getText()); - } - - if (codeGenerator == null) { - Assert.assertTrue("No coding", !codeableConcept.hasCoding()); - } else { - codeGenerator.verify(codeableConcept); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ProblemConcernActGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ProblemConcernActGenerator.java deleted file mode 100644 index 505cedf78..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ProblemConcernActGenerator.java +++ /dev/null @@ -1,155 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Identifier; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.EntryRelationship; -import org.openhealthtools.mdht.uml.cda.consol.ProblemConcernAct; -import org.openhealthtools.mdht.uml.cda.consol.ProblemObservation; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; -import tr.com.srdc.cda2fhir.transform.util.IdentifierMapFactory; -import tr.com.srdc.cda2fhir.transform.util.impl.IdentifierMap; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class ProblemConcernActGenerator { - private static final Map CONDITION_VERIFICATION_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/ConditionVerificationStatus.json"); - - private List problemObservationGenerators = new ArrayList<>(); - - private String statusCode; - - public ProblemConcernAct generate(CDAFactories factories) { - ProblemConcernAct pca = factories.consol.createProblemConcernAct(); - - if (!problemObservationGenerators.isEmpty()) { - problemObservationGenerators.forEach(pog -> { - EntryRelationship er = factories.base.createEntryRelationship(); - pca.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.SUBJ); - ProblemObservation po = pog.generate(factories); - er.setObservation(po); - }); - } - - if (statusCode != null) { - CS cs = factories.datatype.createCS(statusCode); - pca.setStatusCode(cs); - } - - return pca; - } - - public static ProblemConcernActGenerator getDefaultInstance() { - ProblemConcernActGenerator pcag = new ProblemConcernActGenerator(); - - ProblemObservationGenerator pog = ProblemObservationGenerator.getDefaultInstance(); - pcag.problemObservationGenerators.add(pog); - - return pcag; - } - - public static ProblemConcernActGenerator getFullInstance() { - ProblemConcernActGenerator pcag = new ProblemConcernActGenerator(); - - ProblemObservationGenerator pog0 = ProblemObservationGenerator.getDefaultInstance(); - ProblemObservationGenerator pog1 = ProblemObservationGenerator.getFullInstance(); - pcag.problemObservationGenerators.add(pog0); - pcag.problemObservationGenerators.add(pog1); - pcag.statusCode = "active"; - - return pcag; - } - - private int findProblemObservationGeneratorIndex(Condition condition) { - for (int index = 0; index < problemObservationGenerators.size(); ++index) { - IDGenerator idg = problemObservationGenerators.get(index).getIDGenerator(0); - String system = idg.getSystem(); - String value = idg.getValue(); - - List identifiers = condition.getIdentifier(); - for (int index2 = 0; index2 < identifiers.size(); ++index2) { - Identifier identifier = identifiers.get(index2); - String idSystem = identifier.getSystem(); - String idValue = identifier.getValue(); - if (system.equals(idSystem) && value.equals(idValue)) { - return index; - } - } - } - return -1; - } - - public void verify(Bundle bundle) throws Exception { - List conditions = FHIRUtil.findResources(bundle, Condition.class); - int count = problemObservationGenerators == null ? 0 : problemObservationGenerators.size(); - Assert.assertEquals("Num of condition resources", count, conditions.size()); - for (int index = 0; index < 1; ++index) { // assume in order until proven otherwise - Condition condition = conditions.get(index); - int pogIndex = count > 0 ? findProblemObservationGeneratorIndex(condition) : 0; - if (pogIndex < 0) { - throw new TestSetupException("Cannot find problem observation from identifiers."); - } - ProblemObservationGenerator pog = problemObservationGenerators.get(pogIndex); - pog.verify(condition); - pog.verify(bundle, condition); - - if (statusCode == null) { - Assert.assertEquals("Condition verification status", "unknown", - condition.getVerificationStatus().toCode()); - } else { - String actual = (String) CONDITION_VERIFICATION_STATUS.get(statusCode); - if (actual == null) { - actual = "unknown"; - } - Assert.assertEquals("Condition verification status", actual, - condition.getVerificationStatus().toCode()); - } - } - } - - public static void reorderActObservations(CDAFactories factories, ProblemConcernAct act, - List conditions) { - IdentifierMap orderMap = IdentifierMapFactory.resourcesToOrder(conditions); - List observations = new ArrayList<>(); - act.getProblemObservations().forEach(r -> observations.add(r)); - - observations.sort((a, b) -> { - int aval = CDAUtilExtension.idValue("Condition", a.getIds(), orderMap); - int bval = CDAUtilExtension.idValue("Condition", b.getIds(), orderMap); - return aval - bval; - }); - - Iterator it = act.getEntryRelationships().iterator(); - while (it.hasNext()) { - EntryRelationship er = it.next(); - if (er.getObservation() instanceof ProblemObservation) { - it.remove(); - } - } - - observations.forEach(po -> { - EntryRelationship er = factories.base.createEntryRelationship(); - act.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.SUBJ); - er.setObservation(po); - }); - } - - public void setProblemObservationGenerators(List problemObservationGenerators) { - this.problemObservationGenerators = problemObservationGenerators; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ProblemObservationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ProblemObservationGenerator.java deleted file mode 100644 index 6bb608b63..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ProblemObservationGenerator.java +++ /dev/null @@ -1,184 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Condition; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.consol.ProblemObservation; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.datatypes.TS; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class ProblemObservationGenerator { - private List idGenerators = new ArrayList<>(); - private CDGenerator codeGenerator; - private List valueGenerators = new ArrayList<>(); - - private EffectiveTimeGenerator effectiveTimeGenerator; - - private AuthorGenerator authorGenerator; - - private String authorTime; - - public ProblemObservation generate(CDAFactories factories) { - ProblemObservation po = factories.consol.createProblemObservation(); - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - po.getIds().add(ii); - }); - - if (codeGenerator != null) { - CD code = codeGenerator.generate(factories); - po.setCode(code); - } - - valueGenerators.forEach(vg -> { - CD value = vg.generate(factories); - po.getValues().add(value); - }); - - if (effectiveTimeGenerator != null) { - IVL_TS ivlTs = effectiveTimeGenerator.generate(factories); - po.setEffectiveTime(ivlTs); - } - - if (authorGenerator != null) { - Author author = authorGenerator.generate(factories); - - if (authorTime != null) { - TS ts = factories.datatype.createTS(authorTime); - author.setTime(ts); - } - - po.getAuthors().add(author); - } - - return po; - } - - public static ProblemObservationGenerator getDefaultInstance() { - ProblemObservationGenerator pcag = new ProblemObservationGenerator(); - - pcag.idGenerators.add(IDGenerator.getNextInstance()); - pcag.codeGenerator = CDGenerator.getNextInstance(); - pcag.valueGenerators.add(CDGenerator.getNextInstance()); - pcag.effectiveTimeGenerator = new EffectiveTimeGenerator("20171008"); - - return pcag; - } - - public static ProblemObservationGenerator getFullInstance() { - ProblemObservationGenerator pcag = new ProblemObservationGenerator(); - - pcag.idGenerators.add(IDGenerator.getNextInstance()); - pcag.idGenerators.add(IDGenerator.getNextInstance()); - pcag.idGenerators.add(IDGenerator.getNextInstance()); - pcag.idGenerators.add(IDGenerator.getNextInstance()); - pcag.codeGenerator = CDGenerator.getNextInstance(); - pcag.valueGenerators.add(CDGenerator.getNextInstance()); - pcag.valueGenerators.add(CDGenerator.getNextInstance()); - pcag.effectiveTimeGenerator = new EffectiveTimeGenerator("20171008", "20181123"); - pcag.authorGenerator = AuthorGenerator.getDefaultInstance(); - pcag.authorTime = "20190101203500-0500"; - - return pcag; - } - - public IDGenerator getIDGenerator(int index) { - return idGenerators.get(index); - } - - public void verify(Condition condition) { - if (!idGenerators.isEmpty()) { - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(condition.getIdentifier().get(index)); - } - } else { - Assert.assertTrue("No condition identifier", !condition.hasIdentifier()); - } - - if (codeGenerator != null) { - Assert.assertEquals("Condition category count", 1, condition.getCategory().size()); - Coding actual = condition.getCategory().get(0).getCoding().get(0); - Assert.assertEquals("Condition category code", "problem-list-item", actual.getCode()); - Assert.assertEquals("Condition category system", "http://hl7.org/fhir/condition-category", - actual.getSystem()); - Assert.assertEquals("Condition category display", "Problem List Item", actual.getDisplay()); - } else { - Assert.assertTrue("No condition category", !condition.hasCategory()); - } - - if (valueGenerators.isEmpty()) { - Assert.assertTrue("No condition code", !condition.hasCode()); - } else { - CDGenerator valueGenerator = valueGenerators.get(valueGenerators.size() - 1); - valueGenerator.verify(condition.getCode()); - } - - if (effectiveTimeGenerator == null) { - Assert.assertTrue("No condition onset", !condition.hasOnset()); - } else { - String value = effectiveTimeGenerator.getLowOrValue(); - if (value == null) { - Assert.assertTrue("No condition onset", !condition.hasOnset()); - } else { - String actual = FHIRUtil.toCDADatetime(condition.getOnsetDateTimeType().asStringValue()); - Assert.assertEquals("Condition offset", value, actual); - } - } - - if (authorTime != null) { - Assert.assertTrue("Condition asserter date", condition.hasAssertedDate()); - String datetime = condition.getAssertedDateElement().asStringValue(); - String actual = FHIRUtil.toCDADatetime(datetime); - Assert.assertEquals("Condition asserter date", authorTime, actual); - } - } - - public void verify(Bundle bundle, Condition condition) throws Exception { - verify(condition); - - if (authorGenerator == null) { - Assert.assertTrue("No recorder", !condition.hasAsserter()); - } else { - String practitionerId = condition.getAsserter().getReference(); - authorGenerator.verifyFromPractionerId(bundle, practitionerId); - } - } - - public void verify(Practitioner practitioner) { - if (authorGenerator == null) { - Assert.assertNull("Practitioner", practitioner); - } else { - authorGenerator.verify(practitioner); - } - } - - public void verify(PractitionerRole practitionerRole) { - if (authorGenerator == null) { - Assert.assertNull("Practitioner role", practitionerRole); - } else { - authorGenerator.verify(practitionerRole); - } - } - - public void verify(Organization organization) { - if (authorGenerator == null) { - Assert.assertNull("Organization", organization); - } else { - authorGenerator.verify(organization); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ProcedureActivityProcedureGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ProcedureActivityProcedureGenerator.java deleted file mode 100644 index bbe7d49a7..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ProcedureActivityProcedureGenerator.java +++ /dev/null @@ -1,222 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Organization; -import org.hl7.fhir.dstu3.model.Practitioner; -import org.hl7.fhir.dstu3.model.PractitionerRole; -import org.hl7.fhir.dstu3.model.Procedure; -import org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.EntryRelationship; -import org.openhealthtools.mdht.uml.cda.Performer2; -import org.openhealthtools.mdht.uml.cda.consol.Indication; -import org.openhealthtools.mdht.uml.cda.consol.ProcedureActivityProcedure; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; -import org.openhealthtools.mdht.uml.hl7.vocab.x_ActRelationshipEntryRelationship; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; - -public class ProcedureActivityProcedureGenerator { - private static final Map PROCEDURE_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/ProcedureStatus.json"); - - private List idGenerators = new ArrayList<>(); - private IVL_TSPeriodGenerator ivlTsGenerator; - private List targetSiteCodeGenerators = new ArrayList<>(); - - private String statusCode; - private String statusCodeNullFlavor; - - private CDGenerator codeGenerator; - - private List reasonCodeGenerators = new ArrayList<>(); - - private List performerGenerators = new ArrayList<>(); - - public ProcedureActivityProcedure generate(CDAFactories factories) { - ProcedureActivityProcedure pap = factories.consol.createProcedureActivityProcedure(); - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - pap.getIds().add(ii); - }); - - if (ivlTsGenerator != null) { - IVL_TS ivlTs = ivlTsGenerator.generate(factories); - pap.setEffectiveTime(ivlTs); - } - - targetSiteCodeGenerators.forEach(tcg -> { - CD cd = tcg.generate(factories); - pap.getTargetSiteCodes().add(cd); - }); - - if (statusCode != null || statusCodeNullFlavor != null) { - CS cs = factories.datatype.createCS(); - if (statusCode != null) { - cs.setCode(statusCode); - } - if (statusCodeNullFlavor != null) { - NullFlavor nf = NullFlavor.get(statusCodeNullFlavor); - if (nf == null) { - throw new TestSetupException("Invalid null flavor enumeration."); - } - cs.setNullFlavor(nf); - } - pap.setStatusCode(cs); - } - - if (codeGenerator != null) { - CD cd = codeGenerator.generate(factories); - pap.setCode(cd); - } - - reasonCodeGenerators.forEach(rcg -> { - EntryRelationship er = factories.base.createEntryRelationship(); - pap.getEntryRelationships().add(er); - er.setTypeCode(x_ActRelationshipEntryRelationship.RSON); - Indication indication = factories.consol.createIndication(); - er.setObservation(indication); - CD cd = rcg.generate(factories); - indication.setCode(cd); - }); - - performerGenerators.forEach(pg -> { - Performer2 performer = pg.generate(factories); - pap.getPerformers().add(performer); - }); - - return pap; - } - - public static ProcedureActivityProcedureGenerator getDefaultInstance() { - ProcedureActivityProcedureGenerator papg = new ProcedureActivityProcedureGenerator(); - - papg.idGenerators.add(IDGenerator.getNextInstance()); - papg.ivlTsGenerator = IVL_TSPeriodGenerator.getDefaultInstance(); - papg.targetSiteCodeGenerators.add(CDGenerator.getNextInstance()); - papg.statusCode = "active"; - papg.codeGenerator = CDGenerator.getNextInstance(); - papg.reasonCodeGenerators.add(CDGenerator.getNextInstance()); - papg.performerGenerators.add(PerformerGenerator.getDefaultInstance()); - - return papg; - } - - public IDGenerator getIDGenerator(int index) { - return idGenerators.get(index); - } - - public void verify(Procedure procedure) { - if (!idGenerators.isEmpty()) { - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(procedure.getIdentifier().get(index)); - } - } else { - Assert.assertTrue("No condition identifier", !procedure.hasIdentifier()); - } - - if (ivlTsGenerator == null) { - Assert.assertTrue("Missing procedure performed", !procedure.hasPerformedPeriod()); - } else { - ivlTsGenerator.verify(procedure.getPerformedPeriod()); - } - - if (targetSiteCodeGenerators.isEmpty()) { - Assert.assertTrue("Missing procedure target site", !procedure.hasBodySite()); - } else { - for (int index = 0; index < targetSiteCodeGenerators.size(); ++index) { - targetSiteCodeGenerators.get(index).verify(procedure.getBodySite().get(index)); - } - } - - if (statusCode == null || statusCodeNullFlavor != null) { - Assert.assertTrue("Missing procedure status", !procedure.hasStatus()); - } else { - String expected = (String) PROCEDURE_STATUS.get(statusCode); - if (expected == null) { - expected = "unknown"; - } - Assert.assertEquals("Procedure status", expected, procedure.getStatus().toCode()); - } - - if (codeGenerator == null) { - Assert.assertTrue("Missing procedure code", !procedure.hasCode()); - } else { - codeGenerator.verify(procedure.getCode()); - } - - if (reasonCodeGenerators.isEmpty()) { - Assert.assertTrue("Missing procedure reason code", !procedure.hasReasonCode()); - } else { - for (int index = 0; index < reasonCodeGenerators.size(); ++index) { - reasonCodeGenerators.get(index).verify(procedure.getReasonCode().get(index)); - } - } - - if (performerGenerators.isEmpty()) { - Assert.assertTrue("Missing procedure performer", !procedure.hasPerformer()); - } else { - Assert.assertEquals("Procedure performer count", performerGenerators.size(), - procedure.getPerformer().size()); - } - } - - public void verify(Bundle bundle, Procedure procedure) throws Exception { - verify(procedure); - - if (performerGenerators.isEmpty()) { - Assert.assertTrue("Missing procedure performer", !procedure.hasPerformer()); - } else { - BundleUtil util = new BundleUtil(bundle); - - for (int index = 0; index < performerGenerators.size(); ++index) { - PerformerGenerator pg = performerGenerators.get(index); - ProcedurePerformerComponent ppc = procedure.getPerformer().get(index); - - String practitionerId = ppc.getActor().getReference(); - pg.verifyFromPractionerId(bundle, practitionerId); - - Practitioner practitioner = util.getResourceFromReference(practitionerId, Practitioner.class); - pg.verify(practitioner); - - PractitionerRole role = util.getPractitionerRole(practitionerId); - pg.verify(role); - - Assert.assertTrue("Procedure performer has role", ppc.hasRole()); - Coding ppcRole = ppc.getRole().getCoding().get(0); - Assert.assertEquals("Procedure performer has role", pg.getCodeCode(), ppcRole.getCode()); - - if (!role.hasOrganization()) { - pg.verify((Organization) null); - Assert.assertTrue("No on behalf organization", !ppc.hasOnBehalfOf()); - } else { - String reference = role.getOrganization().getReference(); - Organization organization = util.getResourceFromReference(reference, Organization.class); - pg.verify(organization); - Assert.assertEquals("Procedure on behalf organization", reference, - ppc.getOnBehalfOf().getReference()); - } - - } - } - } - - public void verify(Bundle bundle) throws Exception { - Procedure procedure = BundleUtil.findOneResource(bundle, Procedure.class); - verify(bundle, procedure); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/RTOGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/RTOGenerator.java deleted file mode 100644 index 2f4fc6487..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/RTOGenerator.java +++ /dev/null @@ -1,70 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.hl7.fhir.dstu3.model.Ratio; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.REAL; -import org.openhealthtools.mdht.uml.hl7.datatypes.RTO; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class RTOGenerator { - private Double numerator; - private Double denominator; - - public RTOGenerator() { - } - - public RTO generate(CDAFactories factories) { - RTO rto = factories.datatype.createRTO(); - - if (numerator != null) { - REAL real = factories.datatype.createREAL(); - real.setValue(numerator); - rto.setNumerator(real); - } - - if (denominator != null) { - REAL real = factories.datatype.createREAL(); - real.setValue(denominator); - rto.setDenominator(real); - } - - return rto; - } - - public static RTOGenerator getDefaultInstance() { - RTOGenerator rg = new RTOGenerator(); - - rg.numerator = new Double(5.5); - rg.denominator = new Double(9.5); - - return rg; - } - - public static RTOGenerator getFullInstance() { - RTOGenerator rg = new RTOGenerator(); - - rg.numerator = new Double(5.5); - rg.denominator = new Double(9.5); - - return rg; - } - - public void verify(Ratio ratio) { - if (numerator == null) { - Assert.assertTrue("No ratio numerator", !ratio.hasNumerator()); - } else { - double expected = numerator.doubleValue(); - double actual = ratio.getNumerator().getValueElement().getValue().doubleValue(); - Assert.assertTrue("Ration numerator", Math.abs(expected - actual) < 0.001); - } - - if (denominator == null) { - Assert.assertTrue("No ratio denominator", !ratio.hasNumerator()); - } else { - double expected = denominator.doubleValue(); - double actual = ratio.getDenominator().getValueElement().getValue().doubleValue(); - Assert.assertTrue("Ratio denominator", Math.abs(expected - actual) < 0.001); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ReactionObservationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ReactionObservationGenerator.java deleted file mode 100644 index 7a133bcf1..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ReactionObservationGenerator.java +++ /dev/null @@ -1,18 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.openhealthtools.mdht.uml.cda.consol.ReactionObservation; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ReactionObservationGenerator extends ObservationGenerator { - @Override - public ReactionObservation createForGenerate(CDAFactories factories) { - return factories.consol.createReactionObservation(); - } - - public static ReactionObservationGenerator getDefaultInstance() { - ReactionObservationGenerator rog = new ReactionObservationGenerator(); - ObservationGenerator.fillDefaultInstance(rog); - return rog; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ReferenceRangeGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ReferenceRangeGenerator.java deleted file mode 100644 index 755fe1f5b..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ReferenceRangeGenerator.java +++ /dev/null @@ -1,74 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.hl7.fhir.dstu3.model.Observation.ObservationReferenceRangeComponent; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.ObservationRange; -import org.openhealthtools.mdht.uml.cda.ReferenceRange; -import org.openhealthtools.mdht.uml.hl7.datatypes.CE; -import org.openhealthtools.mdht.uml.hl7.datatypes.ED; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_PQ; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ReferenceRangeGenerator { - private IVL_PQRangeGenerator rangeGenerator; - private CEGenerator interpretationCodeGenerator; - private EDGenerator textGenerator; - - public ReferenceRangeGenerator() { - } - - public ReferenceRange generate(CDAFactories factories) { - ReferenceRange rr = factories.base.createReferenceRange(); - - ObservationRange or = factories.base.createObservationRange(); - rr.setObservationRange(or); - - if (rangeGenerator != null) { - IVL_PQ ivlPq = rangeGenerator.generate(factories); - or.setValue(ivlPq); - } - - if (interpretationCodeGenerator != null) { - CE ce = interpretationCodeGenerator.generate(factories); - or.setInterpretationCode(ce); - } - - if (textGenerator != null) { - ED ed = textGenerator.generate(factories); - or.setText(ed); - } - - return rr; - } - - public static ReferenceRangeGenerator getDefaultInstance() { - ReferenceRangeGenerator rrg = new ReferenceRangeGenerator(); - - rrg.rangeGenerator = IVL_PQRangeGenerator.getDefaultInstance(); - rrg.interpretationCodeGenerator = CEGenerator.getNextInstance(); - rrg.textGenerator = EDGenerator.getNextInstance(); - - return rrg; - } - - public void verify(ObservationReferenceRangeComponent range) { - if (rangeGenerator == null) { - Assert.assertNull("No range value", range); - } else { - rangeGenerator.verify(range); - } - - if (interpretationCodeGenerator == null) { - Assert.assertTrue("No range type", !range.hasType()); - } else { - interpretationCodeGenerator.verify(range.getType()); - } - - if (textGenerator == null) { - Assert.assertTrue("No range text", !range.hasText()); - } else { - textGenerator.verify(range.getText()); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ResultObservationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ResultObservationGenerator.java deleted file mode 100644 index b8c458db3..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ResultObservationGenerator.java +++ /dev/null @@ -1,18 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.openhealthtools.mdht.uml.cda.consol.ResultObservation; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ResultObservationGenerator extends ObservationGenerator { - @Override - public ResultObservation createForGenerate(CDAFactories factories) { - return factories.consol.createResultObservation(); - } - - public static ResultObservationGenerator getDefaultInstance() { - ResultObservationGenerator rog = new ResultObservationGenerator(); - ObservationGenerator.fillDefaultInstance(rog); - return rog; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ResultOrganizerGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ResultOrganizerGenerator.java deleted file mode 100644 index 45f7e6e3a..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ResultOrganizerGenerator.java +++ /dev/null @@ -1,149 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Author; -import org.openhealthtools.mdht.uml.cda.consol.ResultOrganizer; -import org.openhealthtools.mdht.uml.hl7.datatypes.CD; -import org.openhealthtools.mdht.uml.hl7.datatypes.CS; -import org.openhealthtools.mdht.uml.hl7.datatypes.II; -import org.openhealthtools.mdht.uml.hl7.datatypes.IVL_TS; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.testutil.BundleUtil; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ResultOrganizerGenerator { - private static final Map DIAGNOSTIC_REPORT_STATUS = JsonUtils - .filepathToMap("src/test/resources//value-maps/DiagnosticReportStatus.json"); - - private List idGenerators = new ArrayList<>(); - - private CDGenerator codeGenerator; - - private CSCodeGenerator statusCodeGenerator; - - private IVL_TSPeriodGenerator effectiveTimeGenerator; - - private List authorGenerators = new ArrayList<>(); - - private List observationGenerators = new ArrayList<>(); - - public ResultOrganizer generate(CDAFactories factories) { - ResultOrganizer ro = factories.consol.createResultOrganizer(); - - idGenerators.forEach(idGenerator -> { - II ii = idGenerator.generate(factories); - ro.getIds().add(ii); - }); - - if (codeGenerator != null) { - CD cd = codeGenerator.generate(factories); - ro.setCode(cd); - } - - if (statusCodeGenerator != null) { - CS cs = statusCodeGenerator.generate(factories); - ro.setStatusCode(cs); - } - - if (effectiveTimeGenerator != null) { - IVL_TS ts = effectiveTimeGenerator.generate(factories); - ro.setEffectiveTime(ts); - } - - authorGenerators.forEach(ag -> { - Author author = ag.generate(factories); - ro.getAuthors().add(author); - }); - - observationGenerators.forEach(og -> { - org.openhealthtools.mdht.uml.cda.Observation obs = og.generate(factories); - ro.addObservation(obs); - }); - - return ro; - } - - public static ResultOrganizerGenerator getDefaultInstance() { - ResultOrganizerGenerator rog = new ResultOrganizerGenerator(); - - rog.idGenerators.add(IDGenerator.getNextInstance()); - rog.codeGenerator = CDGenerator.getNextInstance(); - rog.statusCodeGenerator = new CSCodeGenerator(DIAGNOSTIC_REPORT_STATUS); - rog.statusCodeGenerator.set("active"); - rog.effectiveTimeGenerator = IVL_TSPeriodGenerator.getDefaultInstance(); - rog.authorGenerators.add(AuthorGenerator.getDefaultInstance()); - rog.observationGenerators.add(ResultObservationGenerator.getDefaultInstance()); - - return rog; - } - - public void verify(DiagnosticReport diagnosticReport) { - if (idGenerators.isEmpty()) { - Assert.assertTrue("No diagnostic report identifier", !diagnosticReport.hasIdentifier()); - } else { - for (int index = 0; index < idGenerators.size(); ++index) { - idGenerators.get(index).verify(diagnosticReport.getIdentifier().get(index)); - } - } - - if (codeGenerator == null) { - Assert.assertTrue("No diagnostic report code", !diagnosticReport.hasCode()); - } else { - codeGenerator.verify(diagnosticReport.getCode()); - } - - if (statusCodeGenerator == null) { - Assert.assertTrue("No diagnostic report status", !diagnosticReport.hasStatus()); - } else { - statusCodeGenerator.verify(diagnosticReport.getStatus().toCode()); - } - - if (effectiveTimeGenerator == null) { - Assert.assertTrue("No diagnostic report effective period", !diagnosticReport.hasEffectivePeriod()); - } else { - effectiveTimeGenerator.verify(diagnosticReport.getEffectivePeriod()); - } - } - - public void verify(Bundle bundle, DiagnosticReport diagnosticReport) throws Exception { - verify(diagnosticReport); - - if (authorGenerators.isEmpty()) { - Assert.assertTrue("No practitioner", !diagnosticReport.hasPerformer()); - } else { - Assert.assertEquals("Performer count", authorGenerators.size(), diagnosticReport.getPerformer().size()); - for (int index = 0; index < authorGenerators.size(); ++index) { - String practitionerId = diagnosticReport.getPerformer().get(index).getActor().getReference(); - AuthorGenerator ag = authorGenerators.get(index); - ag.verifyFromPractionerId(bundle, practitionerId); - } - } - - if (observationGenerators.isEmpty()) { - Assert.assertTrue("No practitioner", !diagnosticReport.hasResult()); - } else { - BundleUtil util = new BundleUtil(bundle); - Assert.assertEquals("Result count", observationGenerators.size(), diagnosticReport.getResult().size()); - for (int index = 0; index < observationGenerators.size(); ++index) { - String observationId = diagnosticReport.getResult().get(index).getReference(); - ObservationGenerator og = observationGenerators.get(index); - org.hl7.fhir.dstu3.model.Observation observation = util.getResourceFromReference(observationId, - org.hl7.fhir.dstu3.model.Observation.class); - og.verify(observation); - } - } - } - - public void verify(Bundle bundle) throws Exception { - DiagnosticReport diagnosticReport = BundleUtil.findOneResource(bundle, DiagnosticReport.class); - verify(bundle, diagnosticReport); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/STGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/STGenerator.java deleted file mode 100644 index c1f15fdca..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/STGenerator.java +++ /dev/null @@ -1,52 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.ST; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; - -public class STGenerator { - private static int INDEX = 1; - - private String value; - private String nullFlavor; - - public STGenerator(String value) { - this.value = value; - } - - public void setNullFlavor(String nullFlavor) { - this.nullFlavor = nullFlavor; - } - - public ST generate(CDAFactories factories) { - ST st = factories.datatype.createST(); - - if (value != null) { - st.addText(value); - } - - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - st.setNullFlavor(nf); - } - - return st; - } - - public static STGenerator getNextInstance() { - String value = "ST Text " + INDEX; - ++INDEX; - return new STGenerator(value); - } - - public void verify(String text) { - if (value == null || nullFlavor != null) { - Assert.assertNull("No text", text); - } else { - Assert.assertEquals("Text", value, text); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/SXCM_TSGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/SXCM_TSGenerator.java deleted file mode 100644 index 2a4c2ed2d..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/SXCM_TSGenerator.java +++ /dev/null @@ -1,31 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.openhealthtools.mdht.uml.hl7.datatypes.SXCM_TS; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class SXCM_TSGenerator extends TSGenerator { - private static int INDEX = 1; - - public SXCM_TSGenerator(String value) { - super(value); - } - - @Override - protected SXCM_TS create(CDAFactories factories) { - return factories.datatype.createSXCM_TS(); - } - - @Override - public SXCM_TS generate(CDAFactories factories) { - SXCM_TS ts = create(factories); - fill(ts); - return ts; - } - - public static SXCM_TSGenerator getNextInstance() { - String value = "2019011" + INDEX; - ++INDEX; - return new SXCM_TSGenerator(value); - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ServiceDeliveryLocationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ServiceDeliveryLocationGenerator.java deleted file mode 100644 index 84344e428..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ServiceDeliveryLocationGenerator.java +++ /dev/null @@ -1,83 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Location; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.ParticipantRole; -import org.openhealthtools.mdht.uml.cda.PlayingEntity; -import org.openhealthtools.mdht.uml.hl7.datatypes.AD; -import org.openhealthtools.mdht.uml.hl7.datatypes.PN; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ServiceDeliveryLocationGenerator { - private static int INDEX = 1; - - String name; - - private List telGenerators = new ArrayList<>(); - private List adGenerators = new ArrayList<>(); - - public ParticipantRole generate(CDAFactories factories) { - ParticipantRole pr = factories.base.createParticipantRole(); - - if (name != null) { - PlayingEntity pe = factories.base.createPlayingEntity(); - PN pn = factories.datatype.createPN(); - pn.addText(name); - pe.getNames().add(pn); - pr.setPlayingEntity(pe); - } - - telGenerators.forEach(tg -> { - TEL tel = tg.generate(factories); - pr.getTelecoms().add(tel); - }); - - adGenerators.forEach(adg -> { - AD ad = adg.generate(factories); - pr.getAddrs().add(ad); - }); - - return pr; - } - - public static ServiceDeliveryLocationGenerator getDefaultInstance() { - ServiceDeliveryLocationGenerator sdg = new ServiceDeliveryLocationGenerator(); - - sdg.name = "name_" + (++INDEX); - sdg.telGenerators.add(TELGenerator.getDefaultInstance()); - sdg.adGenerators.add(ADGenerator.getDefaultInstance()); - - return sdg; - } - - public void verify(Location location) { - if (name == null) { - Assert.assertTrue("No location name", !location.hasName()); - } else { - Assert.assertEquals("Location name", name, location.getName()); - } - - if (telGenerators.isEmpty()) { - Assert.assertTrue("No location telecoms", !location.hasTelecom()); - } else { - int count = telGenerators.size(); - Assert.assertEquals("Location telecom count", count, location.getTelecom().size()); - for (int index = 0; index < count; ++index) { - telGenerators.get(index).verify(location.getTelecom().get(index)); - } - } - - if (adGenerators.isEmpty()) { - Assert.assertTrue("No location addresses", !location.hasAddress()); - } else { - ADGenerator adGenerator = adGenerators.get(adGenerators.size() - 1); - adGenerator.verify(location.getAddress()); - - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ServiceEventGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ServiceEventGenerator.java deleted file mode 100644 index 95ccaf720..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/ServiceEventGenerator.java +++ /dev/null @@ -1,71 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Composition.CompositionEventComponent; -import org.hl7.fhir.dstu3.model.Reference; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.AssignedEntity; -import org.openhealthtools.mdht.uml.cda.Performer1; -import org.openhealthtools.mdht.uml.cda.ServiceEvent; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class ServiceEventGenerator { - private IVL_TSPeriodGenerator effectiveTimeGenerator; - - private List performerGenerators = new ArrayList<>(); - - public ServiceEvent generate(CDAFactories factories) { - ServiceEvent se = factories.base.createServiceEvent(); - - if (effectiveTimeGenerator != null) { - se.setEffectiveTime(effectiveTimeGenerator.generate(factories)); - } - - performerGenerators.forEach(aeg -> { - AssignedEntity ae = aeg.generate(factories); - Performer1 performer = factories.base.createPerformer1(); - performer.setAssignedEntity(ae); - se.getPerformers().add(performer); - }); - - return se; - } - - public static ServiceEventGenerator getDefaultInstance() { - ServiceEventGenerator g = new ServiceEventGenerator(); - - g.effectiveTimeGenerator = IVL_TSPeriodGenerator.getDefaultInstance(); - g.performerGenerators.add(AssignedEntityGenerator.getDefaultInstance()); - - return g; - } - - public void verify(CompositionEventComponent event) { - if (effectiveTimeGenerator == null) { - Assert.assertTrue("No event period", !event.hasPeriod()); - } else { - effectiveTimeGenerator.verify(event.getPeriod()); - } - } - - public void verify(Bundle bundle, CompositionEventComponent event) throws Exception { - verify(event); - - if (performerGenerators.isEmpty()) { - Assert.assertTrue("No event performer", !event.hasDetail()); - } else { - int count = performerGenerators.size(); - Assert.assertEquals("Performer count", count, event.getDetail().size()); - - for (int index = 0; index < count; ++index) { - Reference performer = event.getDetail().get(index); - String practitionerId = performer.getReference(); - performerGenerators.get(index).verifyFromPractionerId(bundle, practitionerId); - } - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/TELGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/TELGenerator.java deleted file mode 100644 index 33a0c750a..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/TELGenerator.java +++ /dev/null @@ -1,174 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.hl7.fhir.dstu3.model.ContactPoint; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.TEL; -import org.openhealthtools.mdht.uml.hl7.vocab.TelecommunicationAddressUse; - -import com.bazaarvoice.jolt.JsonUtils; - -import tr.com.srdc.cda2fhir.conf.Config; -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.TestSetupException; - -public class TELGenerator { - private static Map contactPointSystemMap = JsonUtils - .filepathToMap("src/test/resources//value-maps/ContactPointSystem.json"); - private static Map contactPointUseMap = JsonUtils - .filepathToMap("src/test/resources//value-maps/ContactPointUse.json"); - - private static final String VALUE = "tel:+1(555)555-1009"; - private static final String USE = "WP"; - - private String value; - private List uses = new ArrayList<>(); - - String nullFlavor; - - public TELGenerator() { - } - - public TELGenerator(String value) { - this.value = value; - } - - public TELGenerator(Map json) { - value = (String) json.get("value"); - String multiUse = (String) json.get("use"); - if (multiUse != null) { - String[] pieces = multiUse.split(" "); - for (int index = 0; index < pieces.length; ++index) { - uses.add(pieces[index]); - } - } - nullFlavor = (String) json.get("nullFlavor"); - } - - public void addUse(String use) { - uses.add(use); - } - - public TEL generate(CDAFactories factories) { - TEL telecom = factories.datatype.createTEL(); - - if (value != null) { - telecom.setValue(value); - } - uses.forEach(use -> { - TelecommunicationAddressUse telUse = TelecommunicationAddressUse.get(use); - if (telUse == null) { - throw new TestSetupException("Invalid CDA TEL use enumeration."); - } - telecom.getUses().add(telUse); - }); - return telecom; - } - - public static TELGenerator getDefaultInstance() { - TELGenerator tg = new TELGenerator(); - - tg.value = VALUE; - - return tg; - } - - public static TELGenerator getFullInstance() { - TELGenerator tg = new TELGenerator(); - - tg.value = VALUE; - tg.uses.add(USE); - - return tg; - } - - public void verify(ContactPoint contactPoint) { - if (value == null || nullFlavor != null) { - Assert.assertTrue("Contact point value missing", !contactPoint.hasValue()); - Assert.assertTrue("Contact point system missing", !contactPoint.hasSystem()); - } else { - String[] valuePieces = value.split(":"); - - if (valuePieces.length > 1) { - Assert.assertEquals("Contact point value", contactPoint.getValue(), valuePieces[1]); - String expected = (String) contactPointSystemMap.get(valuePieces[0]); - String actual = contactPoint.getSystem().toCode(); - if (expected == null) { - expected = Config.DEFAULT_CONTACT_POINT_SYSTEM.toCode(); - } - Assert.assertEquals("Contact value system", expected, actual); - } else { - String expected = Config.DEFAULT_CONTACT_POINT_SYSTEM.toCode(); - Assert.assertEquals("Contact point system", expected, contactPoint.getSystem().toCode()); - Assert.assertEquals("Contact point value", value, contactPoint.getValue()); - } - } - if (uses.isEmpty() || nullFlavor != null) { - Assert.assertTrue("Contact point use missing", !contactPoint.hasUse()); - } else { - String actual = contactPoint.getUse().toCode(); - String expected = (String) contactPointUseMap.get(uses.get(uses.size() - 1)); - if (expected == null) { - expected = "temp"; - } - Assert.assertEquals("Contact point use", expected, actual); - } - } - - public Map toJson() { - if (nullFlavor != null) { - return null; - } - - Map result = new LinkedHashMap<>(); - - if (value != null) { - String[] valuePieces = value.split(":"); - - if (valuePieces.length > 1) { - String system = (String) contactPointSystemMap.get(valuePieces[0]); - if (system == null) { - system = Config.DEFAULT_CONTACT_POINT_SYSTEM.toCode(); - } - result.put("system", system); - result.put("value", valuePieces[1]); - } else { - String system = Config.DEFAULT_CONTACT_POINT_SYSTEM.toCode(); - result.put("system", system); - result.put("value", value); - } - } - if (!uses.isEmpty()) { - String use = uses.get(uses.size() - 1); - String jsonUse = (String) contactPointUseMap.get(use); - if (jsonUse == null) { - jsonUse = "temp"; - } - result.put("use", jsonUse); - } - if (result.isEmpty()) - return null; - return result; - } - - public static Set getAvailableSystems() { - return Collections.unmodifiableSet(contactPointSystemMap.keySet()); - } - - public static Set getAvailableUses() { - return Collections.unmodifiableSet(contactPointUseMap.keySet()); - } - - public static void verifyList(List actual, List expected) { - Assert.assertEquals("Contact point count", expected.size(), actual.size()); - for (int index = 0; index < actual.size(); ++index) { - expected.get(index).verify(actual.get(index)); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/TSGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/TSGenerator.java deleted file mode 100644 index 08988c5ba..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/TSGenerator.java +++ /dev/null @@ -1,60 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.junit.Assert; -import org.openhealthtools.mdht.uml.hl7.datatypes.TS; -import org.openhealthtools.mdht.uml.hl7.vocab.NullFlavor; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.testutil.CDAUtilExtension; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class TSGenerator { - private static int INDEX = 1; - - private String value; - private String nullFlavor; - - public TSGenerator(String value) { - this.value = value; - } - - public void setNullFlavor(String nullFlavor) { - this.nullFlavor = nullFlavor; - } - - protected TS create(CDAFactories factories) { - return factories.datatype.createTS(); - } - - protected void fill(TS ts) { - if (value != null) { - ts.setValue(value); - } - - if (nullFlavor != null) { - NullFlavor nf = CDAUtilExtension.toNullFlavor(nullFlavor); - ts.setNullFlavor(nf); - } - } - - public TS generate(CDAFactories factories) { - TS ts = create(factories); - fill(ts); - return ts; - } - - public static TSGenerator getNextInstance() { - String value = "2019011" + INDEX; - ++INDEX; - return new TSGenerator(value); - } - - public void verify(String dateTime) { - if (value == null || nullFlavor != null) { - Assert.assertNull("No datetime", dateTime); - } else { - String expected = FHIRUtil.toFHIRDatetime(value); - Assert.assertEquals("Date time", expected, dateTime); - } - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/VitalSignObservationGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/VitalSignObservationGenerator.java deleted file mode 100644 index 6dc3d3f13..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/VitalSignObservationGenerator.java +++ /dev/null @@ -1,18 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import org.openhealthtools.mdht.uml.cda.consol.VitalSignObservation; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; - -public class VitalSignObservationGenerator extends ObservationGenerator { - @Override - public VitalSignObservation createForGenerate(CDAFactories factories) { - return factories.consol.createVitalSignObservation(); - } - - public static VitalSignObservationGenerator getDefaultInstance() { - VitalSignObservationGenerator rog = new VitalSignObservationGenerator(); - ObservationGenerator.fillDefaultInstance(rog); - return rog; - } -} diff --git a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/VitalSignsOrganizerGenerator.java b/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/VitalSignsOrganizerGenerator.java deleted file mode 100644 index 96b3c634f..000000000 --- a/src/test/java/tr/com/srdc/cda2fhir/testutil/generator/VitalSignsOrganizerGenerator.java +++ /dev/null @@ -1,45 +0,0 @@ -package tr.com.srdc.cda2fhir.testutil.generator; - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.dstu3.model.Bundle; -import org.junit.Assert; -import org.openhealthtools.mdht.uml.cda.Observation; -import org.openhealthtools.mdht.uml.cda.consol.VitalSignsOrganizer; - -import tr.com.srdc.cda2fhir.testutil.CDAFactories; -import tr.com.srdc.cda2fhir.util.FHIRUtil; - -public class VitalSignsOrganizerGenerator { - private List generators = new ArrayList<>(); - - public VitalSignsOrganizer generate(CDAFactories factories) { - VitalSignsOrganizer vso = factories.consol.createVitalSignsOrganizer(); - - generators.forEach(g -> { - Observation o = g.generate(factories); - vso.addObservation(o); - }); - - return vso; - } - - public static VitalSignsOrganizerGenerator getDefaultInstance() { - VitalSignsOrganizerGenerator og = new VitalSignsOrganizerGenerator(); - - og.generators.add(VitalSignObservationGenerator.getDefaultInstance()); - - return og; - } - - public void verify(Bundle bundle) { - List result = FHIRUtil.findResources(bundle, - org.hl7.fhir.dstu3.model.Observation.class); - - Assert.assertEquals("Observation count", generators.size(), result.size()); - for (int index = 0; index < result.size(); ++index) { - generators.get(index).verify(result.get(index)); - } - } -} \ No newline at end of file diff --git a/src/test/resources/170.315_b1_toc_gold_sample2_v1.xml b/src/test/resources/170.315_b1_toc_gold_sample2_v1.xml deleted file mode 100644 index 7da3e4753..000000000 --- a/src/test/resources/170.315_b1_toc_gold_sample2_v1.xml +++ /dev/null @@ -1,1348 +0,0 @@ - - - - - - - - - - - - - - - - - 170.315_b1_toc_gold_sample2 test data - - - - - - - - - - - - - - - 1357 Amber Dr - Beaverton - OR - 97006 - US - - - - - - - - Richard - Maur - jr - - - - - - - - - - - - - - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - - - - - - - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - Mary - McDonald - - - - - - - - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - Henry - Seven - - - - - - - - - - - Caroline - Maur - - - - - - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - - - - - - Dr - Henry - Seven - - - - Community Health and Hospitals - - - - - - - - - - - - - - - - - 1357 Amber Dr - Beaverton - OR - 97006 - US - - - - - - Mr. - Issac - Maur - - - - - - - - - - - - 1357 Amber Dr - Beaverton - OR - 97006 - US - - - - - - Ms - Caroline - Maur - - - - - - - - - - - - - - - - Primary Care Provider - - - - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - Dr - Henry - Seven - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - - - - - - - - - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - Mary - McDonald - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - ALLERGIES AND ADVERSE REACTIONS - No Known Drug Allergies - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - MEDICATIONS - No known Medications - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- - - - - - Admission Medications - No Medications Administered - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- - - - - - - Discharge Medications - No Information -
-
- - - - -
- - - - - PROBLEMS - - No known health problems - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- - - - - ENCOUNTERS - No Encounters -
-
- - - - - -
- - - - - - - ADMISSION DIAGNOSIS - Skin burn - - - - - - - - - - - - - - - - - - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - Community Health and Hospitals - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- - - - - PROCEDURES - - - - - - - - - - - - - - -
ProcedureDate
Application of Dressing for burnJuly 22, 2015
-
- - - - - - - - - - - - - - - - - - - - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - - - -
-
- - - -
- - - - MEDICAL EQUIPMENT - - - Patient has no history of implantable devices - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- - - - - IMMUNIZATIONS - No immunization history - - - - - - - - - - - - - - - - - - - - Vaccination - - - - - - - - - -
-
- - - - -
- - - - - VITAL SIGNS - - - - - - - - - - - - - - -
Date / Time: June 22, 2015
Blood Pressure145/88
- - - - - - - - - - - - - - -
Date / Time: July 22, 2015
Body Temperature99 degrees Fahrenheit
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - SOCIAL HISTORY - - - - - - - - - - - - - - - - -
Social History ObservationDescriptionDates Observed
Current Smoking StatusCurrent every dayJuly 22, 2015
-
- - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - RESULTS - Laboratory Test: None needed. Laboratory Values/Results: No Lab Result data -
-
- - - - - - - - - - - - - - - -
- - - - - ASSESSMENTS - The patient Mr Richard Maur was found to have first degree burns and Dr Seven and his staff Mr Bates by cleaning the burn and dressing the burn and observed for couple of hours before discharging Mr Maur. -
-
- - - - -
- - - - - TREATMENT PLAN - - Hand-off Communication: -
-
- - - - - - - - - - - - - - - - - - -
Planned CareStart Date
Schedule an appointment with Dr Seven after 1 week for Follow up with Outpatient facility.July 29, 2015
Medication: Tylenol 500mgAs needed
-
- - - - - - - - - - - - - - - - - - - - - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - - Dr - Henry - Seven - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - - - - - - - - - Schedule an appointment with Dr Seven after 1 week for Follow up with Outpatient facility. - - - - - - - - - - - - - - - - - In case of high fever, take Tylenol according to the following. - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- - - - Goals Section - No goal information -
-
- - - - - - - - -
- - - - Health Concerns - - No Known Health Concerns on 07/22/2015 - - - - - - - - - - - - - - - - - -
-
- - - -
- - - - HOSPITAL DISCHARGE INSTRUCTIONS - - - - Appointments: Schedule an appointment with Dr Seven after 1 week. Follow up with Outpatient facility. - In case of fever, take Tylenol as advised in plan of treatment. - - -
-
- - - - - - -
- - - - - - MENTAL STATUS - No information -
-
- - - - -
- - - - - - FUNCTIONAL STATUS - No information -
-
- -
-
-
diff --git a/src/test/resources/170.315_b1_toc_inp_ccd_r21_sample1_v5.xml b/src/test/resources/170.315_b1_toc_inp_ccd_r21_sample1_v5.xml deleted file mode 100644 index 97b03b159..000000000 --- a/src/test/resources/170.315_b1_toc_inp_ccd_r21_sample1_v5.xml +++ /dev/null @@ -1,3277 +0,0 @@ - - - - - - - - - - - - - - - - - 170.315_b1_toc_inp_ccd_r21_sample1 test data - - - - - - - - - - - - - 1006 Amber Dr - Beaverton - OR - 97266 - US - - - - - - - - Lindsey - Turner - Pitt - - - Lin - Turner - Pitt - - - - - - - - - - - - - - - - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - - - - - - - - - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - - - Mary - McDonald - - - - - - - - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - - - Henry - Seven - - - - - - - - - - - Franklin - Pitt - - - - - - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - - - - - - - - Dr - Henry - Seven - - - - Community Health and Hospitals - - - - - - - - - - - - - - - - - 1006 Amber Dr - Beaverton - OR - 97266 - US - - - - - - Mr - Ralph - Issac - - - - - - - - - - - - 1006 Amber Dr - Beaverton - OR - 97266 - US - - - - - - Mr - Franklin - Pitt - - - - - - - - - - - - - - - - - - - Primary Care Provider - - - - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - - - Dr - Henry - Seven - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - - - - - - - - - - - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - - - Mary - McDonald - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - ALLERGIES AND ADVERSE REACTIONS - - - - - - - - - - - - - - - - - - - - - - - - -
SubstanceReactionSeverityStatus
- Penicillin G - - Hives - - Moderate - Active
- Ampicillin - - Hives - - Moderate - Active
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - MEDICATIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MedicationDirectionsStart Date
Ceftriaxone 100MG/MLTwo Times DailyJune 22, 2015
Vantin 200mgTwo Times DailyJune 22, 2015
Tylenol 500mgAs neededJune 22, 2015
Darbepoetin Alfa 0.5 MG/MLOnce a weekJune 22, 2015
Clindamycin 300mgThree Times DailyJune 23, 2015
Torsemide 20mgDailyJune 23, 2015
Levothyroxine Sodium 1mgDailyJune 23, 2015
Prednisolone 50mgDailyJune 23, 2015
FenoFibric Acid 35mgAt the hour of sleepJune 24, 2015
Mycophenolic Acid 360mgTwo times dailyJune 24, 2015
Everolimus 0.5mgTwo times dailyJune 24, 2015
Ciprofloxacin 250mgThree times dailyJune 25, 2015
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - - - Discharge Medications - No Information -
-
- - - - -
- - - - - PROBLEMS - - Active Concerns - - Problem #1 - - Essential hypertension (Disorder) - - - Problem #2 - - Severe Hypothyroidism (Disorder) - - - Problem #3 - - Chronic rejection of renal transplant (disorder) - - - - Problem #4 - - Iron deficiency anemia (disorder)) - - - - Problem #5 - - Interstitial pneumonia (disorder) - - - - Resolved Concerns - - Problem #6 - - Overweight (finding) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- - - - - ENCOUNTERS - - - - - - - - - - - - - - - - -
Encounter DiagnosisLocationDate
Anemia in Chronic Kidney DiseaseCommunity Health and HospitalsJune 22, 2015 at 8:00am
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - - Community Health and Hospitals - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- - - - - - - ADMISSION DIAGNOSIS - Anemia - - - - - - - - - - - - - - - - - - - - 1002 Healthcare Dr - Beaverton - OR - 97266 - US - - - Community Health and Hospitals - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - PROCEDURES - - - - - - - - - - - - - - - - - - - - - - -
ProcedureDate
BronchoscopyJune 22, 2015
Chest X-Ray, PA and Lateral ViewsJune 22, 2015
Introduction of cardiac pacemaker system via veinOctober 5, 2011
-
- - - - - - - - - - - - - - - - - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - - - - - - - - - - - - - - - - - - - - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - - - - - - - - - - - - - - - - - - - - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - Community Health and Hospitals - - - 1002 Healthcare Dr - Portland - OR - 97266 - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- - - - Implants - - - - - - - - - - - - - - - - -
ImplantedAreaUDI
Cardiac PacemakerSubclavian Vein(01)00643169007222(17)160128(21)BLC200461H
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- - - - - IMMUNIZATIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VaccineDateStatus
Influenza Virus VaccineMay 10, 2014Completed
Tetanus and diphtheria toxoidsJanuary 4, 2012Completed
influenza, intradermal, quadrivalent, preservative freeJune 22, 2015Refused
-
- - - - - - - - - - - - - - - - - - - - - 1 - - - Immuno Inc. - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2 - - - Immuno Inc. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Immuno Inc. - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - VITAL SIGNS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Date / Time: June 22, 2015
Height177 cm
Weight88 kg
Blood Pressure145/88 mm[Hg]
Heart Rate80 beats per minute
O2 Percentage BldC Oximetry95 percent
Body Temperature38 degree celsius
Respiratory Rate18 breaths per minute
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - SOCIAL HISTORY - - - - - - - - - - - - - - - - - - - - - - - - - - -
Social History ObservationDescriptionDates Observed
Smoking StatusHeavy tobacco smokerMay 1, 2005 - February 27, 2011
Current Smoking StatusCurrent every dayJune 22, 2015
Birth SexFemaleJune 22, 2015
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - RESULTS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Result TypeResult ValueRelevant Reference RangeInterpretationDate
HGB10.2 g/dL06/22/2015
WBC12.3 (10*3/uL)N/A - 500,00006/22/2015
PLT123 (10*3/uL)06/22/2015
Everolimus Blood10 ng/mL3.0-8.0 ng/ml06/22/2015
Color of UrineYELLOWYELLOWNormal06/22/2015
Appearance of UrineCLEARCLEARNormal06/22/2015
Specific gravity of Urine by Test strip1.0151.005 – 1.030Normal06/22/2015
pH of Urine by Test strip5.0 [pH]5.0-8.0Normal06/22/2015
Glucose [Mass/volume] in urine by test strip50 mg/dLNeg06/22/2015
Ketones [Mass/Volume] in urine by test stripNegativeNegativeNormal06/22/2015
Protein[Mass/Volume] in urine by test strip100 mg/dLnegative06/22/2015
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - N/A - 500,000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - YELLOW - - - - YELLOW - - - - - - - - - - - - - - - - - CLEAR - - - - CLEAR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - - FUNCTIONAL STATUS - - - - - - - - - - - - - - -
Functional CategoryEffective Dates
Dependence on CaneMay 01, 2005
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
- - - - - - MENTAL STATUS - - - - - - - - - - - - - - -
StatusDate
AmnesiaMay 05, 2005
-
- - - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- - - - - ASSESSMENTS - The patient was found to have Anemia and Dr Seven and his staff diagnosed the condition and treated Ms Alice for Anemia during the 2 day stay at Community Health Hospitals. Ms Alice recovered from Anemia during the stay and is being discharged in a stable condition. If there is fever greater than 101.5 F or onset of chest pain/breathlessness the patient is advised to contact emergency. -
-
- - - - -
- - - - - TREATMENT PLAN - - Hand-off Communication: -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
Planned CareStart Date
Urinanalysis macro (dipstick) panelJune 29, 2015
Immunosuppressive therapyJuly 1, 2015
Schedule an appointment with Dr Seven after 1 week for Follow up with Outpatient facility for Immunosuppressive therapy.July 1, 2015
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Schedule an appointment with Dr Seven after 1 week for Follow up with Outpatient facility for Immunosuppressive therapy. - - - - - - - - -
-
- - - - - -
- - - - - Goals Section - - - - - - - - - - - - - - - - - - - - - - - -
GoalValueDate
Need to gain more energy to do regular activities (Visual Inspection)N/AJune 23, 2015
Negotiated Goal for Body Temperature98-99 degrees FahrenheitJune 23, 2015
-
- - - - - - - - - - - - Need to gain more energy to do regular activities. (Visual Inspection) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - -
- - - - Health Concerns Section - - - - - - - - - - - - - - - - -
ObservationStatusDate
Chronically illActiveJune 22, 2015
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ConcernStatusDate
HyperTension problem concernActiveJune 22, 2015
HypoThyroidism problem concernActiveJune 22, 2015
Anemia problem concernActiveJune 22, 2015
-
- - - - - - - - - - - - - -
Related observationDate
Vital Sign Weight ObservationJune 22, 2015
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- - - - HOSPITAL DISCHARGE INSTRUCTIONS - - - - Diet: Diabetic low salt diet - Medications: Take prescribed medications as advised. - Appointments: Schedule an appointment with Dr Seven after 1 week. Follow up with Outpatient facility for Immunosuppression treatment. - For Fever of > 101.5 F, or onset of chest pain/breathlessness contact Emergency. - - -
-
- - - -
-
-
diff --git a/src/test/resources/C-CDA_R2-1_CCD-w-daf.json b/src/test/resources/C-CDA_R2-1_CCD-w-daf.json deleted file mode 100644 index 827812c2e..000000000 --- a/src/test/resources/C-CDA_R2-1_CCD-w-daf.json +++ /dev/null @@ -1,5068 +0,0 @@ -{ - "resourceType": "Bundle", - "entry": [ - { - "resource": { - "resourceType": "Composition", - "id": "1", - "identifier": { - "system": "urn:oid:2.16.840.1.113883.19.5.99999.1", - "value": "TT988" - }, - "date": "2013-08-15T10:30:00-08:00", - "type": { - "coding": [ - { - "system": "http://loinc.org", - "code": "34133-9", - "display": "Summarization of Episode Note" - } - ] - }, - "title": "Patient Chart Summary", - "status": "preliminary", - "confidentiality": "N", - "subject": { - "reference": "Patient/2" - }, - "author": [ - { - "reference": "Practitioner/4" - } - ], - "attester": [ - { - "mode": [ - "legal" - ], - "time": "2013-08-15T22:36:15-08:00", - "party": { - "reference": "Practitioner/5" - } - }, - { - "mode": [ - "professional" - ], - "time": "2013-08-15T22:15:45-08:00", - "party": { - "reference": "Practitioner/6" - } - } - ], - "custodian": { - "reference": "Organization/7" - }, - "section": [ - { - "title": "FAMILY HISTORY", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "10157-6" - } - ] - }, - "text": { - "status": "additional", - "div": "

Father (deceased)

DiagnosisAge At Onset
Myocardial Infarction (cause of death)57
Diabetes40
" - }, - "entry": [ - { - "reference": "FamilyMemberHistory/8" - } - ] - }, - { - "title": "ALLERGIES AND ADVERSE REACTIONS", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "48765-2" - } - ] - }, - "text": { - "status": "additional", - "div": "
SubstanceReaction
PenicillinNausea
CodeineWheezing
" - }, - "entry": [ - { - "reference": "AllergyIntolerance/9" - }, - { - "reference": "AllergyIntolerance/11" - } - ] - }, - { - "title": "SOCIAL HISTORY", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "29762-2", - "display": "Social History" - } - ] - }, - "text": { - "status": "additional", - "div": "
Social History ObservationDescriptionDates Observed
Current Smoking StatusFormer smokerSeptember 10, 2012
Tobacco UseModerate cigarette smoker, 10-19/dayFebruary, 2009 - February, 2011
Alcoholic drinks per day12Since February, 2012
" - }, - "entry": [ - { - "reference": "Observation/13" - }, - { - "reference": "Observation/15" - }, - { - "reference": "Observation/17" - } - ] - }, - { - "title": "IMMUNIZATIONS", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "11369-6", - "display": "History of immunizations" - } - ] - }, - "text": { - "status": "additional", - "div": "
VaccineDateStatusSeries number
Influenza, seasonal, IM Nov 1999CompletedN/A
Influenza, seasonal, IM Dec 1998CompletedN/A
Pneumococcal polysaccharide vaccine, IM Dec 1998CompletedN/A
Tetanus and diphtheria toxoids, IM 1997RefusedN/A
Hepatitis BAug 1, 2013Completed3rd
" - }, - "entry": [ - { - "reference": "Immunization/19" - }, - { - "reference": "Immunization/23" - }, - { - "reference": "Immunization/27" - }, - { - "reference": "Immunization/31" - }, - { - "reference": "Immunization/36" - } - ] - }, - { - "title": "ENCOUNTERS", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "46240-8", - "display": "History of encounters" - } - ] - }, - "text": { - "status": "additional", - "div": "
EncounterPerformerLocationDate
Checkup Examination Performer NameCommunity Urgent Care CenterSeptember 27, 2012 at 1:00pm
" - }, - "entry": [ - { - "reference": "Encounter/39" - } - ] - }, - { - "title": "ADVANCE DIRECTIVES", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "42348-3" - } - ] - }, - "text": { - "status": "additional", - "div": "
DirectiveDescriptionVerificationSupporting Document(s)
Resuscitation statusDo not resuscitateDr. Patricia Primary, Feb 19, 2011Advance directive
" - } - }, - { - "title": "FUNCTIONAL STATUS", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "47420-5", - "display": "Functional Status" - } - ] - }, - "text": { - "status": "additional", - "div": "
Functional CategoryEffective DatesResults of Evaluation
Functional AssessmentMarch 11, 2013Independent Walking
ADL/IADL: BathingMarch 11,2013Independent
" - }, - "entry": [ - { - "reference": "Observation/43" - }, - { - "reference": "Observation/46" - } - ] - }, - { - "title": "PROCEDURES", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "47519-4", - "display": "HISTORY OF PROCEDURES" - } - ] - }, - "text": { - "status": "additional", - "div": "
ProcedureDate
Colonic polypectomy1998
" - }, - "entry": [ - { - "reference": "Procedure/48" - } - ] - }, - { - "title": "INSURANCE PROVIDERS", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "48768-6", - "display": "Payer" - } - ] - }, - "text": { - "status": "additional", - "div": "
Payer namePolicy type / Coverage typePolicy IDCovered party IDPolicy Holder
Good Health InsuranceExtended healthcare / FamilyContract Number1138345Patient's Mother
" - } - }, - { - "title": "MEDICATIONS", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "10160-0", - "display": "HISTORY OF MEDICATION USE" - } - ] - }, - "text": { - "status": "additional", - "div": "
MedicationDirectionsStart DateStatusIndicationsFill Instructions
Proventil 0.09 MG/ACTUAT inhalant solution2 puffs q6 hours PRN wheezingJan 3, 2011ActiveAsthmaGeneric Substitition Allowed
Atenolol 25 MG Oral Tablet1 every 12 hours OrallyMar 18, 2012ActiveHypertension-none-
" - }, - "entry": [ - { - "reference": "MedicationStatement/52" - }, - { - "reference": "MedicationStatement/56" - } - ] - }, - { - "title": "TREATMENT PLAN", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "18776-5", - "display": "Treatment plan" - } - ] - }, - "text": { - "status": "additional", - "div": "
Hand-off Communication:Nurse Florence, RN to MD to Nancy Nightingale, RN



Planned CareStart DatePatient Provider RatingProvider Provider RatingProviderPatient Support/Caregiver
Procedure: ColonoscopyJune 15, 20131st, Medium3rd, MediumCaregiver: Mother
Medication: Heparin 0.25 ml pre-filled syringeJuly 12, 2013First, MediumThird, MediumCaregiver: Mother
" - } - }, - { - "title": "RESULTS", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "30954-2", - "display": "RESULTS" - } - ] - }, - "text": { - "status": "additional", - "div": "
Result TypeResult ValueRelevant Reference RangeInterpretationDate
Hemoglobin13.2 g/dLNormal range for women is 12.0 to 15.5 grams per deciliterNormal03/19/2008
Leukocytes6.7 10*9/LNormal white blood cell count range 3.5-10.5 billion cells/LNormal03/19/2008
Platelets123 10*9/LNormal white blood cell count range 3.5-10.5 billion cells/LLow03/19/2008
Hematocrit35.3 %Normal hematocrit range for female: 34.9-44.5 percentNormal03/19/2008
Erythrocytes4.21 10*12/LNormal red blood cell count range 3.90-5.03 trillion cells/LNormal03/19/2008
Urea nitrogen, SerumPendingPendingPendingMarch 20, 2008
" - }, - "entry": [ - { - "reference": "DiagnosticReport/61" - }, - { - "reference": "DiagnosticReport/64" - } - ] - }, - { - "title": "MEDICAL EQUIPMENT", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "46264-8" - } - ] - }, - "text": { - "status": "additional", - "div": "
Medical Equipment
  • Implanted Devices: Cardiac PaceMaker July 3, 2013
  • Implanted Devices: Upper GI Prosthesis, January 3, 2013
  • Cane, February 2, 2003
Biliary Stent, May 5, 2013
" - }, - "entry": [ - { - "reference": "Device/76" - }, - { - "reference": "Device/77" - }, - { - "reference": "Device/78" - }, - { - "reference": "Procedure/79" - } - ] - }, - { - "title": "VITAL SIGNS", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "8716-3", - "display": "VITAL SIGNS" - } - ] - }, - "text": { - "status": "additional", - "div": "
Date / Time: Sept 10, 2012Sept 1, 2011
Height177 cm177 cm
Weight86 kg88 kg
Blood Pressure132/88128/80
" - }, - "entry": [ - { - "reference": "Observation/82" - }, - { - "reference": "Observation/84" - }, - { - "reference": "Observation/86" - }, - { - "reference": "Observation/88" - }, - { - "reference": "Observation/90" - }, - { - "reference": "Observation/92" - }, - { - "reference": "Observation/94" - }, - { - "reference": "Observation/96" - } - ] - }, - { - "title": "PROBLEMS", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "11450-4", - "display": "PROBLEM LIST" - } - ] - }, - "text": { - "status": "additional", - "div": "

Active Concerns

  • Problem #1
    • Pneumonia (onset July 3, 2013; resolution Aug 14, 2013) [authored Aug 14, 2013]
  • Problem #2
    • Chest pain (onset Apr 14, 2007) [authored Apr 14, 2007]
    • Angina (onset Apr 17, 2007) [authored Apr 17, 2007]

Resolved Concerns

  • Problem #3
    • Pneumonia - Left lower lobe (onset Mar 10, 1998; resolution Mar 16, 1998) [authored Mar 16, 1998]
" - }, - "entry": [ - { - "reference": "Condition/98" - }, - { - "reference": "Condition/100" - }, - { - "reference": "Condition/102" - }, - { - "reference": "Condition/104" - } - ] - } - ] - } - }, - { - "resource": { - "resourceType": "Patient", - "id": "2", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-patient" - ] - }, - "text": { - "status": "generated", - "div": "
Eve BETTERHALF
Identifier444222222
Address2222 Home Street
Beaverton OR US
Date of birth01 May 1975
" - }, - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/us-core-race", - "valueCodeableConcept": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.238", - "code": "2106-3", - "display": "White" - } - ] - } - }, - { - "url": "http://hl7.org/fhir/StructureDefinition/us-core-ethnicity", - "valueCodeableConcept": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.238", - "code": "2186-5", - "display": "Not Hispanic or Latino" - } - ] - } - }, - { - "url": "http://hl7.org/fhir/StructureDefinition/us-core-religion", - "valueCodeableConcept": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.5.1076", - "code": "1013", - "display": "Christian (non-Catholic, non-specific)" - } - ] - } - }, - { - "url": "http://hl7.org/fhir/StructureDefinition/birthPlace", - "valueAddress": { - "line": [ - "4444 Home Street" - ], - "city": "Beaverton", - "state": "OR", - "postalCode": "97867", - "country": "US" - } - } - ], - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.1", - "value": "444222222" - } - ], - "name": [ - { - "use": "usual", - "family": [ - "Betterhalf" - ], - "given": [ - "Eve" - ] - } - ], - "telecom": [ - { - "system": "phone", - "value": "+1(555)555-2003", - "use": "home" - } - ], - "gender": "female", - "birthDate": "1975-05-01", - "address": [ - { - "use": "home", - "line": [ - "2222 Home Street" - ], - "city": "Beaverton", - "state": "OR", - "postalCode": "97867", - "country": "US" - } - ], - "maritalStatus": { - "coding": [ - { - "system": "http://hl7.org/fhir/v3/MaritalStatus", - "code": "M" - } - ] - }, - "contact": [ - { - "relationship": [ - { - "coding": [ - { - "system": "http://hl7.org/fhir/patient-contact-relationship", - "code": "agent", - "display": "Agent" - } - ] - } - ], - "name": { - "family": [ - "Betterhalf" - ], - "given": [ - "Boris", - "Bo" - ] - }, - "telecom": [ - { - "system": "phone", - "value": "+1(555)555-2008", - "use": "mobile" - } - ], - "address": { - "use": "home", - "line": [ - "2222 Home Street" - ], - "city": "Beaverton", - "state": "OR", - "postalCode": "97867", - "country": "US" - } - } - ], - "communication": [ - { - "language": { - "coding": [ - { - "system": "urn:ietf:bcp:47", - "code": "en" - } - ] - }, - "preferred": true - } - ], - "managingOrganization": { - "reference": "Organization/3" - } - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "3", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier219BX
NameThe DoctorsTogether Physician Group
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "219BX" - } - ], - "name": "The DoctorsTogether Physician Group", - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-5000", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "4", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier5555555555
NamePatricia Patty PRIMARY M.D.
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "5555555555" - } - ], - "name": { - "family": [ - "Primary" - ], - "given": [ - "Patricia", - "Patty" - ], - "suffix": [ - "M.D." - ] - }, - "telecom": [ - { - "system": "phone", - "value": "+1(555)555-1004", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1004 Healthcare Drive " - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "5", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier5555555555
NamePatricia Patty PRIMARY M.D.
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "5555555555" - } - ], - "name": { - "family": [ - "Primary" - ], - "given": [ - "Patricia", - "Patty" - ], - "suffix": [ - "M.D." - ] - }, - "telecom": [ - { - "system": "phone", - "value": "+1(555)555-1004", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1004 Healthcare Drive " - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "6", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier5555555555
NamePatricia Patty PRIMARY M.D.
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "5555555555" - } - ], - "name": { - "family": [ - "Primary" - ], - "given": [ - "Patricia", - "Patty" - ], - "suffix": [ - "M.D." - ] - }, - "telecom": [ - { - "system": "phone", - "value": "+1(555)555-1004", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1004 Healthcare Drive " - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "7", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier321CX
NameGood Health HIE
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "321CX" - } - ], - "name": "Good Health HIE", - "telecom": [ - { - "system": "phone", - "value": "+1(555)555-1009", - "use": "work" - } - ], - "address": [ - { - "use": "work", - "line": [ - "1009 Healthcare Drive " - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ] - } - }, - { - "resource": { - "resourceType": "FamilyMemberHistory", - "id": "8", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-familymemberhistory" - ] - }, - "text": { - "status": "generated", - "div": "
Relationship
Father
Born
Sat Dec 31 00:00:00 EET 1910
DeceasedYES
Condition
Code
Diabetes mellitus type 2
Onset
40a
Condition
Code
Myocardial infarction
Onset
57a
Outcome
Dead
" - }, - "identifier": [ - { - "value": "d42ebf70-5c89-11db-b0de-0855200c9a66" - } - ], - "patient": { - "reference": "Patient/2" - }, - "status": "completed", - "relationship": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.5.111", - "code": "FTH", - "display": "Father" - } - ] - }, - "gender": "male", - "bornDate": "1910", - "deceasedBoolean": true, - "condition": [ - { - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "44054006", - "display": "Diabetes mellitus type 2" - } - ] - }, - "onsetQuantity": { - "value": 40, - "unit": "a", - "system": "http://unitsofmeasure.org" - } - }, - { - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "22298006", - "display": "Myocardial infarction" - } - ] - }, - "outcome": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "419099009", - "display": "Dead" - } - ] - }, - "onsetQuantity": { - "value": 57, - "unit": "a", - "system": "http://unitsofmeasure.org" - } - } - ] - } - }, - { - "resource": { - "resourceType": "AllergyIntolerance", - "id": "9", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-allergyintolerance" - ] - }, - "text": { - "status": "generated", - "div": "
Substance
Penicillin
Onset
Mon May 01 21:45:00 EET 1998
Reaction
Nausea
" - }, - "identifier": [ - { - "value": "36e3e930-7b14-11db-9fe1-0800200c9a66" - } - ], - "onset": "1998-05-01T11:45:00-08:00", - "recorder": { - "reference": "Practitioner/10" - }, - "patient": { - "reference": "Patient/2" - }, - "substance": { - "coding": [ - { - "system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "70618", - "display": "Penicillin" - } - ] - }, - "status": "active", - "criticality": "CRITH", - "category": "other", - "reaction": [ - { - "manifestation": [ - { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "422587007", - "display": "Nausea" - } - ] - } - ], - "onset": "2008-02-26T08:05:00-08:00", - "severity": "mild" - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "10", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "AllergyIntolerance", - "id": "11", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-allergyintolerance" - ] - }, - "text": { - "status": "generated", - "div": "
Substance
Codeine
Onset
Mon May 01 21:45:00 EET 1998
Reaction
Wheezing
" - }, - "identifier": [ - { - "value": "b03805bd-2eb6-4ab8-a9ff-473c6653971a" - } - ], - "onset": "1998-05-01T11:45:00-08:00", - "recorder": { - "reference": "Practitioner/12" - }, - "patient": { - "reference": "Patient/2" - }, - "substance": { - "coding": [ - { - "system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "2670", - "display": "Codeine" - } - ] - }, - "status": "active", - "category": "other", - "reaction": [ - { - "manifestation": [ - { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "56018004", - "display": "Wheezing" - } - ] - } - ], - "severity": "moderate" - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "12", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "13", - "text": { - "status": "generated", - "div": "
Code
Alcoholic drinks per day
Date/PeriodSun Feb 15 00:00:00 EET 2012 - ?
Result
13
" - }, - "identifier": [ - { - "value": "37f76c51-6411-4e1d-8a37-957fd49d2cef" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "74013-4", - "display": "Alcoholic drinks per day" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2012-02-15" - }, - "issued": "2012-09-10T11:45:00-08:00", - "performer": [ - { - "reference": "Practitioner/14" - } - ], - "valueQuantity": { - "value": 12, - "unit": "1" - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "14", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "15", - "text": { - "status": "generated", - "div": "
Code
History of tobacco use
Date/PeriodTue Feb 14 00:00:00 EET 2009 - Mon Feb 15 00:00:00 EET 2011
Result
Moderate cigarette smoker, 10-19/day
" - }, - "identifier": [ - { - "value": "45efb604-7049-4a2e-ad33-d38556c9636c" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "11367-0", - "display": "History of tobacco use" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2009-02-14", - "end": "2011-02-15" - }, - "issued": "2012-09-10T11:45:00-08:00", - "performer": [ - { - "reference": "Practitioner/16" - } - ], - "valueCodeableConcept": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "160604004", - "display": "Moderate cigarette smoker, 10-19/day" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "16", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "17", - "text": { - "status": "generated", - "div": "
Code
Tobacco smoking status NHIS
Date/PeriodThu Sep 10 00:00:00 EET 2012 - ?
Result
Former smoker
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.19", - "value": "123456789" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "72166-2", - "display": "Tobacco smoking status NHIS" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2012-09-10" - }, - "issued": "2012-09-10T11:45:00-08:00", - "performer": [ - { - "reference": "Practitioner/18" - } - ], - "valueCodeableConcept": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "8517006", - "display": "Former smoker" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "18", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Immunization", - "id": "19", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-immunization" - ] - }, - "text": { - "status": "generated", - "div": "
Vaccine Code
Influenza virus vaccine
Date (Vaccine Administered)Fri Dec 15 00:00:00 EET 1998
Not GivenTrue
Route
Intramuscular injection
Dose
50ug
" - }, - "identifier": [ - { - "value": "e6f1ba43-c0ed-4b9b-9f12-f435d8ad8f92" - } - ], - "status": "completed", - "date": "1998-12-15", - "vaccineCode": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.59", - "code": "88", - "display": "Influenza virus vaccine" - } - ] - }, - "patient": { - "reference": "Patient/2" - }, - "wasNotGiven": true, - "reported": false, - "performer": { - "reference": "Practitioner/21" - }, - "manufacturer": { - "reference": "Organization/20" - }, - "lotNumber": "1", - "route": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.3.26.1.1", - "code": "C28161", - "display": "Intramuscular injection" - } - ] - }, - "doseQuantity": { - "value": 50, - "unit": "ug" - } - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "20", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
NameHealth LS - Immuno Inc.
" - }, - "name": "Health LS - Immuno Inc." - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "21", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2981824
NameHarold HIPPOCRATES
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.19.5.9999.456", - "value": "2981824" - } - ], - "name": { - "family": [ - "Hippocrates" - ], - "given": [ - "Harold" - ] - }, - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "managingOrganization": { - "reference": "Organization/22" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "22", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2.16.840.1.113883.19.5.9999.1394
NameGood Health Clinic
" - }, - "identifier": [ - { - "value": "2.16.840.1.113883.19.5.9999.1394" - } - ], - "name": "Good Health Clinic", - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ] - } - }, - { - "resource": { - "resourceType": "Immunization", - "id": "23", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-immunization" - ] - }, - "text": { - "status": "generated", - "div": "
Vaccine Code
Influenza virus vaccine
Date (Vaccine Administered)Wed Nov 30 00:00:00 EET 1999
Route
Intramuscular injection
Dose
50ug
" - }, - "identifier": [ - { - "value": "e6f1ba43-c0ed-4b9b-9f12-f435d8ad8f92" - } - ], - "status": "completed", - "date": "1999-11", - "vaccineCode": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.59", - "code": "88", - "display": "Influenza virus vaccine" - } - ] - }, - "patient": { - "reference": "Patient/2" - }, - "wasNotGiven": false, - "reported": false, - "performer": { - "reference": "Practitioner/25" - }, - "manufacturer": { - "reference": "Organization/24" - }, - "lotNumber": "1", - "route": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.3.26.1.1", - "code": "C28161", - "display": "Intramuscular injection" - } - ] - }, - "doseQuantity": { - "value": 50, - "unit": "ug" - } - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "24", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
NameHealth LS - Immuno Inc.
" - }, - "name": "Health LS - Immuno Inc." - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "25", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2981824
NameHarold HIPPOCRATES
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.19.5.9999.456", - "value": "2981824" - } - ], - "name": { - "family": [ - "Hippocrates" - ], - "given": [ - "Harold" - ] - }, - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "managingOrganization": { - "reference": "Organization/26" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "26", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2.16.840.1.113883.19.5.9999.1394
NameGood Health Clinic
" - }, - "identifier": [ - { - "value": "2.16.840.1.113883.19.5.9999.1394" - } - ], - "name": "Good Health Clinic", - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ] - } - }, - { - "resource": { - "resourceType": "Immunization", - "id": "27", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-immunization" - ] - }, - "text": { - "status": "generated", - "div": "
Vaccine Code
Tetanus and diphtheria toxoids - preservative free
Date (Vaccine Administered)Fri Dec 15 00:00:00 EET 1998
Not GivenTrue
Route
Intramuscular injection
Dose
50ug
" - }, - "identifier": [ - { - "value": "e6f1ba43-c0ed-4b9b-9f12-f435d8ad8f92" - } - ], - "status": "completed", - "date": "1998-12-15", - "vaccineCode": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.59", - "code": "103", - "display": "Tetanus and diphtheria toxoids - preservative free" - } - ] - }, - "patient": { - "reference": "Patient/2" - }, - "wasNotGiven": true, - "reported": false, - "performer": { - "reference": "Practitioner/29" - }, - "manufacturer": { - "reference": "Organization/28" - }, - "lotNumber": "1", - "route": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.3.26.1.1", - "code": "C28161", - "display": "Intramuscular injection" - } - ] - }, - "doseQuantity": { - "value": 50, - "unit": "ug" - }, - "explanation": { - "reasonNotGiven": [ - { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.5.8", - "code": "PATOBJ", - "display": "Patient Objection" - } - ] - } - ] - } - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "28", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
NameHealth LS - Immuno Inc.
" - }, - "name": "Health LS - Immuno Inc." - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "29", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2981824
NameHarold HIPPOCRATES
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.19.5.9999.456", - "value": "2981824" - } - ], - "name": { - "family": [ - "Hippocrates" - ], - "given": [ - "Harold" - ] - }, - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "managingOrganization": { - "reference": "Organization/30" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "30", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2.16.840.1.113883.19.5.9999.1394
NameGood Health Clinic
" - }, - "identifier": [ - { - "value": "2.16.840.1.113883.19.5.9999.1394" - } - ], - "name": "Good Health Clinic", - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ] - } - }, - { - "resource": { - "resourceType": "Immunization", - "id": "31", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-immunization" - ] - }, - "text": { - "status": "generated", - "div": "
Vaccine Code
Pneumococcal polysaccharide vaccine
Date (Vaccine Administered)Fri Dec 15 00:00:00 EET 1998
Route
Intramuscular injection
Dose
50ug
" - }, - "identifier": [ - { - "value": "e6f1ba43-c0ed-4b9b-9f12-f435d8ad8f92" - } - ], - "status": "completed", - "date": "1998-12-15", - "vaccineCode": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.59", - "code": "33", - "display": "Pneumococcal polysaccharide vaccine" - } - ] - }, - "patient": { - "reference": "Patient/2" - }, - "wasNotGiven": false, - "reported": false, - "performer": { - "reference": "Practitioner/33" - }, - "manufacturer": { - "reference": "Organization/32" - }, - "lotNumber": "1", - "route": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.3.26.1.1", - "code": "C28161", - "display": "Intramuscular injection" - } - ] - }, - "doseQuantity": { - "value": 50, - "unit": "ug" - }, - "reaction": [ - { - "date": "1998-12-15T08:05:00-08:00", - "detail": { - "reference": "Observation/35" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "32", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
NameHealth LS - Immuno Inc.
" - }, - "name": "Health LS - Immuno Inc." - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "33", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2981824
NameHarold HIPPOCRATES
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.19.5.9999.456", - "value": "2981824" - } - ], - "name": { - "family": [ - "Hippocrates" - ], - "given": [ - "Harold" - ] - }, - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "managingOrganization": { - "reference": "Organization/34" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "34", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2.16.840.1.113883.19.5.9999.1394
NameGood Health Clinic
" - }, - "identifier": [ - { - "value": "2.16.840.1.113883.19.5.9999.1394" - } - ], - "name": "Good Health Clinic", - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "35", - "text": { - "status": "generated", - "div": "
Code
Date/PeriodFri Dec 15 18:05:00 EET 1998 - Fri Dec 15 22:05:00 EET 1998
Result
Nausea
" - }, - "identifier": [ - { - "value": "4adc1020-7b14-11db-9fe1-0800200c9a64" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.5.4", - "code": "ASSERTION" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "1998-12-15T08:05:00-08:00", - "end": "1998-12-15T12:05:00-08:00" - }, - "valueCodeableConcept": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "422587007", - "display": "Nausea" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Immunization", - "id": "36", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-immunization" - ] - }, - "text": { - "status": "generated", - "div": "
Vaccine Code
Hepatitis B vaccine
Date (Vaccine Administered)Fri Aug 01 00:00:00 EET 2013
Route
Intramuscular injection
Dose
" - }, - "identifier": [ - { - "value": "de10790f-1496-4719-8fe6-f1b87b6219f7" - } - ], - "status": "completed", - "date": "2013-08-01", - "vaccineCode": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.59", - "code": "45", - "display": "Hepatitis B vaccine" - } - ] - }, - "patient": { - "reference": "Patient/2" - }, - "wasNotGiven": false, - "reported": false, - "performer": { - "reference": "Practitioner/37" - }, - "lotNumber": "1", - "route": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.3.26.1.1", - "code": "C28161", - "display": "Intramuscular injection" - } - ] - }, - "explanation": { - "reason": [ - { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "195967001", - "display": "Asthma" - } - ] - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "37", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2981824
NameHarold HIPPOCRATES
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.19.5.9999.456", - "value": "2981824" - } - ], - "name": { - "family": [ - "Hippocrates" - ], - "given": [ - "Harold" - ] - }, - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "managingOrganization": { - "reference": "Organization/38" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "38", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2.16.840.1.113883.19.5.9999.1394
NameGood Health Clinic
" - }, - "identifier": [ - { - "value": "2.16.840.1.113883.19.5.9999.1394" - } - ], - "name": "Good Health Clinic", - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ] - } - }, - { - "resource": { - "resourceType": "Encounter", - "id": "39", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-encounter" - ] - }, - "text": { - "status": "generated", - "div": "
Type
Office outpatient visit 15 minutes
Start
Sun Sep 27 10:00:00 EET 2012
" - }, - "identifier": [ - { - "value": "2a620155-9d11-439e-92b3-5d9815ff4de8" - } - ], - "status": "finished", - "type": [ - { - "coding": [ - { - "system": "http://www.ama-assn.org/go/cpt", - "code": "99213", - "display": "Office outpatient visit 15 minutes" - } - ] - } - ], - "patient": { - "reference": "Patient/2" - }, - "participant": [ - { - "type": [ - { - "coding": [ - { - "system": "http://hl7.org/fhir/v3/ParticipationType", - "code": "PART", - "display": "Participation" - } - ] - } - ], - "individual": { - "reference": "Practitioner/40" - } - } - ], - "period": { - "start": "2012-09-27T13:00:00+05:00" - }, - "indication": [ - { - "reference": "Condition/41" - } - ], - "location": [ - { - "location": { - "reference": "Location/42" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "40", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier333444555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "333444555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "59058001", - "display": "General Physician" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Condition", - "id": "41", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-condition" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Pneumonia
Category
Clinical Statusactive
Onset
Fri Sep 25 08:30:00 EET 2012
" - }, - "identifier": [ - { - "system": "urn:uuid:db734647-fc99-424c-a864-7e3cda82e703", - "value": "45665" - } - ], - "patient": { - "reference": "Patient/2" - }, - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "233604007", - "display": "Pneumonia" - } - ] - }, - "category": { - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "code": "finding" - } - ] - }, - "clinicalStatus": "active", - "verificationStatus": "confirmed", - "onsetDateTime": "2012-09-25T11:30:00+05:00" - } - }, - { - "resource": { - "resourceType": "Location", - "id": "42", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-location" - ] - }, - "text": { - "status": "generated", - "div": "
NameGood Health Urgent Care
" - }, - "name": "Good Health Urgent Care", - "telecom": [ - { - "system": "phone", - "value": " +1(555)555-1030", - "use": "work" - } - ], - "address": { - "line": [ - "1007 Health Drive" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "43", - "text": { - "status": "generated", - "div": "
Category
Functional status
Code
Independent walking
Date/PeriodTue Mar 11 00:00:00 EET 2013 - ?
" - }, - "identifier": [ - { - "value": "b63a8636-cfff-4461-b018-40ba58ba8b32" - } - ], - "status": "final", - "category": { - "coding": [ - { - "system": "http://loinc.org", - "code": "54522-8", - "display": "Functional status" - } - ] - }, - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "165245003", - "display": " Independent walking" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2013-03-11" - }, - "performer": [ - { - "reference": "Practitioner/44" - } - ], - "device": { - "reference": "Device/45" - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "44", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Device", - "id": "45", - "text": { - "status": "generated", - "div": "
Identifier742aee30-21c5-11e1-bfc2-0800200c9a66
Type
cane, device (physical object)
" - }, - "identifier": [ - { - "value": "742aee30-21c5-11e1-bfc2-0800200c9a66" - } - ], - "type": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "87405001", - "display": "cane, device (physical object)" - } - ] - }, - "patient": { - "reference": "Patient/2" - } - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "46", - "text": { - "status": "generated", - "div": "
Category
Bathing
Code
Independent
Date/Period
" - }, - "identifier": [ - { - "value": "c6b5a04b-2bf4-49d1-8336-636a3813df0a" - } - ], - "status": "final", - "category": { - "coding": [ - { - "system": "http://loinc.org", - "code": "46008-9", - "display": "Bathing" - } - ] - }, - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "371153006", - "display": "Independent" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "performer": [ - { - "reference": "Practitioner/47" - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "47", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Procedure", - "id": "48", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-procedure" - ] - }, - "text": { - "status": "generated", - "div": "
Type
Colonoscopy
Date/PeriodTue May 12 00:00:00 EET 2012 - ?
" - }, - "identifier": [ - { - "value": "d68b7e32-7810-4f5b-9cc2-acd54b0fd85d" - } - ], - "subject": { - "reference": "Patient/2" - }, - "status": "completed", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "73761001", - "display": "Colonoscopy" - } - ] - }, - "bodySite": [ - { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.3.88.12.3221.8.9", - "code": "appropriate_code", - "display": "colon" - } - ] - } - ], - "performer": [ - { - "actor": { - "reference": "Practitioner/49" - } - } - ], - "performedPeriod": { - "start": "2012-05-12" - }, - "encounter": { - "reference": "Encounter/51" - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "49", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2981823
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.19.5.9999.456", - "value": "2981823" - } - ], - "telecom": [ - { - "system": "phone", - "value": "+1(555)555-5000", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1001 Village Avenue" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "managingOrganization": { - "reference": "Organization/50" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "50", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2.16.840.1.113883.19.5.9999.1393
NameCommunity Health and Hospitals
" - }, - "identifier": [ - { - "value": "2.16.840.1.113883.19.5.9999.1393" - } - ], - "name": "Community Health and Hospitals", - "telecom": [ - { - "system": "phone", - "value": "+1(555)555-5000", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1001 Village Avenue" - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ] - } - }, - { - "resource": { - "resourceType": "Encounter", - "id": "51", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-encounter" - ] - }, - "identifier": [ - { - "value": "2a620155-9d11-439e-92b3-5d9815ff4de8" - } - ], - "status": "finished", - "patient": { - "reference": "Patient/2" - } - } - }, - { - "resource": { - "resourceType": "MedicationStatement", - "id": "52", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-medicationstatement" - ] - }, - "text": { - "status": "generated", - "div": "
PeriodWed Mar 18 00:00:00 EET 2012 - ?
Dosage
Timing
12/h
Route
ORAL
Quantity
2
" - }, - "identifier": [ - { - "value": "6c844c75-aa34-411c-b7bd-5e4a9f206e29" - } - ], - "patient": { - "reference": "Patient/2" - }, - "informationSource": { - "reference": "Practitioner/53" - }, - "status": "active", - "wasNotTaken": false, - "reasonForUseReference": { - "reference": "Condition/55" - }, - "effectivePeriod": { - "start": "2012-03-18" - }, - "medicationReference": { - "reference": "Medication/54" - }, - "dosage": [ - { - "timing": { - "repeat": { - "period": 12, - "periodUnits": "h" - } - }, - "route": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.3.26.1.1", - "code": "C38288", - "display": "ORAL" - } - ] - }, - "quantityQuantity": { - "value": 1, - "unit": "1" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "53", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier5555555555
NamePatricia Patty PRIMARY M.D.
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "5555555555" - } - ], - "name": { - "family": [ - "Primary" - ], - "given": [ - "Patricia", - "Patty" - ], - "suffix": [ - "M.D." - ] - }, - "telecom": [ - { - "system": "phone", - "value": "+1(555)555-1004", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1004 Healthcare Drive " - ], - "city": "Portland", - "state": "OR", - "postalCode": "99123", - "country": "US" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Medication", - "id": "54", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-medication" - ] - }, - "text": { - "status": "generated", - "div": "
Atenolol 25 MG Oral Tablet
" - }, - "code": { - "coding": [ - { - "system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "197380", - "display": "Atenolol 25 MG Oral Tablet" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Condition", - "id": "55", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-condition" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Hypertension
Category
" - }, - "identifier": [ - { - "value": "e63166c7-6482-4a44-83a1-37ccdbde725b" - } - ], - "patient": { - "reference": "Patient/2" - }, - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "38341003", - "display": "Hypertension" - } - ] - }, - "category": { - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "code": "finding" - } - ] - }, - "verificationStatus": "confirmed" - } - }, - { - "resource": { - "resourceType": "MedicationStatement", - "id": "56", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-medicationstatement" - ] - }, - "text": { - "status": "generated", - "div": "
PeriodSun Jan 03 00:00:00 EET 2011 - ?
Dosage
Timing
6/h
Route
RESPIRATORY (INHALATION)
Quantity
3
" - }, - "identifier": [ - { - "value": "cdbd33f0-6cde-11db-9fe1-0800200c9a66" - } - ], - "patient": { - "reference": "Patient/2" - }, - "status": "active", - "wasNotTaken": false, - "reasonForUseReference": { - "reference": "Condition/60" - }, - "effectivePeriod": { - "start": "2011-01-03" - }, - "medicationReference": { - "reference": "Medication/57" - }, - "dosage": [ - { - "timing": { - "repeat": { - "period": 6, - "periodUnits": "h" - } - }, - "route": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.3.26.1.1", - "code": "C38216", - "display": "RESPIRATORY (INHALATION)" - } - ] - }, - "quantityQuantity": { - "value": 2, - "unit": "1" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Medication", - "id": "57", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-medication" - ] - }, - "text": { - "status": "generated", - "div": "
Proventil 0.09 MG/ACTUAT inhalant solution
" - }, - "code": { - "coding": [ - { - "system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "573621", - "display": "Proventil 0.09 MG/ACTUAT inhalant solution" - } - ] - }, - "manufacturer": { - "reference": "Organization/59" - }, - "product": { - "ingredient": [ - { - "item": { - "reference": "Substance/58" - } - } - ] - } - } - }, - { - "resource": { - "resourceType": "Substance", - "id": "58", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-substance" - ] - }, - "text": { - "status": "generated", - "div": "
Substance
Proventil HFA
" - }, - "code": { - "coding": [ - { - "system": "http://www.nlm.nih.gov/research/umls/rxnorm", - "code": "219483", - "display": "Proventil HFA" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "59", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
NameMedication Factory Inc.
" - }, - "name": "Medication Factory Inc." - } - }, - { - "resource": { - "resourceType": "Condition", - "id": "60", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-condition" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Asthma
Category
Clinical Statusactive
Onset
Sun Jan 03 00:00:00 EET 2011
" - }, - "identifier": [ - { - "system": "urn:uuid:db734647-fc99-424c-a864-7e3cda82e703", - "value": "45665" - } - ], - "patient": { - "reference": "Patient/2" - }, - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "195967001", - "display": "Asthma" - } - ] - }, - "category": { - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "code": "finding" - } - ] - }, - "clinicalStatus": "active", - "verificationStatus": "confirmed", - "onsetDateTime": "2011-01-03" - } - }, - { - "resource": { - "resourceType": "DiagnosticReport", - "id": "61", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-diagnosticreport" - ] - }, - "text": { - "status": "generated", - "div": "
Blood chemistry test
Statuspartial
Issued20 March 2008 19:30:00
" - }, - "identifier": [ - { - "value": "122ed3ae-6d9e-43d0-bfa2-434ea34b1426" - } - ], - "status": "partial", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "166312007", - "display": "Blood chemistry test" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2008-03-20T09:30:00-08:00", - "end": "2008-03-20T09:30:00-08:00" - }, - "issued": "2008-03-20T09:30:00-08:00", - "performer": { - "reference": "Practitioner/62" - }, - "result": [ - { - "reference": "Observation/63" - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "62", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Name
" - }, - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason", - "valueCoding": { - "system": "http://hl7.org/fhir/data-absent-reason", - "code": "unknown", - "display": "Unknown" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "63", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-resultobs" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Urea nitrogen, Serum
Date/PeriodWed Mar 20 19:30:00 EET 2008 - ?
" - }, - "identifier": [ - { - "value": "aed821af-3330-4138-97f0-e84dfe5f3c35" - } - ], - "status": "preliminary", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "3094-0", - "display": "Urea nitrogen, Serum" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2008-03-20T09:30:00-08:00" - }, - "dataAbsentReason": { - "coding": [ - { - "system": "http://hl7.org/fhir/data-absent-reason", - "code": "error", - "display": "Error" - } - ] - } - } - }, - { - "resource": { - "resourceType": "DiagnosticReport", - "id": "64", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-diagnosticreport" - ] - }, - "text": { - "status": "generated", - "div": "
CBC W Auto Differential panel in Blood
Statusfinal
Issued19 March 2008 18:30:00
" - }, - "identifier": [ - { - "value": "7d5a02b0-67a4-11db-bd13-0800200c9a66" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "57021-8", - "display": "CBC W Auto Differential panel in Blood" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2008-03-19T08:30:00-08:00", - "end": "2008-03-19T08:30:00-08:00" - }, - "issued": "2008-03-19T08:30:00-08:00", - "performer": { - "reference": "Practitioner/65" - }, - "result": [ - { - "reference": "Observation/66" - }, - { - "reference": "Observation/68" - }, - { - "reference": "Observation/70" - }, - { - "reference": "Observation/72" - }, - { - "reference": "Observation/74" - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "65", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Name
" - }, - "extension": [ - { - "url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason", - "valueCoding": { - "system": "http://hl7.org/fhir/data-absent-reason", - "code": "unknown", - "display": "Unknown" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "66", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-resultobs" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Hemoglobin
Date/PeriodTue Mar 19 18:30:00 EET 2008 - ?
Result
13.2g/dL
Interpretation
" - }, - "identifier": [ - { - "value": "107c2dc0-67a5-11db-bd13-0800200c9a66" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "718-7", - "display": "Hemoglobin" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2008-03-19T08:30:00-08:00" - }, - "issued": "2008-03-19T08:30:00-08:00", - "performer": [ - { - "reference": "Practitioner/67" - } - ], - "valueQuantity": { - "value": 13.2, - "unit": "g/dL" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - }, - "referenceRange": [ - { - "low": { - "value": 12.0, - "unit": "g/dL" - }, - "high": { - "value": 15.5, - "unit": "g/dL" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "67", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier333444444
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "333444444" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "246Q00000X", - "display": "Technician, Pathology" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "68", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-resultobs" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Platelets
Date/PeriodTue Mar 19 18:30:00 EET 2008 - ?
Result
12310*9/L
Interpretation
Low
" - }, - "identifier": [ - { - "value": "ef5c1c58-4665-4556-a8e8-6e720d82f572" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "777-3", - "display": "Platelets" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2008-03-19T08:30:00-08:00" - }, - "issued": "2008-03-19T08:30:00-08:00", - "performer": [ - { - "reference": "Practitioner/69" - } - ], - "valueQuantity": { - "value": 123, - "unit": "10*9/L" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "L", - "display": "Low" - } - ] - }, - "referenceRange": [ - { - "low": { - "value": 150, - "unit": "10*9/L" - }, - "high": { - "value": 350, - "unit": "10*9/L" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "69", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier333444444
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "333444444" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "246Q00000X", - "display": "Technician, Pathology" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "70", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-resultobs" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Hematocrit
Date/PeriodTue Mar 19 18:30:00 EET 2008 - ?
Result
35.3%
Interpretation
Low
" - }, - "identifier": [ - { - "value": "7c0704bb-9c40-41b5-9c7d-26b2d59e234f" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "4544-3", - "display": "Hematocrit" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2008-03-19T08:30:00-08:00" - }, - "issued": "2008-03-19T08:30:00-08:00", - "performer": [ - { - "reference": "Practitioner/71" - } - ], - "valueQuantity": { - "value": 35.3, - "unit": "%" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "L", - "display": "Low" - } - ] - }, - "referenceRange": [ - { - "low": { - "value": 34.9, - "unit": "%" - }, - "high": { - "value": 44.5, - "unit": "%" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "71", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier333444444
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "333444444" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "246Q00000X", - "display": "Technician, Pathology" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "72", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-resultobs" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Erythrocytes
Date/PeriodTue Mar 19 18:30:00 EET 2008 - ?
Result
4.2110*12/L
Interpretation
" - }, - "identifier": [ - { - "value": "bccd6fc9-0c7f-455e-8616-923ed0d04d09" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "789-8", - "display": "Erythrocytes" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2008-03-19T08:30:00-08:00" - }, - "issued": "2008-03-19T08:30:00-08:00", - "performer": [ - { - "reference": "Practitioner/73" - } - ], - "valueQuantity": { - "value": 4.21, - "unit": "10*12/L" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - }, - "referenceRange": [ - { - "low": { - "value": 3.90, - "unit": "10*12/L" - }, - "high": { - "value": 5.03, - "unit": "10*12/L" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "73", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier333444444
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "333444444" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "246Q00000X", - "display": "Technician, Pathology" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "74", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-resultobs" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Leukocytes
Date/PeriodTue Mar 19 18:30:00 EET 2008 - ?
Result
6.710*9/L
Interpretation
" - }, - "identifier": [ - { - "value": "a69b3d60-2ffd-4440-958b-72b3335ff35f" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "6690-2", - "display": "Leukocytes" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2008-03-19T08:30:00-08:00" - }, - "issued": "2008-03-19T08:30:00-08:00", - "performer": [ - { - "reference": "Practitioner/75" - } - ], - "valueQuantity": { - "value": 6.7, - "unit": "10*9/L" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - }, - "referenceRange": [ - { - "low": { - "value": 4.3, - "unit": "10*9/L" - }, - "high": { - "value": 10.8, - "unit": "10*9/L" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "75", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier333444444
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "333444444" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "246Q00000X", - "display": "Technician, Pathology" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Device", - "id": "76", - "text": { - "status": "generated", - "div": "
Identifier24993f33-6222-41ce-add6-37a9d3da6acb
Type
cane
" - }, - "identifier": [ - { - "value": "24993f33-6222-41ce-add6-37a9d3da6acb" - } - ], - "type": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "87405001", - "display": "cane" - } - ] - }, - "patient": { - "reference": "Patient/2" - } - } - }, - { - "resource": { - "resourceType": "Device", - "id": "77", - "text": { - "status": "generated", - "div": "
Identifier24993f33-6222-41ce-add6-37a9d3da6acb
Type
cardiac pacemaker, device (physical object)
" - }, - "identifier": [ - { - "value": "24993f33-6222-41ce-add6-37a9d3da6acb" - } - ], - "type": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "14106009", - "display": "cardiac pacemaker, device (physical object)" - } - ] - }, - "patient": { - "reference": "Patient/2" - } - } - }, - { - "resource": { - "resourceType": "Device", - "id": "78", - "text": { - "status": "generated", - "div": "
Identifier24993f33-6222-41ce-add6-37a9d3da6acb
Type
upper gastrointestinal prosthesis (physical object)
" - }, - "identifier": [ - { - "value": "24993f33-6222-41ce-add6-37a9d3da6acb" - } - ], - "type": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "303406003", - "display": "upper gastrointestinal prosthesis (physical object)" - } - ] - }, - "patient": { - "reference": "Patient/2" - } - } - }, - { - "resource": { - "resourceType": "Procedure", - "id": "79", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-procedure" - ] - }, - "text": { - "status": "generated", - "div": "
Type
Stent Placement
Date/PeriodMon May 12 00:00:00 EET 2013 - ?
" - }, - "identifier": [ - { - "value": "d5b614bd-01ce-410d-8726-e1fd01dcc72a" - } - ], - "subject": { - "reference": "Patient/2" - }, - "status": "completed", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "103716009", - "display": "Stent Placement" - } - ] - }, - "bodySite": [ - { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "28273000", - "display": "bile duct" - } - ] - } - ], - "performer": [ - { - "actor": { - "reference": "Practitioner/80" - } - } - ], - "performedPeriod": { - "start": "2013-05-12" - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "80", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier1234
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.19", - "value": "1234" - } - ], - "telecom": [ - { - "system": "phone", - "value": " +1(555)-555-5004", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1004 Health Care Drive" - ], - "city": "Ann Arbor", - "state": "MI", - "postalCode": "02368", - "country": "US" - } - ], - "practitionerRole": [ - { - "managingOrganization": { - "reference": "Organization/81" - } - } - ] - } - }, - { - "resource": { - "resourceType": "Organization", - "id": "81", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-organization" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier2.16.840.1.113883.19.5
NameCommunity Health and Hospitals
" - }, - "identifier": [ - { - "value": "2.16.840.1.113883.19.5" - } - ], - "name": "Community Health and Hospitals", - "telecom": [ - { - "system": "phone", - "value": "+1(555)-555-5005", - "use": "work" - } - ], - "address": [ - { - "line": [ - "1003 Health Care Drive" - ], - "city": "Ann Arbor", - "state": "MI", - "postalCode": "02368", - "country": "US" - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "82", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-vitalsigns" - ] - }, - "text": { - "status": "generated", - "div": "
Code
BP Systolic
Date/PeriodWed Sep 01 00:00:00 EET 2011 - ?
Result
128mm[Hg]
Interpretation
" - }, - "identifier": [ - { - "value": "b046c35a-59c7-4215-ae09-9a8409a30b21" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "8480-6", - "display": "BP Systolic" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2011-09-01" - }, - "issued": "2011-09-01T09:15:00-08:00", - "performer": [ - { - "reference": "Practitioner/83" - } - ], - "valueQuantity": { - "value": 128, - "unit": "mm[Hg]" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "83", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "84", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-vitalsigns" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Patient Body Weight - Measured
Date/PeriodWed Sep 01 00:00:00 EET 2011 - ?
Result
88kg
Interpretation
" - }, - "identifier": [ - { - "value": "21b0f3d5-7d07-4f4f-ad7e-c33dc2ca3835" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "3141-9", - "display": "Patient Body Weight - Measured" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2011-09-01" - }, - "issued": "2011-09-01T09:15:00-08:00", - "performer": [ - { - "reference": "Practitioner/85" - } - ], - "valueQuantity": { - "value": 88, - "unit": "kg" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "85", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "86", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-vitalsigns" - ] - }, - "text": { - "status": "generated", - "div": "
Code
BP Diastolic
Date/PeriodWed Sep 01 00:00:00 EET 2011 - ?
Result
80mm[Hg]
Interpretation
" - }, - "identifier": [ - { - "value": "44f54e66-fb4b-4ee5-9ced-9574ef307a23" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "8462-4", - "display": "BP Diastolic" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2011-09-01" - }, - "issued": "2011-09-01T09:15:00-08:00", - "performer": [ - { - "reference": "Practitioner/87" - } - ], - "valueQuantity": { - "value": 80, - "unit": "mm[Hg]" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "87", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "88", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-vitalsigns" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Height
Date/PeriodWed Sep 01 00:00:00 EET 2011 - ?
Result
177cm
Interpretation
" - }, - "identifier": [ - { - "value": "05c047cd-28c3-41cd-be6c-56f8cc0c3f2f" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "8302-2", - "display": "Height" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2011-09-01" - }, - "issued": "2011-09-01T09:15:00-08:00", - "performer": [ - { - "reference": "Practitioner/89" - } - ], - "valueQuantity": { - "value": 177, - "unit": "cm" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "89", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "90", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-vitalsigns" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Patient Body Weight - Measured
Date/PeriodThu Sep 10 00:00:00 EET 2012 - ?
Result
86kg
Interpretation
" - }, - "identifier": [ - { - "value": "f4e729e2-a97f-4a7e-8e23-c92f9b6b55cf" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "3141-9", - "display": "Patient Body Weight - Measured" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2012-09-10" - }, - "issued": "2012-09-10T11:45:00-08:00", - "performer": [ - { - "reference": "Practitioner/91" - } - ], - "valueQuantity": { - "value": 86, - "unit": "kg" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "91", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "92", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-vitalsigns" - ] - }, - "text": { - "status": "generated", - "div": "
Code
BP Diastolic
Date/PeriodThu Sep 10 00:00:00 EET 2012 - ?
Result
88mm[Hg]
Interpretation
" - }, - "identifier": [ - { - "value": "1c2748b7-e440-41ba-bc01-dde97d84a036" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "8462-4", - "display": "BP Diastolic" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2012-09-10" - }, - "issued": "2011-09-01T09:15:00-08:00", - "performer": [ - { - "reference": "Practitioner/93" - } - ], - "valueQuantity": { - "value": 88, - "unit": "mm[Hg]" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "93", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "94", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-vitalsigns" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Intravascular Systolic
Date/PeriodThu Sep 10 00:00:00 EET 2012 - ?
Result
132mm[Hg]
Interpretation
" - }, - "identifier": [ - { - "value": "a0e39c70-9674-4b2a-9837-cdf74200d8d5" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "8480-6", - "display": "Intravascular Systolic" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2012-09-10" - }, - "issued": "2012-09-10T11:45:00-08:00", - "performer": [ - { - "reference": "Practitioner/95" - } - ], - "valueQuantity": { - "value": 132, - "unit": "mm[Hg]" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "95", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Observation", - "id": "96", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-vitalsigns" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Height
Date/PeriodThu Sep 10 00:00:00 EET 2012 - ?
Result
177cm
Interpretation
" - }, - "identifier": [ - { - "value": "ed9589fd-fda0-41f7-a3d0-dc537554f5c2" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://loinc.org", - "code": "8302-2", - "display": "Height" - } - ] - }, - "subject": { - "reference": "Patient/2" - }, - "effectivePeriod": { - "start": "2012-09-10" - }, - "issued": "2012-09-10T11:45:00-08:00", - "performer": [ - { - "reference": "Practitioner/97" - } - ], - "valueQuantity": { - "value": 177, - "unit": "cm" - }, - "interpretation": { - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0078", - "code": "N" - } - ] - } - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "97", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Condition", - "id": "98", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-condition" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Chest pain
Date RecordedTue Apr 15 01:15:00 EET 2007
Category
Clinical Statusactive
Onset
Mon Apr 14 00:00:00 EET 2007
" - }, - "identifier": [ - { - "value": "11d088a8-b957-401c-8ee0-3bd20a772fc0" - } - ], - "patient": { - "reference": "Patient/2" - }, - "asserter": { - "reference": "Practitioner/99" - }, - "dateRecorded": "2007-04-15", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "29857009", - "display": "Chest pain" - } - ] - }, - "category": { - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "code": "diagnosis" - } - ] - }, - "clinicalStatus": "active", - "verificationStatus": "confirmed", - "onsetDateTime": "2007-04-14" - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "99", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Condition", - "id": "100", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-condition" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Angina
Date RecordedFri Apr 18 01:15:00 EET 2007
Category
Clinical Statusactive
Onset
Thu Apr 17 00:00:00 EET 2007
" - }, - "identifier": [ - { - "value": "4991db40-4c4f-41e8-9146-50c12d716424" - } - ], - "patient": { - "reference": "Patient/2" - }, - "asserter": { - "reference": "Practitioner/101" - }, - "dateRecorded": "2007-04-18", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "194828000", - "display": "Angina" - } - ] - }, - "category": { - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "code": "diagnosis" - } - ] - }, - "clinicalStatus": "active", - "verificationStatus": "confirmed", - "onsetDateTime": "2007-04-17" - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "101", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier222334444
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "222334444" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Condition", - "id": "102", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-condition" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Pneumonia
Date RecordedThu Mar 16 20:30:00 EET 1998
Category
Clinical Statusresolved
Onset
Fri Mar 10 00:00:00 EET 1998
" - }, - "identifier": [ - { - "value": "10506b4d-c30a-4220-8bec-97bff9568fd1" - } - ], - "patient": { - "reference": "Patient/2" - }, - "asserter": { - "reference": "Practitioner/103" - }, - "dateRecorded": "1998-03-16", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "233604007", - "display": "Pneumonia" - } - ] - }, - "category": { - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "code": "diagnosis" - } - ] - }, - "clinicalStatus": "resolved", - "verificationStatus": "confirmed", - "onsetDateTime": "1998-03-10", - "abatementDateTime": "1998-03-16" - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "103", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - }, - { - "resource": { - "resourceType": "Condition", - "id": "104", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-condition" - ] - }, - "text": { - "status": "generated", - "div": "
Code
Pneumonia
Date RecordedWed Aug 14 20:30:00 EET 2008
Category
Clinical Statusactive
Onset
Thu Jul 03 00:00:00 EET 2013
" - }, - "identifier": [ - { - "value": "ab1791b0-5c71-11db-b0de-0800200c9a66" - } - ], - "patient": { - "reference": "Patient/2" - }, - "asserter": { - "reference": "Practitioner/105" - }, - "dateRecorded": "2008-08-14", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "233604007", - "display": "Pneumonia" - } - ] - }, - "category": { - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "code": "diagnosis" - } - ] - }, - "clinicalStatus": "active", - "verificationStatus": "confirmed", - "onsetDateTime": "2013-07-03", - "abatementDateTime": "2008-08-14" - } - }, - { - "resource": { - "resourceType": "Practitioner", - "id": "105", - "meta": { - "profile": [ - "http://hl7.org/fhir/StructureDefinition/daf-pract" - ] - }, - "text": { - "status": "generated", - "div": "
Identifier555555555
Name
" - }, - "identifier": [ - { - "system": "urn:oid:2.16.840.1.113883.4.6", - "value": "555555555" - } - ], - "practitionerRole": [ - { - "role": { - "coding": [ - { - "system": "urn:oid:2.16.840.1.113883.6.101", - "code": "207QA0505X", - "display": "Adult Medicine" - } - ] - } - } - ] - } - } - ] -} \ No newline at end of file diff --git a/src/test/resources/C-CDA_R2-1_CCD.xml b/src/test/resources/C-CDA_R2-1_CCD.xml deleted file mode 100644 index 524cfca19..000000000 --- a/src/test/resources/C-CDA_R2-1_CCD.xml +++ /dev/null @@ -1,3493 +0,0 @@ - - - - - - - - - - - - - - Patient Chart Summary - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - US - - - - - - - Eve - - Betterhalf - - - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - US - - - - - Boris - Bo - Betterhalf - - - - - - - 4444 Home Street - Beaverton - OR - 97867 - US - - - - - - - - - - - - - - - The DoctorsTogether Physician Group - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - - 1007 Healthcare Drive - Portland - OR - 99123 - US - - - - - Ellen - Enter - - - - - - - - - - 1007 Healthcare Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - M.D. - - - - The DoctorsApart Physician Group - - - - - - - - 1025 Health Drive - Portland - OR - 99123 - US - - - - - Ramsey - Reaction - M.D. - - - - The DoctorsApart Physician Group - - - - - - - - 1017 Health Drive - Portland - OR - 99123 - US - - - - - William - Bill - Beaker - - - - Good Health Laboratory - - - - - - - - 1016 Health Drive - Portland - OR - 99123 - US - - - - - Susan - Script - Pharm.D. - - - - People's Pharmacy - - - - - - - - 1027 Health Drive - Portland - OR - 99123 - US - - - - - Patrick - Pump - M.D. - - - - The DoctorsApart Physician Group - - - - - - - - - - Boris - Bo - Betterhalf - - - - - - - - - - Good Health HIE - - - 1009 Healthcare Drive - Portland - OR - 99123 - US - - - - - - - - - - Sara - Specialize - M.D. - - - - The DoctorsApart Physician Group - - - - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - US - - - - - Boris - Bo - Betterhalf - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - US - - - - - Boris - Bo - Betterhalf - - - - - - - - - - - - - - - - Primary Care Provider - - - - - - 1004 Healthcare Drive - Portland - OR - 99123 - US - - - - - Patricia - Patty - Primary - M.D. - - - - - The DoctorsTogether Physician Group - - - 1004 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - -
- - - - - ADVANCE DIRECTIVES - - - - - - - - - - - - - - - - - - -
DirectiveDescriptionVerificationSupporting Document(s)
Resuscitation statusDo not resuscitateDr. Patricia Primary, Feb 19, 2011 - Advance directive -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1004 Health Drive - Portland - OR - 99123 - US - - - - - Dr. - Patricia - Primary - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - ALLERGIES AND ADVERSE REACTIONS - - - - - - - - - - - - - - - - - - -
SubstanceReaction
PenicillinNausea
CodeineWheezing
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - ENCOUNTERS - - - - - - - - - - - - - - - - - - -
EncounterPerformerLocationDate
Checkup Examination Performer NameCommunity Urgent Care CenterSeptember 27, 2012 at 1:00pm
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - Good Health Urgent Care - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - FAMILY HISTORY - - Father (deceased) - - - - - - - - - - - - - - - - - -
DiagnosisAge At Onset
Myocardial Infarction (cause of death)57
Diabetes40
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- - - - FUNCTIONAL STATUS - - - - - - - - - - - - - - - - - - - - - -
Functional CategoryEffective DatesResults of Evaluation
Functional AssessmentMarch 11, 2013Independent Walking
ADL/IADL: BathingMarch 11,2013Independent
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - IMMUNIZATIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VaccineDateStatusSeries number
- Influenza, seasonal, IM Nov 1999CompletedN/A
- Influenza, seasonal, IM Dec 1998CompletedN/A
- Pneumococcal polysaccharide vaccine, IM Dec 1998CompletedN/A
- Tetanus and diphtheria toxoids, IM 1997RefusedN/A
Hepatitis BAug 1, 2013Completed3rd
-
- - - - - - - Influenza, seasonal, IM - - - - - - - - - - - - 1 - - - Health LS - Immuno Inc. - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - Possible flu-like symptoms for three days. - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - Health LS - Immuno Inc. - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - Possible flu-like symptoms for three days. - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - Health LS - Immuno Inc. - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - Health LS - Immuno Inc. - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - MEDICAL EQUIPMENT - - Medical Equipment - - Implanted Devices: Cardiac PaceMaker July 3, 2013 - Implanted Devices: Upper GI Prosthesis, January 3, 2013 - Cane, February 2, 2003 - - Biliary Stent, May 5, 2013 - - - - - - - - Implants - - - - - - - - - - - - - - - - - - - - - - - - - Cardiac Pacemaker - - - - - Good Health Durable Medical Equipment - - - - - - - - - - - - - - - - - - - - - - - - Upper GI Prosthesis - - - - - Good Health Durable Medical Equipment - - - - - - - - - - - - - - - - - - - - - - - - - - Upper GI Prosthesis - - - - - Good Health Durable Medical Equipment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1004 Health Care Drive - Ann Arbor - MI - 02368 - US - - - - - Community Health and Hospitals - - - 1003 Health Care Drive - Ann Arbor - MI - 02368 - US - - - - - - -
-
- - -
- - - - - MEDICATIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MedicationDirectionsStart DateStatusIndicationsFill Instructions
Proventil 0.09 MG/ACTUAT inhalant solution2 puffs q6 hours PRN wheezingJan 3, 2011ActiveAsthmaGeneric Substitition Allowed
Atenolol 25 MG Oral Tablet1 every 12 hours OrallyMar 18, 2012ActiveHypertension-none-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Medication Factory Inc. - - - - - - - - - - - Community Health and Hospitals - - - - - - - - - - - - - Aerosol - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Medication Factory Inc. - - - - - - - - - - - - - label in spanish - - - - - - - - - - - - - - - - - - - - - - - - - - Medication Factory Inc. - - - - - - - - 1016 Health Drive - Portland - OR - 99123 - US - - - - - Susan - Script - Pharm.D. - - - - People's Pharmacy - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - INSURANCE PROVIDERS - - - - - - - - - - - - - - - - - - - - -
Payer namePolicy type / Coverage typePolicy IDCovered party IDPolicy Holder
Good Health InsuranceExtended healthcare / FamilyContract Number1138345Patient's Mother
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9009 Health Drive - Portland - OR - 99123 - US - - - - Good Health Insurance - - - 9009 Health Drive - Portland - OR - 99123 - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - - - - - Boris - Betterhalf - - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - - - - - Boris - Betterhalf - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - TREATMENT PLAN - - Hand-off Communication: - Nurse Florence, RN to MD to Nancy Nightingale, RN -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Planned CareStart DatePatient Provider RatingProvider Provider RatingProviderPatient Support/Caregiver
Procedure: ColonoscopyJune 15, 20131st, Medium3rd, Medium - Caregiver: Mother
Medication: Heparin 0.25 ml pre-filled syringeJuly 12, 2013 - First, MediumThird, MediumCaregiver: Mother
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - PROBLEMS - - Active Concerns - - Problem #1 - Pneumonia (onset July 3, 2013; resolution Aug 14, 2013) [authored Aug 14, 2013] - - - Problem #2 - Chest pain (onset Apr 14, 2007) [authored Apr 14, 2007] - Angina (onset Apr 17, 2007) [authored Apr 17, 2007] - - - - Resolved Concerns - - Problem #3 - Pneumonia - Left lower lobe (onset Mar 10, 1998; resolution Mar 16, 1998) [authored Mar 16, - 1998] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - PROCEDURES - - - - - - - - - - - - - - -
ProcedureDate
Colonic polypectomy1998
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - Community Health and Hospitals - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - Community Health and Hospitals - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - - - - - - - 1009 Health Drive - Portland - OR - 99123 - US - - - - Community Gastroenterology Clinic - - - - - - - - - - - - - - - - - - - - - - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - Community Health and Hospitals - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - - - - - - - 1009 Health Drive - Portland - OR - 99123 - US - - - - Community Gastroenterology Clinic - - - - - -
-
- - -
- - - - - RESULTS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Result TypeResult ValueRelevant Reference RangeInterpretationDate
Hemoglobin13.2 g/dLNormal range for women is 12.0 to 15.5 grams per deciliterNormal03/19/2008
Leukocytes6.7 10*9/LNormal white blood cell count range 3.5-10.5 billion cells/LNormal03/19/2008
Platelets123 10*9/LNormal white blood cell count range 3.5-10.5 billion cells/LLow03/19/2008
Hematocrit35.3 %Normal hematocrit range for female: 34.9-44.5 percentNormal03/19/2008
Erythrocytes4.21 10*12/LNormal red blood cell count range 3.90-5.03 trillion cells/LNormal03/19/2008
Urea nitrogen, SerumPendingPendingPendingMarch 20, 2008
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6.7 billion per liter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - SOCIAL HISTORY - - - - - - - - - - - - - - - - - - - - - - - - - - -
Social History ObservationDescriptionDates Observed
Current Smoking StatusFormer smokerSeptember 10, 2012
Tobacco UseModerate cigarette smoker, 10-19/dayFebruary, 2009 - February, 2011
Alcoholic drinks per day12Since February, 2012
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - VITAL SIGNS - - - - - - - - - - - - - - - - - - - - - - - - - - -
Date / Time: Sept 10, 2012Sept 1, 2011
Height177 cm177 cm
Weight86 kg88 kg
Blood Pressure132/88128/80
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
diff --git a/src/test/resources/C-CDA_R2-1_CCD2.xml b/src/test/resources/C-CDA_R2-1_CCD2.xml deleted file mode 100644 index 872a39f14..000000000 --- a/src/test/resources/C-CDA_R2-1_CCD2.xml +++ /dev/null @@ -1,3495 +0,0 @@ - - - - - - - - - - - - - - Patient Chart Summary - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - US - - - - - - - Eve - - Betterhalf - - - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - US - - - - - Boris - Bo - Betterhalf - - - - - - - 4444 Home Street - Beaverton - OR - 97867 - US - - - - - - - - - - - - - - - The DoctorsTogether Physician Group - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - - 1007 Healthcare Drive - Portland - OR - 99123 - US - - - - - Ellen - Enter - - - - - - - - - - 1007 Healthcare Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - M.D. - - - - The DoctorsApart Physician Group - - - - - - - - 1025 Health Drive - Portland - OR - 99123 - US - - - - - Ramsey - Reaction - M.D. - - - - The DoctorsApart Physician Group - - - - - - - - 1017 Health Drive - Portland - OR - 99123 - US - - - - - William - Bill - Beaker - - - - Good Health Laboratory - - - - - - - - 1016 Health Drive - Portland - OR - 99123 - US - - - - - Susan - Script - Pharm.D. - - - - People's Pharmacy - - - - - - - - 1027 Health Drive - Portland - OR - 99123 - US - - - - - Patrick - Pump - M.D. - - - - The DoctorsApart Physician Group - - - - - - - - - - Boris - Bo - Betterhalf - - - - - - - - - - Good Health HIE - - - 1009 Healthcare Drive - Portland - OR - 99123 - US - - - - - - - - - - Sara - Specialize - M.D. - - - - The DoctorsApart Physician Group - - - - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - US - - - - - Boris - Bo - Betterhalf - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - US - - - - - Boris - Bo - Betterhalf - - - - - - - - - - - - - - - - Primary Care Provider - - - - - - 1004 Healthcare Drive - Portland - OR - 99123 - US - - - - - Patricia - Patty - Primary - M.D. - - - - - The DoctorsTogether Physician Group - - - 1004 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - -
- - - - - ADVANCE DIRECTIVES - - - - - - - - - - - - - - - - - - -
DirectiveDescriptionVerificationSupporting Document(s)
Resuscitation statusDo not resuscitateDr. Patricia Primary, Feb 19, 2011 - Advance directive -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1004 Health Drive - Portland - OR - 99123 - US - - - - - Dr. - Patricia - Primary - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - ALLERGIES AND ADVERSE REACTIONS - - - - - - - - - - - - - - - - - - -
SubstanceReaction
PenicillinNausea
CodeineWheezing
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - ENCOUNTERS - - - - - - - - - - - - - - - - - - -
EncounterPerformerLocationDate
Checkup Examination Performer NameCommunity Urgent Care CenterSeptember 27, 2012 at 1:00pm
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - Good Health Urgent Care - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - FAMILY HISTORY - - Father (deceased) - - - - - - - - - - - - - - - - - -
DiagnosisAge At Onset
Myocardial Infarction (cause of death)57
Diabetes40
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- - - - FUNCTIONAL STATUS - - - - - - - - - - - - - - - - - - - - - -
Functional CategoryEffective DatesResults of Evaluation
Functional AssessmentMarch 11, 2013Independent Walking
ADL/IADL: BathingMarch 11,2013Independent
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - IMMUNIZATIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VaccineDateStatusSeries number
- Influenza, seasonal, IM Nov 1999CompletedN/A
- Influenza, seasonal, IM Dec 1998CompletedN/A
- Pneumococcal polysaccharide vaccine, IM Dec 1998CompletedN/A
- Tetanus and diphtheria toxoids, IM 1997RefusedN/A
Hepatitis BAug 1, 2013Completed3rd
-
- - - - - - - Influenza, seasonal, IM - - - - - - - - - - - - 1 - - - Health LS - Immuno Inc. - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - Possible flu-like symptoms for three days. - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - Health LS - Immuno Inc. - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - Possible flu-like symptoms for three days. - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - Health LS - Immuno Inc. - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - Health LS - Immuno Inc. - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - Harold - Hippocrates - - - - - Good Health Clinic - - - 1007 Health Drive - Portland - OR - 99123 - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - MEDICAL EQUIPMENT - - Medical Equipment - - Implanted Devices: Cardiac PaceMaker July 3, 2013 - Implanted Devices: Upper GI Prosthesis, January 3, 2013 - Cane, February 2, 2003 - - Biliary Stent, May 5, 2013 - - - - - - - - Implants - - - - - - - - - - - - - - - - - - - - - - - - - Cardiac Pacemaker - - - - - Good Health Durable Medical Equipment - - - - - - - - - - - - - - - - - - - - - - - - Upper GI Prosthesis - - - - - Good Health Durable Medical Equipment - - - - - - - - - - - - - - - - - - - - - - - - - - Upper GI Prosthesis - - - - - Good Health Durable Medical Equipment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1004 Health Care Drive - Ann Arbor - MI - 02368 - US - - - - - Community Health and Hospitals - - - 1003 Health Care Drive - Ann Arbor - MI - 02368 - US - - - - - - -
-
- - -
- - - - - MEDICATIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MedicationDirectionsStart DateStatusIndicationsFill Instructions
Proventil 0.09 MG/ACTUAT inhalant solution2 puffs q6 hours PRN wheezingJan 3, 2011ActiveAsthmaGeneric Substitition Allowed
Atenolol 25 MG Oral Tablet1 every 12 hours OrallyMar 18, 2012ActiveHypertension-none-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Medication Factory Inc. - - - - - - - - - - - Community Health and Hospitals - - - - - - - - - - - - - Aerosol - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Medication Factory Inc. - - - - - - - - - - - - - label in spanish - - - - - - - - - - - - - - - - - - - - - - - - - - Medication Factory Inc. - - - - - - - - 1016 Health Drive - Portland - OR - 99123 - US - - - - - Susan - Script - Pharm.D. - - - - People's Pharmacy - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - INSURANCE PROVIDERS - - - - - - - - - - - - - - - - - - - - -
Payer namePolicy type / Coverage typePolicy IDCovered party IDPolicy Holder
Good Health InsuranceExtended healthcare / FamilyContract Number1138345Patient's Mother
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9009 Health Drive - Portland - OR - 99123 - US - - - - Good Health Insurance - - - 9009 Health Drive - Portland - OR - 99123 - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - - - - - Boris - Betterhalf - - - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - - - - - Boris - Betterhalf - - - - - - - - - - - - 2222 Home Street - Beaverton - OR - 97867 - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - TREATMENT PLAN - - Hand-off Communication: - Nurse Florence, RN to MD to Nancy Nightingale, RN -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Planned CareStart DatePatient Provider RatingProvider Provider RatingProviderPatient Support/Caregiver
Procedure: ColonoscopyJune 15, 20131st, Medium3rd, Medium - Caregiver: Mother
Medication: Heparin 0.25 ml pre-filled syringeJuly 12, 2013 - First, MediumThird, MediumCaregiver: Mother
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - PROBLEMS - - Active Concerns - - Problem #1 - Pneumonia (onset July 3, 2013; resolution Aug 14, 2013) [authored Aug 14, 2013] - - - Problem #2 - Chest pain (onset Apr 14, 2007) [authored Apr 14, 2007] - Angina (onset Apr 17, 2007) [authored Apr 17, 2007] - - - - Resolved Concerns - - Problem #3 - Pneumonia - Left lower lobe (onset Mar 10, 1998; resolution Mar 16, 1998) [authored Mar 16, - 1998] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - PROCEDURES - - - - - - - - - - - - - - -
ProcedureDate
Colonic polypectomy1998
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - Community Health and Hospitals - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - Community Health and Hospitals - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - - - - - - - 1009 Health Drive - Portland - OR - 99123 - US - - - - Community Gastroenterology Clinic - - - - - - - - - - - - - - - - - - - - - - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - Community Health and Hospitals - - - 1001 Village Avenue - Portland - OR - 99123 - US - - - - - - - - - - - 1009 Health Drive - Portland - OR - 99123 - US - - - - Community Gastroenterology Clinic - - - - - -
-
- - -
- - - - - RESULTS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Result TypeResult ValueRelevant Reference RangeInterpretationDate
Hemoglobin13.2 g/dLNormal range for women is 12.0 to 15.5 grams per deciliterNormal03/19/2008
Leukocytes6.7 10*9/LNormal white blood cell count range 3.5-10.5 billion cells/LNormal03/19/2008
Platelets123 10*9/LNormal white blood cell count range 3.5-10.5 billion cells/LLow03/19/2008
Hematocrit35.3 %Normal hematocrit range for female: 34.9-44.5 percentNormal03/19/2008
Erythrocytes4.21 10*12/LNormal red blood cell count range 3.90-5.03 trillion cells/LNormal03/19/2008
Urea nitrogen, SerumPendingPendingPendingMarch 20, 2008
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6.7 billion per liter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - SOCIAL HISTORY - - - - - - - - - - - - - - - - - - - - - - - - - - -
Social History ObservationDescriptionDates Observed
Current Smoking StatusFormer smokerSeptember 10, 2012
Tobacco UseModerate cigarette smoker, 10-19/dayFebruary, 2009 - February, 2011
Alcoholic drinks per day12Since February, 2012
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - - - VITAL SIGNS - - - - - - - - - - - - - - - - - - - - - - - - - - -
Date / Time: Sept 10, 2012Sept 1, 2011
Height177 cm177 cm
Weight86 kg88 kg
Blood Pressure132/88128/80
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
diff --git a/src/test/resources/SampleCDADocument.xml b/src/test/resources/SampleCDADocument.xml deleted file mode 100644 index 94591988a..000000000 --- a/src/test/resources/SampleCDADocument.xml +++ /dev/null @@ -1,1098 +0,0 @@ - - - - - - - - - - Good Health Clinic Consultation Note - - - - - - - - - - - Henry - Levin - the 7th - - - - - - - - - - - - - - - - Good Health Clinic - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - History of Present Illness - - Henry Levin, the 7th - is a 67 year old male referred for further asthma management. Onset of asthma in his twenties - teens. He was hospitalized twice last year, and already twice this year. He has not been able to be weaned off steroids for the past several months. - -
-
- - -
- - Past Medical History - - - - Asthma - - - Hypertension (see HTN.cda for details) - - - Osteoarthritis, - right knee - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - Medications - - - Theodur 200mg BID - Proventil inhaler 2puffs QID PRN - Prednisone 20mg qd - HCTZ 25mg qd - - - - - Theodur 200mg BID - - - - - - - - - - - - - - - - - Proventil inhaler 2puffs QID PRN - - - - - - - - - - - - - - - - - - - Prednisone 20mg qd - - - - - - - - - - - - - - - - - HCTZ 25mg qd - - - - - - - - - - - - - -
-
- - -
- - Allergies and Adverse Reactions - - - Penicillin - Hives - Aspirin - Wheezing - Codeine - Itching and nausea - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - Family history - - - Father had fatal MI in his early 50's. - No cancer or diabetes. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - Social History - - - Smoking :: 1 PPD between the ages of 20 and 55, and then he quit. - Alcohol :: rare - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - Physical Examination - - -
- - Vital Signs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Date / TimeApril 7, 2000 14:30April 7, 2000 15:30
Height177 cm (69.7 in)
Weight194.0 lbs (88.0 kg)
BMI28.1 kg/m2
BSA2.05 m2
Temperature36.9 C (98.5 F)36.9 C (98.5 F)
Pulse86 / minute84 / minute
RhythmRegularRegular
Respirations16 / minute, unlabored14 / minute
Systolic132 mmHg135 mmHg
Diastolic86 mmHg88 mmHg
Position / CuffLeft ArmLeft Arm
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - Skin Exam - Erythematous rash, palmar surface, left index finger. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - Lungs - Clear with no wheeze. Good air flow. - - - - - - - - - - - - - - -
-
- - -
- - Cardiac - RRR with no murmur, no S3, no S4. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
- - -
- - Labs - - - CXR 02/03/1999: Hyperinflated. Normal cardiac silhouette, clear lungs. - Peak Flow today: 260 l/m - - - - - - - - - - - - - - - - - normal cardiac silhouette - - - - - - - - radiopacities - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - In-office Procedures - - - Suture removal, left forearm. - - - - - - - - - - -
-
- - -
- - Assessment - - - Asthma, with prior smoking history. Difficulty weaning off steroids. Will try gradual taper. - Hypertension, well-controlled. - Contact dermatitis on finger. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - -
- - - Plan - - - Complete PFTs with lung volumes. - Chem-7 tomorrow. - Teach peak flow rate measurement. - Decrease prednisone to 20qOD alternating with 18qOD. - Hydrocortisone cream to finger BID. - RTC 1 week. - - - - - - - Complete PFTs with lung volumes. - - - - - - - - - - - Chem-7 - - - Chem-7 tomorrow - - - - - - - - - - - - - - - - - prednisone 20qOD alternating with 18qOD. - - - - - - - - - - - - - Hydrocortisone cream to finger BID. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
diff --git a/src/test/resources/Vitera_CCDA_SMART_Sample.xml b/src/test/resources/Vitera_CCDA_SMART_Sample.xml deleted file mode 100644 index edaa570c5..000000000 --- a/src/test/resources/Vitera_CCDA_SMART_Sample.xml +++ /dev/null @@ -1,16727 +0,0 @@ - - - - - - - - - - Full Chart - Madison Medical Center P. A. - - - - - - - - - 3456 West Palm - Apt. #34 - Madison - CA - US - 95653 - - - - - - - Sharon - A - Carlson - - - - - - - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - Madison Medical Center P. A. - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Sharon A. Carlson - - - - - - - - - - - - - - - - - - - - - - Wendy - M - Perez - PA - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - Gary - Madder - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - 8620 Palmetto Drive - Madison - CA - US - 95653 - - - - - Depak - E - Shah - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - -
- - - - Problems - - - - - - - - - - - - - - - - - - - - - - -
All VisitsEffective Date(s)ProviderCondition Status
COMN MIGRNE WO NTRC MGRN12/02/2002David E Ford MDActive
- Note: Unchanged - Negative MRI of skull on 2/10/2003
-
- - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - Plan of Care - - - - - - - - - - - - - - - - - - - - -
Pending TestsOrderDiagnosisResults DueOrdering Provider
LabMetabolic Panel - 01/03/08James T Monroe MD
- - - - - - - - - - - - - - - - - - - -
Future TestsOrderDiagnosisResults DueOrdering Provider
Radiology - CT ScansCT SCAN HEADCOMN MIGRNE WO NTRC MGRN01/22/08Depak E Shah MD
-
- - - - - - - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - 8620 Palmetto Drive - Madison - CA - US - 95653 - - - - - Depak - E - Shah - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - Instructions - - No Instructions Recorded - -
-
- -
- - - - Medications - - - - - - - - - - - - -
Current Medications (continue as prescribed) - -
-
- - - - - - - - - - - - - - - - - - - - -
12 Hour Decongestant 120 MG CP1202/23/2010Diagnosis:Migraine Headache, Unspecified
- - -
- -
- - - - - - - - - - - -
Past Medications on file - -
-
- - - - - - - - - - - - - - - - - - - - -
2nd Skin Blister Kit MISC01/13/2012Diagnosis:Migraine Headache, Unspecified
- - -
- -
- - - - - - - - - - - - - - - - - - - - -
12 Hour Nasal Relief Spray 0.05 % SOLN01/13/2012Diagnosis: -
- - -
- -
- - - - - - - - - - - - - - - - - - - - -
Prasad Schedule 4 Drug TBDR02/16/2010Diagnosis: -
- - -
2 twice a day , Test case 1 directions go here. All information existing. -
- - - - - - - - - - - - - - - - - - - - -
5-Hydroxy-L-Tryptophan POWD11/02/2009Diagnosis:Migraine Headache, Unspecified
- - -
- -
- - - - - - - - - - - - - - - - - - - - -
Ginko Biloba 1 Gram CPSP01/08/2008Diagnosis:Migraine Headache, Unspecified
- - -
Take one capsule with tea twice a day by mouth. -
- - - - - - - - - - - - - - - - - - - - -
Promethazine HCl 25 MG TABS01/08/2008Diagnosis:NAUSEA ALONE
- - -
Take one tablet by mouth every four to six hours as needed. -
- - - - - - - - - - - - - - - - - - - - -
Naproxen Sodium 550 MG TABS01/08/2008Diagnosis:COMN MIGRNE WO NTRC MGRN
- - -
Take one tablet by mouth every six hours as needed. -
- - - - - - - - - - - - - - - - - - - - -
Imitrex 25 MG TABS01/03/2008 - 01/08/2008Diagnosis:Migraine Headache, Unspecified
- - -
Take 1 tablet by mouth at onset of symptoms. Do not exceed 2 tablets daily. -
- - - - - - - - - - - - - - - - - - - - -
Valium 5 MG TABS11/02/2007 - 02/01/2007Diagnosis:Migraine Headache, Unspecified
- - -
Take 1 tablet at bedtime. -
- - - - - - - - - - - - - - - - - - - - -
Imitrex 25 MG TABS11/02/2007Diagnosis:Migraine Headache, Unspecified
- - -
Take 1 tablet as needed fror migraine headache. -
- - - - - - - - - - - - - - - - - - - - -
Imitrex 25 MG TABS10/05/2007 - 11/02/2007Diagnosis:Migraine Headache, Unspecified
- - -
Take 1 tablet as directed at onset of headache. -
- - - - - - - - - - - - - - - - - - - - -
Stress Formula Plus Iron TABS10/05/2007Diagnosis:Migraine Headache, Unspecified
- - -
Take 1 tablet once a day by mouth. -
- - - - - - - - - - - - - - - - - - - - -
Imitrex 25 MG TABS09/03/2007 - 10/05/2007Diagnosis:Migraine Headache, Unspecified
- - -
Take 1 tablet as directed at onset of headache. -
- - - - - - - - - - - - - - - - - - - - -
Fiorinal/Codeine #3 50-325-40-30 MG CAPS09/03/2007 - 10/05/2007Diagnosis:Migraine Headache, Unspecified
- - -
1-2 tabs every 6 hours for pain, not to exceed 6 tablets a day -
- - - - - - - - - - - - - - - - - - - - -
Valium 5 MG TABS02/01/2007 - 01/08/2008Diagnosis:Migraine Headache, Unspecified
- - -
Take 1 tablet at bedtime. -
-
- - - - - 2 Puffs q6hrs prn - - - - - - - - - - - - - - - - 12 Hour Decongestant - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 12 Hour Decongestant - - - - - - - - - - - - - - - - - - - - - - - 12 Hour Decongestant - - - - - - - - 3469 Altamonte Springs Terrace - Madison - CA - US - 245 - - - - - - - - Altamonte Medical Center Pharmacy - - - 3469 Altamonte Springs Terrace - Madison - CA - US - 245 - - - - - - - - - - - - - - - - - - - - - 4 once a day - - - - - - - - - - - - - - - - 2nd Skin Blister Kit - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2nd Skin Blister Kit - - - - - - - - - - - - - - - - - - - - - - - 2nd Skin Blister Kit - - - - - - - - 123 Test Street - Twinsburg - OH - 44087 - - - - - - - - SelfTest NEWRX in REFREQ out - - - 123 Test Street - Twinsburg - OH - 44087 - - - - - - - - - - - - - - - - - - - - - 3 three times a day - - - - - - - - - - - - - - - - 12 Hour Nasal Relief Spray - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 12 Hour Nasal Relief Spray - - - - - - - - - - - - - - - - - - - - - - - 12 Hour Nasal Relief Spray - - - - - - - - 123 Test Street - Twinsburg - OH - 44087 - - - - - - - - SelfTest NEWRX in REFREQ out - - - 123 Test Street - Twinsburg - OH - 44087 - - - - - - - - - - - - - - - - - - - - - 2 twice a day - - - - - - - - - - - - - - - - Prasad Schedule 4 Drug - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - 2 twice a day , Test case 1 directions go here. All information existing. - - - - - - - - - - - - - - - - - - - - - - - - Prasad Schedule 4 Drug - - - - - - - - - - - - - - - - - - - - - - - Prasad Schedule 4 Drug - - - - - - - - 1191 Main Street - Madison - CA - US - 95654 - - - - - - - - Sunshine Drugs - - - 1191 Main Street - Madison - CA - US - 95654 - - - - - - - - - - - - - - - - - - - - - twice a day - - - - - - - - - - - - - - - - 5-Hydroxy-L-Tryptophan - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5-Hydroxy-L-Tryptophan - - - - - - - - - - - - - - - - - - - - - - twice a day - - - - - - - - - - - - - - - - Ginko Biloba - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take one capsule with tea twice a day by mouth. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ginko Biloba - - - - - - - - - - - - - - - - - - - - - - - Ginko Biloba - - - - - - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - Evan's Discount Drugs - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - - - - - - - - - - - - - - 1 every 4 to 6 hours - - - - - - - - - - - - - - - - Promethazine HCl - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take one tablet by mouth every four to six hours as needed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Promethazine HCl - - - - - - - - - - - - - - - - - - - - - - - Promethazine HCl - - - - - - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - Evan's Discount Drugs - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - - - - - - - - - - - - - - 1 every 6 hours - - - - - - - - - - - - - - - - Naproxen Sodium - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take one tablet by mouth every six hours as needed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Naproxen Sodium - - - - - - - - - - - - - - - - - - - - - - - Naproxen Sodium - - - - - - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - Evan's Discount Drugs - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - - - - - - - - - - - - - - as needed - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take 1 tablet by mouth at onset of symptoms. Do not exceed 2 tablets daily. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - Evan's Discount Drugs - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - - - - - - - - - - - - - - 1 every evening - - - - - - - - - - - - - - - - - Valium - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take 1 tablet at bedtime. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Valium - - - - - - - - - - - - - - - - - - - - - - - - Valium - - - - - - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - Evan's Discount Drugs - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - - - - - - - - - - - - - - as needed - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take 1 tablet as needed fror migraine headache. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - Evan's Discount Drugs - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - - - - - - - - - - - - - - as needed - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take 1 tablet as directed at onset of headache. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - Evan's Discount Drugs - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - - - - - - - - - - - - - - once a day - - - - - - - - - - - - - - - - Stress Formula Plus Iron - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take 1 tablet once a day by mouth. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Stress Formula Plus Iron - - - - - - - - - - - - - - - - - - - - - - as needed - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take 1 tablet as directed at onset of headache. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Imitrex - - - - - - - - - - - - - - - - - - - - - - as needed - - - - - - - - - - - - - - - - - Fiorinal with Codeine - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - 1-2 tabs every 6 hours for pain, not to exceed 6 tablets a day - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Fiorinal with Codeine - - - - - - - - - - - - - - - - - - - - - - - - Fiorinal with Codeine - - - - - - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - Evan's Discount Drugs - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - - - - - - - - - - - - - - 1 every evening - - - - - - - - - - - - - - - - - Valium - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - Take 1 tablet at bedtime. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Valium - - - - - - - - - - - - - - - - - - - - - - - - Valium - - - - - - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - Evan's Discount Drugs - - - 3170 NW Virginia Place - Madison - CA - US - 95655 - - - - - - - - - - - - - - - - -
-
- -
- - - - Medications Administered - - No Administered Medications Recorded - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - Vital Signs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Vital Name11/02/2007 10:07A10/05/2007 10:06A09/03/2007 10:05A
Systolic BP-Sitting (mmHg)133131130
Diastolic BP-Sitting (mmHg)767576
Pulse Rate (bpm)868282
Respiration Rate (breaths/min)293030
Temp-Oral (F)98.698.698.6
Height (in)666666
Weight (lb)160160166
Body Mass Index (kg/m2)25.825.826.8
Body Surface Area (m2)1.821.821.85
-
- - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - -
-
- -
- - - - Lab Results - - - - - - - - - - - - - - - - - - -
CBC w/ Differential & PlateletLabCorp Madison
Ordered by David E Ford MD on 01/03/2008Collected: 01/03/2008 Reported: 01/03/2008
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
White Blood Cell (WBC) Count - 6.8 - THOUS/MCL(3.8-10.8) - N (Normal) - -
Red Blood Cell (RBC) Count - 4.50 - MILL/MCL(3.80-5.10) - N (Normal) - -
Hemoglobin - 13.7 - G/DL(11.7-15.5) - N (Normal) - -
Hematocrit - 41.0 - %(35.0-45.0) - N (Normal) - -
MCV - 80.0 - FL(.0-100.0) - N (Normal) - -
MCH - 30.0 - PG(27.0-33.0) - N (Normal) - -
MCHC - 35.5 - G/DL(32.0-36.0) - N (Normal) - -
Polys - 52.0 - % - - N (Normal) - -
Lymphs - 32.6 - % - - N (Normal) - -
Monocytes - 8.3 - % - - N (Normal) - -
Eos - 6.2 - % - - N (Normal) - -
Basos - 0.9 - % - - N (Normal) - -
Platelets - 349 - THOUS/MCL(140-400) - N (Normal) - -
Polys (Absolute) - 2852 - CELLS/MCL(1500-7800) - N (Normal) - -
Lymphs (Absolute) - 1901 - CELLS/MCL(850-3900) - N (Normal) - -
Monocytes(Absolute) - 601 - CELLS/MCL(200-950) - N (Normal) - -
Eos (Absolute Value) - 420 - CELLS/MCL(15-500) - N (Normal) - -
Baso(Absolute) - 45 - CELLS/MCL(0-200) - N (Normal) - -
RDW - 12.5 - %(11.0-15.0) - N (Normal) - -
Reviewed by David E Ford MD on 01/08/2008; All test results are final unless otherwise noted.
- - - - - - - - - - - - - - - - - - - -
CBC WITH DIFFERENTIAL/PLATELETLabCorp Madison
Ordered by David E Ford MD on 11/02/2007Collected: 11/02/2007 Reported: 11/05/2007
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
White Blood Cell (WBC) Count - 5.3 - X_10-3/uL(4.0-10.5) - None - -
Red Blood Cell (RBC) Count - 3.86 - X_10-6/uL(3.80-5.10) - None - -
Hemoglobin - 11.5 - g/dL(11.5-15.0) - N (Normal) - -
Hematocrit - 34.2 - %(34.0-44.0) - N (Normal) - -
MCV - 86 - fL(80-98) - None - -
MCH - 28.6 - pg(27.0-34.0) - None - -
MCHC - 33.2 - g/dL(32.0-36.0) - None - -
Polys - 57 - %(40-74) - None - -
Lymphs - 29 - %(14-46) - None - -
Monocytes - 11 - %(4-13) - None - -
Eos - 3 - %(0-7) - None - -
Basos - 0 - %(0-3) - None - -
Platelets - 258 - X_10-3/uL(140-415) - None - -
Hematology Comments: - - - - - - None - Status: Cannot be done
Polys (Absolute) - 3.0 - X_10-3/uL(1.8-7.8) - None - -
Lymphs (Absolute) - 1.5 - X_10-3/uL(0.7-4.5) - None - -
Monocytes(Absolute) - 0.6 - X_10-3/uL(0.1-1.0) - None - -
Eos (Absolute Value) - 0.2 - X_10-3/uL(0.0-0.4) - None - -
Baso(Absolute) - 0.0 - X_10-3/uL(0.0-0.2) - None - -
RDW - 14.8 - %(11.7-15.0) - N (Normal) - -
Reviewed by David E Ford MD on 11/05/2007; All test results are final unless otherwise noted.
- - - - - - - - - - - - - - - - - - - -
HFP7+3ACLabCorp Madison
Ordered by David E Ford MD on 11/02/2007Collected: 11/02/2007 Reported: 11/05/2007
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cholesterol, Total - 220 - mg/dL(100-199) - H (High) - -
Note: Performed At: MA -LABCORP MADISON -1447 YORK COURT -MADISON, CA 956530000 -
Protein, Total, Serum - 6.3 - g/dL(6.0-8.5) - N (Normal) - -
Albumin, Serum - 3.7 - g/dL(3.6-4.8) - None - -
Bilirubin, Total - 0.8 - mg/dL(0.1-1.2) - None - -
Alkaline Phosphatase, Serum - 142 - IU/L(25-165) - None - -
LDH - 108 - IU/L(100-250) - None - -
AST (SGOT) - 27 - IU/L(0-40) - None - -
Bilirubin, Direct - 0.31 - mg/dL(0.00-0.40) - None - -
ALT (SGPT) - 23 - IU/L(0-40) - None - -
GGT - 36 - IU/L(0-60) - None - -
Reviewed by David E Ford MD on 11/05/2007; All test results are final unless otherwise noted.
- - - - - - - - - - - - - - - - - - - -
THYROID PANEL WITH TSHLabCorp Madison
Ordered by David E Ford MD on 10/05/2007Collected: 10/05/2007 Reported: 10/08/2007
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Thyroxine (T4) - 5.1 - mcg/dL(4.5-12.0) - N (Normal) - -
Note: ***EFFECTIVE NOVEMBER 26, 2001 The reference interval*** - will be changing to: - Male Female - Cord Blood 6.6-17.5 6.6-17.5 - 1- 3 Days 11.0-21.5 11.0-21.5 - 1- 4 Weeks 8.2-16.6 8.2-16.6 - 1- 11 Months 6.4-13.9 4.9-13.7 - 1- 3 Years 7.0-13.1 7.1-14.1 - 4- 6 Years 6.1-12.6 7.2-14.0 - 7- 12 Years 6.7-13.4 6.1-12.1 - 13-15 Years 4.8-11.5 5.8-11.2 - Adult 4.5-12.0 4.5-12.0 - . -
T3 Uptake - 31 - %(24-39) - N (Normal) - -
Free Thyroxine Index - 3.2 - - (1.2-4.9) - N (Normal) - -
TSH, High Sensitivity, Serum - 4.21 - mcIU/mL(0.35-5.50) - N (Normal) - -
Note: **Please Note Reference Interval Change** - . -
Reviewed by David E Ford MD on 10/08/2007; All test results are final unless otherwise noted.
- - - - - - - - - - - - - - - - - - - -
Cl+K+NaLabCorp Madison
Ordered by David E Ford MD on 10/05/2007Collected: 10/05/2007 Reported: 10/08/2007
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Potassium, Serum - 4.1 - mmol/L(3.5-5.5) - N (Normal) - -
Sodium, Serum - 139 - mmol/L(135-148) - N (Normal) - -
Chloride, Serum - 101 - mmol/L(96-109) - N (Normal) - -
Reviewed by David E Ford MD on 10/08/2007; All test results are final unless otherwise noted.
- - - - - - - - - - - - - - - - - - - -
RPRLabCorp Madison
Ordered by David E Ford MD on 10/05/2007Collected: 10/05/2007 Reported: 10/08/2007
-
- - - - - - - - - - - - - - - - - - - - - - - -
RPR - Non-Reactive - - (Non-Reactive) - N (Normal) - -
Note: Performed At: MA -LABCORP MADISON -1447 YORK COURT -MADISON, CA 956530000 -
Reviewed by David E Ford MD on 10/08/2007; All test results are final unless otherwise noted.
- - - - - - - - - - - - - - - - - - - -
CBC w/ Differential & PlateletLabCorp Madison
Ordered by David E Ford MD on 09/03/2007Collected: 09/03/2007 Reported: 09/03/2007
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
White Blood Cell (WBC) Count - 5.8 - THOUS/MCL(3.8-10.8) - N (Normal) - -
Red Blood Cell (RBC) Count - 4.20 - MILL/MCL(3.80-5.10) - N (Normal) - -
Hemoglobin - 11.7 - G/DL(11.7-15.5) - N (Normal) - -
Hematocrit - 36.2 - %(35.0-45.0) - N (Normal) - -
MCV - 86.1 - FL(.0-100.0) - N (Normal) - -
MCH - 28.0 - PG(27.0-33.0) - N (Normal) - -
MCHC - 32.5 - G/DL(32.0-36.0) - N (Normal) - -
Polys - 51.1 - % - - N (Normal) - -
Lymphs - 31.8 - % - - N (Normal) - -
Monocytes - 9.1 - % - - N (Normal) - -
Eos - 7.2 - % - - N (Normal) - -
Basos - 0.8 - % - - N (Normal) - -
Platelets - 354 - THOUS/MCL(140-400) - N (Normal) - -
Polys (Absolute) - 2964 - CELLS/MCL(1500-7800) - N (Normal) - -
Lymphs (Absolute) - 1844 - CELLS/MCL(850-3900) - N (Normal) - -
Monocytes(Absolute) - 528 - CELLS/MCL(200-950) - N (Normal) - -
Eos (Absolute Value) - 418 - CELLS/MCL(15-500) - N (Normal) - -
Baso(Absolute) - 46 - CELLS/MCL(0-200) - N (Normal) - -
RDW - 13.4 - %(11.0-15.0) - N (Normal) - -
Reviewed by David E Ford MD on 01/08/2008; All test results are final unless otherwise noted.
- - - - - - - - - - - - - - - - - - - -
HematocritMadison Laboratory
Ordered by James T Monroe MD on 09/03/2007Collected: 09/03/2007 Reported: 09/03/2007
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Female - 40 - - (37-47) - N (Normal) - -
Male - 00 - - (40-54) - N (Normal) - -
Reviewed by James T Monroe MD on 09/03/2007; All test results are final unless otherwise noted.
- - - - - - - - - - - - - - - - - - - -
UrinalysisMadison Laboratory
Ordered by James T Monroe MD on 09/03/2007Collected: 09/03/2007 Reported: 09/03/2007
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Appearance - Clear - - (Clear-Mod Cloud) - N (Normal) - -
Bilirubin - Negative - - (Negative-Small) - N (Normal) - -
Blood - Negative - - (Negative) - N (Normal) - -
Color - Yellow - - (None-Yellow) - N (Normal) - -
Glucose - Negative - - (Negative-250) - N (Normal) - -
Specific Gravity - 1.005 - - (1.000-1.010) - N (Normal) - -
Ketone - Negative - - (Negative-Trace) - N (Normal) - -
Leukocytes - Negative - - (Negative-Trace) - N (Normal) - -
Nitrites - Negative - - (Negative) - N (Normal) - -
pH Level - 6.0 - - (5.0-6.5) - N (Normal) - -
Urobilinogen - Negative - - (Negative) - N (Normal) - -
Reviewed by James T Monroe MD on 09/03/2007; All test results are final unless otherwise noted.
- - -
- - - - - - - - - - - - - - Whole blood - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - - - - - 1447 York Court - Madison - CA - US - 95653 - - - - LabCorp Madison - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (3.8-10.8) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (3.80-5.10) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (11.7-15.5) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (35.0-45.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (.0-100.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (27.0-33.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (32.0-36.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (140-400) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (1500-7800) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (850-3900) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (200-950) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (15-500) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (0-200) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (11.0-15.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - - - - - 1447 York Court - Madison - CA - US - 95653 - - - - LabCorp Madison - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (4.0-10.5) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (3.80-5.10) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (11.5-15.0) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (34.0-44.0) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (80-98) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (27.0-34.0) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (32.0-36.0) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (40-74) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (14-46) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (4-13) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0-7) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0-3) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (140-415) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - N/A - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (1.8-7.8) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0.7-4.5) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0.1-1.0) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0.0-0.4) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0.0-0.2) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (11.7-15.0) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - - - - - 1447 York Court - Madison - CA - US - 95653 - - - - LabCorp Madison - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - (100-199) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (6.0-8.5) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (3.6-4.8) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0.1-1.2) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (25-165) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (100-250) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0-40) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0.00-0.40) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0-40) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (0-60) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - - - - - 1447 York Court - Madison - CA - US - 95653 - - - - LabCorp Madison - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - (4.5-12.0) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (24-39) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (1.2-4.9) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - (0.35-5.50) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - - - - - 1447 York Court - Madison - CA - US - 95653 - - - - LabCorp Madison - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (3.5-5.5) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (135-148) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - (96-109) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - - - - - 1447 York Court - Madison - CA - US - 95653 - - - - LabCorp Madison - - - - - - - - - - - - - - - - Non-Reactive - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - (Non-Reactive) - - - - - - - - - - - - - - - - - - - - - - - - - - MA - - - - - - - - - - - - - - - - - - - - - - - Whole blood - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - - - - - 1447 York Court - Madison - CA - US - 95653 - - - - LabCorp Madison - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (3.8-10.8) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (3.80-5.10) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (11.7-15.5) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (35.0-45.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (.0-100.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (27.0-33.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (32.0-36.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (140-400) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (1500-7800) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (850-3900) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (200-950) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (15-500) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (0-200) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LabCorp Madison - - - - 1447 York Court - Madison - CA - US - 95653 - - - - - - - (11.0-15.0) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Whole blood - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - Madison Laboratory - - - - - - - - - - - - - - - - - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (37-47) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (40-54) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - Madison Laboratory - - - - - - - - - - - - - - - - Clear - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (Clear-Mod Cloud) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Negative - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (Negative-Small) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Negative - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (Negative) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Yellow - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (None-Yellow) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Negative - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (Negative-250) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (1.000-1.010) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Negative - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (Negative-Trace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Negative - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (Negative-Trace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Negative - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (Negative) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (5.0-6.5) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Negative - - - - - - - - - - - - Madison Laboratory - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - - - (Negative) - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - History of Present Illness - - No History of Present Illness Recorded - -
-
- -
- - - - Social History - - - - - - - - - - - - - - - - - - - - - - - - - -
DescriptionLast Updated
Wine consumption (___ glasses/day)01/08/2008
Caffeine use01/08/2008
Tobacco use01/08/2008
Smoking Status Unknown -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - Procedures and Surgical/Medical History - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ProceduresCPT-4DiagnosisPerforming ProviderService LocationService Date
Hematocrit85014ROUTINE GENERAL MEDICAL EXAMJames T Monroe MDOffice - Madison Medical Center, P.A.09/03/2007
Urinalysis81000ROUTINE GENERAL MEDICAL EXAMJames T Monroe MDOffice - Madison Medical Center, P.A.09/03/2007
- - - - - - - - - - - - - -
Surgical HistoryLast Updated
History of prior surgery [For Hx of Tx, use H prefix]01/08/2008
- - - - - - - - - - - - - -
Medical HistoryLast Updated
Reported medical history01/08/2008
-
- - - - - - - - - - - - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - Madison Medical Center P. A. - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - 34 Sycamore Street, Suite 3 - Gainesville - FL - US - 32608 - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - Madison Medical Center P. A. - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - 34 Sycamore Street, Suite 3 - Gainesville - FL - US - 32608 - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - Family History - - - - - - - - - - - - - - - - - - -
DescriptionLast Updated
Reported family history of cancer01/08/2008
Family history [For FHx of Dx use Dx w/ F prefix]01/08/2008
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - Review of Systems - - No Review of Systems Recorded - -
-
- -
- - - - Functional and Cognitive Status - - No Functional or Cognitive Status Recorded - -
-
- -
- - - - Physical Exam - - No Physical Exam Recorded - -
-
- -
- - - - Immunizations - - - - - - - - - - - - - - - - - - - - - - - - - -
VaccineDose #DateSiteReaction(s)StatusSource -
Influenza106/28/2006Left Arm - Active (Administered)Madison Medical Center P. A. -
-
- - - - - - - - - - - - - - - - - - - - - - - - - Influenza - b714523 - - - Aventis Pasteur Inc - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EncounterDate=200606281502|CompletionStatus=CP|OPIDNumber=9990058700|OPAssigningAuth=NPI|OPFirstName=David|OPLastName=Ford|EPIDNumber=9990058700|EPAssigningAuth=NPI|EPFirstName=David|EPLastName=Ford|PatientAuthorization=U|PatientAuthorizationDate=U|ImmunizationSourceCode=00|ImmunizationSourceDesc=New immunization record - - - - - -
-
- -
- - - - Allergies - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SubstanceTypeReactionEffectiveStatus
RagweedAllergyItchy eyes and nasal congestion02/04/1970Active
LatexAllergySkin Rashes/Hives03/07/2002Active
Fiorinal/Codeine #3IntoleranceNausea/Vomiting/Diarrhea09/05/2007Active
- Note: Patient stopped taking med on day 2
CheeseAllergyNausea/Vomiting/Diarrhea03/07/2002Active
BirdsAllergySkin Rashes/Hives, Nausea/Vomiting/Diarrhea11/05/2009Active
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - Aspirin 325 MG / butalbital 50 MG / Caffeine 40 MG / Codeine 30 MG Oral Capsule - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - Encounters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EncounterProviderLocationDateDiagnosis
[Patient Encounter]David E Ford MD - 01/13/2012 -
[Patient Encounter]David E Ford MD - 03/01/2010 -
[Patient Encounter]David E Ford MD - 02/23/2010 -
[Patient Encounter]David E Ford MD - 11/02/2009 -
ConsultationDepak E Shah MDOffice - Madison Medical Center, P.A.01/08/2008 -
[Patient Encounter]David E Ford MDOffice - Madison Medical Center, P.A.01/08/2008 -
New Patient VisitGary Madder MDOffice - Madison Medical Center, P.A.01/08/2008 -
ConsultationJames T Monroe MDOffice - Madison Medical Center, P.A.01/03/2008 -
ConsultationJames T Monroe MDOffice - Madison Medical Center, P.A.01/03/2008 -
ConsultationJames T Monroe MDOffice - Madison Medical Center, P.A.11/02/2007 -
Re-CheckJames T Monroe MDOffice - Madison Medical Center, P.A.10/05/2007 -
New Patient EvaluationJames T Monroe MDOffice - Madison Medical Center, P.A.09/03/2007 -
General Check-upDavid E Ford MDOffice - Madison Medical Center, P.A.06/28/2006 -
-
- - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - - - - - - - - - 8620 Palmetto Drive - Madison - CA - US - 95653 - - - - - Depak - E - Shah - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - 34 Sycamore Street, Suite 3 - Gainesville - FL - US - 32608 - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - 34 Sycamore Street - Suite 3 - Madison - CA - US - 95653 - - - - - Gary - Madder - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - 34 Sycamore Street, Suite 3 - Gainesville - FL - US - 32608 - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - 34 Sycamore Street, Suite 3 - Gainesville - FL - US - 32608 - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - 34 Sycamore Street, Suite 3 - Gainesville - FL - US - 32608 - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - 34 Sycamore Street, Suite 3 - Gainesville - FL - US - 32608 - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - 34 Sycamore Street, Suite 3 - Gainesville - FL - US - 32608 - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - 11554 Weedside Lane - Madison - CA - US - 95653 - - - - - James - T - Monroe - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - 34 Sycamore Street, Suite 3 - Gainesville - FL - US - 32608 - - - - Office - Madison Medical Center, P.A. - - - - - - - - - - - - - - - - - - - - - - - - - 87 Bayshore Drive - Madison - CA - US - 95653 - - - - - David - E - Ford - MD - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - Office - Madison Medical Center, P.A. - - - - - -
-
- -
- - - - Insurance - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan NameMember IDGroup #SubscriberRelationshipEffective Dates
1 - Anaheim Managed Health643005639048-27-9873Sharon A CarlsonSelf10/03/2007 - 10/01/2008
2 - Medicare B - California643005639 - Sharon A CarlsonSelf10/03/2007 - 10/01/2008
-
- - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - 8147 NW 128th Place - Madison - CA - US - 95653 - - - - - - - - - - - - - - - - - - - 3456 West Palm - Apt. #34 - Madison - CA - US - 95653 - - - - - - Sharon - A - Carlson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - Madison Medical Center P. A. - - - - 99 Sycamore Street - Suite 3 - Gainesville - FL - US - 32608 - - - - - - - - - - - - - - - - - - 263 Sunnydale Way - Madison - CA - US - 95655 - - - - - - Medicare Part B of California - Northern California - - - - - - - - - - - - - 3456 West Palm - Apt. #34 - Madison - CA - US - 95653 - - - - - - Sharon - A - Carlson - - - - - - - - - - - - - - - - - - -
-
- -
- - - - Advance Directives - - No Advance Directives Recorded - -
-
-
-
-
\ No newline at end of file diff --git a/src/test/resources/docker-compose.yaml b/src/test/resources/docker-compose.yaml deleted file mode 100644 index 04edf8fa6..000000000 --- a/src/test/resources/docker-compose.yaml +++ /dev/null @@ -1,4 +0,0 @@ -hapi: - image: amidatech/hapi-fhir-jpaserver-starter:latest - ports: - - 1137:8080 diff --git a/src/test/resources/snippets/procedure_encounter.xml b/src/test/resources/snippets/procedure_encounter.xml deleted file mode 100644 index ea8a18dff..000000000 --- a/src/test/resources/snippets/procedure_encounter.xml +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - - - - Continuity of Care Document - - - - - - -
- - - - - - Encounter - - - AMIDACOMFIN 6666666666 Date(s): - 10/7/16 - 1/9/18 -
- AMIDAUH 500 HIGH STREET PITTSBURGH, DC 20005- US -
- Discharge Disposition: EXAMPLE -
- Attending Physician: JOE ATTENDING -
- Admitting Physician: JOE ADMITTING -
- Referring Physician: JOE REFERRING -
-
-
- - - - - - - Inpatient - - - - - - - - - - - - - - - DRUDE BLDG SUITE 4500 - 456 FOURTH STREET - ROCKVILLE - DC - 20005- - US - - - - - MARCUD - S - SILVERMANN - - - - - - - - - - 500 HIGH STREET - WASHINGTON - DC - 20005- - US - - - - AMIDAPUH - - - - - - - - - - - - Outpatient - - - - - - - -
-
- -
- - - - Procedures - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ProcedureDateRelated DiagnosisBody SiteStatus
- - APPENDECTOMY LAPAROSCOPIC - 1 - - 1/12/17 - - Completed
- - REMOVAL IMPLANTED DEVICES FROM BONE - 2 - - 1/12/17 - - Completed
- - REPAIR ELBOW - 3 - - 1/12/17 - - Completed
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
\ No newline at end of file diff --git a/src/test/resources/snippets/procedure_text.xml b/src/test/resources/snippets/procedure_text.xml deleted file mode 100644 index 08afd1036..000000000 --- a/src/test/resources/snippets/procedure_text.xml +++ /dev/null @@ -1 +0,0 @@ -Continuity of Care Document
Procedures
ProcedureDateRelated DiagnosisBody SiteStatus
APPENDECTOMY LAPAROSCOPIC13/26/18 Completed
REMOVAL IMPLANTED DEVICES FROM BONE23/26/18 Completed
REPAIR ELBOW33/26/18 Completed
1auto-populated from documented surgical case2auto-populated from documented surgical case3auto-populated from documented surgical case
\ No newline at end of file diff --git a/src/test/resources/value-maps/AddressType.json b/src/test/resources/value-maps/AddressType.json deleted file mode 100644 index cd59a7a0b..000000000 --- a/src/test/resources/value-maps/AddressType.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "PHYS": "physical", - "PST": "postal" -} diff --git a/src/test/resources/value-maps/AddressUse.json b/src/test/resources/value-maps/AddressUse.json deleted file mode 100644 index 14b07b829..000000000 --- a/src/test/resources/value-maps/AddressUse.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "HP": "home", - "H": "home", - "WP": "work", - "TMP": "temp", - "BAD": "old" -} diff --git a/src/test/resources/value-maps/AllergyIntoleranceCategory.json b/src/test/resources/value-maps/AllergyIntoleranceCategory.json deleted file mode 100644 index e7b58ba57..000000000 --- a/src/test/resources/value-maps/AllergyIntoleranceCategory.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "416098002": "medication", - "59037007": "medication", - "419511003": "medication", - "414285001": "food", - "235719002": "food", - "418471000": "food", - "232347008": "environment", - "420134006": "environment", - "418038007": "environment", - "419199007": "environment" -} \ No newline at end of file diff --git a/src/test/resources/value-maps/AllergyIntoleranceClinicalStatus.json b/src/test/resources/value-maps/AllergyIntoleranceClinicalStatus.json deleted file mode 100644 index e1ea284b1..000000000 --- a/src/test/resources/value-maps/AllergyIntoleranceClinicalStatus.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "55561003": "active", - "73425007": "inactive", - "413322009": "resolved" -} diff --git a/src/test/resources/value-maps/AllergyIntoleranceCriticality.json b/src/test/resources/value-maps/AllergyIntoleranceCriticality.json deleted file mode 100644 index 14393a6e4..000000000 --- a/src/test/resources/value-maps/AllergyIntoleranceCriticality.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "critl": "low", - "crith": "high", - "critu": "unable-to-assess" -} diff --git a/src/test/resources/value-maps/AllergyIntoleranceSeverity.json b/src/test/resources/value-maps/AllergyIntoleranceSeverity.json deleted file mode 100644 index cb9dd2b40..000000000 --- a/src/test/resources/value-maps/AllergyIntoleranceSeverity.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "255604002": "mild", - "371923003": "mild", - "6736007": "moderate", - "371924009": "moderate", - "24484000": "severe", - "399166001": "severe" -} diff --git a/src/test/resources/value-maps/AllergyIntoleranceType.json b/src/test/resources/value-maps/AllergyIntoleranceType.json deleted file mode 100644 index 233e0bbb9..000000000 --- a/src/test/resources/value-maps/AllergyIntoleranceType.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "416098002": "allergy", - "59037007": "intolerance", - "419511003": "intolerance", - "414285001": "allergy", - "235719002": "intolerance", - "418471000": "intolerance", - "420134006": "intolerance", - "418038007": "intolerance", - "419199007": "allergy", - "232347008": "allergy" -} \ No newline at end of file diff --git a/src/test/resources/value-maps/AllergyIntoleranceVerificationStatus.json b/src/test/resources/value-maps/AllergyIntoleranceVerificationStatus.json deleted file mode 100644 index 00e83a49a..000000000 --- a/src/test/resources/value-maps/AllergyIntoleranceVerificationStatus.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "completed": "confirmed", - "active": "confirmed", - "aborted": "unconfirmed", - "suspended": "unconfirmed" -} \ No newline at end of file diff --git a/src/test/resources/value-maps/CCDClassConstant.json b/src/test/resources/value-maps/CCDClassConstant.json deleted file mode 100644 index d3c4c87c1..000000000 --- a/src/test/resources/value-maps/CCDClassConstant.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "system": "http://hl7.org/fhir/ValueSet/doc-classcodes", - "display": "Note", - "code": "LP173421-7" -} diff --git a/src/test/resources/value-maps/ConditionCategory.json b/src/test/resources/value-maps/ConditionCategory.json deleted file mode 100644 index bed261309..000000000 --- a/src/test/resources/value-maps/ConditionCategory.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "248536006": { - "code": "finding", - "display": "Finding", - "system": "http://hl7.org/fhir/condition-category" - }, - "373930000": { - "code": "finding", - "display": "Finding", - "system": "http://hl7.org/fhir/condition-category" - }, - "404684003": { - "code": "finding", - "display": "Finding", - "system": "http://hl7.org/fhir/condition-category" - }, - "75321-0": { - "code": "finding", - "display": "Finding", - "system": "http://hl7.org/fhir/condition-category" - }, - "75312-9": { - "code": "finding", - "display": "Finding", - "system": "http://hl7.org/fhir/condition-category" - }, - "409586006": { - "code": "complaint", - "display": "Complaint", - "system": "http://hl7.org/fhir/condition-category" - }, - "75322-8": { - "code": "complaint", - "display": "Complaint", - "system": "http://hl7.org/fhir/condition-category" - }, - "75313-7": { - "code": "complaint", - "display": "Complaint", - "system": "http://hl7.org/fhir/condition-category" - }, - "282291009": { - "code": "diagnosis", - "display": "Diagnosis", - "system": "http://hl7.org/fhir/condition-category" - }, - "29308-4": { - "code": "diagnosis", - "display": "Diagnosis", - "system": "http://hl7.org/fhir/condition-category" - }, - "75314-5": { - "code": "diagnosis", - "display": "Diagnosis", - "system": "http://hl7.org/fhir/condition-category" - }, - "55607006": { - "code": "diagnosis", - "display": "Diagnosis", - "system": "http://hl7.org/fhir/condition-category" - }, - "75318-6": { - "code": "diagnosis", - "display": "Diagnosis", - "system": "http://hl7.org/fhir/condition-category" - }, - "75323-6": { - "code": "diagnosis", - "display": "Diagnosis", - "system": "http://hl7.org/fhir/condition-category" - }, - "75315-2": { - "code": "diagnosis", - "display": "Diagnosis", - "system": "http://hl7.org/fhir/condition-category" - }, - "64572001": { - "code": "diagnosis", - "display": "Diagnosis", - "system": "http://hl7.org/fhir/condition-category" - }, - "418799008": { - "code": "symptom", - "display": "Symptom", - "system": "http://hl7.org/fhir/condition-category" - }, - "75325-1": { - "code": "symptom", - "display": "Symptom", - "system": "http://hl7.org/fhir/condition-category" - }, - "75317-8": { - "code": "symptom", - "display": "Symptom", - "system": "http://hl7.org/fhir/condition-category" - } -} diff --git a/src/test/resources/value-maps/ConditionCategoryConstant.json b/src/test/resources/value-maps/ConditionCategoryConstant.json deleted file mode 100644 index 6dbfabe69..000000000 --- a/src/test/resources/value-maps/ConditionCategoryConstant.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "display": "Problem List Item", - "code": "problem-list-item" - } - ] -} diff --git a/src/test/resources/value-maps/ConditionVerificationStatus.json b/src/test/resources/value-maps/ConditionVerificationStatus.json deleted file mode 100644 index 1b413e92c..000000000 --- a/src/test/resources/value-maps/ConditionVerificationStatus.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "completed": "refuted", - "active": "confirmed", - "aborted": "entered-in-error", - "suspended": "provisional" -} \ No newline at end of file diff --git a/src/test/resources/value-maps/ContactPointSystem.json b/src/test/resources/value-maps/ContactPointSystem.json deleted file mode 100644 index 340a2b8ea..000000000 --- a/src/test/resources/value-maps/ContactPointSystem.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "phone": "phone", - "tel": "phone", - "email": "email", - "mailto": "email", - "fax": "fax", - "http": "url", - "https": "url" -} \ No newline at end of file diff --git a/src/test/resources/value-maps/ContactPointUse.json b/src/test/resources/value-maps/ContactPointUse.json deleted file mode 100644 index 5882f5d50..000000000 --- a/src/test/resources/value-maps/ContactPointUse.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "H": "home", - "HP": "home", - "WP": "work", - "TMP": "temp", - "BAD": "old", - "MC": "mobile" -} diff --git a/src/test/resources/value-maps/ContactRelationship.json b/src/test/resources/value-maps/ContactRelationship.json deleted file mode 100644 index 391f8e9b3..000000000 --- a/src/test/resources/value-maps/ContactRelationship.json +++ /dev/null @@ -1,163 +0,0 @@ -{ - "econ": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "ext": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "guard": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "frnd": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "sps": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "dompart": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "husb": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "wife": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "prn": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "fth": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "mth": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "nprn": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "nfth": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "nmth": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "prinlaw": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "fthinlaw": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "mthinlaw": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "stpprn": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "stpfth": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "stpmth": [ - { - "code": "C", - "display": "Emergency Contact", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "work": [ - { - "code": "E", - "display": "Employer", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "fammemb": [ - { - "code": "N", - "display": "Next-of-Kin", - "system": "http://hl7.org/fhir/v2/0131" - } - ], - "_": [ - { - "code": "O", - "display": "Other", - "system": "http://hl7.org/fhir/v2/0131" - } - ] -} diff --git a/src/test/resources/value-maps/DiagnosticReportStatus.json b/src/test/resources/value-maps/DiagnosticReportStatus.json deleted file mode 100644 index 49fc8d793..000000000 --- a/src/test/resources/value-maps/DiagnosticReportStatus.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "cancelled": "cancelled", - "aborted": "cancelled", - "nullified": "cancelled", - "active": "partial", - "held": "registered", - "suspended": "entered-in-error", - "completed": "final" -} diff --git a/src/test/resources/value-maps/DocumentConfidentiality.json b/src/test/resources/value-maps/DocumentConfidentiality.json deleted file mode 100644 index 6c5af6227..000000000 --- a/src/test/resources/value-maps/DocumentConfidentiality.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "U": { - "code": "U", - "display": "U", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "L": { - "code": "L", - "display": "L", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "M": { - "code": "M", - "display": "M", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "N": { - "code": "N", - "display": "N", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "R": { - "code": "R", - "display": "R", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "V": { - "code": "V", - "display": "V", - "system": "http://hl7.org/fhir/v3/ActCode" - } -} diff --git a/src/test/resources/value-maps/EncounterClass.json b/src/test/resources/value-maps/EncounterClass.json deleted file mode 100644 index 6a19e7ee1..000000000 --- a/src/test/resources/value-maps/EncounterClass.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "amb": { - "code": "AMB", - "display": "ambulatory", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "ambulatory": { - "code": "AMB", - "display": "ambulatory", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "out": { - "code": "AMB", - "display": "ambulatory", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "outpatient": { - "code": "AMB", - "display": "ambulatory", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "day": { - "code": "AMB", - "display": "ambulatory", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "daytime": { - "code": "AMB", - "display": "ambulatory", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "in": { - "code": "IMP", - "display": "inpatient encounter", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "inp": { - "code": "IMP", - "display": "inpatient encounter", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "inpatient": { - "code": "IMP", - "display": "inpatient encounter", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "em": { - "code": "EMER", - "display": "emergency", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "eme": { - "code": "EMER", - "display": "emergency", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "emergency": { - "code": "EMER", - "display": "emergency", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "hom": { - "code": "HH", - "display": "home health", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "home": { - "code": "HH", - "display": "home health", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "vir": { - "code": "VR", - "display": "virtual", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "virtual": { - "code": "VR", - "display": "virtual", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "fie": { - "code": "FLD", - "display": "field", - "system": "http://hl7.org/fhir/v3/ActCode" - }, - "field": { - "code": "FLD", - "display": "field", - "system": "http://hl7.org/fhir/v3/ActCode" - } -} diff --git a/src/test/resources/value-maps/EncounterConditionCategoryConstant.json b/src/test/resources/value-maps/EncounterConditionCategoryConstant.json deleted file mode 100644 index 5ffaf0525..000000000 --- a/src/test/resources/value-maps/EncounterConditionCategoryConstant.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "display": "Encounter Diagnosis", - "code": "encounter-diagnosis" - } - ] -} diff --git a/src/test/resources/value-maps/EncounterStatus.json b/src/test/resources/value-maps/EncounterStatus.json deleted file mode 100644 index 5af559192..000000000 --- a/src/test/resources/value-maps/EncounterStatus.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "in-progress": "in-progress", - "active": "in-progress", - "onleave":"onleave", - "finished": "finished", - "completed": "finished", - "cancelled":"cancelled", - "planned":"planned", - "arrived":"arrived" -} diff --git a/src/test/resources/value-maps/Gender.json b/src/test/resources/value-maps/Gender.json deleted file mode 100644 index c296d0c3b..000000000 --- a/src/test/resources/value-maps/Gender.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "f": "female", - "m": "male", - "un": "unknown", - "_": "unknown" -} diff --git a/src/test/resources/value-maps/ImmunizationRoleConstant.json b/src/test/resources/value-maps/ImmunizationRoleConstant.json deleted file mode 100644 index 5f1bf1c0b..000000000 --- a/src/test/resources/value-maps/ImmunizationRoleConstant.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "coding": [ - { - "system": "http://hl7.org/fhir/v2/0443", - "display": "Administering Provider", - "code": "AP" - } - ] -} diff --git a/src/test/resources/value-maps/ImmunizationStatus.json b/src/test/resources/value-maps/ImmunizationStatus.json deleted file mode 100644 index e59ad796b..000000000 --- a/src/test/resources/value-maps/ImmunizationStatus.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "completed": "completed", - "active": "completed", - "normal": "completed", - "new": "completed", - "aborted": "entered-in-error", - "suspended": "entered-in-error", - "cancelled": "entered-in-error", - "held": "entered-in-error", - "obselete": "entered-in-error", - "nullified": "entered-in-error" -} \ No newline at end of file diff --git a/src/test/resources/value-maps/MaritalStatus.json b/src/test/resources/value-maps/MaritalStatus.json deleted file mode 100644 index 6489b0ae9..000000000 --- a/src/test/resources/value-maps/MaritalStatus.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "A": [ - { - "code": "A", - "display": "Annulled", - "system": "http://hl7.org/fhir/v3/MaritalStatus" - } - ], - "D": [ - { - "code": "D", - "display": "Divorced", - "system": "http://hl7.org/fhir/v3/MaritalStatus" - } - ], - "I": [ - { - "code": "I", - "display": "Interlocutory", - "system": "http://hl7.org/fhir/v3/MaritalStatus" - } - ], - "L": [ - { - "code": "L", - "display": "Legally Separated", - "system": "http://hl7.org/fhir/v3/MaritalStatus" - } - ], - "M": [ - { - "code": "M", - "display": "Married", - "system": "http://hl7.org/fhir/v3/MaritalStatus" - } - ], - "P": [ - { - "code": "P", - "display": "Polygamous", - "system": "http://hl7.org/fhir/v3/MaritalStatus" - } - ], - "S": [ - { - "code": "S", - "display": "Never Married", - "system": "http://hl7.org/fhir/v3/MaritalStatus" - } - ], - "T": [ - { - "code": "T", - "display": "Domestic partner", - "system": "http://hl7.org/fhir/v3/MaritalStatus" - } - ], - "W": [ - { - "code": "W", - "display": "Widowed", - "system": "http://hl7.org/fhir/v3/MaritalStatus" - } - ], - "UN": [ - { - "code": "UNK", - "display": "unknown", - "system": "http://hl7.org/fhir/v3/NullFlavor" - } - ], - "_": [ - { - "code": "UNK", - "display": "unknown", - "system": "http://hl7.org/fhir/v3/NullFlavor" - } - ] -} diff --git a/src/test/resources/value-maps/MedicationConditionCategoryConstant.json b/src/test/resources/value-maps/MedicationConditionCategoryConstant.json deleted file mode 100644 index 6dbfabe69..000000000 --- a/src/test/resources/value-maps/MedicationConditionCategoryConstant.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "coding": [ - { - "system": "http://hl7.org/fhir/condition-category", - "display": "Problem List Item", - "code": "problem-list-item" - } - ] -} diff --git a/src/test/resources/value-maps/MedicationDispenseStatus.json b/src/test/resources/value-maps/MedicationDispenseStatus.json deleted file mode 100644 index 1cf7c4df7..000000000 --- a/src/test/resources/value-maps/MedicationDispenseStatus.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "aborted": "stopped", - "completed": "completed" -} diff --git a/src/test/resources/value-maps/MedicationRequestStatus.json b/src/test/resources/value-maps/MedicationRequestStatus.json deleted file mode 100644 index 71173b4e1..000000000 --- a/src/test/resources/value-maps/MedicationRequestStatus.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "cancelled": "cancelled", - "aborted": "cancelled", - "nullified": "cancelled", - "active": "active", - "held": "on-hold", - "suspended": "on-hold", - "completed": "completed" -} diff --git a/src/test/resources/value-maps/MedicationStatementStatus.json b/src/test/resources/value-maps/MedicationStatementStatus.json deleted file mode 100644 index bfe00a18e..000000000 --- a/src/test/resources/value-maps/MedicationStatementStatus.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "intended": "intended", - "active": "active", - "completed": "completed", - "nullified": "entered-in-error" -} \ No newline at end of file diff --git a/src/test/resources/value-maps/NameUse.json b/src/test/resources/value-maps/NameUse.json deleted file mode 100644 index 54337e694..000000000 --- a/src/test/resources/value-maps/NameUse.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "C": "usual", - "P": "nickname" -} diff --git a/src/test/resources/value-maps/ObservationDataAbsentReason.json b/src/test/resources/value-maps/ObservationDataAbsentReason.json deleted file mode 100644 index 6dbfe06f7..000000000 --- a/src/test/resources/value-maps/ObservationDataAbsentReason.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "UNK": { - "code": "unknown", - "display": "Unkown", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "ASKU": { - "code": "asked", - "display": "Asked", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "MSK": { - "code": "masked", - "display": "Masked", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "NA": { - "code": "unsupported", - "display": "Unsupported", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "NASK": { - "code": "not-asked", - "display": "Not Asked", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "NAV": { - "code": "temp", - "display": "Temp", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "NI": { - "code": "error", - "display": "Error", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "NINF": { - "code": "NaN", - "display": "Not a Number", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "NP": { - "code": "unknown", - "display": "Unkown", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "OTH": { - "code": "error", - "display": "Error", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "PINF": { - "code": "NaN", - "display": "Not a Number", - "system": "http://hl7.org/fhir/data-absent-reason" - }, - "TRC": { - "code": "NaN", - "display": "Not a Number", - "system": "http://hl7.org/fhir/data-absent-reason" - } -} diff --git a/src/test/resources/value-maps/ObservationInterpretation.json b/src/test/resources/value-maps/ObservationInterpretation.json deleted file mode 100644 index d1307d00e..000000000 --- a/src/test/resources/value-maps/ObservationInterpretation.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "AC": { - "code": "IE", - "display": "Insufficient evidence", - "system": "http://hl7.org/fhir/v2/0078" - }, - "EX": { - "code": "IND", - "display": "Indeterminate", - "system": "http://hl7.org/fhir/v2/0078" - }, - "HX": { - "code": "H", - "display": "High", - "system": "http://hl7.org/fhir/v2/0078" - }, - "LX": { - "code": "L", - "display": "Low", - "system": "http://hl7.org/fhir/v2/0078" - }, - "QCF": { - "code": "IND", - "display": "Indeterminate", - "system": "http://hl7.org/fhir/v2/0078" - }, - "TOX": { - "code": "IND", - "display": "Indeterminate", - "system": "http://hl7.org/fhir/v2/0078" - }, - "CAR": { - "code": "DET", - "display": "Detected", - "system": "http://hl7.org/fhir/v2/0078" - }, - "H>": { - "code": "HU", - "display": "Very high", - "system": "http://hl7.org/fhir/v2/0078" - }, - "L<": { - "code": "LU", - "display": "Very low", - "system": "http://hl7.org/fhir/v2/0078" - } -} diff --git a/src/test/resources/value-maps/ObservationStatus.json b/src/test/resources/value-maps/ObservationStatus.json deleted file mode 100644 index fa22e67b9..000000000 --- a/src/test/resources/value-maps/ObservationStatus.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "completed": "final", - "active": "preliminary", - "normal": "preliminary", - "new": "registered", - "held": "registered", - "aborted": "cancelled", - "suspended": "cancelled", - "cancelled": "cancelled", - "nullified": "cancelled", - "obselete": "unknown", - "error": "entered-in-error" -} diff --git a/src/test/resources/value-maps/ParticipantTypeConstant.json b/src/test/resources/value-maps/ParticipantTypeConstant.json deleted file mode 100644 index f2267f058..000000000 --- a/src/test/resources/value-maps/ParticipantTypeConstant.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "coding": [ - { - "system": "http://hl7.org/fhir/v3/ParticipationType", - "code": "PART", - "display": "Participation" - } - ] - } -] diff --git a/src/test/resources/value-maps/ProcedureStatus.json b/src/test/resources/value-maps/ProcedureStatus.json deleted file mode 100644 index d0ba7d755..000000000 --- a/src/test/resources/value-maps/ProcedureStatus.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "completed": "completed", - "active": "in-progress", - "aborted": "aborted", - "cancelled": "suspended" -} \ No newline at end of file diff --git a/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.jar b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.jar new file mode 100644 index 000000000..71ba9252c Binary files /dev/null and b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.jar differ diff --git a/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.jar.md5 b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.jar.md5 new file mode 100644 index 000000000..8f934306a --- /dev/null +++ b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.jar.md5 @@ -0,0 +1 @@ +9ac03382606db96dfa47793b6ace42d1 \ No newline at end of file diff --git a/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.jar.sha1 b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.jar.sha1 new file mode 100644 index 000000000..3bb992949 --- /dev/null +++ b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.jar.sha1 @@ -0,0 +1 @@ +a81852d5767c54773243357bf23137eec10b1957 \ No newline at end of file diff --git a/pom.xml b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.pom similarity index 100% rename from pom.xml rename to tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.pom diff --git a/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.pom.md5 b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.pom.md5 new file mode 100644 index 000000000..f2523d957 --- /dev/null +++ b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.pom.md5 @@ -0,0 +1 @@ +d4cad5c2f6c5ffc7b886d46963d822ae \ No newline at end of file diff --git a/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.pom.sha1 b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.pom.sha1 new file mode 100644 index 000000000..192c12e6c --- /dev/null +++ b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/cda2fhir-0.1.0-SNAPSHOT.pom.sha1 @@ -0,0 +1 @@ +7112b696b427d83cddb113d5b61e399abaf86bf5 \ No newline at end of file diff --git a/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/maven-metadata-local.xml b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 000000000..3a1ae1255 --- /dev/null +++ b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + tr.com.srdc + cda2fhir + 0.1.0-SNAPSHOT + + + true + + 20190510171026 + + + jar + 0.1.0-SNAPSHOT + 20190510171026 + + + pom + 0.1.0-SNAPSHOT + 20190510171026 + + + + diff --git a/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/maven-metadata-local.xml.md5 b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/maven-metadata-local.xml.md5 new file mode 100644 index 000000000..78260dc2d --- /dev/null +++ b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/maven-metadata-local.xml.md5 @@ -0,0 +1 @@ +a9575159c5f2f824c73895c58707c51b \ No newline at end of file diff --git a/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/maven-metadata-local.xml.sha1 b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/maven-metadata-local.xml.sha1 new file mode 100644 index 000000000..c71754cd5 --- /dev/null +++ b/tr/com/srdc/cda2fhir/0.1.0-SNAPSHOT/maven-metadata-local.xml.sha1 @@ -0,0 +1 @@ +aa03941bba26a5ed8c9c211037349993428b6b5d \ No newline at end of file diff --git a/tr/com/srdc/cda2fhir/maven-metadata-local.xml b/tr/com/srdc/cda2fhir/maven-metadata-local.xml new file mode 100644 index 000000000..2b5e146c9 --- /dev/null +++ b/tr/com/srdc/cda2fhir/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + tr.com.srdc + cda2fhir + + + 0.1.0-SNAPSHOT + + 20190510171026 + + diff --git a/tr/com/srdc/cda2fhir/maven-metadata-local.xml.md5 b/tr/com/srdc/cda2fhir/maven-metadata-local.xml.md5 new file mode 100644 index 000000000..d9dee1619 --- /dev/null +++ b/tr/com/srdc/cda2fhir/maven-metadata-local.xml.md5 @@ -0,0 +1 @@ +554719f189a441c042789da290451c3e \ No newline at end of file diff --git a/tr/com/srdc/cda2fhir/maven-metadata-local.xml.sha1 b/tr/com/srdc/cda2fhir/maven-metadata-local.xml.sha1 new file mode 100644 index 000000000..8affcc4bb --- /dev/null +++ b/tr/com/srdc/cda2fhir/maven-metadata-local.xml.sha1 @@ -0,0 +1 @@ +6fc3f8c66f47e15a6c09db8264659b280f698d1e \ No newline at end of file