@icure/be-fhc-api 0.6.6 → 0.6.7

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.
@@ -39,6 +39,9 @@ export declare class InvoiceItem {
39
39
  timeOfDay?: InvoiceItem.TimeOfDayEnum;
40
40
  transplantationCode?: InvoiceItem.TransplantationCodeEnum;
41
41
  units?: number;
42
+ options?: {
43
+ [key: string]: string;
44
+ };
42
45
  }
43
46
  export declare namespace InvoiceItem {
44
47
  type DerogationMaxNumberEnum = "Other" | "DerogationMaxNumber" | "OtherPrescription" | "SecondPrestationOfDay" | "ThirdAndNextPrestationOfDay";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icure/be-fhc-api",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "Typescript version of Freehealth Connector standalone API client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -585,6 +585,14 @@ class MessageXApi {
585
585
  });
586
586
  }
587
587
  }
588
+ if (r.et25 && r.et25.errorDetail) {
589
+ let refEt25 = r.et25.invoiceReference.trim();
590
+ errors.push({
591
+ itemId: (0, efact_util_1.decodeBase36Uuid)(refEt25),
592
+ error: r.et25.errorDetail,
593
+ record: "ET25"
594
+ });
595
+ }
588
596
  _.each(r.items, i => {
589
597
  let ref = (i.et50 && i.et50.itemReference.trim()) || refEt20; //fallback
590
598
  if (i.et50 && i.et50.errorDetail) {
@@ -809,7 +817,11 @@ class MessageXApi {
809
817
  return (0, efact_util_1.getFederaton)(invoices, this.insuranceApi).then(fed => {
810
818
  return (prefixer
811
819
  ? prefixer(fed, hcp.id)
812
- : Promise.resolve(`efact:${hcp.id}:${year}:${fed.code === "306" ? "300" : fed.code === "675" ? "600" : fed.code}:`)).then(prefix => {
820
+ : Promise.resolve(`efact:${hcp.id}:${year}:${fed.code === "306"
821
+ ? "300"
822
+ : fed.code === "675" || fed.code === "690"
823
+ ? "600"
824
+ : fed.code}:`)).then(prefix => {
813
825
  return this.entityReferenceApi
814
826
  .getLatest(prefix)
815
827
  .then((er) => er && er.id && er.id.startsWith(prefix)
@@ -67,6 +67,25 @@ export interface ET20Data extends ETData {
67
67
  insurabilityStartDate: string;
68
68
  insurabilityEndDate: string;
69
69
  }
70
+ export interface ET25Data extends ETData {
71
+ recordOrderNumber: string;
72
+ mutualityCode: string;
73
+ ssin: string;
74
+ sexe: string;
75
+ urgencyMedicalAssistance: string;
76
+ nihii: string;
77
+ establishmentStayNumber: string;
78
+ mutualityDestination: string;
79
+ codeCover: string;
80
+ invoiceNumber: string;
81
+ invoiceReference: string;
82
+ identityFlag: string;
83
+ cbePcsa: string;
84
+ refElectronicAMU: string;
85
+ cardNumber: string;
86
+ versionNumber: string;
87
+ recordControlNumber: string;
88
+ }
70
89
  export interface ET50Data extends ETData {
71
90
  recordOrderNumber: string;
72
91
  sex: string;
@@ -149,6 +168,7 @@ export interface ET92Data {
149
168
  }
150
169
  export interface ET20_80Data {
151
170
  et20: ET20Data;
171
+ et25?: ET25Data;
152
172
  items: Array<{
153
173
  et50?: ET50Data | undefined;
154
174
  et51?: ET51Data | undefined;
@@ -202,6 +222,7 @@ export declare abstract class EfactMessageReader {
202
222
  readZone300Short(zone300: Record): Zone300Short;
203
223
  readET10(et10: Record): ET10Data;
204
224
  readET20(et20: Record): ET20Data;
225
+ readET25(et25: Record): ET25Data;
205
226
  readET50(et50: Record): ET50Data;
206
227
  readET51(et51: Record): ET51Data;
207
228
  readET52(et52: Record): ET52Data;
@@ -291,6 +291,55 @@ class EfactMessageReader {
291
291
  insurabilityEndDate
292
292
  };
293
293
  }
294
+ readET25(et25) {
295
+ const etNumber = 25;
296
+ let i = 0;
297
+ if (et25.zones[i].value !== etNumber.toString()) {
298
+ throw new Error(`Trying to parse an ET${etNumber} that is not an ET${etNumber} --- ${JSON.stringify(et25)}`);
299
+ }
300
+ i++;
301
+ this.log("EnregistrementDeType25", et25.zones[i].value);
302
+ const recordOrderNumber = this.log("NumOrdreEnregistrement", et25.zones[i++].value);
303
+ const mutualityCode = this.log("NumMutuelleAffiliation", et25.zones[i++].value);
304
+ const ssin = this.log("NumIdentificationMediprima", et25.zones[i++].value);
305
+ const sexe = this.log("CodeSexeBeneficiaire", et25.zones[i++].value);
306
+ const urgencyMedicalAssistance = this.log("CodeAideMedicaleUrgente", et25.zones[i++].value);
307
+ const nihii = this.log("NumEtablissementQuiFacture", et25.zones[i++].value);
308
+ const establishmentStayNumber = this.log("NumEtablissementDeSejour", et25.zones[i++].value);
309
+ const mutualityDestination = this.log("NumMutualiteDestination", et25.zones[i++].value);
310
+ const invoiceNumber = this.log("NumFactureIndividuelle", et25.zones[i++].value);
311
+ const codeCover = this.log("CodeCouverture", et25.zones[i++].value);
312
+ const invoiceReference = this.log("ReferenceDeLetablissement", et25.zones[i++].value);
313
+ const identityFlag = this.log("FlagIdentificationDuBeneficiaire", et25.zones[i++].value);
314
+ const cbePcsa = this.log("NumBceCpas", et25.zones[i++].value);
315
+ const refElectronicAMU = this.log("ReferenceAMUElectronique", et25.zones[i++].value);
316
+ const cardNumber = this.log("NumeroCarte", et25.zones[i++].value);
317
+ const versionNumber = this.log("NumVersionCarte", et25.zones[i++].value);
318
+ const recordControlNumber = this.log("ChiffreDeControle", et25.zones[i++].value);
319
+ if (i !== et25.zones.length) {
320
+ throw new Error(`You didn\'t parse every zones of the ET${etNumber}`);
321
+ }
322
+ return {
323
+ errorDetail: et25.errorDetail,
324
+ recordOrderNumber: recordOrderNumber,
325
+ mutualityCode: mutualityCode,
326
+ ssin: ssin,
327
+ sexe: sexe,
328
+ urgencyMedicalAssistance: urgencyMedicalAssistance,
329
+ nihii: nihii,
330
+ establishmentStayNumber: establishmentStayNumber,
331
+ codeCover: codeCover,
332
+ invoiceReference: invoiceReference,
333
+ identityFlag: identityFlag,
334
+ cbePcsa: cbePcsa,
335
+ refElectronicAMU: refElectronicAMU,
336
+ cardNumber: cardNumber,
337
+ versionNumber: versionNumber,
338
+ recordControlNumber: recordControlNumber,
339
+ mutualityDestination: mutualityDestination,
340
+ invoiceNumber: invoiceNumber
341
+ };
342
+ }
294
343
  readET50(et50) {
295
344
  const etNumber = 50;
296
345
  let i = 0;
@@ -867,6 +916,10 @@ class EfactMessage920900Reader extends EfactMessageReader {
867
916
  while (rawRecords[i].zones[0].value === "20") {
868
917
  const et20 = this.readET20(rawRecords[i]);
869
918
  i++;
919
+ if (rawRecords[i].zones[0].value === "25") {
920
+ const et25 = this.readET25(rawRecords[i]);
921
+ i++;
922
+ }
870
923
  const items = [];
871
924
  while (rawRecords[i].zones[0].value === "50" ||
872
925
  rawRecords[i].zones[0].value === "51" ||
@@ -961,6 +1014,10 @@ class EfactMessage920099Reader extends EfactMessageReader {
961
1014
  while (rawRecords[i].zones[0].value === "20") {
962
1015
  const et20 = this.readET20(rawRecords[i]);
963
1016
  i++;
1017
+ if (rawRecords[i].zones[0].value === "25") {
1018
+ const et25 = this.readET25(rawRecords[i]);
1019
+ i++;
1020
+ }
964
1021
  const items = [];
965
1022
  while (rawRecords[i].zones[0].value === "50" ||
966
1023
  rawRecords[i].zones[0].value === "51" ||
@@ -1033,6 +1090,10 @@ class EfactMessage920098Reader extends EfactMessageReader {
1033
1090
  while (rawRecords[i].zones[0].value === "20") {
1034
1091
  const et20 = this.readET20(rawRecords[i]);
1035
1092
  i++;
1093
+ if (rawRecords[i].zones[0].value === "25") {
1094
+ const et25 = this.readET25(rawRecords[i]);
1095
+ i++;
1096
+ }
1036
1097
  const items = [];
1037
1098
  while (rawRecords[i].zones[0].value === "50" ||
1038
1099
  rawRecords[i].zones[0].value === "51" ||
@@ -19,8 +19,10 @@ const moment = require("moment");
19
19
  const uuid_encoder_1 = require("./uuid-encoder");
20
20
  const base36UUID = new uuid_encoder_1.UuidEncoder();
21
21
  function ensureNoFederation(invoices, insurances) {
22
- // We will check here for recipient which are federations (except 306).
23
- const federations = insurances.filter(i => i.code !== "306" && i.code !== "675" && i.id === i.parent);
22
+ // We will check here for recipient which are federations (except 306, 675, 690).
23
+ // 675 => Mutuality for marines
24
+ // 690 => Mutuality for Public Centres for Social Welfare
25
+ const federations = insurances.filter(i => i.code !== "306" && i.code !== "675" && i.code !== "690" && i.id === i.parent);
24
26
  if (federations.length > 0) {
25
27
  console.error(`Invoices directed to ${federations.map(i => i.code).join()}, invoices ${invoices.map(i => i.invoice.id)}`);
26
28
  throw "Some invoices are directly destinated to federations inside of mutuality office !";
@@ -251,6 +253,7 @@ function toInvoiceItem(nihiiHealthcareProvider, patient, invoice, invoicingCode,
251
253
  invoiceItem.units = invoicingCode.units || 1;
252
254
  invoiceItem.derogationMaxNumber = getDerogationMaxNumber(invoicingCode.derogationMaxNumber || 0);
253
255
  invoiceItem.internshipNihii = invoice.internshipNihii;
256
+ invoiceItem.options = invoice.options;
254
257
  return invoiceItem;
255
258
  }
256
259
  function getPercentNorm(norm) {