001/*-
002 * #%L
003 * Smile CDR - CDR
004 * %%
005 * Copyright (C) 2016 - 2024 Smile CDR, Inc.
006 * %%
007 * All rights reserved.
008 * #L%
009 */
010package ca.cdr.api.pub.cdaexchange.model;
011
012import ca.cdr.api.model.json.IModelJson;
013import com.fasterxml.jackson.annotation.JsonCreator;
014import com.fasterxml.jackson.annotation.JsonProperty;
015import com.fasterxml.jackson.annotation.JsonPropertyOrder;
016import org.hl7.fhir.instance.model.api.IBaseBundle;
017import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
018
019import static ca.cdr.api.pub.cdaexchange.model.CdaToFhirConversionResultJson.BUNDLE;
020import static ca.cdr.api.pub.cdaexchange.model.CdaToFhirConversionResultJson.DO_PROCESS;
021import static ca.cdr.api.pub.cdaexchange.model.CdaToFhirConversionResultJson.MODIFIABLE_DOCUMENT;
022import static ca.cdr.api.pub.cdaexchange.model.CdaToFhirConversionResultJson.OPERATION_OUTCOME;
023import static ca.cdr.api.pub.cdaexchange.model.CdaToFhirConversionResultJson.ORIGINAL_DOCUMENT;
024
025/**
026 * Contains all the relevant data involved in the conversion of a CDA document to a FHIR IBaseBundle resource.
027 */
028@JsonPropertyOrder({ORIGINAL_DOCUMENT, MODIFIABLE_DOCUMENT, BUNDLE, DO_PROCESS, OPERATION_OUTCOME})
029public class CdaToFhirConversionResultJson implements IModelJson {
030
031        public static final String ORIGINAL_DOCUMENT = "originalDocument";
032        public static final String MODIFIABLE_DOCUMENT = "modifiableDocument";
033        public static final String BUNDLE = "bundle";
034        public static final String DO_PROCESS = "doProcess";
035        public static final String OPERATION_OUTCOME = "operationOutcome";
036
037        /**
038         * The original CDA Exchange document before any customizations have been applied.
039         */
040        @JsonProperty(ORIGINAL_DOCUMENT)
041        private final String myOriginalDocument;
042
043        /**
044         * The CDA Exchange document which customizations can be applied to.
045         */
046        @JsonProperty(MODIFIABLE_DOCUMENT)
047        private String myModifiableDocument;
048
049        /**
050         * A bundle resource that has been created from the modifiableDocument.
051         */
052        @JsonProperty(BUNDLE)
053        private IBaseBundle myBundle;
054
055        /**
056         * A flag to indicate whether a given document should be processed.
057         */
058        @JsonProperty(DO_PROCESS)
059        private boolean myDoProcess;
060
061        /**
062         * The information, warnings, or errors that result from a conversion process.
063         */
064        @JsonProperty(OPERATION_OUTCOME)
065        private IBaseOperationOutcome myOperationOutcome;
066
067        @JsonCreator
068        public CdaToFhirConversionResultJson(@JsonProperty(ORIGINAL_DOCUMENT) String theOriginalDocument) {
069                myOriginalDocument = theOriginalDocument;
070                myModifiableDocument = theOriginalDocument;
071                myDoProcess = true;
072        }
073
074        /**
075         * @return A copy of the original CDA Exchange document before any customizations have been applied.
076         */
077        public String getOriginalDocument() {
078                return myOriginalDocument;
079        }
080
081        /**
082         * @return The CDA Exchange document which customizations can be applied to.
083         */
084        public String getModifiableDocument() {
085                return myModifiableDocument;
086        }
087
088        /**
089         * Sets the CDA Exchange document which customizations can be applied to.
090         * @param theModifiableDocument The modifiable document
091         */
092        public void setModifiableDocument(String theModifiableDocument) {
093                myModifiableDocument = theModifiableDocument;
094        }
095
096        /**
097         * @return A bundle resource that has been created from the modifiable CDA Exchange document.
098         */
099        public IBaseBundle getBundle() {
100                return myBundle;
101        }
102
103        /**
104         * Sets the bundle resource that has been created from the modifiable CDA Exchange document.
105         * @param theBundle The bundle resource
106         */
107        public void setBundle(IBaseBundle theBundle) {
108                myBundle = theBundle;
109        }
110
111        /**
112         * @return Whether the modifiable CDA Exchange document should be processed.
113         */
114        public boolean isDoProcess() {
115                return myDoProcess;
116        }
117
118        /**
119         * Sets a flag to indicate whether the modifiable CDA Exchange document should be processed.
120         * @param theDoProcess The value of the flag
121         */
122        public void setDoProcess(boolean theDoProcess) {
123                myDoProcess = theDoProcess;
124        }
125
126        /**
127         * Set the operation outcome resource.
128         *
129         * @param theOperationOutcome the operation outcome
130         */
131        public void setOperationOutcome(IBaseOperationOutcome theOperationOutcome) {
132                myOperationOutcome = theOperationOutcome;
133        }
134
135        /**
136         * @return The operation outcome resource.
137         */
138        public IBaseOperationOutcome getOperationOutcome() {
139                return myOperationOutcome;
140        }
141}