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