<div dir="ltr">Hello...<div><br></div><div>My basic question is if using a MagmaReader is the best way to search a MagmaCollection for a SINGLE object...</div><div><br></div><div>Background information follows!<br></div><div>
<br></div><div>---------------------------------------------------------------</div><div><br><div>I am using Magma to create a sort of Object-Based Warehouse for multiple Applications in a Healthcare Environment.</div><div>
<br></div><div>I have developed a pretty decent &quot;batch loading&quot; strategy that is based upon my knowledge of my own system limitations, which unfortunately is actually driving my Data Model. &nbsp;Basically, I have a PatientEncounter, which has multiple PatientEncounterElement(s) (demographics, coding information, billing information, etc...) which are pretty much tied directly to the systems and functions they come from, NOT exactly how it makes the most sense! &nbsp;However, this lets us batch update &quot;pages&quot; of PatientEncounterElement(s) at a time and limiting the number of ODBC calls required.</div>
<div><br></div><div>My question, though, is in my strategy for checking for NEW PatientEncounter(s). &nbsp;Basically I am searching through my live data over a date range (I have no triggers available, and most of our systems don&#39;t lend themselves to finding new patients that weren&#39;t there yesterday) and making sure the PatientEncounter is present in the Magma database like so:</div>
<div><br></div><div><div>EncounterReader&gt;&gt;updateEncounterListFrom: anAccountList &quot;a collection of ODBCRow(s)&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>| i pat |</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>i := 0.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>anAccountList do:&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>[ :each |&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>pat := PatientEncounter forAccount: each acct.</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>pat ifNil:&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>[ pat := PatientEncounter newAccount: each acct.</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>pat admissionDate: each admDate.</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>pat dischargeDate: each disDate.</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>FMCMagmaClient demographics add: pat demographics.</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>FMCMagmaClient encounters add: pat.</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>i := i + 1.</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>i &gt; self pageSize ifTrue:&nbsp;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>[ FMCMagmaClient commitAndBegin.</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>i := 0 ] ] ].</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>(i &gt; 0) ifTrue: [ FMCMagmaClient commitAndBegin ]</div>
<div><br></div><div>Where FMCMagmaClient encounters, FMCMagmaDemographics, etc... return the MagmaCollections that hold those objects, and:</div><div><br></div><div><br></div><div><div>Class PatientEncounter&gt;&gt;forAccount: anAccountNumber&nbsp;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>| reader |</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>reader := FMCMagmaClient encounters where: [ :each | each acct = anAccountNumber ].</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>reader size = 0 ifTrue: [ ^ nil ].</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^ reader first</div><div><br></div><div>and I have indexed #acct.</div>
<div><br></div><div>Anyway, checking for existing records and adding new ones as necessary seems to take longer than just updating existing records, which is to be expected, so I was wondering if this is the best way to check for existing records in my MagmaCollection.</div>
<div><br></div><div>Thanks, and take care,</div><div><br></div><div>Rob</div></div><div><br></div></div></div></div>