@eeplatform/basic-edu 1.10.15 → 1.10.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eeplatform/basic-edu
2
2
 
3
+ ## 1.10.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 7be68b4: Fix curriculum index
8
+
9
+ ## 1.10.16
10
+
11
+ ### Patch Changes
12
+
13
+ - 7d830d3: Add removeProgramById to enrollment repo and service
14
+
3
15
  ## 1.10.15
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -383,6 +383,7 @@ declare function useEnrollmentRepo(): {
383
383
  }>;
384
384
  updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
385
385
  getById: (_id: string | ObjectId, status?: string) => Promise<TEnrollment | null>;
386
+ removeProgramById: (_id: string | ObjectId, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
386
387
  };
387
388
 
388
389
  declare function useEnrollmentService(): {
package/dist/index.js CHANGED
@@ -1549,8 +1549,7 @@ function useCurriculumRepo() {
1549
1549
  key: {
1550
1550
  name: 1,
1551
1551
  school: 1,
1552
- effectiveSchoolYear: 1,
1553
- status: 1
1552
+ effectiveSchoolYear: 1
1554
1553
  },
1555
1554
  unique: true,
1556
1555
  partialFilterExpression: { status: "active" },
@@ -3607,13 +3606,38 @@ function useEnrollmentRepo() {
3607
3606
  throw new Error("Failed to update enrollment status.");
3608
3607
  }
3609
3608
  }
3609
+ async function removeProgramById(_id, session) {
3610
+ try {
3611
+ _id = new import_mongodb6.ObjectId(_id);
3612
+ } catch (error) {
3613
+ throw new import_nodejs_utils9.BadRequestError(namespace_collection + " Invalid ID.");
3614
+ }
3615
+ try {
3616
+ const result = await collection.updateOne(
3617
+ { _id },
3618
+ {
3619
+ $set: {
3620
+ specialProgram: "",
3621
+ specialProgramName: "",
3622
+ updatedAt: /* @__PURE__ */ new Date()
3623
+ }
3624
+ },
3625
+ { session }
3626
+ );
3627
+ delCachedData();
3628
+ return result;
3629
+ } catch (error) {
3630
+ throw new Error("Failed to update enrollment program.");
3631
+ }
3632
+ }
3610
3633
  return {
3611
3634
  createIndexes,
3612
3635
  add,
3613
3636
  getAll,
3614
3637
  getByApplicantInfo,
3615
3638
  updateStatusById,
3616
- getById
3639
+ getById,
3640
+ removeProgramById
3617
3641
  };
3618
3642
  }
3619
3643
 
@@ -4767,7 +4791,7 @@ var import_joi11 = __toESM(require("joi"));
4767
4791
  // src/resources/program-screening/program.screening.service.ts
4768
4792
  var import_nodejs_utils16 = require("@eeplatform/nodejs-utils");
4769
4793
  function useProgramScreeningService() {
4770
- const { updateStatusById: updateEnrollmentStatusById } = useEnrollmentRepo();
4794
+ const { updateStatusById: updateEnrollmentStatusById, removeProgramById } = useEnrollmentRepo();
4771
4795
  const { updateFieldById, getById: getProgramScreeningById } = useProgramScreeningRepo();
4772
4796
  async function updateStatusById(id, status) {
4773
4797
  const session = import_nodejs_utils16.useAtlas.getClient()?.startSession();
@@ -4783,6 +4807,9 @@ function useProgramScreeningService() {
4783
4807
  );
4784
4808
  let enrollmentStatus = "pending";
4785
4809
  const ReclassifyCond = status === "reclassified" && application.status && ["failed", "withdrawn"].includes(application.status);
4810
+ if (ReclassifyCond) {
4811
+ await removeProgramById(String(application.applicant), session);
4812
+ }
4786
4813
  if (status === "passed" && application.status === "pending" || ReclassifyCond) {
4787
4814
  enrollmentStatus = "pending";
4788
4815
  }