@icure/be-fhc-api 0.4.17 → 0.4.19

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.17",
3
+ "version": "0.4.19",
4
4
  "description": "Typescript version of Freehealth Connector standalone API client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -30,7 +30,7 @@ export declare class MessageXApi {
30
30
  message: Message;
31
31
  invoices: Array<Invoice>;
32
32
  }>;
33
- sendBatch(user: User, hcp: HealthcareParty, invoices: Array<InvoiceWithPatient>, xFHCKeystoreId: string, xFHCTokenId: string, xFHCPassPhrase: string, efactApi: fhcEfactApi, fhcServer?: string | undefined, prefixer?: (fed: Insurance, hcpId: string) => Promise<string>, isConnectedAsPmg?: boolean, medicalLocationId?: string | null): Promise<Message>;
33
+ sendBatch(user: User, hcp: HealthcareParty, invoices: Array<InvoiceWithPatient>, xFHCKeystoreId: string, xFHCTokenId: string, xFHCPassPhrase: string, efactApi: fhcEfactApi, fhcServer?: string | undefined, prefixer?: (fed: Insurance, hcpId: string) => Promise<string>, isConnectedAsPmg?: boolean, medicalLocationId?: string | null, speciality?: string): Promise<Message>;
34
34
  saveMessageAttachment(user: User, msg: Message, res: EfactSendResponseWithError): Promise<Receipt>;
35
35
  }
36
36
  export {};
@@ -339,10 +339,11 @@ class MessageXApi {
339
339
  }
340
340
  isBlockingError(errorDetail, oa) {
341
341
  //check : https://medispring.atlassian.net/browse/MS-7967
342
+ //check : https://medispring.atlassian.net/browse/MS-8650
342
343
  const lineNumbersToVerify = ["1", "2", "3"];
343
344
  const nonBlockingErrorLetters = ["E"];
344
345
  const nonBlockingErrorCodesByOa = {
345
- "100": [],
346
+ "100": ["502744"],
346
347
  "200": [],
347
348
  "300": [],
348
349
  "306": [],
@@ -697,7 +698,7 @@ class MessageXApi {
697
698
  }));
698
699
  });
699
700
  }
700
- sendBatch(user, hcp, invoices, xFHCKeystoreId, xFHCTokenId, xFHCPassPhrase, efactApi, fhcServer = undefined, prefixer, isConnectedAsPmg = false, medicalLocationId = null) {
701
+ sendBatch(user, hcp, invoices, xFHCKeystoreId, xFHCTokenId, xFHCPassPhrase, efactApi, fhcServer = undefined, prefixer, isConnectedAsPmg = false, medicalLocationId = null, speciality = "doctor") {
701
702
  const uuid = this.crypto.randomUuid();
702
703
  const smallBase36 = (0, efact_util_1.uuidBase36Half)(uuid);
703
704
  const fullBase36 = (0, efact_util_1.uuidBase36)(uuid);
@@ -719,7 +720,7 @@ class MessageXApi {
719
720
  docId: uuid
720
721
  }));
721
722
  })
