-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
1227 lines (1108 loc) · 49.2 KB
/
Copy pathapp.py
File metadata and controls
1227 lines (1108 loc) · 49.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import annotations
import uuid
from datetime import date, datetime
from pathlib import Path
import pandas as pd
import streamlit as st
APP_DIR = Path(__file__).resolve().parent
DATA_DIR = APP_DIR / "data"
CSV_PATH = DATA_DIR / "prospects.csv"
SEGMENTS = [
"NGO",
"CSR",
"Hospital",
"Government",
"Occupational Health",
"Research Institution",
]
FIT_SCORES = ["High", "Medium", "Low"]
STAGES = [
"Prospect Identified",
"Contacted",
"Discovery",
"Proposal",
"Negotiation",
"Won",
"Lost",
]
CSV_COLUMNS = [
"id",
"organisation_name",
"segment",
"state",
"website",
"contact_person",
"email",
"disease_focus",
"fit_score",
"stage",
"deal_value",
"probability",
"next_follow_up_date",
"notes",
"created_at",
"updated_at",
]
def configure_page() -> None:
st.set_page_config(
page_title="Respyr BD OS",
page_icon="🫁",
layout="wide",
initial_sidebar_state="expanded",
)
st.markdown(
"""
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
/* ════ BASE ════ */
html, body, .stApp {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
background-color: #f5f7fa !important;
color: #0f172a !important;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* ════ SIDEBAR — LIGHT ════ */
[data-testid="stSidebar"] {
background: #ffffff !important;
border-right: 1px solid #e8edf2 !important;
}
[data-testid="stSidebar"] * {
font-family: 'Inter', sans-serif !important;
}
[data-testid="stSidebar"] p,
[data-testid="stSidebar"] span {
color: #64748b !important;
}
[data-testid="stSidebarContent"] hr {
border: none !important;
border-top: 1px solid #e8edf2 !important;
margin: 6px 0 !important;
}
[data-testid="stSidebar"] label {
display: block;
padding: 9px 12px !important;
border-radius: 8px !important;
color: #334155 !important;
font-size: 0.875rem !important;
font-weight: 500 !important;
transition: background 0.12s ease, color 0.12s ease !important;
cursor: pointer !important;
line-height: 1.4 !important;
}
[data-testid="stSidebar"] label:hover {
background: #f1f5f9 !important;
color: #0f172a !important;
}
/* Hide the radio dot */
[data-testid="stSidebar"] [data-baseweb="radio"] svg { display: none !important; }
[data-testid="stSidebar"] [data-baseweb="radio"] > div:first-child { display: none !important; }
/* ════ LAYOUT ════ */
.block-container {
padding-top: 2.25rem !important;
padding-bottom: 4rem !important;
max-width: 1400px !important;
margin: 0 auto !important;
}
/* ════ TYPOGRAPHY ════ */
h1 {
font-size: 1.875rem !important;
font-weight: 800 !important;
letter-spacing: -0.04em !important;
color: #0f172a !important;
line-height: 1.15 !important;
margin-bottom: 0.15rem !important;
}
h2 {
font-size: 1.1rem !important;
font-weight: 700 !important;
letter-spacing: -0.025em !important;
color: #0f172a !important;
line-height: 1.3 !important;
}
h3 {
font-size: 0.95rem !important;
font-weight: 700 !important;
letter-spacing: -0.015em !important;
color: #1e293b !important;
}
p, li, span {
color: #334155 !important;
}
/* ════ METRIC TILES ════ */
div[data-testid="stMetric"] {
background: #ffffff;
border: 1px solid #e8edf2;
border-top: 3px solid #0d9488;
border-radius: 14px;
padding: 20px 24px 22px;
box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 4px 16px rgba(15,23,42,0.04);
transition: transform 0.18s cubic-bezier(.4,0,.2,1), box-shadow 0.18s cubic-bezier(.4,0,.2,1);
}
div[data-testid="stMetric"]:hover {
transform: translateY(-3px);
box-shadow: 0 6px 12px rgba(15,23,42,0.07), 0 16px 40px rgba(15,23,42,0.09);
}
div[data-testid="stMetric"] label {
font-size: 0.7rem !important;
font-weight: 700 !important;
text-transform: uppercase !important;
letter-spacing: 0.09em !important;
color: #94a3b8 !important;
}
div[data-testid="stMetric"] [data-testid="stMetricValue"] {
font-size: 1.85rem !important;
font-weight: 800 !important;
color: #0f172a !important;
letter-spacing: -0.04em !important;
line-height: 1.1 !important;
}
/* ════ CARDS ════ */
.respyr-card {
background: #ffffff;
border: 1px solid #e8edf2;
border-radius: 16px;
padding: 24px 28px;
margin-bottom: 20px;
box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 4px 16px rgba(15,23,42,0.03);
}
.respyr-hero {
background: linear-gradient(135deg, #0d9488 0%, #0f766e 45%, #134e4a 100%);
border-radius: 18px;
padding: 32px 38px;
margin-bottom: 28px;
position: relative;
overflow: hidden;
border: none;
box-shadow: 0 4px 24px rgba(13,148,136,0.3), 0 1px 4px rgba(13,148,136,0.2);
}
.respyr-hero::before {
content: "";
position: absolute;
width: 320px; height: 320px;
top: -120px; right: -60px;
background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 60%);
pointer-events: none;
}
.respyr-hero::after {
content: "";
position: absolute;
width: 200px; height: 200px;
bottom: -70px; left: 10%;
background: radial-gradient(circle, rgba(255,255,255,0.07) 0%, transparent 60%);
pointer-events: none;
}
.respyr-hero h2 {
color: #ffffff !important;
font-size: 1.45rem !important;
font-weight: 700 !important;
letter-spacing: -0.03em !important;
margin: 0 0 0.45rem 0 !important;
position: relative; z-index: 1;
}
.respyr-hero p {
color: rgba(255,255,255,0.7) !important;
margin: 0 !important;
font-size: 0.875rem !important;
position: relative; z-index: 1;
line-height: 1.6 !important;
}
/* ════ CHARTS ════ */
[data-testid="stArrowVegaLiteChart"] {
background: #ffffff;
border-radius: 14px;
padding: 16px 12px 8px;
border: 1px solid #e8edf2;
box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 4px 12px rgba(15,23,42,0.03);
}
/* ════ FORM CARD ════ */
[data-testid="stForm"] {
background: #ffffff !important;
border: 1px solid #e8edf2 !important;
border-radius: 16px !important;
padding: 24px 28px !important;
box-shadow: 0 1px 3px rgba(15,23,42,0.04) !important;
}
/* ════ BUTTONS ════ */
.stButton > button {
border-radius: 10px !important;
padding: 9px 20px !important;
font-weight: 600 !important;
font-size: 0.875rem !important;
letter-spacing: 0.005em !important;
font-family: 'Inter', sans-serif !important;
transition: all 0.15s cubic-bezier(0.4,0,0.2,1) !important;
border: 1px solid #e8edf2 !important;
color: #334155 !important;
background: #ffffff !important;
box-shadow: 0 1px 2px rgba(15,23,42,0.05) !important;
}
.stButton > button[kind="primary"] {
background: #0d9488 !important;
border-color: #0d9488 !important;
color: #ffffff !important;
box-shadow: 0 1px 2px rgba(13,148,136,0.2), 0 4px 14px rgba(13,148,136,0.22) !important;
}
.stButton > button[kind="primary"]:hover {
background: #0f766e !important;
border-color: #0f766e !important;
box-shadow: 0 2px 6px rgba(13,148,136,0.25), 0 10px 28px rgba(13,148,136,0.28) !important;
transform: translateY(-1px) !important;
}
.stButton > button:not([kind="primary"]):hover {
background: #f8fafc !important;
border-color: #cbd5e1 !important;
color: #0f172a !important;
}
/* ════ INPUTS ════ */
.stTextInput input,
.stTextArea textarea,
.stNumberInput input {
border-radius: 10px !important;
border: 1px solid #e8edf2 !important;
background: #ffffff !important;
font-family: 'Inter', sans-serif !important;
font-size: 0.875rem !important;
color: #0f172a !important;
box-shadow: 0 1px 2px rgba(15,23,42,0.04) !important;
transition: border-color 0.15s, box-shadow 0.15s !important;
}
.stTextInput input:focus,
.stTextArea textarea:focus,
.stNumberInput input:focus {
border-color: #0d9488 !important;
box-shadow: 0 0 0 3px rgba(13,148,136,0.12), 0 1px 2px rgba(15,23,42,0.04) !important;
outline: none !important;
}
.stTextInput label, .stTextArea label, .stNumberInput label,
.stSelectbox label, .stSlider label, .stDateInput label,
.stMultiSelect label {
font-size: 0.8rem !important;
font-weight: 600 !important;
letter-spacing: 0.01em !important;
color: #475569 !important;
}
/* ════ TABS ════ */
.stTabs [data-baseweb="tab-list"] {
gap: 3px !important;
background: #eef2f7 !important;
padding: 4px !important;
border-radius: 12px !important;
border: 1px solid #e8edf2 !important;
width: fit-content !important;
margin-bottom: 20px !important;
}
.stTabs [data-baseweb="tab"] {
border-radius: 9px !important;
font-weight: 600 !important;
font-size: 0.84rem !important;
padding: 8px 22px !important;
color: #64748b !important;
background: transparent !important;
border: none !important;
letter-spacing: 0.005em !important;
transition: color 0.12s !important;
}
.stTabs [aria-selected="true"] {
background: #ffffff !important;
color: #0f172a !important;
box-shadow: 0 1px 4px rgba(15,23,42,0.1), 0 0 0 1px rgba(15,23,42,0.06) !important;
}
.stTabs [data-baseweb="tab-highlight"],
.stTabs [data-baseweb="tab-border"] { display: none !important; }
/* ════ SELECT / MULTISELECT ════ */
[data-baseweb="select"] > div:first-child {
border-radius: 10px !important;
border: 1px solid #e8edf2 !important;
background: #ffffff !important;
font-size: 0.875rem !important;
font-family: 'Inter', sans-serif !important;
box-shadow: 0 1px 2px rgba(15,23,42,0.04) !important;
}
/* ════ DATA TABLES ════ */
[data-testid="stDataFrame"],
[data-testid="stDataEditor"] {
border-radius: 14px !important;
overflow: hidden !important;
border: 1px solid #e8edf2 !important;
box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 4px 12px rgba(15,23,42,0.03) !important;
}
/* ════ MISC ════ */
[data-testid="stAlert"] { border-radius: 12px !important; font-size: 0.875rem !important; }
hr { border: none !important; border-top: 1px solid #e8edf2 !important; }
.small-muted { color: #94a3b8 !important; font-size: 0.85rem !important; }
[data-testid="stCaption"] { color: #94a3b8 !important; font-size: 0.8rem !important; }
[data-testid="stDownloadButton"] button {
border-radius: 10px !important;
font-weight: 600 !important;
font-size: 0.875rem !important;
font-family: 'Inter', sans-serif !important;
}
</style>
""",
unsafe_allow_html=True,
)
def ensure_data_file() -> None:
DATA_DIR.mkdir(parents=True, exist_ok=True)
if not CSV_PATH.exists():
pd.DataFrame(columns=CSV_COLUMNS).to_csv(CSV_PATH, index=False)
def load_prospects() -> pd.DataFrame:
ensure_data_file()
try:
df = pd.read_csv(CSV_PATH)
except pd.errors.EmptyDataError:
df = pd.DataFrame(columns=CSV_COLUMNS)
for column in CSV_COLUMNS:
if column not in df.columns:
df[column] = ""
df = df[CSV_COLUMNS].copy()
df["deal_value"] = pd.to_numeric(df["deal_value"], errors="coerce").fillna(0.0)
df["probability"] = pd.to_numeric(df["probability"], errors="coerce").fillna(0.0)
df["next_follow_up_date"] = pd.to_datetime(
df["next_follow_up_date"], errors="coerce"
)
return df
def save_prospects(df: pd.DataFrame) -> None:
output = df.copy()
output["next_follow_up_date"] = pd.to_datetime(
output["next_follow_up_date"], errors="coerce"
).dt.strftime("%Y-%m-%d")
output.to_csv(CSV_PATH, index=False)
def money(value: float) -> str:
return f"₹{value:,.0f}"
def compact_money(value: float) -> str:
if value >= 10_000_000:
return f"₹{value / 10_000_000:.1f} Cr"
if value >= 100_000:
return f"₹{value / 100_000:.1f} L"
if value >= 1_000:
return f"₹{value / 1_000:.1f} K"
return money(value)
def organisation_options(df: pd.DataFrame) -> list[str]:
if df.empty:
return []
return sorted(df["organisation_name"].dropna().astype(str).unique().tolist())
def get_prospect_by_name(df: pd.DataFrame, organisation: str) -> dict:
if not organisation or df.empty:
return {}
match = df[df["organisation_name"] == organisation]
return match.iloc[0].to_dict() if not match.empty else {}
def build_outreach_email(
segment: str,
organisation: str,
contact_person: str,
disease_focus: str,
state: str,
sender_name: str,
request: str,
) -> tuple[str, str]:
contact = contact_person.strip() or "there"
org = organisation.strip() or "your organisation"
focus = disease_focus.strip() or "priority respiratory and metabolic conditions"
location = state.strip() or "your target communities"
context = {
"NGO": (
f"your work with underserved communities in {location}",
"extend accessible screening without requiring a conventional laboratory setup",
"explore a community screening pilot for your beneficiaries",
),
"CSR": (
f"{org}'s focus on measurable health and social impact",
"create a scalable preventive-health programme with clear reach and outcome metrics",
"explore a CSR-supported screening initiative in a priority geography",
),
"Hospital": (
f"your commitment to earlier diagnosis and stronger care pathways",
"support high-throughput, non-invasive pre-screening and appropriate clinical referrals",
"evaluate a pilot within an OPD, outreach camp, or preventive-health programme",
),
"Government": (
f"the public-health priorities being addressed in {location}",
"enable population-level screening with a portable, non-invasive model",
"discuss a limited pilot aligned with existing public-health infrastructure",
),
"Occupational Health": (
f"the need to protect workforce health while keeping screening simple",
"offer convenient on-site screening with minimal disruption to operations",
"consider a workforce screening pilot at one site",
),
"Research Institution": (
f"your work in translational and population-health research",
"support evidence generation around breath biomarkers and real-world screening pathways",
"explore a validation study or research collaboration",
),
}
research, reward, default_request = context[segment]
request_line = request.strip() or default_request
subject = f"Exploring a breath-based screening collaboration with {org}"
body = f"""Dear {contact},
I have been following {research}. It is closely aligned with the problem Respyr is working to solve: making early health screening more accessible through breath-based, non-invasive technology.
Respyr is developing a portable screening approach for {focus}. A collaboration could help {reward}, while generating practical evidence on uptake, referrals, and programme outcomes.
Would you be open to a 25-minute conversation next week to {request_line}? I would be happy to share a concise pilot concept tailored to {org}.
Warm regards,
{sender_name.strip() or "Respyr Business Development"}
Respyr"""
return subject, body
DISCOVERY_QUESTIONS = {
"NGO": [
"Which communities and geographies are your current health programmes serving?",
"What conditions are you actively screening for or referring today?",
"Where do beneficiaries face the greatest barriers to timely testing?",
"How are screening camps or community-health activities currently delivered?",
"What monthly or quarterly beneficiary volume could a pilot realistically reach?",
"Who provides clinical confirmation and referral after an initial positive screen?",
"Which outcome indicators matter most to your programme and funders?",
"What approvals, local partners, or community mobilisation would be required?",
"What budget source could support a pilot if the model is suitable?",
"What would make a 60–90 day pilot successful from your perspective?",
],
"CSR": [
"What health themes and geographies are priorities in your current CSR portfolio?",
"Which beneficiary group would create the strongest strategic fit?",
"How do you select and monitor implementing partners?",
"What measurable outputs and outcomes must be reported to leadership?",
"Is the priority awareness, screening access, referral completion, or all three?",
"What programme scale and budget range is realistic for an initial pilot?",
"Which internal and implementation stakeholders need to approve the programme?",
"Are there existing NGO, hospital, or government partners we should integrate with?",
"What reporting cadence and evidence standards do you expect?",
"What would enable the pilot to scale across sites or funding cycles?",
],
"Hospital": [
"Where in the patient journey would pre-screening create the most value?",
"Which departments and patient cohorts should be prioritised?",
"What is the current volume, cost, and turnaround time for relevant tests?",
"How are at-risk patients identified today?",
"Who would operate the screening workflow and review results?",
"What confirmatory testing and referral pathway would follow a positive screen?",
"Which clinical, operational, and commercial outcomes would justify adoption?",
"What hospital approvals are needed for a pilot or evaluation?",
"How should Respyr integrate with existing records and reporting?",
"What pilot sample size and duration would be credible to your clinical team?",
],
"Government": [
"Which public-health priority and population should the programme address?",
"What screening infrastructure and field workforce are already available?",
"Which districts or facilities would be appropriate for a controlled pilot?",
"What beneficiary volume and coverage targets would be expected?",
"How are positive cases currently confirmed, referred, and tracked?",
"Which programme indicators and reporting formats are mandatory?",
"What technical, ethical, and administrative approvals would be required?",
"How would procurement or an implementation partnership be structured?",
"What evidence would be required before considering broader deployment?",
"Which government, clinical, and implementation stakeholders should be involved?",
],
"Occupational Health": [
"Which workforce groups have the highest health or exposure risk?",
"What annual or periodic medical examinations are currently conducted?",
"Which conditions, symptoms, or absenteeism patterns are most concerning?",
"How many employees and sites could be included in an initial pilot?",
"What level of operational disruption is acceptable for on-site screening?",
"How are employee consent, confidentiality, and referrals managed?",
"Which metrics matter most: participation, risk detection, referrals, or productivity?",
"Who owns the programme across HR, EHS, medical, and operations?",
"What budget cycle and approval process applies?",
"What result would justify expanding the programme to other sites?",
],
"Research Institution": [
"What research hypothesis or evidence gap would be most valuable to investigate?",
"Which disease area, population, and clinical setting are most relevant?",
"What reference standard and study design would you consider credible?",
"What sample size, cohort access, and recruitment capacity are available?",
"Which endpoints and performance measures should be primary?",
"What ethics, regulatory, and data-governance approvals are required?",
"How would samples, metadata, and follow-up outcomes be collected?",
"What roles should each party play in protocol, operations, and analysis?",
"What funding routes or grant opportunities could support the study?",
"What is the expected approach to publications and intellectual property?",
],
}
def build_proposal(
partner_name: str,
segment: str,
disease_focus: str,
geography: str,
target_population: str,
population_size: int,
duration_weeks: int,
commercial_model: str,
price_per_screen: float,
) -> str:
partner = partner_name.strip() or "Partner Organisation"
focus = disease_focus.strip() or "priority health conditions"
place = geography.strip() or "the selected pilot geography"
population = target_population.strip() or "eligible at-risk participants"
segment_models = {
"NGO": "community mobilisation through field teams and assisted screening camps",
"CSR": "a sponsored programme delivered with local implementation and referral partners",
"Hospital": "screening embedded into an OPD, preventive-health, or outreach workflow",
"Government": "deployment through selected public facilities and field-health teams",
"Occupational Health": "scheduled on-site screening integrated with workplace health processes",
"Research Institution": "protocol-led participant recruitment, screening, and comparative evaluation",
}
model = segment_models[segment]
if commercial_model == "Per-screen":
commercial = (
f"Indicative fee: {money(price_per_screen)} per completed screening. "
f"For {population_size:,} participants, the indicative screening value is "
f"{money(population_size * price_per_screen)}, excluding applicable taxes, "
"travel, confirmatory diagnostics, and any site-specific infrastructure."
)
elif commercial_model == "Fixed pilot fee":
commercial = (
f"A fixed pilot fee will be agreed after finalising sites and scope. "
f"A working estimate based on {population_size:,} screenings at "
f"{money(price_per_screen)} per screening is "
f"{money(population_size * price_per_screen)}."
)
else:
commercial = (
"The pilot may be jointly funded through partner contribution, grant support, "
"or an implementation sponsor. Roles, in-kind contributions, and any per-screen "
"charges will be defined in the final agreement."
)
return f"""# Pilot Concept Note
## Breath-based non-invasive screening collaboration
**Prepared for:** {partner}
**Partner segment:** {segment}
**Geography:** {place}
**Proposed duration:** {duration_weeks} weeks
## 1. Problem statement
Delayed detection of {focus} can lead to poorer outcomes, higher treatment costs, and avoidable pressure on health systems. Conventional diagnostic pathways may be limited by cost, access, infrastructure, time, or low screening uptake—especially for dispersed or underserved populations.
## 2. Respyr solution
Respyr proposes a portable, breath-based, non-invasive screening approach designed to make early risk identification simpler and more accessible. The pilot will assess operational feasibility, participant uptake, screening outputs, and the effectiveness of referral pathways. Screening results are intended to support risk stratification and referral; they do not replace confirmatory clinical diagnosis.
## 3. Target population
The pilot will target **{population}**, with an indicative reach of **{population_size:,} participants** in {place}. Final eligibility criteria will be agreed with {partner}.
## 4. Screening model
The delivery model will use {model}. The workflow will cover participant registration and consent, breath-based screening, result communication, referral of at-risk participants, and programme reporting.
## 5. Implementation plan
1. **Co-design:** Confirm objectives, sites, cohort, roles, consent, referral pathways, and success metrics.
2. **Readiness:** Train operators, prepare devices and materials, test data capture, and complete site approvals.
3. **Deployment:** Mobilise participants and conduct screening under agreed operating procedures.
4. **Referral:** Direct at-risk participants to the partner's nominated clinical or diagnostic pathway.
5. **Review:** Analyse programme data, document learning, and agree recommendations for scale.
## 6. Indicative timeline
- **Weeks 1–2:** Programme design, approvals, site selection, and workflow finalisation
- **Weeks 3–4:** Training, mobilisation, device readiness, and dry run
- **Weeks 5–{max(duration_weeks - 2, 6)}:** Screening delivery and referral tracking
- **Final 2 weeks:** Analysis, partner review, and final report
## 7. Deliverables
- Agreed pilot protocol and implementation plan
- Operator training and deployment support
- Screening of up to {population_size:,} eligible participants
- Secure programme-level data capture and monitoring
- Referral list for participants requiring follow-up, subject to consent
- Interim progress update and final pilot report
- Scale-up recommendations based on operational and outcome data
## 8. Expected outcomes
- Improved access to convenient, non-invasive screening
- Identification of participants who may benefit from confirmatory evaluation
- Evidence on participation, throughput, field feasibility, and referral completion
- A practical understanding of cost and resource requirements
- A decision framework for expansion to additional sites or populations
## 9. Commercial model
{commercial}
## 10. Proposed next step
Respyr and {partner} will hold a working session to finalise the use case, clinical referral pathway, target cohort, governance requirements, success metrics, and commercial scope before signing a pilot agreement.
"""
_NAV = {
"📊 Dashboard": "Dashboard",
"🗂 Prospect CRM": "Prospect CRM",
"✉️ Outreach Generator": "Outreach Generator",
"🔍 Discovery Questions": "Discovery Questions",
"📄 Proposal Generator": "Proposal Generator",
}
def render_sidebar() -> str:
with st.sidebar:
st.markdown(
"""
<div style="padding:0.5rem 0 1.25rem 0;">
<div style="font-size:1.3rem;font-weight:800;color:#0f172a;
letter-spacing:-0.03em;line-height:1.2;">
🫁 Respyr
</div>
<div style="font-size:0.68rem;font-weight:600;color:#94a3b8;
text-transform:uppercase;letter-spacing:0.13em;margin-top:5px;">
Business Development OS
</div>
</div>
""",
unsafe_allow_html=True,
)
st.divider()
nav_label = st.radio(
"Workspace",
list(_NAV.keys()),
label_visibility="collapsed",
)
st.divider()
st.markdown(
'<p style="font-size:0.75rem;color:#94a3b8;margin:0;">Built for a focused healthtech BD team.</p>',
unsafe_allow_html=True,
)
return _NAV[nav_label]
def render_dashboard(df: pd.DataFrame) -> None:
st.title("Sales Forecast Dashboard")
st.caption("A live view of pipeline health, follow-ups, and likely revenue.")
st.markdown(
"""
<div class="respyr-hero">
<h2>Pipeline at a glance</h2>
<p>Track open deals, follow-up timing, and forecast revenue across your full funnel.</p>
</div>
""",
unsafe_allow_html=True,
)
active = df[~df["stage"].isin(["Lost"])].copy()
open_pipeline = active[~active["stage"].isin(["Won"])].copy()
total_pipeline = open_pipeline["deal_value"].sum()
weighted_pipeline = (
open_pipeline["deal_value"] * open_pipeline["probability"] / 100
).sum()
won_value = df.loc[df["stage"] == "Won", "deal_value"].sum()
today = pd.Timestamp(date.today())
overdue = open_pipeline[
open_pipeline["next_follow_up_date"].notna()
& (open_pipeline["next_follow_up_date"] < today)
]
high_priority = open_pipeline[
(open_pipeline["fit_score"] == "High")
& (open_pipeline["probability"] >= 40)
]
cols = st.columns(5)
cols[0].metric("Open pipeline", compact_money(total_pipeline))
cols[1].metric("Weighted pipeline", compact_money(weighted_pipeline))
cols[2].metric("Won value", compact_money(won_value))
cols[3].metric("Overdue follow-ups", len(overdue))
cols[4].metric("High-priority leads", len(high_priority))
if df.empty:
st.info("Add your first prospect in the CRM to activate the dashboard.")
return
chart_left, chart_right = st.columns(2)
with chart_left:
st.subheader("Deals by stage")
stage_counts = (
df["stage"].value_counts().reindex(STAGES, fill_value=0).rename("Deals")
)
st.bar_chart(stage_counts, color="#0d9488")
with chart_right:
st.subheader("Expected revenue by month")
forecast = open_pipeline[open_pipeline["next_follow_up_date"].notna()].copy()
if forecast.empty:
st.caption("Add follow-up dates to produce a monthly forecast.")
else:
forecast["month"] = forecast["next_follow_up_date"].dt.to_period("M").astype(str)
forecast["weighted_value"] = (
forecast["deal_value"] * forecast["probability"] / 100
)
monthly = (
forecast.groupby("month", as_index=False)["weighted_value"]
.sum()
.set_index("month")
)
st.bar_chart(monthly, color="#f97316")
list_left, list_right = st.columns(2)
with list_left:
st.subheader("Overdue follow-ups")
if overdue.empty:
st.success("No overdue follow-ups.")
else:
overdue_view = overdue[
[
"organisation_name",
"contact_person",
"stage",
"next_follow_up_date",
"deal_value",
]
].sort_values("next_follow_up_date")
st.dataframe(
overdue_view,
width="stretch",
hide_index=True,
column_config={
"organisation_name": "Organisation",
"contact_person": "Contact",
"stage": "Stage",
"next_follow_up_date": st.column_config.DateColumn("Follow-up"),
"deal_value": st.column_config.NumberColumn(
"Deal value", format="₹ %.0f"
),
},
)
with list_right:
st.subheader("High-priority leads")
if high_priority.empty:
st.caption("High-fit leads with probability of 40% or more will appear here.")
else:
priority_view = high_priority[
[
"organisation_name",
"segment",
"stage",
"probability",
"deal_value",
]
].sort_values(["probability", "deal_value"], ascending=False)
st.dataframe(
priority_view,
width="stretch",
hide_index=True,
column_config={
"organisation_name": "Organisation",
"segment": "Segment",
"stage": "Stage",
"probability": st.column_config.ProgressColumn(
"Probability", min_value=0, max_value=100, format="%d%%"
),
"deal_value": st.column_config.NumberColumn(
"Deal value", format="₹ %.0f"
),
},
)
def render_crm(df: pd.DataFrame) -> pd.DataFrame:
st.title("Prospect CRM")
st.caption("Capture opportunities, follow-up dates, and deal confidence in one place.")
add_tab, manage_tab = st.tabs(["Add prospect", "Manage pipeline"])
with add_tab:
with st.form("add_prospect", clear_on_submit=True):
left, middle, right = st.columns(3)
organisation = left.text_input("Organisation name *")
segment = middle.selectbox("Segment *", SEGMENTS)
state = right.text_input("State")
website = left.text_input("Website")
contact_person = middle.text_input("Contact person")
email = right.text_input("Email")
disease_focus = left.text_input(
"Disease focus", placeholder="e.g. TB, diabetes, lung cancer"
)
fit_score = middle.selectbox("Fit score", FIT_SCORES)
stage = right.selectbox("Stage", STAGES)
deal_value = left.number_input(
"Deal value (₹)", min_value=0.0, step=50_000.0, format="%.0f"
)
probability = middle.slider("Probability (%)", 0, 100, 20, 5)
follow_up = right.date_input("Next follow-up date", value=date.today())
notes = st.text_area("Notes", height=110)
submitted = st.form_submit_button(
"Add prospect", type="primary", width="stretch"
)
if submitted:
if not organisation.strip():
st.error("Organisation name is required.")
else:
now = datetime.now().isoformat(timespec="seconds")
new_row = {
"id": str(uuid.uuid4()),
"organisation_name": organisation.strip(),
"segment": segment,
"state": state.strip(),
"website": website.strip(),
"contact_person": contact_person.strip(),
"email": email.strip(),
"disease_focus": disease_focus.strip(),
"fit_score": fit_score,
"stage": stage,
"deal_value": deal_value,
"probability": probability,
"next_follow_up_date": pd.Timestamp(follow_up),
"notes": notes.strip(),
"created_at": now,
"updated_at": now,
}
df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
save_prospects(df)
st.success(f"{organisation.strip()} added to the pipeline.")
with manage_tab:
if df.empty:
st.info("No prospects yet. Add one in the first tab.")
return df
filter_cols = st.columns(4)
segment_filter = filter_cols[0].multiselect("Segment", SEGMENTS)
stage_filter = filter_cols[1].multiselect("Stage", STAGES)
fit_filter = filter_cols[2].multiselect("Fit", FIT_SCORES)
search = filter_cols[3].text_input("Search organisation")
filtered = df.copy()
if segment_filter:
filtered = filtered[filtered["segment"].isin(segment_filter)]
if stage_filter:
filtered = filtered[filtered["stage"].isin(stage_filter)]
if fit_filter:
filtered = filtered[filtered["fit_score"].isin(fit_filter)]
if search:
filtered = filtered[
filtered["organisation_name"]
.astype(str)
.str.contains(search, case=False, na=False)
]
display_columns = [
"id",
"organisation_name",
"segment",
"state",
"contact_person",
"email",
"disease_focus",
"fit_score",
"stage",
"deal_value",
"probability",
"next_follow_up_date",
"notes",
]
edited = st.data_editor(
filtered[display_columns],
width="stretch",
hide_index=True,
disabled=["id"],
num_rows="fixed",
column_config={
"id": None,
"organisation_name": "Organisation",
"segment": st.column_config.SelectboxColumn(
"Segment", options=SEGMENTS, required=True
),
"state": "State",
"contact_person": "Contact person",
"email": "Email",
"disease_focus": "Disease focus",
"fit_score": st.column_config.SelectboxColumn(
"Fit", options=FIT_SCORES, required=True
),
"stage": st.column_config.SelectboxColumn(
"Stage", options=STAGES, required=True
),
"deal_value": st.column_config.NumberColumn(
"Deal value", min_value=0, format="₹ %.0f"
),
"probability": st.column_config.NumberColumn(
"Probability", min_value=0, max_value=100, format="%d%%"
),
"next_follow_up_date": st.column_config.DateColumn(
"Next follow-up", format="DD MMM YYYY"
),
"notes": st.column_config.TextColumn("Notes", width="large"),
},
key="pipeline_editor",
)
action_left, action_middle, action_right = st.columns([1, 1.6, 1])
if action_left.button("Save changes", type="primary", width="stretch"):
original = df.set_index("id")
updates = edited.set_index("id")
for prospect_id, row in updates.iterrows():
for column in updates.columns:
original.loc[prospect_id, column] = row[column]
original.loc[prospect_id, "updated_at"] = datetime.now().isoformat(
timespec="seconds"
)
df = original.reset_index()
save_prospects(df)
st.success("Pipeline changes saved.")
delete_options = {
f"{row.organisation_name} · {row.stage}": row.id
for row in df.itertuples()
}
delete_label = action_middle.selectbox(
"Delete a prospect",