@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/dist/index.mjs CHANGED
@@ -1424,8 +1424,7 @@ function useCurriculumRepo() {
1424
1424
  key: {
1425
1425
  name: 1,
1426
1426
  school: 1,
1427
- effectiveSchoolYear: 1,
1428
- status: 1
1427
+ effectiveSchoolYear: 1
1429
1428
  },
1430
1429
  unique: true,
1431
1430
  partialFilterExpression: { status: "active" },
@@ -3505,13 +3504,38 @@ function useEnrollmentRepo() {
3505
3504
  throw new Error("Failed to update enrollment status.");
3506
3505
  }
3507
3506
  }
3507
+ async function removeProgramById(_id, session) {
3508
+ try {
3509
+ _id = new ObjectId6(_id);
3510
+ } catch (error) {
3511
+ throw new BadRequestError9(namespace_collection + " Invalid ID.");
3512
+ }
3513
+ try {
3514
+ const result = await collection.updateOne(
3515
+ { _id },
3516
+ {
3517
+ $set: {
3518
+ specialProgram: "",
3519
+ specialProgramName: "",
3520
+ updatedAt: /* @__PURE__ */ new Date()
3521
+ }
3522
+ },
3523
+ { session }
3524
+ );
3525
+ delCachedData();
3526
+ return result;
3527
+ } catch (error) {
3528
+ throw new Error("Failed to update enrollment program.");
3529
+ }
3530
+ }
3508
3531
  return {
3509
3532
  createIndexes,
3510
3533
  add,
3511
3534
  getAll,
3512
3535
  getByApplicantInfo,
3513
3536
  updateStatusById,
3514
- getById
3537
+ getById,
3538
+ removeProgramById
3515
3539
  };
3516
3540
  }
3517
3541
 
@@ -4696,7 +4720,7 @@ import Joi11 from "joi";
4696
4720
  // src/resources/program-screening/program.screening.service.ts
4697
4721
  import { AppError as AppError8, useAtlas as useAtlas8 } from "@eeplatform/nodejs-utils";
4698
4722
  function useProgramScreeningService() {
4699
- const { updateStatusById: updateEnrollmentStatusById } = useEnrollmentRepo();
4723
+ const { updateStatusById: updateEnrollmentStatusById, removeProgramById } = useEnrollmentRepo();
4700
4724
  const { updateFieldById, getById: getProgramScreeningById } = useProgramScreeningRepo();
4701
4725
  async function updateStatusById(id, status) {
4702
4726
  const session = useAtlas8.getClient()?.startSession();
@@ -4712,6 +4736,9 @@ function useProgramScreeningService() {
4712
4736
  );
4713
4737
  let enrollmentStatus = "pending";
4714
4738
  const ReclassifyCond = status === "reclassified" && application.status && ["failed", "withdrawn"].includes(application.status);
4739
+ if (ReclassifyCond) {
4740
+ await removeProgramById(String(application.applicant), session);
4741
+ }
4715
4742
  if (status === "passed" && application.status === "pending" || ReclassifyCond) {
4716
4743
  enrollmentStatus = "pending";
4717
4744
  }