PK.CLINICAL.NOTES
A^prefix,
^?(A)^admindx,
^$(A)^admdata,
^*(N2)^nurdata,
"PATS",@1,
END;

[1]::PATS
/ARGV[1]^DT,
2^nr,
DO{nr</ARGC 1,
   /ARGV[nr]^ACT,
   [admindx]AAAI[ACT]^aa,
   "NOTES",@2,
   nr+1^nr};

[2]::NOTES
DO{"NEXT.NOTE",@3 1,
   IF{[nurdata]NOTE[aa]N[note]TU!(('/CONF[.notes.nursing.cats]["all"])&('/CONF[.notes.nursing.cats][[nurdata]NOTE[aa]N[note]|3])) 1;
      "SEND",@4}};

[3]::NEXT.NOTE
+([nurdata]NOTE[aa]N[note],XX)^note;

[4]::SEND
IF{"check rx enter date against date from pk",
   "XX|4<DT;",
   "<Document>"^!,
   "<InstanceMnemonic>"_prefix_aa_"-"_note_"</InstanceMnemonic>"^!,
   IF{-([nurdata]NOTE[aa]N[note]TA[""],YY)^AMEND YY|0_YY|1;XX|0_XX|1}^UPD,
   "append x to key because t0 may be empty",
   "<Key>"_"x"_UPD_"</Key>"^!,
   "<PersonMnemonic>"_[admdata]AA[aa]|3_"</PersonMnemonic>"^!,
   "<EventEndDateTime>"_[nurdata]NOTE[aa]N[note]|0_"</EventEndDateTime>"^!,
   "<EventSetMnemonic>NURSE</EventSetMnemonic>"^!,
   "</Document>"^!};
