@hipnation-truth/sdk 0.26.11 → 0.26.12

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/react.js CHANGED
@@ -2754,6 +2754,17 @@ function useConversationTasksByPhonePair(phonePair) {
2754
2754
 
2755
2755
  // src/react/hooks.ts
2756
2756
  var import_react5 = require("react");
2757
+
2758
+ // src/react/elation-id.ts
2759
+ function toFiniteElationId(value) {
2760
+ if (value === void 0 || value === null || value === "") {
2761
+ return void 0;
2762
+ }
2763
+ const n = typeof value === "number" ? value : Number(value);
2764
+ return Number.isFinite(n) ? n : void 0;
2765
+ }
2766
+
2767
+ // src/react/hooks.ts
2757
2768
  var import_server5 = require("convex/server");
2758
2769
  var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
2759
2770
  var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
@@ -2837,24 +2848,25 @@ function usePatientMedical(elationId, options) {
2837
2848
  const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
2838
2849
  const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
2839
2850
  const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
2851
+ const id = toFiniteElationId(elationId);
2840
2852
  const medications = usePersistentQuery(
2841
2853
  medicationsByPatientRef,
2842
- elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2854
+ id !== void 0 ? { elationPatientId: id } : "skip"
2843
2855
  );
2844
2856
  const problems = usePersistentQuery(
2845
2857
  problemsByPatientRef,
2846
- elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2858
+ id !== void 0 ? { elationPatientId: id } : "skip"
2847
2859
  );
2848
2860
  const allergies = usePersistentQuery(
2849
2861
  allergiesByPatientRef,
2850
- elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2862
+ id !== void 0 ? { elationPatientId: id } : "skip"
2851
2863
  );
2852
2864
  const appointments = usePersistentQuery(
2853
2865
  appointmentsByPatientRef,
2854
- elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2866
+ id !== void 0 ? { elationPatientId: id } : "skip"
2855
2867
  );
2856
2868
  (0, import_react5.useEffect)(() => {
2857
- if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
2869
+ if (id === void 0 || (options == null ? void 0 : options.skipRefresh)) {
2858
2870
  return;
2859
2871
  }
2860
2872
  if (!apiBaseUrl || !apiKey) {
@@ -2865,12 +2877,12 @@ function usePatientMedical(elationId, options) {
2865
2877
  `${apiBaseUrl}/api/patients/medical/refresh`,
2866
2878
  apiKey,
2867
2879
  getAuthToken,
2868
- { elationId },
2880
+ { elationId: id },
2869
2881
  controller.signal
2870
2882
  ).catch(() => {
2871
2883
  });
2872
2884
  return () => controller.abort();
2873
- }, [elationId, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
2885
+ }, [id, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
2874
2886
  return { medications, problems, allergies, appointments };
2875
2887
  }
2876
2888
  var elationPatientByIdRef = (0, import_server5.makeFunctionReference)("elationPatients:getByElationId");
@@ -2883,9 +2895,10 @@ function usePatientBasic(input, options) {
2883
2895
  const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
2884
2896
  const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
2885
2897
  const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
2898
+ const elationId = toFiniteElationId(input.elationId);
2886
2899
  const elationRow = usePersistentQuery(
2887
2900
  elationPatientByIdRef,
2888
- input.elationId !== void 0 ? { elationId: input.elationId } : "skip"
2901
+ elationId !== void 0 ? { elationId } : "skip"
2889
2902
  );
2890
2903
  const hintRow = usePersistentQuery(
2891
2904
  hintPatientByIdRef,
@@ -2895,7 +2908,7 @@ function usePatientBasic(input, options) {
2895
2908
  if (options == null ? void 0 : options.skipRefresh) {
2896
2909
  return;
2897
2910
  }
2898
- if (!input.hintId && input.elationId === void 0) {
2911
+ if (!input.hintId && elationId === void 0) {
2899
2912
  return;
2900
2913
  }
2901
2914
  if (!apiBaseUrl || !apiKey) {
@@ -2906,14 +2919,14 @@ function usePatientBasic(input, options) {
2906
2919
  `${apiBaseUrl}/api/patients/basic/refresh`,
2907
2920
  apiKey,
2908
2921
  getAuthToken,
2909
- { hintId: input.hintId, elationId: input.elationId },
2922
+ { hintId: input.hintId, elationId },
2910
2923
  controller.signal
2911
2924
  ).catch(() => {
2912
2925
  });
2913
2926
  return () => controller.abort();
2914
2927
  }, [
2915
2928
  input.hintId,
2916
- input.elationId,
2929
+ elationId,
2917
2930
  apiBaseUrl,
2918
2931
  apiKey,
2919
2932
  getAuthToken,
@@ -2921,7 +2934,7 @@ function usePatientBasic(input, options) {
2921
2934
  ]);
2922
2935
  const elationPatient = elationRow === void 0 ? void 0 : elationRow === null ? null : (_c = elationRow.raw) != null ? _c : null;
2923
2936
  const hintPatient = hintRow === void 0 ? void 0 : hintRow === null ? null : (_d = hintRow.raw) != null ? _d : null;
2924
- const elationLoading = input.elationId !== void 0 && elationRow === void 0;
2937
+ const elationLoading = elationId !== void 0 && elationRow === void 0;
2925
2938
  const hintLoading = input.hintId !== void 0 && hintRow === void 0;
2926
2939
  return {
2927
2940
  elationPatient,
@@ -2943,15 +2956,16 @@ function usePatientPhoto(elationId, options) {
2943
2956
  const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
2944
2957
  const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
2945
2958
  const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
2959
+ const id = toFiniteElationId(elationId);
2946
2960
  const photo = usePersistentQuery(
2947
2961
  patientPhotoByIdRef,
2948
- elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2962
+ id !== void 0 ? { elationPatientId: id } : "skip"
2949
2963
  );
2950
2964
  (0, import_react5.useEffect)(() => {
2951
2965
  if (options == null ? void 0 : options.skipRefresh) {
2952
2966
  return;
2953
2967
  }
2954
- if (elationId === void 0) {
2968
+ if (id === void 0) {
2955
2969
  return;
2956
2970
  }
2957
2971
  if (!apiBaseUrl || !apiKey) {
@@ -2962,12 +2976,12 @@ function usePatientPhoto(elationId, options) {
2962
2976
  `${apiBaseUrl}/api/patients/photo/refresh`,
2963
2977
  apiKey,
2964
2978
  getAuthToken,
2965
- { elationId },
2979
+ { elationId: id },
2966
2980
  controller.signal
2967
2981
  ).catch(() => {
2968
2982
  });
2969
2983
  return () => controller.abort();
2970
- }, [elationId, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
2984
+ }, [id, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
2971
2985
  return photo;
2972
2986
  }
2973
2987
  var messagesByPhonesRef = (0, import_server5.makeFunctionReference)("conversationMessages:getByPhones");