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