@icure/be-fhc-api 0.4.34 → 0.4.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icure/be-fhc-api",
3
- "version": "0.4.34",
3
+ "version": "0.4.35",
4
4
  "description": "Typescript version of Freehealth Connector standalone API client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -711,15 +711,18 @@ class MessageXApi {
711
711
  : Promise.resolve(`efact:${hcp.id}:${year}:${fed.code === "306" ? "300" : fed.code === "675" ? "600" : fed.code}:`)).then(prefix => {
712
712
  return this.entityReferenceApi
713
713
  .getLatest(prefix)
714
- .then((er) => {
715
- let nextSeqNumber = er && er.id && er.id.startsWith(prefix)
716
- ? (Number(er.id.split(":").pop()) || 0) + 1
717
- : 1;
718
- return this.entityReferenceApi.createEntityReference(new api_1.EntityReference({
719
- id: prefix + _.padStart("" + (nextSeqNumber % 1000000000), 9, "0"),
720
- docId: uuid
721
- }));
714
+ .then((er) => er && er.id && er.id.startsWith(prefix)
715
+ ? (Number(er.id.split(":").pop()) || 0) + 1
716
+ : 1, (e) => {
717
+ if (e.statusCode === 404)
718
+ return 1;
719
+ else
720
+ throw e;
722
721
  })
722
+ .then((nextSeqNumber) => this.entityReferenceApi.createEntityReference(new api_1.EntityReference({
723
+ id: prefix + _.padStart("" + (nextSeqNumber % 1000000000), 9, "0"),
724
+ docId: uuid
725
+ })))
723
726
  .then(er => (0, efact_util_1.toInvoiceBatch)(invoices, hcp, fullBase36, er && er.id ? Number(er.id.substr(prefix.length)) % 1000 : 0, smallBase36, this.insuranceApi, this.invoiceXApi, this.api, speciality, professionCode))
724
727
  .then(batch => efactApi
725
728
  .sendBatchUsingPOST(xFHCKeystoreId, xFHCTokenId, xFHCPassPhrase, batch)