@@ -43,7 +43,8 @@ public Map<String, StructureDefinitionBindingObject> visitStructureDefinition(St
4343 getBindings (sdName , eds , sdURL , sdVersion , bindingObjects );
4444 }
4545 if (sd .hasBaseDefinition ()) {
46- bindingObjects .putAll (visitStructureDefinition (this .canonicalResourceDependenciesAtlas .getStructureDefinitions ().getByCanonicalUrlWithVersion (sd .getBaseDefinition ()), snapshotOnly )); }
46+ bindingObjects .putAll (visitStructureDefinition (this .canonicalResourceDependenciesAtlas .getStructureDefinitions ().getByCanonicalUrlWithVersion (sd .getBaseDefinition ()), snapshotOnly ));
47+ }
4748 }
4849 return bindingObjects ;
4950 }
@@ -71,7 +72,7 @@ private void getBindings(String sdName, List<ElementDefinition> eds, String sdUR
7172 sdbo .setSdURL (sdURL );
7273 sdbo .setSdVersion (sdVersion );
7374 sdbo .setBindingStrength (ed .getBinding ().getStrength ().toString ().toLowerCase ());
74- if (ed .hasMin () && ed .hasMax ()){
75+ if (ed .hasMin () && ed .hasMax ()) {
7576 String edCardinality = ed .getMin () + "..." + ed .getMax ();
7677 sdbo .setCardinality (edCardinality );
7778 }
@@ -97,16 +98,16 @@ private void getBindings(String sdName, List<ElementDefinition> eds, String sdUR
9798 valueSetVersion = pipeVersion ;
9899 }
99100 if (null != elementValueSet ) {
100- StringBuilder codeSystemURLs = new StringBuilder ();;
101+ StringBuilder codeSystemURLs = new StringBuilder ();
101102 Map <String , String > codeSystemsMap = new HashMap <>();
102103 getValueSetCodeSystems (elementValueSet , codeSystemsMap );
103- if (null != codeSystemsMap && !codeSystemsMap .isEmpty ()) {
104- AtomicReference <Integer > valueCount = new AtomicReference <>(0 );
105- codeSystemsMap .values ().forEach ((url )-> {
104+ if (null != codeSystemsMap && !codeSystemsMap .isEmpty ()) {
105+ AtomicReference <Integer > valueCount = new AtomicReference <>(0 );
106+ codeSystemsMap .values ().forEach ((url ) -> {
106107 codeSystemURLs .append (url );
107108 valueCount .set (valueCount .get () + 1 );
108- if (valueCount .get () > 0 &&
109- valueCount .get () < codeSystemsMap .size ()) {
109+ if (valueCount .get () > 0 &&
110+ valueCount .get () < codeSystemsMap .size ()) {
110111 codeSystemURLs .append (";" );
111112 }
112113 });
@@ -121,15 +122,100 @@ private void getBindings(String sdName, List<ElementDefinition> eds, String sdUR
121122 sdbo .setBindingValueSetVersion (valueSetVersion );
122123 bindingObjects .put (sdName + "." + sdbo .getElementId (), sdbo );
123124 }
125+ else if (ed .hasExtension ()) {
126+ visitExtensions (ed , bindingObjects , sdName , sdURL , sdVersion );
127+ }
124128 index .set (index .get () + 1 );
125129 }
126130 }
127131
132+ private void visitExtensions (ElementDefinition ed , Map <String , StructureDefinitionBindingObject > bindingObjects , String sdName , String sdURL , String sdVersion ) {
133+ StructureDefinitionBindingObject sdbo = new StructureDefinitionBindingObject ();
134+ sdbo .setSdName (sdName );
135+ sdbo .setSdURL (sdURL );
136+ sdbo .setSdVersion (sdVersion );
137+ sdbo .setElementId (ed .getId ());
138+ if (ed .getMustSupport ()) {
139+ sdbo .setMustSupport ("Y" );
140+ } else {
141+ sdbo .setMustSupport ("N" );
142+ }
143+ if (ed .hasMin ()) {
144+ String edCardinality = ed .getMin () + "..." + ed .getMax ();
145+ sdbo .setCardinality (edCardinality );
146+ }
147+ CanonicalType canonicalType = new CanonicalType ();
148+ Iterable <StructureDefinition > sdList = null ;
149+ try {
150+ if (ed .getType ().get (0 ).getProfile ().size () != 0 ) {
151+ canonicalType .setValue (String .valueOf (ed .getType ().get (0 ).getProfile ().get (0 )));
152+ sdList = this .canonicalResourceDependenciesAtlas .getStructureDefinitions ().getByCanonicalUrl (ed .getType ().get (0 ).getProfile ().get (0 ).getValueAsString ());
153+ } else if (ed .getType ().get (0 ).getTargetProfile ().size () != 0 ) {
154+ canonicalType .setValue (String .valueOf (ed .getType ().get (0 ).getTargetProfile ()));
155+ sdList = this .canonicalResourceDependenciesAtlas .getStructureDefinitions ().getByCanonicalUrl (ed .getType ().get (0 ).getTargetProfile ().get (0 ).getValueAsString ());
156+ }
157+ else {
158+ return ;
159+ }
160+ } catch (Exception ex ) {
161+ return ;
162+ }
163+ if (sdList != null ) {
164+ sdList .forEach ((structDef ) -> {
165+ List <ElementDefinition > edsds = structDef .getDifferential ().getElement ();
166+ edsds .forEach (edsd -> {
167+ if (edsd .hasBinding ()) {
168+ sdbo .setBindingStrength (edsd .getBinding ().getStrength ().toString ().toLowerCase ());
169+ String bindingValueSet = edsd .getBinding ().getValueSet ();
170+ String pipeVersion = "" ;
171+ if (bindingValueSet .contains ("|" )) {
172+ pipeVersion = bindingValueSet .substring (bindingValueSet .indexOf ("|" ) + 1 );
173+ bindingValueSet = bindingValueSet .substring (0 , bindingValueSet .indexOf ("|" ));
174+ }
175+ sdbo .setBindingValueSetURL (bindingValueSet );
176+ String valueSetVersion = "" ;
177+ ValueSet elementValueSet = null ;
178+ if (null != this .canonicalResourceAtlas .getValueSets ().getByCanonicalUrlWithVersion (sdbo .getBindingValueSetURL ())) {
179+ valueSetVersion = this .canonicalResourceAtlas .getValueSets ().getByCanonicalUrlWithVersion (sdbo .getBindingValueSetURL ()).getVersion ();
180+ sdbo .setBindingValueSetName (this .canonicalResourceAtlas .getValueSets ().getByCanonicalUrlWithVersion (sdbo .getBindingValueSetURL ()).getName ());
181+ elementValueSet = this .canonicalResourceAtlas .getValueSets ().getByCanonicalUrlWithVersion (sdbo .getBindingValueSetURL ());
182+ } else if (null != this .canonicalResourceDependenciesAtlas .getValueSets ().getByCanonicalUrlWithVersion (sdbo .getBindingValueSetURL ())) {
183+ valueSetVersion = this .canonicalResourceDependenciesAtlas .getValueSets ().getByCanonicalUrlWithVersion (sdbo .getBindingValueSetURL ()).getVersion ();
184+ sdbo .setBindingValueSetName (this .canonicalResourceDependenciesAtlas .getValueSets ().getByCanonicalUrlWithVersion (sdbo .getBindingValueSetURL ()).getName ());
185+ elementValueSet = this .canonicalResourceDependenciesAtlas .getValueSets ().getByCanonicalUrlWithVersion (sdbo .getBindingValueSetURL ());
186+ } else if (valueSetVersion .isEmpty () && bindingValueSet .contains ("|" )) {
187+ valueSetVersion = pipeVersion ;
188+ }
189+ sdbo .setBindingValueSetVersion (valueSetVersion );
190+ if (null != elementValueSet ) {
191+ StringBuilder codeSystemURLs = new StringBuilder ();
192+ Map <String , String > codeSystemsMap = new HashMap <>();
193+ getValueSetCodeSystems (elementValueSet , codeSystemsMap );
194+ if (!codeSystemsMap .isEmpty ()) {
195+ AtomicReference <Integer > valueCount = new AtomicReference <>(0 );
196+ codeSystemsMap .values ().forEach ((url ) -> {
197+ codeSystemURLs .append (url );
198+ valueCount .set (valueCount .get () + 1 );
199+ if (valueCount .get () > 0 &&
200+ valueCount .get () < codeSystemsMap .size ()) {
201+ codeSystemURLs .append (";" );
202+ }
203+ });
204+ sdbo .setCodeSystemsURLs (codeSystemURLs .toString ());
205+ }
206+ }
207+ }
208+ });
209+ });
210+ }
211+ bindingObjects .put (sdName + "." + sdbo .getElementId (), sdbo );
212+ }
213+
128214 private void getValueSetCodeSystems (ValueSet elementValueSet , Map <String , String > codeSystemsMap ) {
129215 ValueSet .ValueSetComposeComponent compose = elementValueSet .getCompose ();
130216 if (null != compose ) {
131217 for (ValueSet .ConceptSetComponent include : compose .getInclude ()) {
132- if (include .hasSystem ()){
218+ if (include .hasSystem ()) {
133219 codeSystemsMap .put (include .getSystem (), include .getSystem ());
134220 }
135221 for (CanonicalType r : include .getValueSet ()) {
0 commit comments