Skip to content

Commit

Permalink
[26379] add method to add xref to encounter to IEncounterService
Browse files Browse the repository at this point in the history
  • Loading branch information
huthomas committed Jun 4, 2024
1 parent b9b653a commit f0a705a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import ch.rgw.tools.Money;
import ch.rgw.tools.Result;
import ch.rgw.tools.Result.SEVERITY;
import ch.rgw.tools.VersionedResource;

@Component
public class EncounterService implements IEncounterService {
Expand Down Expand Up @@ -366,4 +367,29 @@ public void addDefaultDiagnosis(IEncounter encounter) {
}
}
}

@Override
public void addXRef(IEncounter encounter, String provider, String id, int pos, String text) {
// fire prerelease triggers save
ContextServiceHolder.get().sendEvent(ElexisEventTopics.EVENT_LOCK_PRERELEASE, encounter);

VersionedResource vr = encounter.getVersionedEntry();
String ntext = vr.getHead();
Samdas samdas = new Samdas(ntext);
Samdas.Record record = samdas.getRecord();
String recText = record.getText();
if ((pos == -1) || pos > recText.length()) {
pos = recText.length();
recText += StringUtils.LF + text;
} else {
recText = recText.substring(0, pos) + StringUtils.LF + text + recText.substring(pos);
}
record.setText(recText);
// ++pos because \n has been added
Samdas.XRef xref = new Samdas.XRef(provider, id, ++pos, text.length());
record.add(xref);
updateVersionedEntry(encounter, samdas); // XRefs may always be added
// update with the added content
ContextServiceHolder.get().postEvent(ElexisEventTopics.EVENT_UPDATE, encounter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,14 @@ public interface IEncounterService {
*/
public Result<IEncounter> reBillEncounter(IEncounter encounter);

/**
* Insert an XREF to the encounters {@link Samdas} text.
*
* @param encounter
* @param provider unique String identifying the provider
* @param id String identifying the item
* @param pos position of the item as offset relative to the contents
* @param text text to insert
*/
void addXRef(IEncounter encounter, String provider, String id, int pos, String text);
}

0 comments on commit f0a705a

Please sign in to comment.