722
- .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, medicalLocationId === "medicalhouse"))
723
+ .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))
723
724
  .then(batch => efactApi
724
725
  .sendBatchUsingPOST(xFHCKeystoreId, xFHCTokenId, xFHCPassPhrase, batch)
725
726
  //.then(() => { throw "ERREUR FORCEE" })
@@ -16,7 +16,7 @@ export interface InvoiceWithPatient {
16
16
  }
17
17
  export declare function getFederaton(invoices: Array<InvoiceWithPatient>, insuranceApi: IccInsuranceApi): Promise<Insurance>;
18
18
  export declare function getRelatedInvoicesInfo(invoicesWithPatient: InvoiceWithPatient[], insuranceApi: IccInsuranceApi, invoiceXApi: IccInvoiceXApi, messageXApi: IccMessageXApi): Promise<RelatedInvoiceInfo[]>;
19
- export declare function toInvoiceBatch(invoicesWithPatient: Array<InvoiceWithPatient>, hcp: HealthcareParty, batchRef: string, batchNumber: number, fileRef: string, insuranceApi: IccInsuranceApi, invoiceXApi: IccInvoiceXApi, messageXApi: IccMessageXApi, flatrateInvoice?: boolean): Promise<InvoicesBatch>;
19
+ export declare function toInvoiceBatch(invoicesWithPatient: Array<InvoiceWithPatient>, hcp: HealthcareParty, batchRef: string, batchNumber: number, fileRef: string, insuranceApi: IccInsuranceApi, invoiceXApi: IccInvoiceXApi, messageXApi: IccMessageXApi, speciality: string): Promise<InvoicesBatch>;
20
20
  export declare function getDerogationMaxNumber(code: number): InvoiceItem.DerogationMaxNumberEnum;
21
21
  export declare function toDerogationMaxNumber(derogation: InvoiceItem.DerogationMaxNumberEnum): number;
22
22
  export declare function uuidBase36(uuid: string): string;
@@ -91,7 +91,7 @@ function getRelatedInvoicesInfo(invoicesWithPatient, insuranceApi, invoiceXApi,
91
91
  }
92
92
  exports.getRelatedInvoicesInfo = getRelatedInvoicesInfo;
93
93
  // Here we trust the invoices argument for grouping validity (month, year and patient)
94
- function toInvoiceBatch(invoicesWithPatient, hcp, batchRef, batchNumber, fileRef, insuranceApi, invoiceXApi, messageXApi, flatrateInvoice = false) {
94
+ function toInvoiceBatch(invoicesWithPatient, hcp, batchRef, batchNumber, fileRef, insuranceApi, invoiceXApi, messageXApi, speciality) {
95
95
  return insuranceApi
96
96
  .getInsurances(new api_1.ListOfIds({
97
97
  ids: _.compact(invoicesWithPatient.map(iwp => iwp.invoice.recipientId))
@@ -112,10 +112,8 @@ function toInvoiceBatch(invoicesWithPatient, hcp, batchRef, batchNumber, fileRef
112
112
  const invoicesBatch = new models_1.InvoicesBatch({});
113
113
  invoicesBatch.batchRef = batchRef;
114
114
  invoicesBatch.fileRef = fileRef;
115
- invoicesBatch.magneticInvoice = flatrateInvoice; //flatrateInvoice have some different fields
116
- if (flatrateInvoice) {
117
- invoicesBatch.invoiceContent = 0;
118
- }
115
+ invoicesBatch.magneticInvoice = speciality === "medicalhouse"; //flatrateInvoice have some different fields
116
+ speciality === "medicalhouse" ? invoicesBatch.invoiceContent = 0 : speciality === "midwife" ? invoicesBatch.invoiceContent = 50 : null;
119
117
  invoicesBatch.invoices = _.map(invoicesWithPatient, (invWithPat) => {
120
118
  const invoice = invWithPat.aggregatedInvoice || invWithPat.invoice;
121
119
  const relatedInvoiceInfo = _.find(relatedInvoicesInfo, rivi => rivi.invoiceId === invoice.id);
@@ -123,7 +121,7 @@ function toInvoiceBatch(invoicesWithPatient, hcp, batchRef, batchNumber, fileRef
123
121
  if (!insurance) {
124
122
  throw "Insurance is invalid for patient " + invWithPat.patient.id;
125
123
  }
126
- return toInvoice(hcp.nihii, invoice, invWithPat.patient, insurance, relatedInvoiceInfo, flatrateInvoice);
124
+ return toInvoice(hcp.nihii, invoice, invWithPat.patient, insurance, relatedInvoiceInfo, speciality);
127
125
  });
128
126
  const now = new Date();
129
127
  const invoiceDates = _.groupBy(invoicesWithPatient.map(inv => { var _a, _b; return ((_b = (_a = inv === null || inv === void 0 ? void 0 : inv.invoice) === null || _a === void 0 ? void 0 : _a.invoiceDate) !== null && _b !== void 0 ? _b : 100001).toString().substring(0, 6) + "01"; }));
@@ -163,7 +161,7 @@ function toInvoiceBatch(invoicesWithPatient, hcp, batchRef, batchNumber, fileRef
163
161
  });
164
162
  }
165
163
  exports.toInvoiceBatch = toInvoiceBatch;
166
- function toInvoice(nihiiHealthcareProvider, invoice, patient, insurance, relatedInvoiceInfo, flatrateInvoice = false) {
164
+ function toInvoice(nihiiHealthcareProvider, invoice, patient, insurance, relatedInvoiceInfo, speciality) {
167
165
  const efactInvoice = new models_1.Invoice({});
168
166
  const invoiceYear = moment(invoice.created)
169
167
  .year()
@@ -175,7 +173,7 @@ function toInvoice(nihiiHealthcareProvider, invoice, patient, insurance, related
175
173
  efactInvoice.invoiceRef = uuidBase36(invoice.id);
176
174
  efactInvoice.ioCode = insurance.code.substr(0, 3);
177
175
  efactInvoice.items = _.map(invoice.invoicingCodes, (invoicingCode) => {
178
- return toInvoiceItem(invoice.supervisorNihii || nihiiHealthcareProvider, patient, invoice, invoicingCode, flatrateInvoice);
176
+ return toInvoiceItem(invoice.supervisorNihii || nihiiHealthcareProvider, patient, invoice, invoicingCode, speciality);
179
177
  });
180
178
  efactInvoice.patient = (0, fhc_patient_util_1.toPatient)(patient);
181
179
  efactInvoice.ignorePrescriptionDate = !!invoice.longDelayJustification;
@@ -189,7 +187,7 @@ function toInvoice(nihiiHealthcareProvider, invoice, patient, insurance, related
189
187
  // TODO : fix me later
190
188
  efactInvoice.reason = models_1.Invoice.ReasonEnum.Other;
191
189
  efactInvoice.creditNote = invoice.creditNote;
192
- if (flatrateInvoice) {
190
+ if (speciality === "medicalhouse") {
193
191
  efactInvoice.startOfCoveragePeriod = invoice.invoicingCodes[0].contractDate;
194
192
  }
195
193
  if (invoice === null || invoice === void 0 ? void 0 : invoice.locationNihii) {
@@ -199,12 +197,12 @@ function toInvoice(nihiiHealthcareProvider, invoice, patient, insurance, related
199
197
  }
200
198
  return efactInvoice;
201
199
  }
202
- function toInvoiceItem(nihiiHealthcareProvider, patient, invoice, invoicingCode, flatrateInvoice = false) {
200
+ function toInvoiceItem(nihiiHealthcareProvider, patient, invoice, invoicingCode, speciality) {
203
201
  const invoiceItem = new models_1.InvoiceItem({});
204
202
  invoiceItem.codeNomenclature = Number(invoicingCode.tarificationId.split("|")[1]);
205
203
  invoiceItem.dateCode = (0, formatting_util_1.dateEncode)((0, formatting_util_1.toMoment)(invoicingCode.dateCode).toDate());
206
204
  // Only applies to flatrate invoicing (https://medispring.atlassian.net/wiki/spaces/EN/pages/2536013825/Behavior+of+diabetes+pre-care+pathways+flatrate+invoicing)
207
- if (flatrateInvoice) {
205
+ if (speciality === "medicalhouse") {
208
206
  invoiceItem.endDateCode =
209
207
  invoiceItem.codeNomenclature === 109594 // Diabetes pre-care pathways
210
208
  ? (0, formatting_util_1.dateEncode)((0, formatting_util_1.toMoment)(invoicingCode.dateCode).toDate())