@phenyxhealth/importer 1.1.14 → 1.1.16

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": "@phenyxhealth/importer",
3
- "version": "1.1.14",
3
+ "version": "1.1.16",
4
4
  "type": "module",
5
5
  "description": "Imports a Phenyx-compatible JSON file with patients into a PhenyxHealth instance.",
6
6
  "publishConfig": {
@@ -1,17 +1,18 @@
1
- import ApiInstance from '../services/phenyxSdkInstance.js';
2
- import { login } from '../controllers/login.js';
1
+ import { PhenyxSDK } from '@phenyxhealth/sdk';
3
2
 
4
3
  const clearPatients = async (config) => {
5
- await login(config);
6
-
7
- const allPatients = await ApiInstance.getPatients();
4
+ const { apiUrl: apiHost, apiUser: user, apiPwd: password } = config;
5
+ const api = new PhenyxSDK();
6
+ await api.login({ apiHost, user, password });
7
+
8
+ const allPatients = await api.getPatients();
8
9
  const allPatientsIds = allPatients.map(p => p.id);
9
10
 
10
11
  for (const patientId of allPatientsIds) {
11
12
  console.log(`Deleting patient ${patientId}`);
12
- await ApiInstance.deletePatient(patientId);
13
+ await api.deletePatient(patientId);
13
14
  }
14
-
15
+
15
16
  console.log('All patients deleted');
16
17
  };
17
18
 
@@ -1,11 +1,11 @@
1
1
  import path from 'path';
2
2
  import { loadJson } from '@dmbejar/json-files';
3
- import { checkGlobals, beSureDoctorExists, beSureLinacsExists } from '@phenyxhealth/sdk';
4
- import ApiInstance from '../services/phenyxSdkInstance.js';
5
- import { login } from '../controllers/login.js';
3
+ import { PhenyxSDK, checkGlobals, beSureDoctorExists, beSureLinacsExists } from '@phenyxhealth/sdk';
6
4
  import { getListFromField } from '../utils/text.js';
7
5
 
8
6
  const importer = async (config) => {
7
+ const ApiInstance = new PhenyxSDK();
8
+
9
9
  // Config
10
10
  ApiInstance.showLogs(config.showLogs);
11
11
 
@@ -28,7 +28,8 @@ const importer = async (config) => {
28
28
  }
29
29
 
30
30
  console.log('\nLogin...');
31
- await login(config);
31
+ const { apiUrl: apiHost, apiUser: user, apiPwd: password } = config;
32
+ await ApiInstance.login({ apiHost, user, password });
32
33
 
33
34
  // check globals
34
35
  console.log('\nVerifying globals...');
@@ -168,8 +169,6 @@ const importer = async (config) => {
168
169
  sendingDepartment: ApiInstance.getSendingDepartmentIdByName(registration.sendingDepartment),
169
170
  },
170
171
  consultation: {
171
- // Hay que eliminar cei, la correcta es cie
172
- cei: ApiInstance.getCie10ByCode(consultation.cie10).id, // <-- Borrar esta línea
173
172
  cie: ApiInstance.getCie10ByCode(consultation.cie10).id,
174
173
  tnm: consultation.tnm,
175
174
  estadio: consultation.stage,
@@ -294,7 +293,7 @@ const importer = async (config) => {
294
293
  confirmedLinac: linacs.find(linac => linac.name === dosimetry.confirmedLinac)?.id || '',
295
294
  treatmentTechnique: ApiInstance.getGlobalInfoElementId(ApiInstance.globalTypes.treatmentTechnique, treatmentDefinition.treatmentTechnique),
296
295
  tentativeTreatmentStart: treatmentDelivery.tentativeTreatmentStartDate,
297
- confirmedTreatmentStart: treatmentDelivery.confirmedTreatmentStartingDate,
296
+ confirmedTreatmentStart: treatmentDelivery.confirmedTreatmentStartDate,
298
297
  numberOfCompleteSessions: treatmentDelivery.completedSessions || 0,
299
298
  numberOfPendingSessions: treatmentDelivery.totalSessions
300
299
  ? treatmentDelivery.totalSessions - (treatmentDelivery.completedSessions || 0)
@@ -1,15 +0,0 @@
1
- import ApiInstance from '../services/phenyxSdkInstance.js';
2
-
3
- const login = (config) => {
4
- const {
5
- apiUrl: apiHost,
6
- apiUser: user,
7
- apiPwd: password,
8
- } = config;
9
-
10
- return ApiInstance.login({ apiHost, user, password });
11
- };
12
-
13
- export {
14
- login,
15
- };
@@ -1,5 +0,0 @@
1
- import { PhenyxSDK } from '@phenyxhealth/sdk';
2
-
3
- const phenyxSdkInstance = new PhenyxSDK();
4
-
5
- export default phenyxSdkInstance;