      (when-let [name-loc (cdzx/xml1-> el-loc :entry :string)]
        [(cdzx/text name-loc) (cz/right name-loc)]))))
 
+(defn name-script-sequence
+  "Take a script loc to find and build the script name."
+  [prefix loc]
+  (str prefix
+       (cdzx/xml1-> loc cz/up :sequenceNumber cdzx/text)
+       (cdzx/xml1-> loc cz/up :name cdzx/text (fn [x]
+                                                (if (= x "")
+                                                  nil
+                                                  (str "-" x))))))
+
+(defn this-tag=
+  "Returns a query predicate that matches if the current exact node is a tag named
+  tagname."
+  [tagname]
+  (fn [loc]
+    (when (= tagname (:tag (cz/node loc)))
+      loc)))
+
 (def channel-deconstructors
-  [[#(cdzx/xml1-> % :connector :name cdzx/text)
-    #(cdzx/xml1-> % :connector :properties :script)]
-   [#(cdzx/xml1-> % :sourceConnector :name cdzx/text)
-    #(cdzx/xml1-> % :sourceConnector :properties :script)]
+  [[(partial name-script-sequence "destinationConnector-filter-step-")
+    #(cdzx/xml1-> %
+                  (this-tag= :com.mirth.connect.plugins.javascriptrule.JavaScriptRule)
+                  :script
+                  [cz/up cz/up cz/up :filter cz/up :destinationConnectors])]
+
+   [(fn [loc] (let [destname (apply cdzx/xml1-> loc (flatten [(repeat 4 cz/up) :name cdzx/text]))]
+                (str "destinationConnector-" destname "-" (name-script-sequence "transformer-step-" loc))))
+    #(cdzx/xml1-> %
+                  (this-tag= :com.mirth.connect.plugins.javascriptstep.JavaScriptStep)
+                  :script
+                  [cz/up cz/up cz/up :transformer cz/up :connector cz/up :destinationConnectors])]
+
+   [(fn [loc] (let [destname (apply cdzx/xml1-> loc (flatten [(repeat 4 cz/up) :name cdzx/text]))]
+                (str "destinationConnector-" destname "-" (name-script-sequence "responseTransformer-step-" loc))))
+    #(cdzx/xml1-> %
+                  (this-tag= :com.mirth.connect.plugins.javascriptstep.JavaScriptStep)
+                  :script
+                  [cz/up cz/up cz/up :responseTransformer cz/up :connector cz/up :destinationConnectors])]
+
+   [(partial name-script-sequence "sourceConnector-transformer-step-")
+    #(cdzx/xml1-> %
+                  (this-tag= :com.mirth.connect.plugins.javascriptstep.JavaScriptStep)
+                  :script
+                  [cz/up cz/up cz/up :transformer cz/up :sourceConnector])]
+
+   [(partial name-script-sequence "sourceConnector-filter-step-")
+    #(cdzx/xml1-> %
+                  (this-tag= :com.mirth.connect.plugins.javascriptrule.JavaScriptRule)
+                  :script
+                  [cz/up cz/up cz/up :filter cz/up :sourceConnector])]
+
+   [(fn [loc] (let [name (cdzx/xml1-> loc cz/up cz/up :name cdzx/text)]
+                (str "sourceConnector" (when-not (cs/blank? name)
+                                         (str "-" name)))))
+    #(cdzx/xml1-> % (this-tag= :script) [cz/up :properties cz/up :sourceConnector])]
+
+   [(fn [loc] (let [name (cdzx/xml1-> loc cz/up cz/up :name cdzx/text)]
+                (str "connector" (when-not (cs/blank? name)
+                                         (str "-" name)))))
+    #(cdzx/xml1-> % (this-tag= :script) [cz/up :properties cz/up :connector])]
+
    [(fn [_] "PreprocessingScript")
-    #(cdzx/xml1-> % :preprocessingScript)]
+    #(cdzx/xml1-> % (this-tag= :preprocessingScript))]
+
    [(fn [_] "PostprocessingScript")
-    #(cdzx/xml1-> % :postprocessingScript)]
+    #(cdzx/xml1-> % (this-tag= :postprocessingScript))]
+
    [(fn [_] "DeployScript")
-    #(cdzx/xml1-> % :deployScript)]
+    #(cdzx/xml1-> % (this-tag= :deployScript))]
+
    [(fn [_] "UndeployScript")
-    #(cdzx/xml1-> % :undeployScript)]])
+    #(cdzx/xml1-> % (this-tag= :undeployScript))]])
+
 
 (defmethod mi/deconstruct-node :channels [_ file-path el-loc]
   (deconstruct-node

  (:require [clojure.data.xml :as cdx]
            [clojure.data.zip :as cdz]
            [clojure.data.zip.xml :as cdzx]
            [clojure.string :as cs]
            [clojure.tools.logging :as log]
            [clojure.zip :as cz]
            [mirthsync.actions :as ma]
            [mirthsync.files :as mf]
            [mirthsync.interfaces :as mi]
            [clojure.data.xml :as xml])
  (:import java.io.File))

(defn- api-element-id

  (let [base-path (mf/remove-extension file-path)]
    (loop [el-loc el-loc
           deconstruction []]
      ;; (log/info (str "tag: " (:tag (cz/node el-loc))))
      (if (cz/end? el-loc)
        (conj deconstruction [file-path (cdx/indent-str (cz/root el-loc))])
        (let [[script-name script] (find-name-val el-loc)
